문제

LoadPackage (...)를 사용하여 SSIS 패키지를 호출합니다.

이 호출을 비동기 호출로 만들 수 있습니까?

도움이 되었습니까?

해결책

예, 여기에 디모치로 된대로 비동기 대의원을 사용하십시오.

http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx

다른 팁

백그라운드에서 실행되기를 원한다면 예, 스레드를 스풀링하거나 T-SQL을 호출하여 동적으로 작업을 만들고 나중에 다시 제거 할 수 있습니다. 당신이 그것을 비동기식으로 실행하고 싶다면 콜백이 완료되기를 원한다면 불행히도 운이 좋지 않다고 생각합니다.

Are you asking if it's 1) legal to call LoadPackage on a background thread or 2) is it possible. For #1 I can't give a definitive answer because I don't use the SSIS framework.

However #2 (as long as #1 is true) is definately doable. IMHO, you're better off using an existing framework which has API's designed to calling API's async and waiting for the results. For instance with Parellel Extensions June 08 CTP, the following code will do.

using System.Threading.Tasks;
...
var future = Future.Create(()=>LoadPackage); // Starts loading the package
// Do other stuff
var package = future.Value;  // Wait for package load to complete and get the value

I'm calling an SSIS package from my UI (WPF) via an async WCF service call. Service code is:

public string ImportMarriageXML(bool isWakeUp, bool clearExistingMarriage)
{
    try
    {
        var dts = new Microsoft.SqlServer.Dts.Runtime.Application();

        using (var package = dts.LoadFromSqlServer(
            ServiceSettings.Settings.SSIS.ImportMarriages,
            ServiceSettings.Settings.SSIS.ServerIP,
            ServiceSettings.Settings.SSIS.UserID,
            ServiceSettings.Settings.SSIS.Password,
            null))
        {
            package.InteractiveMode = false;
            package.Connections["DB.STAGING"].ConnectionString = String.Format("{0};Provider={1};", DBSettings.ConnectionString(Core.Database.Staging), ServiceSettings.Settings.SSIS.Provider);

            var variables = package.Variables;
            variables["IsWakeUp"].Value = isWakeUp;
            variables["ClearExistingMarriage"].Value = clearExistingMarriage;
            variables["XmlDirectory"].Value = ServiceSettings.Settings.SSIS.Properties.XmlDirectory;

            if (package.Execute() == DTSExecResult.Failure)
            {
                // HACK: Need to refactor this at some point. Will do for now.
                var errors = new System.Text.StringBuilder();
                foreach (var error in package.Errors)
                    errors.AppendFormat("SubComponent: {0}; Description: {1}{2}", error.SubComponent, error.Description, Environment.NewLine);
                throw new ApplicationException(errors.ToString());
            }

            return package.Connections["Text Logging"].ConnectionString;
        }
    }
}

And (part of) the client-side code is as follows:

private void InvokeLoadMarriages()
{
    integrationServicesServiceClient.BeginImportMarriageXML(false, OnEndImportMarriageXML, null);
}

private void OnEndImportMarriageXML(IAsyncResult asyncResult)
{
    view.InvokeDisplayResults(integrationServicesServiceClient.EndImportMarriageXML(asyncResult));
}

Where BeginImportMarriageXML & EndImportMarriageXML are the generated async operations in the proxy class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top