Renaud Harduin
Développement de composant Integration Services (SSIS)
Par Renaud Harduin publié le 08/01/2006 à 14:16, lu 7556 fois, 6 pages
 5 | 5 - Un peu de cosmétique
Téléchargez le code source - 263 Kb
5 - Un peu de cosmétique
Vous avez la possibilité d'attacher une interface graphique à votre composant. Pour cela, il vous faudra créer une classe qui implémente IDtsComponentUI.
using System;
using System.Collections.Generic;
using System.Text;

using System.Windows.Forms;

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

using Microsoft.SqlServer.Dts.Runtime;


namespace BILab.Technical.BI.ETL.Pipeline.XmlDestination
{
 class XmlDestinationAdapterUI : IDtsComponentUI
 {

  IDTSComponentMetaData90 _md;
  IServiceProvider _sp;

  public void Help(System.Windows.Forms.IWin32Window parentWindow)
  {
  }
  public void New(System.Windows.Forms.IWin32Window parentWindow)
  {
  }
  public void Delete(System.Windows.Forms.IWin32Window parentWindow)
  {
  }

  
  public bool Edit(System.Windows.Forms.IWin32Window parentWindow, Variables vars, Connections cons)
  {
   XmlDestinationAdapterUIForm form = new XmlDestinationAdapterUIForm(this._md);
   DialogResult result = form.ShowDialog(parentWindow);
   if (result == DialogResult.OK)
   {
    return true;
   }
   return false;
  }
  public void Initialize(IDTSComponentMetaData90 dtsComponentMetadata, IServiceProvider serviceProvider)
  {
   // Store the component metadata.
   this._md = dtsComponentMetadata;
   this._sp = serviceProvider;
  }
 
 }
}
Lors du double clic sur votre composant, la méthode initalize est appelée et vous pourrez récupérer ComponentMetadata. Puis la méthode Edit est appelée, et à cette occasion vous pouvez appeler un WinForm.

Nous vous conseillons de gérer l'ensemble sous forme de deux classes séparées. Dans l'attribut DtsPipelineComponent, la propriété UITypeName devra référencer notre classe XmlDestinationAdapterUI.

Le résultat en action :

 
» Démarrer une discussion
 
Discussion démarée par dystopy le 18/07/2007 à 10:52, 2 commentaire(s).