XMLTask.InitializeTask 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化與這個工作相關聯的屬性。 這個方法由執行階段呼叫,並不使用於程式碼中。
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
工作所使用之 Connections 的集合。
- variableDispenser
- VariableDispenser
用於鎖定變數的 VariableDispenser 物件。
- events
- IDTSInfoEvents
實作 IDTSInfoEvents 介面的物件。
- log
- IDTSLogging
實作 IDTSLogging 介面的物件。
- eventInfos
- EventInfos
包含工作執行期間要引發之事件的集合。
- 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"];
}
備註
若為 XMLTask 和所有其他股票工作,則會使用這個方法來設定每個工作的記錄事件。 執行時間引擎會在工作建立之後、驗證、執行或持續性作業之前,立即呼叫這個方法。 程式碼中不會使用這個方法。 但是,如果您要撰寫自訂工作的程式碼,您可能需要覆寫這個方法,並為工作提供任何初始化值。