Zaman uyumlu çıkışlarına ile özel dönüşümü bileşen geliştirme

Zaman uyumlu çıkışlarına dönüşümü bileşenlerle satır ters yönde bileşenlerinden almak ve okumak veya satır aşağı akım bileşenleri geçirirken bu satır ve sütun değerleri değiştirin. Onlar da ters yönde bileşenleri tarafından sağlanan sütunlar türetilen ek çıktı sütunları tanımlayabilir, ancak veri akışı satır eklemeyin. Senkron ve asenkron bileşenleri arasındaki fark hakkında daha fazla bilgi için bkz: Zaman uyumlu ve zaman uyumsuz dönüşümleri anlama.

Bu tür bir bileşen, bileşenin koşuluyla veri olarak içi nerede ve nerede bileşen işlemeden önce tüm satırları görmek yok görevler için uygundur. Öyle dönüşümleri ile zaman uyumlu çıkışlarına genellikle dış veri kaynaklarına bağlanmak yok çünkü geliştirmek için en kolay bileşeni dış meta veri sütunları yönetmek veya çıktı arabelleği için satır ekleyebilir.

İle zaman uyumlu çıkışlarına dönüşümü bileşeni oluşturma içerir ekleyerek bir IDTSInput100, seçili bileşen için ters yönde sütun içerir ve bir IDTSOutput100içeren nesne bileşeni tarafından oluşturulan sütunlar türetilen. Ayrıca tasarım zamanı yöntemleri uygulanması ve okur veya yürütme sırasında gelen arabellek satırları sütunlara değiştiren kod sağlar içerir.

Bu bölümde özel dönüşüm bileşeni uygulamak için gerekli, ve daha iyi yardımcı olmak için kod örnekleri kavramlarını anlamak sağlar bilgileri sağlar. Zaman uyumlu çıkışlarına ile örnek dönüşüm bileşeni için bkz: Change Case Component Sample. Bu tür bir bileşeni tam bir örnek için bkz: Change Case Component Sample.

Tasarım Zamanı

Girişleri ve çıkışları oluşturma, bileşenin oluşturduğu ek çıktı sütunları ekleme ve bileşen doğrularken bu bileşen Tasarım Zamanı kodunu içerir.

Bileşeni oluşturma

Girdileri, çıktıları ve bileşenin özel özellikleri genellikle sırasında oluşturulan ProvideComponentPropertiesyöntemi. İki şekilde giriş ve çıkış ile zaman uyumlu çıkışlarına dönüşümü bileşeni ekleyebilirsiniz. Temel sınıf uygulaması yöntemi kullanın ve varsayılan giriş ve çıkış oluşturur veya açıkça giriş ekleyebilir ve kendinize çıkış değiştirin.

Aşağıdaki kod örneği uygulaması gösterir ProvideComponentPropertiesaçıkça giriş ve çıkış nesneleri ekler. Aynı şeyi başarmak istiyorsunuz temel sınıf çağrısı bir yorum eklenmiştir.

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

namespace Microsoft.Samples.SqlServer.Dts
{
    [DtsPipelineComponent(DisplayName = "SynchronousComponent", ComponentType = ComponentType.Transform)]
    public class SyncComponent : PipelineComponent
    {

        public override void ProvideComponentProperties()
        {
            // Add the input.
            IDTSInput100 input = ComponentMetaData.InputCollection.New();
            input.Name = "Input";

            // Add the output.
            IDTSOutput100 output = ComponentMetaData.OutputCollection.New();
            output.Name = "Output";
            output.SynchronousInputID = input.ID;

            // Alternatively, you can let the base class add the input and output
            // and set the SynchronousInputID of the output to the ID of the input.
            // base.ProvideComponentProperties();
        }
    }
}
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime;

namespace Microsoft.Samples.SqlServer.Dts
{
    [DtsPipelineComponent(DisplayName = "SynchronousComponent", ComponentType = ComponentType.Transform)]
    public class SyncComponent : PipelineComponent
    {

