FtpTask.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
任务中使用的一系列连接。
- 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"];
}
注解
对于 FtpTask 所有其他库存任务,该方法用于设置每个任务的日志事件。
运行时引擎在任务创建后立即调用 InitializeTask ——在验证、执行或持久化操作之前。