Bagikan melalui


Menyambungkan Komponen Aliran Data Secara Terprogram

Berlaku untuk: SQL Server SSIS Integration Runtime di Azure Data Factory

Setelah Anda menambahkan komponen ke tugas aliran data, Anda menyambungkannya untuk membuat pohon eksekusi yang mewakili aliran data dari sumber melalui transformasi ke tujuan. Anda menggunakan IDTSPath100 objek untuk menyambungkan komponen dalam aliran data.

Membuat Jalur

Panggil metode PathCollection Baru properti MainPipe antarmuka untuk membuat jalur baru dan menambahkannya ke kumpulan jalur dalam tugas aliran data. Metode ini mengembalikan objek baru yang terputus, yang kemudian Anda gunakan untuk menyambungkan IDTSPath100 dua komponen.

AttachPathAndPropagateNotifications Panggil metode untuk menyambungkan jalur dan untuk memberi tahu komponen yang berpartisipasi dalam jalur bahwa mereka telah terhubung. Metode ini menerima IDTSOutput100 komponen upstream dan IDTSInput100 komponen hilir sebagai parameter. Secara default, panggilan ke metode komponen ProvideComponentProperties membuat input tunggal untuk komponen yang memiliki input, dan satu output untuk komponen yang memiliki output. Contoh berikut menggunakan output default sumber dan input tujuan ini.

Langkah Selanjutnya

Setelah Anda membuat jalur antara dua komponen, langkah selanjutnya adalah memetakan kolom input di komponen hilir, yang dibahas dalam topik berikutnya, Memilih Kolom Input Secara Terprogram.

Sampel

Sampel kode berikut menunjukkan cara membuat jalur antara dua komponen.

using System;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Pipeline;  
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;  
  
namespace Microsoft.SqlServer.Dts.Samples  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  
      Package package = new Package();  
      Executable e = package.Executables.Add("STOCK:PipelineTask");  
      TaskHost thMainPipe = e as TaskHost;  
      MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;  
  
      // Create the source component.    
      IDTSComponentMetaData100 source =  
        dataFlowTask.ComponentMetaDataCollection.New();  
      source.ComponentClassID = "DTSAdapter.OleDbSource";  
      CManagedComponentWrapper srcDesignTime = source.Instantiate();  
      srcDesignTime.ProvideComponentProperties();  
  
      // Create the destination component.  
      IDTSComponentMetaData100 destination =  
        dataFlowTask.ComponentMetaDataCollection.New();  
      destination.ComponentClassID = "DTSAdapter.OleDbDestination";  
      CManagedComponentWrapper destDesignTime = destination.Instantiate();  
      destDesignTime.ProvideComponentProperties();  
  
      // Create the path.  
      IDTSPath100 path = dataFlowTask.PathCollection.New();  
      path.AttachPathAndPropagateNotifications(source.OutputCollection[0],  
        destination.InputCollection[0]);  
    }  
  }  

}

Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Pipeline  
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper  
  
Module Module1  
  
  Sub Main()  
  
    Dim package As Microsoft.SqlServer.Dts.Runtime.Package = _  
      New Microsoft.SqlServer.Dts.Runtime.Package()  
    Dim e As Executable = package.Executables.Add("STOCK:PipelineTask")  
    Dim thMainPipe As Microsoft.SqlServer.Dts.Runtime.TaskHost = _  
      CType(e, Microsoft.SqlServer.Dts.Runtime.TaskHost)  
    Dim dataFlowTask As MainPipe = CType(thMainPipe.InnerObject, MainPipe)  
  
    ' Create the source component.    
    Dim source As IDTSComponentMetaData100 = _  
      dataFlowTask.ComponentMetaDataCollection.New()  
    source.ComponentClassID = "DTSAdapter.OleDbSource"  
    Dim srcDesignTime As CManagedComponentWrapper = source.Instantiate()  
    srcDesignTime.ProvideComponentProperties()  
  
    ' Create the destination component.  
    Dim destination As IDTSComponentMetaData100 = _  
      dataFlowTask.ComponentMetaDataCollection.New()  
    destination.ComponentClassID = "DTSAdapter.OleDbDestination"  
    Dim destDesignTime As CManagedComponentWrapper = destination.Instantiate()  
    destDesignTime.ProvideComponentProperties()  
  
    ' Create the path.  
    Dim path As IDTSPath100 = dataFlowTask.PathCollection.New()  
    path.AttachPathAndPropagateNotifications(source.OutputCollection(0), _  
      destination.InputCollection(0))  
  
  End Sub  
  
End Module  

Lihat Juga

Memilih Kolom Input Secara Terprogram