        public override void ProvideComponentProperties()
        {
            // Add the input.
            IDTSInput100 input = ComponentMetaData.InputCollection.New();
            input.Name = "Input";

            // Add the output.
            IDTSOutput100 output = ComponentMetaData.OutputCollection.New();
            output.Name = "Output";
            output.SynchronousInputID = input.ID;

            // Alternatively, you can let the base class add the input and output
            // and set the SynchronousInputID of the output to the ID of the input.
            // base.ProvideComponentProperties();
        }
    }
}
Imports Microsoft.SqlServer.Dts.Pipeline
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime

<DtsPipelineComponent(DisplayName:="SynchronousComponent", ComponentType:=ComponentType.Transform)> _
Public Class SyncComponent
    Inherits PipelineComponent

    Public Overrides Sub ProvideComponentProperties()

        ' Add the input.
        Dim input As IDTSInput100 = ComponentMetaData.InputCollection.New()
        input.Name = "Input"

        ' Add the output.
        Dim output As IDTSOutput100 = ComponentMetaData.OutputCollection.New()
        output.Name = "Output"
        output.SynchronousInputID = Input.ID

        ' Alternatively, you can let the base class add the input and output
        ' and set the SynchronousInputID of the output to the ID of the input.
        ' base.ProvideComponentProperties();

    End Sub

End Class
Imports Microsoft.SqlServer.Dts.Pipeline
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime

<DtsPipelineComponent(DisplayName:="SynchronousComponent", ComponentType:=ComponentType.Transform)> _
Public Class SyncComponent
    Inherits PipelineComponent

    Public Overrides Sub ProvideComponentProperties()

        ' Add the input.
        Dim input As IDTSInput100 = ComponentMetaData.InputCollection.New()
        input.Name = "Input"

        ' Add the output.
        Dim output As IDTSOutput100 = ComponentMetaData.OutputCollection.New()
        output.Name = "Output"
        output.SynchronousInputID = Input.ID

        ' Alternatively, you can let the base class add the input and output
        ' and set the SynchronousInputID of the output to the ID of the input.
        ' base.ProvideComponentProperties();

    End Sub

End Class

Çıktı sütunları yapılandırma ve oluşturma

Zaman uyumlu çıkışlarına dönüşümü bileşenlerle satır arabelleği eklemeyin rağmen ekstra ekleyebilirsiniz çıkış sütunlar için kendi çıktı. Bir bileşeni bir çıkış sütunu eklediğinde, genellikle yeni çıktı sütununun değerlerini zamanında bir veya daha fazla bileşen ters yönde bir bileşen tarafından sağlanan sütun içerdiği verileri türetilmiştir.

Çıktı sütunu oluşturduktan sonra veri türü özelliklerini ayarlamanız gerekir. Özel işlem gerektiren bir çıktı sütununun veri türü özelliklerini ayarlama ve çağrılarak yapılır SetDataTypePropertiesyöntemi. Bu yöntem gereklidir, çünkü DataType, Length, Precision, ve CodePageözellikleri, ayrı ayrı salt okunur, çünkü her diğer ayarlara bağlıdır. Bu yöntem, özelliklerin değerlerini sürekli olarak ayarlanır ve veri akışı görev onlar düzgün ayarlandığını doğrulama garanti eder.

DataTypeDiğer özelliklerini ayarlama değerleri sütun belirler. Bağımlı özelliklerin her biri için gereksinimleri aşağıdaki tabloda gösterilmiştir DataType. Listede veri türlerini sıfıra ayarlamak onların bağımlı özellikleri vardır.

DataType

Uzunluk

Ölçek

Hassas

Kod sayfası

DT_DECIMAL

0

0'dan büyük ve küçük veya eşit 28.

0

0

DT_CY

0

0

0

0

DT_NUMERIC

0

0 Büyüktür ve daha az daha veya eşit 28 ve daha hassas.

