DtsEventHandlers.GetEnumerator 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컬렉션을 DtsEventHandlers 반복할 때 사용할 수 있는 열거자를 반환합니다.
public:
Microsoft::SqlServer::Dts::Runtime::DtsEventHandlerEnumerator ^ GetEnumerator();
public Microsoft.SqlServer.Dts.Runtime.DtsEventHandlerEnumerator GetEnumerator();
override this.GetEnumerator : unit -> Microsoft.SqlServer.Dts.Runtime.DtsEventHandlerEnumerator
Public Function GetEnumerator () As DtsEventHandlerEnumerator
반품
DtsEventHandlerEnumerator A는 컬렉션을 반복할 때 사용하는 데 사용됩니다.
예제
다음 코드 샘플은 패키지에 대해 두 개의 이벤트 핸들러를 생성합니다. 하나의 이벤트 핸들러에 대해 두 개의 작업이 추가됩니다. 그 다음 컬렉션에서 Package``EventHandlers a DtsEventHandlerEnumerator 를 생성하고, and MoveNext 메서드를 사용 Current 해 컬렉션을 탐색합니다.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.SendMailTask;
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;
namespace DtsEventHandler_API
{
class Program
{
static void Main(string[] args)
{
Package pkg = new Package();
// Set up a DtsEventHandler for the OnError event of the package.
DtsEventHandler dtsEHOE = (DtsEventHandler)pkg.EventHandlers.Add("OnError");
DtsEventHandler dtsEHW = (DtsEventHandler)pkg.EventHandlers.Add("OnWarning");
// When an OnError Event occurs, the Executables collection contains
// the items to run. For this example, there will be a SendMailtTask
// and a BulkInsertTask with a precedence constraint between them.
Executable dtsEH1 = dtsEHOE.Executables.Add("STOCK:SendMailTask");
TaskHost th = (TaskHost)dtsEH1;
SendMailTask smTask = (SendMailTask)th.InnerObject;
smTask.Subject = "Send Mail task";
// Add a second executable to the DtsEventHandler.
Executable dtsEH2 = dtsEHOE.Executables.Add("STOCK:BulkInsertTask");
TaskHost th2 = (TaskHost)dtsEH2;
//Create the Enumerator. Since we added the DtsEventhandler to the
// package, then that's where to get the EventHandlers collection.
DtsEventHandlerEnumerator myEnum = pkg.EventHandlers.GetEnumerator();
Console.WriteLine("The collection contains the following values:");
int i = 0;
while ((myEnum.MoveNext()) && (myEnum.Current != null))
Console.WriteLine("[{0}] {1}", i++, myEnum.Current.Name);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.SendMailTask
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
Namespace DtsEventHandler_API
Class Program
Shared Sub Main(ByVal args() As String)
Dim pkg As Package = New Package()
' Set up a DtsEventHandler for the OnError event of the package.
Dim dtsEHOE As DtsEventHandler = CType(pkg.EventHandlers.Add("OnError"), DtsEventHandler)
Dim dtsEHW As DtsEventHandler = CType(pkg.EventHandlers.Add("OnWarning"), DtsEventHandler)
' When an OnError Event occurs, the Executables collection contains
' the items to run. For this example, there will be a SendMailtTask
' and a BulkInsertTask with a precedence constraint between them.
Dim dtsEH1 As Executable = dtsEHOE.Executables.Add("STOCK:SendMailTask")
Dim th As TaskHost = CType(dtsEH1, TaskHost)
Dim smTask As SendMailTask = CType(th.InnerObject, SendMailTask)
smTask.Subject = "Send Mail task"
' Add a second executable to the DtsEventHandler.
Dim dtsEH2 As Executable = dtsEHOE.Executables.Add("STOCK:BulkInsertTask")
Dim th2 As TaskHost = CType(dtsEH2, TaskHost)
'Create the Enumerator. Since we added the DtsEventhandler to the
' package, then that's where to get the EventHandlers collection.
Dim myEnum As DtsEventHandlerEnumerator = pkg.EventHandlers.GetEnumerator()
Console.WriteLine("The collection contains the following values:")
Dim i As Integer = 0
While (myEnum.MoveNext()) &&(myEnum.Current <> Nothing)
Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
End While
End Sub
End Class
End Namespace
샘플 출력:
이 수집품에는 다음과 같은 값들이 포함되어 있습니다:
[0] OnError
[1] 경고
설명
EventHandlers 컬렉션을 가져오는 컨테이너가 이벤트가 추가된 컨테이너입니다. 예를 들어, 이 코드 DtsEventHandler dtsEHOE = (DtsEventHandler)pkg.EventHandlers.Add("OnError");한 줄을 작성하면 는 GetEnumerator 컬렉션에 pkg.EventHandlers 속하게 됩니다. 만약 이벤트가 컬렉션 메서드 Sequence's``EventHandlers 를 사용 Add 해 컨테이너에 Sequence 추가되었다면, 이벤트 핸들러의 컬렉션에서 Sequence 열거자를 다시 가져옵니다.