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 값입니다.

예제

다음 코드 예시는 의 상속자를 Task포함하는 패키지를 실행하는 방법을 보여줍니다.BulkInsertTask Bulk Insert 작업이 이 코드 샘플의 예시입니다; 어떤 작업이든 그 자리에 새로 만들 수 있습니다.

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 오버라이드하는 방법에 대한 자세한 내용은 ' 사용자 지정 작업 코딩(Coding a Custom Task)'을 참조하세요.

메서드는 Execute 패키지가 실행되기 전에 암묵적으로 메서드를 Validate 호출합니다. 패키지 내 모든 작업은 검증 시 적절한 설정에 대해 검토되며, 패키지, 컨테이너 및 기타 구성 요소를 포함한 모든 객체가 검토됩니다.

검증 단계에서 패키지가 실패할 만한 문제가 발생하지 않는다면, 패키지 객체는 패키지 내 각 작업과 객체에 대해 메서드를 Execute 호출합니다.

속성이 nulltransaction때 매개변수를 통과 TransactionOption 합니다false. 속성이 TransactionOption 참이라면, 컨테이너가 트랜잭션을 지원하지만 참여하지 않는다는 매개변수를 전달 nulltransaction 할 수 있습니다.

적용 대상