Veri akışı bileşen sürümünü yükseltme

Bileşeniniz eski bir sürümüyle oluşturulan paketler, özelliklerin kullanımı bileşenin daha yeni sürümlerinde değiştirildi gibi geçersiz meta veriler içerebilir. Geçersiz kılınabilir PerformUpgradeyöntemi PipelineComponenttemel sınıfı, bileşenin geçerli özelliklerini yansıtacak şekilde eski paketleri önceden kaydedilen meta veri güncelleştirmesi.

[!NOT]

Ne zaman özel bir bileşen için yeni bir sürümünü derlemeniz Integration Services, değerini değiştirmek gerekmez DtsPipelineComponentAttribute.CurrentVersionbileşenin özelliklerini değişmemiş, özellik.

Örnek

Aşağıdaki örnek kurgusal veri akışı bileşen sürüm 2.0 kodunu içerir. Yeni sürüm numarası tanımlı CurrentVersionözelliği DtsPipelineComponentAttribute. Bileşen, bir eşiği aşan nasıl sayısal değerlerini tanımlayan bir özellik vardır ele vardır. Hayali bileşen sürüm 1.0, içinde bu özellik adlı RaiseErrorOnInvalidValueve bir Boolean değeri doğru veya yanlış kabul. Hayali bileşen sürüm 2.0, içinde için özellik değiştirildi InvalidValueHandlingve özel bir numaralandırma dört olası değerden birine kabul.

Geçersiz kılınmış PerformUpgradeyöntemi aşağıdaki örnek aşağıdaki eylemleri gerçekleştirir:

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

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

  • Eski özellik özel özellik koleksiyonundan kaldırır.

  • Mümkünse eski özelliğinin değeri temelinde yeni bir özel özellik değerini ayarlar.

  • Sürüm meta verileri için bileşenin geçerli sürümünü ayarlar.

[!NOT]

Veri akışı altyapısı sürüm numarası haline geçer PerformUpgradeyöntemi pipelineVersionparametresi. Bu parametre sürümü 1.0 yararlı değil Integration Services, daha sonraki sürümlerde yararlı olabilir ama.

Örnek kod, yalnızca doğrudan özel özellik önceki Boole değerlerini eşleştirmek iki numaralandırma değerleri kullanır. Kullanıcılar bileşenin özel kullanıcı arabirimi, diğer kullanılabilir numaralandırma değerleri seçebilirsiniz Gelişmiş Düzenleyici ya da programlı. Gelişmiş Düzenleyicisi'nde özel bir özellik için numaralandırma değerleri görüntüleme hakkında daha fazla bilgi için "Özel özellikler oluşturma" konusuna bakın. in Bileşen tasarım zamanı yöntemleri bir veri akışı.

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
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;

  }

}
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 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.