1'e eşit veya daha büyük ve küçük veya eşittir 38.

0

DT_BYTES

0 Büyüktür.

0

0

0

DT_STR

0 Ve az 8000 büyüktür.

0

0

Değil 0 ve geçerli kod sayfası.

DT_WSTR

0 Ve az 4000 büyüktür.

0

0

0

Çıktı sütununun veri türü veri türü özelliklerini kısıtlamalar tabanlı olduğundan, doğru seçmelisiniz Integration Servicesveri türü yönetilen türleriyle çalışırken. Üç yardımcı yöntemler, temel sınıf sağlar ConvertBufferDataTypeToFitManaged, BufferTypeToDataRecordType, ve DataRecordTypeToBufferTypeseçiminde yönetilen bileşen geliştiriciler yardımcı bir SSISveri türü bir yönetilen türüne verilen. Bu yöntemleri yönetilen veri türleri dönüştürme SSISveri türleri tersi.

Çalışma süresi

Bileşen çalışma zamanı parçası uygulanması iki görevlere genellikle kategorize — bileşenin giriş ve çıkış sütunları arabellekte bulma ve okuma veya bu sütunların değerleri gelen arabellek satırları yazma.

Sütunları arabellekte bulma

Bir bileşen için yürütme sırasında sağlanan arabellek sütun sayısı büyük olasılıkla bileşenin giriş veya çıkış koleksiyonlarında sütun sayısını aşıyor. Bunun nedeni, her arabellek veri akışı bileşenleri tanımlanan tüm çıkış sütunlar içerir. Arabellek sütun doğru giriş ya da çıkış sütunları eşleştirilir emin olmak için bileşen geliştiriciler kullanmalıdır FindColumnByLineageIDyöntemi BufferManager. Bu yöntem, lineage kimliği tarafından belirtilen arabellek sütun bulur Genellikle sütun sırasında bulunan PreExecuteBu ilk çalıştırma yöntemi olduğundan burada BufferManagerözelliği kullanılabilir duruma gelir.

Aşağıdaki kod örneği, giriş ve çıkış sütunu toplanması sırasında dizin sütunları bulur bir bileşeni gösterir PreExecute. Sütun dizinleri bir tamsayı dizisi içinde saklanır ve sırasında bileşen tarafından erişilebilen ProcessInput.

int []inputColumns;
int []outputColumns;

public override void PreExecute()
{
    IDTSInput100 input = ComponentMetaData.InputCollection[0];
    IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

    inputColumns = new int[input.InputColumnCollection.Count];
    outputColumns = new int[output.OutputColumnCollection.Count];

    for(int col=0; col < input.InputColumnCollection.Count; col++)
    {
        IDTSInputColumn100 inputColumn = input.InputColumnCollection[col];
        inputColumns[col] = BufferManager.FindColumnByLineageID(input.Buffer, inputColumn.LineageID);
    }

    for(int col=0; col < output.OutputColumnCollection.Count; col++)
    {
        IDTSOutputColumn100 outputColumn = output.OutputColumnCollection[col];
        outputColumns[col] = BufferManager.FindColumnByLineageID(input.Buffer, outputColumn.LineageID);
    }

}
int []inputColumns;
int []outputColumns;

