InitializeTask 方法

Initializes the properties associated with the task. This method is called by the runtime and is not used in code.

命名空间:  Microsoft.SqlServer.Dts.Runtime
程序集:  Microsoft.SqlServer.ManagedDTS(在 Microsoft.SqlServer.ManagedDTS.dll 中)

语法

声明
Public Overridable Sub InitializeTask ( _
    connections As Connections, _
    variableDispenser As VariableDispenser, _
    events As IDTSInfoEvents, _
    log As IDTSLogging, _
    eventInfos As EventInfos, _
    logEntryInfos As LogEntryInfos, _
    refTracker As ObjectReferenceTracker _
)
用法
Dim instance As Task
Dim connections As Connections
Dim variableDispenser As VariableDispenser
Dim events As IDTSInfoEvents
Dim log As IDTSLogging
Dim eventInfos As EventInfos
Dim logEntryInfos As LogEntryInfos
Dim refTracker As ObjectReferenceTracker

instance.InitializeTask(connections, _
    variableDispenser, events, log, eventInfos, _
    logEntryInfos, refTracker)
public virtual void InitializeTask(
    Connections connections,
    VariableDispenser variableDispenser,
    IDTSInfoEvents events,
    IDTSLogging log,
    EventInfos eventInfos,
    LogEntryInfos logEntryInfos,
    ObjectReferenceTracker refTracker
)
public:
virtual void InitializeTask(
    Connections^ connections, 
    VariableDispenser^ variableDispenser, 
    IDTSInfoEvents^ events, 
    IDTSLogging^ log, 
    EventInfos^ eventInfos, 
    LogEntryInfos^ logEntryInfos, 
    ObjectReferenceTracker^ refTracker
)
abstract InitializeTask : 
        connections:Connections * 
        variableDispenser:VariableDispenser * 
        events:IDTSInfoEvents * 
        log:IDTSLogging * 
        eventInfos:EventInfos * 
        logEntryInfos:LogEntryInfos * 
        refTracker:ObjectReferenceTracker -> unit 
override InitializeTask : 
        connections:Connections * 
        variableDispenser:VariableDispenser * 
        events:IDTSInfoEvents * 
        log:IDTSLogging * 
        eventInfos:EventInfos * 
        logEntryInfos:LogEntryInfos * 
        refTracker:ObjectReferenceTracker -> unit 
public function InitializeTask(
    connections : Connections, 
    variableDispenser : VariableDispenser, 
    events : IDTSInfoEvents, 
    log : IDTSLogging, 
    eventInfos : EventInfos, 
    logEntryInfos : LogEntryInfos, 
    refTracker : ObjectReferenceTracker
)

参数

注释

For stock tasks, this method is used to set the log events of each task.

The run-time engine calls InitializeTask immediately after the task is created—before validation, execution, or persistence operations.

示例

Task developers define custom events by overriding the InitializeTask method of the Task base class, and creating a new EventInfo. The following code sample shows the InitializeTask method of a custom task, where two custom events are created, and added to the eventInfos collection.

public override void InitializeTask(Connections connections, VariableDispenser variables, IDTSInfoEvents events, IDTSLogging log, EventInfos eventInfos, LogEntryInfos logEntryInfos, ObjectReferenceTracker refTracker)
{
    this.eventInfos = eventInfos;
    string[] paramNames = new string[1];
    TypeCode[] paramTypes = new TypeCode[1]{TypeCode.Int32};
    string[] paramDescriptions = new string[1];

    paramNames[0] = "InitialValue";
    paramDescriptions[0] = "The value before increment.";

    this.eventInfos.Add("OnBeforeIncrement","Fires before the task increments the value.",true,paramNames,paramTypes,paramDescriptions);
    this.onBeforeIncrement = this.eventInfos["OnBeforeIncrement"];

    paramDescriptions[0] = "The value after increment.";
    this.eventInfos.Add("OnAfterIncrement","Fires after the initial value is updated.",true,paramNames, paramTypes,paramDescriptions);
    this.onAfterIncrement = this.eventInfos["OnAfterIncrement"];
}
Public Overrides Sub InitializeTask(ByVal connections As Connections,  ByVal variables As VariableDispenser, ByVal events As IDTSInfoEvents, ByVal log As IDTSLogging, ByVal eventInfos As EventInfos, ByVal logEntryInfos As LogEntryInfos, ByVal refTracker As ObjectReferenceTracker) 
    Me.eventInfos = eventInfos
    Dim paramNames(0) As String
    Dim paramTypes(0) As TypeCode = {TypeCode.Int32}
    Dim paramDescriptions(0) As String
    
    paramNames(0) = "InitialValue"
    paramDescriptions(0) = "The value before increment."
    
    Me.eventInfos.Add("OnBeforeIncrement", "Fires before the task increments the value.", True, paramNames, paramTypes, paramDescriptions)
    Me.onBeforeIncrement = Me.eventInfos("OnBeforeIncrement")
    
    paramDescriptions(0) = "The value after increment."
    Me.eventInfos.Add("OnAfterIncrement", "Fires after the initial value is updated.", True, paramNames, paramTypes, paramDescriptions)
    Me.onAfterIncrement = Me.eventInfos("OnAfterIncrement")
End Sub