Udostępnij za pośrednictwem


Uaktualnianie wersji składnika przepływu danych

Pakiety, które zostały utworzone za pomocą starszej wersja składnika może zawierać metadane, który nie jest już prawidłowy, takie jak właściwości niestandardowe, w których obciążenie została zmodyfikowana w nowszych wersja składnika.Można zastąpić PerformUpgrade metoda PipelineComponent klasy podstawowej do aktualizacji metadane uprzednio zapisane w starszych pakietów do odzwierciedlenia bieżącej właściwości składnika.

Ostrzeżenie

Gdy ponownie skompilować niestandardowy składnik do nowej wersja Integration Services, nie trzeba zmieniać wartości DtsPipelineComponentAttribute.CurrentVersion właściwość, jeśli właściwość składnika nie uległy zmianie.

Przykład

Poniższy przykład zawiera kod wersja 2.0 fikcyjnej składnik przepływu danych.Nowy numer wersja jest zdefiniowany w CurrentVersion Właściwość DtsPipelineComponentAttribute.Składnik ma właściwość, która definiuje sposób wartości przekraczających próg mają być obsługiwane.W wersja 1.0 fikcyjne składnika nosiła nazwę tej właściwość RaiseErrorOnInvalidValue i przyjęta wartość logiczna PRAWDA lub FAŁSZ.W wersja 2.0 fikcyjne składnika właściwość została zmieniona na InvalidValueHandling i akceptuje jeden z czterech możliwych wartości z wyliczenia niestandardowe.

Zastąpiona PerformUpgrade metoda w następującym przykładzie wykonuje następujące akcje:

  • Pobiera bieżącą wersja składnika.

  • Pobiera wartość stare właściwość niestandardowych.

  • Usuwa stare właściwość z kolekcja właściwość niestandardowych.

  • Ustawia wartość nowej właściwość niestandardowych na podstawie wartości właściwość stare, jeśli to możliwe.

  • Ustawia metadane wersja bieżąca wersja składnika.

Ostrzeżenie

aparat przepływ danych Przekazuje swój własny numer wersja w PerformUpgrade metoda w pipelineVersion parametru.Ten parametr nie jest użyteczne w wersja 1.0 Integration Services, ale może stać się przydatne w późniejszych wersjach.

Kod przykładowy używa tylko wartości wyliczenia dwóch, które bezpośrednio mapować do uprzedniego wartość logiczna wartości właściwość niestandardowej.Użytkownicy mogą wybrać inne wartości wyliczenia dostępne za pośrednictwem składnika niestandardowego interfejs użytkownika, Zaawansowany edytor lub programowo.Aby uzyskać informacje dotyczące wyświetlania wartości wyliczenia dla właściwość niestandardowej w Zaawansowany edytor zobacz "Tworzenie niestandardowych właściwość" in Projekt —czas metody danych przepływu składnika.

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;

  }

}
Ikona usług Integration Services (mała)Bieżąco z usług integracji

Najnowsze pliki do pobrania, artykuły, próbki i wideo firmy Microsoft, jak również wybranych rozwiązań ze Wspólnoty, odwiedź witrynę Integration Services strona na MSDN i TechNet:

Aby otrzymywać automatyczne powiadomienia dotyczące tych aktualizacji, zasubskrybuj źródła danych RSS dostępne na tej stronie.