public override void PreExecute()
{
    IDTSInput100 input = ComponentMetaData.InputCollection[0];
    IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

    inputColumns = new int[input.InputColumnCollection.Count];
    outputColumns = new int[output.OutputColumnCollection.Count];

    for(int col=0; col < input.InputColumnCollection.Count; col++)
    {
        IDTSInputColumn100 inputColumn = input.InputColumnCollection[col];
        inputColumns[col] = BufferManager.FindColumnByLineageID(input.Buffer, inputColumn.LineageID);
    }

    for(int col=0; col < output.OutputColumnCollection.Count; col++)
    {
        IDTSOutputColumn100 outputColumn = output.OutputColumnCollection[col];
        outputColumns[col] = BufferManager.FindColumnByLineageID(input.Buffer, outputColumn.LineageID);
    }

}
Public Overrides Sub PreExecute()

    Dim input As IDTSInput100 = ComponentMetaData.InputCollection(0)
    Dim output As IDTSOutput100 = ComponentMetaData.OutputCollection(0)


    ReDim inputColumns(input.InputColumnCollection.Count)
    ReDim outputColumns(output.OutputColumnCollection.Count)

    For col As Integer = 0 To input.InputColumnCollection.Count

        Dim inputColumn As IDTSInputColumn100 = input.InputColumnCollection(col)
        inputColumns(col) = BufferManager.FindColumnByLineageID(input.Buffer, inputColumn.LineageID)
    Next

    For col As Integer = 0 To output.OutputColumnCollection.Count

        Dim outputColumn As IDTSOutputColumn100 = output.OutputColumnCollection(col)
        outputColumns(col) = BufferManager.FindColumnByLineageID(input.Buffer, outputColumn.LineageID)
    Next

End Sub
Public Overrides Sub PreExecute()

    Dim input As IDTSInput100 = ComponentMetaData.InputCollection(0)
    Dim output As IDTSOutput100 = ComponentMetaData.OutputCollection(0)


    ReDim inputColumns(input.InputColumnCollection.Count)
    ReDim outputColumns(output.OutputColumnCollection.Count)

    For col As Integer = 0 To input.InputColumnCollection.Count

        Dim inputColumn As IDTSInputColumn100 = input.InputColumnCollection(col)
        inputColumns(col) = BufferManager.FindColumnByLineageID(input.Buffer, inputColumn.LineageID)
    Next

    For col As Integer = 0 To output.OutputColumnCollection.Count

        Dim outputColumn As IDTSOutputColumn100 = output.OutputColumnCollection(col)
        outputColumns(col) = BufferManager.FindColumnByLineageID(input.Buffer, outputColumn.LineageID)
    Next

End Sub

Satır işleniyor

Bileşenleri almak PipelineBuffersatır ve sütunları içeren nesneleri ProcessInputyöntemi. Sırasında bu yöntemi arabellek satırları iterated ve sütun sırasında tespit PreExecuteokumak ve değiştirilebilen. Kadar daha fazla satır ters yönde bileşenden sağlanan yöntem sürekli veri akışı görev tarafından denir.

Tek bir sütun arabellek okumak ya da dizinin dizin Oluşturucu erişim yöntemini kullanarak ya da birini kullanarak yazılmış Getya Setyöntemleri. GetVe Setyöntemleri daha verimli ve arabellek sütun veri türü bilindiğinde kullanılmalıdır.

Aşağıdaki kod örneği uygulaması gösterir ProcessInputgelen satırları işler yöntemi.

public override void ProcessInput( int InputID, PipelineBuffer buffer)
{
       while( buffer.NextRow())
       {
            for(int x=0; x < inputColumns.Length;x++)
            {
                if(!buffer.IsNull(inputColumns[x]))
                {
                    object columnData = buffer[inputColumns[x]];
                    // TODO: Modify the column data.
                    buffer[inputColumns[x]] = columnData;
                }
            }
        
      }
}
public override void ProcessInput( int InputID, PipelineBuffer buffer)
{
       while( buffer.NextRow())
       {
            for(int x=0; x < inputColumns.Length;x++)
            {
                if(!buffer.IsNull(inputColumns[x]))
                {
                    object columnData = buffer[inputColumns[x]];
                    // TODO: Modify the column data.
                    buffer[inputColumns[x]] = columnData;
                }
            }
        
      }
}
Public Overrides Sub ProcessInput(ByVal InputID As Integer, ByVal buffer As PipelineBuffer)

        While (buffer.NextRow())

            For x As Integer = 0 To inputColumns.Length

                if buffer.IsNull(inputColumns(x)) = false then

                    Dim columnData As Object = buffer(inputColumns(x))
                    ' TODO: Modify the column data.
                    buffer(inputColumns(x)) = columnData

                End If
            Next

        End While
