Compartir a través de


DtsEnumerator(IEnumerator, DTSReadOnlyCollectionBase) Constructor

Definición

Inicializa una nueva instancia de la clase DtsEnumerator.

public:
 DtsEnumerator(System::Collections::IEnumerator ^ enumerator, Microsoft::SqlServer::Dts::Runtime::DTSReadOnlyCollectionBase ^ collBase);
public DtsEnumerator (System.Collections.IEnumerator enumerator, Microsoft.SqlServer.Dts.Runtime.DTSReadOnlyCollectionBase collBase);
new Microsoft.SqlServer.Dts.Runtime.DtsEnumerator : System.Collections.IEnumerator * Microsoft.SqlServer.Dts.Runtime.DTSReadOnlyCollectionBase -> Microsoft.SqlServer.Dts.Runtime.DtsEnumerator
Public Sub New (enumerator As IEnumerator, collBase As DTSReadOnlyCollectionBase)

Parámetros

enumerator
IEnumerator

Un enumerador que implementa IEnumerator.

collBase
DTSReadOnlyCollectionBase

Una colección que implementa DTSReadOnlyCollectionBase.

Ejemplos

En el ejemplo de código siguiente se agrega una tarea a un paquete y, a continuación, se ejecuta el paquete. La colección de advertencias se crea mediante la creación de un WarningEnumerator, que hereda de esta DtsEnumerator clase y muestra cada descripción de advertencia.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;  

namespace Microsoft.SqlServer.SSIS.Samples  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Package package = new Package();  
            Console.WriteLine("Package warnings count before running: {0}", package.Warnings.Count);  

            TaskHost taskH2 = (TaskHost)package.Executables.Add("STOCK:SendMailTask");  
            taskH2.FailPackageOnFailure = false;  
            taskH2.FailParentOnFailure = false;  
            Console.WriteLine("SendMailTask: {0}", taskH2.ID);  

            // Test that warnings were successfully added to the collection.  
            package.MaximumErrorCount = 100;  
            package.FailPackageOnFailure = false;  
            package.FailParentOnFailure = false;  
            package.DelayValidation = true;  
            package.Execute();  

            Console.WriteLine("Package warnings count after running the package: {0}", package.Warnings.Count);  

            // Create the enumerator.  
            WarningEnumerator myEnumerator = package.Warnings.GetEnumerator();  
            Console.WriteLine("The collection contains the following values:");  
            int i = 0;  
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))  
                Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Description);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask  

Namespace Microsoft.SqlServer.SSIS.Samples  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim package As Package =  New Package()   
            Console.WriteLine("Package warnings count before running: {0}", package.Warnings.Count)  

            Dim taskH2 As TaskHost = CType(package.Executables.Add("STOCK:SendMailTask"), TaskHost)  
            taskH2.FailPackageOnFailure = False  
            taskH2.FailParentOnFailure = False  
            Console.WriteLine("SendMailTask: {0}", taskH2.ID)  

            ' Test that warnings were successfully added to the collection.  
            package.MaximumErrorCount = 100  
            package.FailPackageOnFailure = False  
            package.FailParentOnFailure = False  
            package.DelayValidation = True  
            package.Execute()  

            Console.WriteLine("Package warnings count after running the package: {0}", package.Warnings.Count)  

            ' Create the enumerator.  
            Dim myEnumerator As WarningEnumerator =  package.Warnings.GetEnumerator()   
            Console.WriteLine("The collection contains the following values:")  
            Dim i As Integer =  0   
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)  
                Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1  
            End While  
        End Sub  
    End Class  
End Namespace  

Salida del ejemplo:

Recuento de advertencias de paquete antes de ejecutar: 0

SendMailTask: {34CAEFF9-64BF-401D-B646-C88B705DB971}

Recuento de advertencias de paquete después de ejecutar el paquete: 2

La colección contiene los siguientes valores:

[0] La dirección de la línea From no se forma correctamente. Falta una @ o no es válida.

[1] El asunto está vacío

Se aplica a