SendMailTask.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

锁定变量的 P:Microsoft.SqlServer.Dts.Runtime.DtsContainer.VariableDispenser 对象。

events
IDTSInfoEvents

实现 T:Microsoft.SqlServer.Dts.Runtime.IDTSInfoEvents 接口的对象。

log
IDTSLogging

实现 T:Microsoft.SqlServer.Dts.Runtime.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"];  
}  

注解

SendMailTask对于所有其他库存任务,此方法用于设置每个任务的日志事件。

在创建任务后、验证、执行或持久性操作之前,SSIS 运行时会立即调用 InitializeTask

适用于