Bir veri akışı bileşen sürümüne yükseltme

Bir eski oluşturulan paketler sürüm bileşeniniz artık özel özellikleri, kullanım içinde değiştirildi gibi geçersiz meta veriler içerebilir daha yeni sürümbileşenin s.Geçersiz kılabilirsiniz PerformUpgrade yöntem, PipelineComponent Bileşen geçerli özellikleri yansıtmak için eski paketleri önceden kaydedilen meta veriler güncelleştirmek için temel sınıf

Not

Özel bir bileşen için yeni bir sürüm derlemeniz ne zaman Integration Services, değerini değiştirmek zorunda DtsPipelineComponentAttribute.CurrentVersion bileşeninin özelliklerini değişmemiş, özellik.

Örnek

Aşağıdaki örnek kod sürüm 2. 0'ın bir hayali içerir veri akışı bileşeni.Yeni sürüm numarası tanımlanır CurrentVersion özellik DtsPipelineComponentAttribute.Bileşenine sahip bir özellik , bir eşiği aşan nasıl sayısal değerlerin tanımlar şekilde ele alınması gereken.De sürüm hayali bileşen 1.0, bu özellik adlı RaiseErrorOnInvalidValue ve kabul edilen Boole true veya false.Hayali bileşenin sürüm 2.0, özellik için adı değiştirilmiş InvalidValueHandling ve özel bir numaralandırma dört olası değerden birine kabul eder

Geçersiz kılınmış PerformUpgrade yöntem aşağıdaki örnek, aşağıdaki eylemleri gerçekleştirir:

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

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

  • Eski özellik özel özelliğinden kaldırır koleksiyon.

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

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

Not

Veri akışı altyapısı kendi sürüm numarası uygulamasına geçirmeden PerformUpgrade yöntem , pipelineVersion parametresi.Bu parametre yararlı değil sürüm 1 Integration Services, sonraki de yararlı olur, ancak sürüms.

Örnek kod, yalnızca doğrudan özel özellik önceki Boole değerlerini eşleştirmek iki numaralandırma değerleri kullanır.Bileşenin özel kullanıcı arabirim yoluyla diğer kullanılabilir numaralandırma değerleri kullanıcı seçmek Gelişmiş Düzenleyici veya program aracılığıyla.Gelişmiş Düzenleyicisi'nde özel bir özellik için numaralandırma değerleri görüntüleme hakkında bilgi için "Özel özellikler oluşturma" konusuna bakın. in Tasarım -saat yöntemleri bir veri akışı bileşen.

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 simgesi (küçük)Integration Services ile güncel kalın

En son karşıdan yüklemeler, makaleler, örnekler ve seçilen topluluk çözümleri yanı sıra Microsoft videolar için ziyaret Integration Services sayfa msdn veya TechNet:

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