共用方式為


建立自訂資料流程元件

在 Microsoft SQL Server Integration Services 中,資料流程工作會公開物件模型,讓開發人員透過使用 Microsoft .NET Framework 與 Managed 程式碼建立自訂資料流程元件 (來源、轉換和目的地)。

資料流程工作是由兩個元件所組成:IDTSComponentMetaData100 介面以及定義元件之間資料移動的 IDTSPath100 物件之集合。

設計階段與執行階段

在執行之前,資料流程工作在進行累加變更時,是在設計階段狀態。變更可包括元件的加入或移除、連接元件的路徑物件之加入或移除,以及對於元件中繼資料的變更。當中繼資料變更發生時,元件可以監視變更並對其做出反應。例如,元件可以不允許某些變更,或是做其他變更以回應變更。在設計階段,設計工具會透過設計階段 IDTSDesigntimeComponent100 介面與元件互動。

在執行時,資料流程工作會檢查元件的順序、準備執行計劃以及管理執行工作計劃的工作者執行緒集區。雖然每個工作者執行緒都會執行資料流程工作內部的某些工作,但是工作者執行緒的主要工作是透過執行階段 IDTSRuntimeComponent100 介面來呼叫元件的方法。

建立元件

若要建立資料流程元件,您可以從 PipelineComponent 基底類別衍生類別、套用 DtsPipelineComponentAttribute 類別,然後覆寫基底類別的適當方法。PipelineComponent 會實作 IDTSDesigntimeComponent100IDTSRuntimeComponent100 介面,並為您公開其方法以便在元件中覆寫。

視您的元件使用的物件而定,專案將需要參考下列組件的某些或是全部:

功能

要參考的組件

要匯入的命名空間

資料流程

Microsoft.SqlServer.PipelineHost

Microsoft.SqlServer.Dts.Pipeline

資料流程包裝函式

Microsoft.SqlServer.DTSPipelineWrap

Microsoft.SqlServer.Dts.Pipeline.Wrapper

執行階段

Microsoft.SQLServer.ManagedDTS

Microsoft.SqlServer.Dts.Runtime

執行階段包裝函式

Microsoft.SqlServer.DTSRuntimeWrap

Microsoft.SqlServer.Dts.Runtime.Wrapper

下列程式碼範例顯示從基底類別衍生的簡單元件,並套用 DtsPipelineComponentAttribute

using System;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace Microsoft.Samples.SqlServer.Dts
{
    [DtsPipelineComponent(DisplayName = "SampleComponent", ComponentType = ComponentType.Transform )]
    public class BasicComponent: PipelineComponent
    {
        // TODO: Override the base class methods.
    }
}
Imports Microsoft.SqlServer.Dts.Pipeline
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

<DtsPipelineComponent(DisplayName:="SampleComponent", ComponentType:=ComponentType.Transform)> _
Public Class BasicComponent

    Inherits PipelineComponent

    ' TODO: Override the base class methods.

End Class
Integration Services 圖示 (小) 掌握 Integration Services 的最新狀態

若要取得 Microsoft 的最新下載、文件、範例和影片以及社群中的選定解決方案,請瀏覽 MSDN 或 TechNet 上的 Integration Services 頁面:

若要得到這些更新的自動通知,請訂閱該頁面上所提供的 RSS 摘要。