End Sub
Public Overrides Sub ProcessInput(ByVal InputID As Integer, ByVal buffer As PipelineBuffer)

        While (buffer.NextRow())

            For x As Integer = 0 To inputColumns.Length

                if buffer.IsNull(inputColumns(x)) = false then

                    Dim columnData As Object = buffer(inputColumns(x))
                    ' TODO: Modify the column data.
                    buffer(inputColumns(x)) = columnData

                End If
            Next

        End While
End Sub

Örnek

Aşağıdaki örnek, tüm dize sütun değerleri büyük harfe dönüştüren basit dönüşüm bileşeni ile zaman uyumlu çıkışlarına göstermektedir. Bu örnek, tüm yöntemleri ve bu konuda anlatılan işlevsellik göstermek değil. Önemli yöntemleri her zaman uyumlu çıkışlarına ile özel dönüşümü bileşen geçersiz kılmak gerekir, ama does değil içermek için Tasarım Zamanı doğrulama kodu gösterilmiştir. Zaman uyumlu çıkışlarına ile tam örnek dönüşüm bileşeni için bkz: Change Case Component Sample.

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

namespace Uppercase
{
  [DtsPipelineComponent(DisplayName = "Uppercase")]
  public class Uppercase : PipelineComponent
  {
    ArrayList m_ColumnIndexList = new ArrayList();

    public override void ProvideComponentProperties()
    {
      base.ProvideComponentProperties();
      ComponentMetaData.InputCollection[0].Name = "Uppercase Input";
      ComponentMetaData.OutputCollection[0].Name = "Uppercase Output";
    }

    public override void PreExecute()
    {
      IDTSInput100 input = ComponentMetaData.InputCollection[0];
      IDTSInputColumnCollection100 inputColumns = input.InputColumnCollection;

      foreach (IDTSInputColumn100 column in inputColumns)
      {
        if (column.DataType == DataType.DT_STR || column.DataType == DataType.DT_WSTR)
        {
          m_ColumnIndexList.Add((int)BufferManager.FindColumnByLineageID(input.Buffer, column.LineageID));
        }
      }
    }

    public override void ProcessInput(int inputID, PipelineBuffer buffer)
    {
      while (buffer.NextRow())
      {
        foreach (int columnIndex in m_ColumnIndexList)
        {
          string str = buffer.GetString(columnIndex);
          buffer.SetString(columnIndex, str.ToUpper());
        }
      }
    }
  }
}
using System;
using System.Collections;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

namespace Uppercase
{
  [DtsPipelineComponent(DisplayName = "Uppercase")]
  public class Uppercase : PipelineComponent
  {
    ArrayList m_ColumnIndexList = new ArrayList();

    public override void ProvideComponentProperties()
    {
      base.ProvideComponentProperties();
      ComponentMetaData.InputCollection[0].Name = "Uppercase Input";
      ComponentMetaData.OutputCollection[0].Name = "Uppercase Output";
    }

    public override void PreExecute()
    {
      IDTSInput100 input = ComponentMetaData.InputCollection[0];
      IDTSInputColumnCollection100 inputColumns = input.InputColumnCollection;

      foreach (IDTSInputColumn100 column in inputColumns)
      {
        if (column.DataType == DataType.DT_STR || column.DataType == DataType.DT_WSTR)
        {
          m_ColumnIndexList.Add((int)BufferManager.FindColumnByLineageID(input.Buffer, column.LineageID));
        }
      }
    }

