Task.Execute 메서드

정의

작업을 실행합니다.

public:
 virtual Microsoft::SqlServer::Dts::Runtime::DTSExecResult Execute(Microsoft::SqlServer::Dts::Runtime::Connections ^ connections, Microsoft::SqlServer::Dts::Runtime::VariableDispenser ^ variableDispenser, Microsoft::SqlServer::Dts::Runtime::IDTSComponentEvents ^ componentEvents, Microsoft::SqlServer::Dts::Runtime::IDTSLogging ^ log, System::Object ^ transaction);
public virtual Microsoft.SqlServer.Dts.Runtime.DTSExecResult Execute (Microsoft.SqlServer.Dts.Runtime.Connections connections, Microsoft.SqlServer.Dts.Runtime.VariableDispenser variableDispenser, Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents componentEvents, Microsoft.SqlServer.Dts.Runtime.IDTSLogging log, object transaction);
abstract member Execute : Microsoft.SqlServer.Dts.Runtime.Connections * Microsoft.SqlServer.Dts.Runtime.VariableDispenser * Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents * Microsoft.SqlServer.Dts.Runtime.IDTSLogging * obj -> Microsoft.SqlServer.Dts.Runtime.DTSExecResult
override this.Execute : Microsoft.SqlServer.Dts.Runtime.Connections * Microsoft.SqlServer.Dts.Runtime.VariableDispenser * Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents * Microsoft.SqlServer.Dts.Runtime.IDTSLogging * obj -> Microsoft.SqlServer.Dts.Runtime.DTSExecResult
Public Overridable Function Execute (connections As Connections, variableDispenser As VariableDispenser, componentEvents As IDTSComponentEvents, log As IDTSLogging, transaction As Object) As DTSExecResult

매개 변수

connections
Connections

태스크에서 사용하는 연결의 컬렉션입니다.

variableDispenser
VariableDispenser

변수를 잠그기 위한 VariableDispenser 개체입니다.

componentEvents
IDTSComponentEvents

IDTSComponentEvents 인터페이스를 구현하는 개체

log
IDTSLogging

IDTSLogging 인터페이스를 구현하는 개체

transaction
Object

해당 컨테이너가 포함된 트랜잭션 개체입니다. 이 값은 null일 수 있습니다.

반환

DTSExecResult 열거형의 값입니다.

예제

다음 코드 예제에서는 상속자를 TaskBulkInsertTask포함 하는 패키지를 실행 하는 방법을 보여 있습니다. 대량 삽입 태스크는 이 코드 샘플의 예입니다. 모든 작업을 해당 위치에서 만들 수 있습니다.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask  

namespace Microsoft.SqlServer.SSIS.Samples  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Package p = new Package();  
            p.InteractiveMode = true;  
            p.OfflineMode = true;  
            Executable exec1 = pkg.Executables.Add("STOCK:BulkInsertTask");  
            TaskHost th = exec1 as TaskHost;  

            // Set the CheckConstraints and DataFileType properties.             
            th.Properties["CheckConstraints"].SetValue(th, true);  
            th.Properties["DataFileType"].SetValue(th, DTSBulkInsert_DataFileType.DTSBulkInsert_DataFileType_Native);  

            // Run the package that contains the task.  
            pkg.Execute();  

            // Review the results of the run.  
            if (taskH.ExecutionResult == DTSExecResult.Failure || taskH.ExecutionStatus == DTSExecStatus.Abend)  
                Console.WriteLine("Task failed or abended");  
            else  
                Console.WriteLine("Task ran successfully");  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask  

Namespace Microsoft.SqlServer.SSIS.Samples  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim p As Package =  New Package()   
            p.InteractiveMode = True  
            p.OfflineMode = True  
            Dim exec1 As Executable =  pkg.Executables.Add("STOCK:BulkInsertTask")   
            Dim th As TaskHost =  exec1 as TaskHost   

            ' Set the CheckConstraints and DataFileType properties.             
            th.Properties("CheckConstraints").SetValue(th, True)  
            th.Properties("DataFileType").SetValue(th, DTSBulkInsert_DataFileType.DTSBulkInsert_DataFileType_Native)  

            ' Run the package that contains the task.  
            pkg.Execute()  

            ' Review the results of the run.  
            If taskH.ExecutionResult = DTSExecResult.Failure Or taskH.ExecutionStatus = DTSExecStatus.Abend Then  
                Console.WriteLine("Task failed or abended")  
            Else   
                Console.WriteLine("Task ran successfully")  
            End If  
        End Sub  
    End Class  
End Namespace  

설명

Execute 메서드는 추상 클래스의 태스크 호스트 및 기타 개체에서 Executable 클래스를 통해 DtsContainer 상속되며 런타임 엔진에서 상속되는 개체를 실행할 수 있습니다. Execute 개별 개체에서 상속된 메서드는 코드에서 일반적으로 사용되지 않으며 패키지에서 태스크 또는 컨테이너를 실행해야 하는 경우 메서드를 호출 Execute 하는 것이 좋습니다. 그러나 Execute 필요한 고유한 상황을 찾으면 개별 개체에서 메서드를 사용할 수 있습니다.

메서드의 Execute 주요 용도는 사용자 지정 작업을 만들 때 상속되고 재정의되는 것입니다. 메서드를 재정의 Execute 하는 방법에 대한 자세한 내용은 사용자 지정 작업 코딩을 참조하세요.

메서드는 Execute 패키지를 실행하기 전에 메서드를 암시적으로 호출 Validate 합니다. 패키지의 모든 태스크는 유효성 검사 중에 적절한 설정을 검토하며 패키지의 모든 개체(패키지, 컨테이너 및 패키지의 다른 구성 요소 포함)를 검토합니다.

유효성 검사 단계에서 패키지가 실패하는 데 문제가 없는 경우 패키지 개체는 패키지의 각 태스크 및 개체에 대한 메서드를 계속 호출 Execute 합니다.

속성이 .인 transaction 경우 매개 변수에 TransactionOption 대해 전달 null 합니다false. 속성이 TransactionOption true이면 매개 변수를 transaction 전달 null 하여 컨테이너가 트랜잭션을 지원하지만 참여하지 않음을 나타낼 수 있습니다.

적용 대상