/* * Metodo invocato quando il componente UI viene caricato per la prima volta, generalmente in seguito al doppio click sul componente. */ public void Initialize(IDTSComponentMetaData100 dtsComponentMetadata, IServiceProvider serviceProvider) { // Salva un link ai metadati del runtime editor ed al serviceProvider _sp = serviceProvider; _md = dtsComponentMetadata; // Controlla se l'oggetto contiene il model serializzato nelle proprietà. In caso negativo, creane uno nuovo ed attribuisciglielo. IDTSCustomProperty100 model = _md.CustomPropertyCollection[ComponentConstants.PROPERTY_KEY_MODEL]; if (model.Value == null) { _model = new TransformationModel(); model.Value = _model.ToJsonConfig(); } else { _model = TransformationModel.LoadFromJson(model.Value.ToString()); } if (_md == null) { _md = (IDTSComponentMetaData100)_md.Instantiate(); } }
public bool Edit(System.Windows.Forms.IWin32Window parentWindow, Variables vars, Connections cons) { // Create and display the form for the user interface. _model.Inputs.Clear(); IDTSInput100 input = _md.InputCollection[0]; foreach (IDTSVirtualInputColumn100 vcol in input.GetVirtualInput().VirtualInputColumnCollection) { // Only add the textual columns as valid input. if (vcol.DataType == Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_NTEXT || vcol.DataType == Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_TEXT || vcol.DataType == Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_STR || vcol.DataType == Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_WSTR) { _model.Inputs.Add(vcol.Name, vcol.LineageID); } } JsonTransformUI componentEditor = new JsonTransformUI(parentWindow, _model, _sp); DialogResult result = componentEditor.ShowDialog(parentWindow); if (result == DialogResult.OK) { _md.CustomPropertyCollection[ComponentConstants.PROPERTY_KEY_MODEL].Value = _model.ToJsonConfig(); AddInputColumn(_model.InputColumnName); AddOutputColumns(_model.IoMap); return(true); } return(false); }