    public override void ProcessInput(int inputID, PipelineBuffer buffer)
    {
      while (buffer.NextRow())
      {
        foreach (int columnIndex in m_ColumnIndexList)
        {
          string str = buffer.GetString(columnIndex);
          buffer.SetString(columnIndex, str.ToUpper());
        }
      }
    }
  }
}
Imports System 
Imports System.Collections 
Imports Microsoft.SqlServer.Dts.Pipeline 
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper 
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper 
Namespace Uppercase 

 <DtsPipelineComponent(DisplayName="Uppercase")> _ 
 Public Class Uppercase 
 Inherits PipelineComponent 
   Private m_ColumnIndexList As ArrayList = New ArrayList 

   Public  Overrides Sub ProvideComponentProperties() 
     MyBase.ProvideComponentProperties 
     ComponentMetaData.InputCollection(0).Name = "Uppercase Input" 
     ComponentMetaData.OutputCollection(0).Name = "Uppercase Output" 
   End Sub 

   Public  Overrides Sub PreExecute() 
     Dim input As IDTSInput100 = ComponentMetaData.InputCollection(0) 
     Dim inputColumns As IDTSInputColumnCollection100 = input.InputColumnCollection 
     For Each column As IDTSInputColumn100 In inputColumns 
       If column.DataType = DataType.DT_STR OrElse column.DataType = DataType.DT_WSTR Then 
         m_ColumnIndexList.Add(CType(BufferManager.FindColumnByLineageID(input.Buffer, column.LineageID), Integer)) 
       End If 
     Next 
   End Sub 

   Public  Overrides Sub ProcessInput(ByVal inputID As Integer, ByVal buffer As PipelineBuffer) 
     While buffer.NextRow 
       For Each columnIndex As Integer In m_ColumnIndexList 
         Dim str As String = buffer.GetString(columnIndex) 
         buffer.SetString(columnIndex, str.ToUpper) 
       Next 
     End While 
   End Sub 
 End Class 
End Namespace
Imports System 
Imports System.Collections 
Imports Microsoft.SqlServer.Dts.Pipeline 
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper 
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper 
Namespace Uppercase 

 <DtsPipelineComponent(DisplayName="Uppercase")> _ 
 Public Class Uppercase 
 Inherits PipelineComponent 
   Private m_ColumnIndexList As ArrayList = New ArrayList 

   Public  Overrides Sub ProvideComponentProperties() 
     MyBase.ProvideComponentProperties 
     ComponentMetaData.InputCollection(0).Name = "Uppercase Input" 
     ComponentMetaData.OutputCollection(0).Name = "Uppercase Output" 
   End Sub 

   Public  Overrides Sub PreExecute() 
     Dim input As IDTSInput100 = ComponentMetaData.InputCollection(0) 
     Dim inputColumns As IDTSInputColumnCollection100 = input.InputColumnCollection 
     For Each column As IDTSInputColumn100 In inputColumns 
       If column.DataType = DataType.DT_STR OrElse column.DataType = DataType.DT_WSTR Then 
         m_ColumnIndexList.Add(CType(BufferManager.FindColumnByLineageID(input.Buffer, column.LineageID), Integer)) 
       End If 
     Next 
   End Sub 

   Public  Overrides Sub ProcessInput(ByVal inputID As Integer, ByVal buffer As PipelineBuffer) 
     While buffer.NextRow 
       For Each columnIndex As Integer In m_ColumnIndexList 
         Dim str As String = buffer.GetString(columnIndex) 
         buffer.SetString(columnIndex, str.ToUpper) 
       Next 
     End While 
   End Sub 
 End Class 
End Namespace
Integration Services simgesi (küçük) Integration Services ile güncel kalın

En son karşıdan yüklemeler, makaleler, örnekler ve Microsoft video yanı sıra topluluk seçili çözümleri için ziyaret Integration ServicesMSDN sayfası:


Bu güncelleştirmelerle ilgili otomatik bildirim almak için, sayfadaki RSS akışlarına abone olun.

Ayrıca bkz.

Kavramlar

Zaman uyumsuz çıkışlarına ile özel dönüşümü bileşen geliştirme

Zaman uyumlu ve zaman uyumsuz dönüşümleri anlama

Zaman uyumlu dönüşümü Script bileşeni ile oluşturma