veri akışı bileşeni sürümünü yükseltmeden

Bileþeniniz eski sürüm ile oluşturulmuş paketler, bileşenin daha yeni sürümlerinde, kullanım değiştirilmiş olan özel özellikler gibi geçersiz meta veriler içerebilir.Geçersiz kılmak PerformUpgrade(Int32) yöntem PipelineComponent daha önce geçerli bileşeniniz özelliklerini yansıtmak için eski paketlerinde kaydedilen meta veriler güncelleştirmek için taban sınıf.

Not

Yeni sürüm için özel bir bileşen ne zaman yeniden derle Integration Services, değeri değiştirmek zorunda DtsPipelineComponentAttributeCurrentVersion() bileşenin özelliklerini değişmemiş, özellik.

Örnek

Aşağıdaki örnek, sürüm 2.0 hayali veri akışı bileşeninin kodunu içerir.Yeni sürüm numarasını tanımlanan CurrentVersion() özellik DtsPipelineComponentAttribute. Bileşen, bir eşiği aşan nasıl sayısal değerlerin sayısını tanımlayan bir özellik olan işleneceğini üzeresiniz.Sürümünde hayali bileşeni 1.0, bu özellik adlı RaiseErrorOnInvalidValue ve bir Boole değeri true veya false kabul edildi. Içinde sürüm 2.0 hayali bileşeninin, özellik için adlandırıldı InvalidValueHandling ve bir özel bir numaralandırma dört olası değerleri kabul eder.

Geçersiz kılınmış PerformUpgrade(Int32) yöntem Aşağıdaki örnekte, aşağıdaki eylemleri gerçekleştirir:

  • Bileşen geçerli sürüm alır.

  • Eski özel özellik değerini alır.

  • Eski özelliği özel özellik koleksiyonundan kaldırır.

  • Olanaklıysa, eski özelliğinin değerine dayanarak yeni bir özel özellik değerini ayarlar.

  • Sürüm meta veriler, bileşenin geçerli sürüme ayarlar.

Not

veri akışı altyapısı içinde kendi sürüm numarası geçirmeden PerformUpgrade(Int32) yöntem, pipelineVersion parametre. Bu parametre, 1.0 sürümünde yararlı değildir. Integration Services, ancak, sonraki sürümlerde yararlı olabilir.

Örnek kod, yalnızca, özel özellik için doğrudan önceki Boole değerleri eşleyen iki numaralandırma değerleri kullanır.Kullanıcılar, diğer kullanılabilir numaralandırma değerleri bileşenin özel kullanıcı arabiriminden seçebilir Gelişmiş düzenleyiciyi veya programlı olarak.Gelişmiş Düzenleyicisi'nde bir özel özellik için numaralandırma değerleri görüntüleme hakkında bilgi için "Özel özellikler oluşturma" konusuna bakın. Tasarım saatı yöntemleri bir veri akışı bileşeni.

Imports Microsoft.SqlServer.Dts.Pipeline
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

<DtsPipelineComponent(ComponentType:=ComponentType.Transform, CurrentVersion:=2)> _
Public Class PerformUpgrade
  Inherits PipelineComponent

  ' Define the set of possible values for the new custom property.
  Private Enum InvalidValueHandling
    Ignore
    FireInformation
    FireWarning
    FireError
  End Enum

  Public Overloads Overrides Sub PerformUpgrade(ByVal pipelineVersion As Integer)

    ' Obtain the current component version from the attribute.
    Dim componentAttribute As DtsPipelineComponentAttribute = _
      CType(Attribute.GetCustomAttribute(Me.GetType, _
      GetType(DtsPipelineComponentAttribute), False), _
      DtsPipelineComponentAttribute)
    Dim currentVersion As Integer = componentAttribute.CurrentVersion

    ' If the component version saved in the package is less than
    '  the current version, Version 2, perform the upgrade.
    If ComponentMetaData.Version < currentVersion Then

      ' Get the current value of the old custom property, RaiseErrorOnInvalidValue, 
      ' and then remove the property from the custom property collection.
      Dim oldValue As Boolean = False
      Try
        Dim oldProperty As IDTSCustomProperty100 = _
          ComponentMetaData.CustomPropertyCollection("RaiseErrorOnInvalidValue")
        oldValue = CType(oldProperty.Value, Boolean)
        ComponentMetaData.CustomPropertyCollection.RemoveObjectByIndex("RaiseErrorOnInvalidValue")
      Catch ex As Exception
        ' If the old custom property is not available, ignore the error.
      End Try

      ' Set the value of the new custom property, InvalidValueHandling,
      '  by using the appropriate enumeration value.
      Dim newProperty As IDTSCustomProperty100 = _
        ComponentMetaData.CustomPropertyCollection("InvalidValueHandling")
      If oldValue = True Then
        newProperty.Value = InvalidValueHandling.FireError
      Else
        newProperty.Value = InvalidValueHandling.Ignore
      End If

    End If

    ' Update the saved component version metadata to the current version.
    ComponentMetaData.Version = currentVersion

  End Sub

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

[DtsPipelineComponent(ComponentType = ComponentType.Transform, CurrentVersion = 2)]
public class PerformUpgradeCS :
  PipelineComponent

  // Define the set of possible values for the new custom property.
{
  private enum InvalidValueHandling
  {
    Ignore,
    FireInformation,
    FireWarning,
    FireError
  };

  public override void PerformUpgrade(int pipelineVersion)
  {

    // Obtain the current component version from the attribute.
    DtsPipelineComponentAttribute componentAttribute = 
      (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false);
    int currentVersion = componentAttribute.CurrentVersion;

    // If the component version saved in the package is less than
    //  the current version, Version 2, perform the upgrade.
    if (ComponentMetaData.Version < currentVersion)

    // Get the current value of the old custom property, RaiseErrorOnInvalidValue, 
    // and then remove the property from the custom property collection.
    {
      bool oldValue = false;
      try
      {
        IDTSCustomProperty100 oldProperty = 
          ComponentMetaData.CustomPropertyCollection["RaiseErrorOnInvalidValue"];
        oldValue = (bool)oldProperty.Value;
        ComponentMetaData.CustomPropertyCollection.RemoveObjectByIndex("RaiseErrorOnInvalidValue");
      }
      catch (Exception ex)
      {
        // If the old custom property is not available, ignore the error.
      }

      // Set the value of the new custom property, InvalidValueHandling,
      //  by using the appropriate enumeration value.
      IDTSCustomProperty100 newProperty = 
         ComponentMetaData.CustomPropertyCollection["InvalidValueHandling"];
      if (oldValue == true)
      {
        newProperty.Value = InvalidValueHandling.FireError;
      }
      else
      {
        newProperty.Value = InvalidValueHandling.Ignore;
      }

    }

    // Update the saved component version metadata to the current version.
    ComponentMetaData.Version = currentVersion;

  }

}
Integration Services icon (small) Tümleştirme Hizmetleri ile güncel kalın

Karşıdan yüklemeler, makaleleri, örnekler ve en son Microsoft video yanı sıra, seçili topluluğun çözümleri için ziyaret Integration Services sayfa MSDN veya TechNet:

Bu güncelleştirmelerin otomatik bildirim için kullanılabilir RSS akışlarına abone olmak sayfa.