FileSystemTask.InitializeTask 方法

定義

初始化與工作相關聯的屬性。 這個方法由執行階段呼叫,並不使用於程式碼中。

public:
 override void InitializeTask(Microsoft::SqlServer::Dts::Runtime::Connections ^ connections, Microsoft::SqlServer::Dts::Runtime::VariableDispenser ^ variableDispenser, Microsoft::SqlServer::Dts::Runtime::IDTSInfoEvents ^ events, Microsoft::SqlServer::Dts::Runtime::IDTSLogging ^ log, Microsoft::SqlServer::Dts::Runtime::EventInfos ^ eventInfos, Microsoft::SqlServer::Dts::Runtime::LogEntryInfos ^ logEntryInfos, Microsoft::SqlServer::Dts::Runtime::ObjectReferenceTracker ^ refTracker);
public override void InitializeTask (Microsoft.SqlServer.Dts.Runtime.Connections connections, Microsoft.SqlServer.Dts.Runtime.VariableDispenser variableDispenser, Microsoft.SqlServer.Dts.Runtime.IDTSInfoEvents events, Microsoft.SqlServer.Dts.Runtime.IDTSLogging log, Microsoft.SqlServer.Dts.Runtime.EventInfos eventInfos, Microsoft.SqlServer.Dts.Runtime.LogEntryInfos logEntryInfos, Microsoft.SqlServer.Dts.Runtime.ObjectReferenceTracker refTracker);
override this.InitializeTask : Microsoft.SqlServer.Dts.Runtime.Connections * Microsoft.SqlServer.Dts.Runtime.VariableDispenser * Microsoft.SqlServer.Dts.Runtime.IDTSInfoEvents * Microsoft.SqlServer.Dts.Runtime.IDTSLogging * Microsoft.SqlServer.Dts.Runtime.EventInfos * Microsoft.SqlServer.Dts.Runtime.LogEntryInfos * Microsoft.SqlServer.Dts.Runtime.ObjectReferenceTracker -> unit
Public Overrides Sub InitializeTask (connections As Connections, variableDispenser As VariableDispenser, events As IDTSInfoEvents, log As IDTSLogging, eventInfos As EventInfos, logEntryInfos As LogEntryInfos, refTracker As ObjectReferenceTracker)

參數

connections
Connections

工作所使用之連接的集合。

variableDispenser
VariableDispenser

用於鎖定變數的 VariableDispenser 物件。

events
IDTSInfoEvents

實作 IDTSInfoEvents 介面以便在保存期間引發事件 (錯誤、警告等) 的物件。

log
IDTSLogging

實作 IDTSLogging 介面的物件。

eventInfos
EventInfos

EventInfos

logEntryInfos
LogEntryInfos

LogEntryInfos工作所使用的集合。

refTracker
ObjectReferenceTracker

物件參考追蹤程式。

範例

工作開發人員藉由覆寫基類的方法來定義自訂事件 InitializeTask Task ,以及建立新的 EventInfo 。 下列程式碼範例顯示自訂工作的 >initializetask 方法,其中會建立兩個自訂事件並加入至 eventInfos 集合。

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"];  
}  

備註

針對 FileSystemTask 和所有其他股票工作,請使用這個方法來設定每個工作的記錄事件。

適用於