Udostępnij za pośrednictwem


Metoda FileSystemTask.Execute

Uruchamia zadanie.

Przestrzeń nazw:  Microsoft.SqlServer.Dts.Tasks.FileSystemTask
Zestaw:  Microsoft.SqlServer.FileSystemTask (w Microsoft.SqlServer.FileSystemTask.dll)

Składnia

'Deklaracja
Public Overrides Function Execute ( _
    connections As Connections, _
    variableDispenser As VariableDispenser, _
    events As IDTSComponentEvents, _
    log As IDTSLogging, _
    txn As Object _
) As DTSExecResult
'Użycie
Dim instance As FileSystemTask
Dim connections As Connections
Dim variableDispenser As VariableDispenser
Dim events As IDTSComponentEvents
Dim log As IDTSLogging
Dim txn As Object
Dim returnValue As DTSExecResult

returnValue = instance.Execute(connections, _
    variableDispenser, events, log, txn)
public override DTSExecResult Execute(
    Connections connections,
    VariableDispenser variableDispenser,
    IDTSComponentEvents events,
    IDTSLogging log,
    Object txn
)
public:
virtual DTSExecResult Execute(
    Connections^ connections, 
    VariableDispenser^ variableDispenser, 
    IDTSComponentEvents^ events, 
    IDTSLogging^ log, 
    Object^ txn
) override
abstract Execute : 
        connections:Connections * 
        variableDispenser:VariableDispenser * 
        events:IDTSComponentEvents * 
        log:IDTSLogging * 
        txn:Object -> DTSExecResult 
override Execute : 
        connections:Connections * 
        variableDispenser:VariableDispenser * 
        events:IDTSComponentEvents * 
        log:IDTSLogging * 
        txn:Object -> DTSExecResult 
public override function Execute(
    connections : Connections, 
    variableDispenser : VariableDispenser, 
    events : IDTSComponentEvents, 
    log : IDTSLogging, 
    txn : Object
) : DTSExecResult

Parametry

  • txn
    Typ: System.Object
    Obiekt transakcji kontener jest częścią.Wartość ta może być nullodwołanie o wartości null (Nothing w języku Visual Basic).

Wartość zwracana

Typ: Microsoft.SqlServer.Dts.Runtime.DTSExecResult
Wartość z DTSExecResult wyliczania.

Uwagi

Execute Metoda jest dziedziczona przez hosty zadań i innych obiektów z Executable abstrakcyjne klasy, poprzez DtsContainer klasy i pozwala dziedziczące obiektów do uruchomienia przez aparat runtime.Wykonywanie metoda dziedziczone przez poszczególne obiekty nie jest powszechnie używany w kodzie i zaleca się, że wywołania Execute metoda, jeśli trzeba uruchomić zadania lub pojemników w pakiet.Jednak Wykonywanie metoda jest dostępna w poszczególnych obiektach powinny możesz znaleźć unikatowy okoliczności tam, gdzie to konieczne.

Głównym zastosowaniem Wykonywanie metoda jest dziedziczone i zastąpiona podczas tworzenia niestandardowego zadania.Aby uzyskać więcej informacji na temat zastąpić metoda Execute, zobacz Kodowanie niestandardowego zadania.

Wykonywanie wywołania metoda sprawdzania poprawności metoda niejawnie, przed uruchomieniem pakiet.Wszystkie zadania w pakiet są przeglądane odpowiednie ustawienia podczas sprawdzania poprawności i wszystkich obiektów w pakiet rewidowane, włączając pakiet, kontenerów i innych składników w pakiet.

Jeżeli nie ma żadnych problemów napotkanych w fazie sprawdzania poprawności, które mogłyby spowodować pakiet nie powiedzie się, obiekt pakietu przechodzą do wywołania Wykonywanie metoda dla każdego zadania i obiektów w pakiecie.

Przekazywanie nullodwołanie o wartości null (Nothing w języku Visual Basic) dla transaction parametr podczas TransactionOption właściwość jest false.Jeśli TransactionOption właściwość ma wartość true, można przekazać null w transaction parametru, aby wskazać, że kontener obsługuje transakcje, ale nie uczestniczy.

Przykłady

Poniższy przykład kodu pokazuje, jak uruchomić pakiet zawierający BulkInsertTask po niektóre właściwości zadania są zestaw.Wstaw luzem zadanie jest przykład ten przykładowy kod; wszelkie zadania mogą być tworzone w jego miejsce.

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

namespace Microsoft.SqlServer.SSIS.Samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Package p = new Package();
            p.InteractiveMode = true;
            p.OfflineMode = true;
            Executable exec1 = pkg.Executables.Add("STOCK:BulkInsertTask");
            TaskHost th = exec1 as TaskHost;

            // Set the CheckConstraints and DataFileType properties.           
            th.Properties["CheckConstraints"].SetValue(th, true);
            th.Properties["DataFileType"].SetValue(th, DTSBulkInsert_DataFileType.DTSBulkInsert_DataFileType_Native);
           
            // Run the package that contains the task.
            pkg.Execute();

            // Review the results of the run.
            if (taskH.ExecutionResult == DTSExecResult.Failure || taskH.ExecutionStatus == DTSExecStatus.Abend)
                Console.WriteLine("Task failed or abended");
            else
                Console.WriteLine("Task ran successfully");
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
 
Namespace Microsoft.SqlServer.SSIS.Samples
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim p As Package =  New Package() 
            p.InteractiveMode = True
            p.OfflineMode = True
            Dim exec1 As Executable =  pkg.Executables.Add("STOCK:BulkInsertTask") 
            Dim th As TaskHost =  exec1 as TaskHost 
 
            ' Set the CheckConstraints and DataFileType properties.           
            th.Properties("CheckConstraints").SetValue(th, True)
            th.Properties("DataFileType").SetValue(th, DTSBulkInsert_DataFileType.DTSBulkInsert_DataFileType_Native)
 
            ' Run the package that contains the task.
            pkg.Execute()
 
            ' Review the results of the run.
            If taskH.ExecutionResult = DTSExecResult.Failure Or taskH.ExecutionStatus = DTSExecStatus.Abend Then
                Console.WriteLine("Task failed or abended")
            Else 
                Console.WriteLine("Task ran successfully")
            End If
        End Sub
    End Class
End Namespace