/// <summary> /// Rebuilds mapping of input and output columns /// (errors are corrected if possible) /// </summary> /// <param name="componentMetaData">SSIS components metadata</param> public void RebuildMappings(IDTSComponentMetaData100 componentMetaData, IsagEvents events) { IDTSInput100 input = componentMetaData.InputCollection[Constants.INPUT_NAME]; IDTSVirtualInput100 vInput = input.GetVirtualInput(); Dictionary <int, ColumnConfig> mappingsInput = new Dictionary <int, ColumnConfig>(); List <ColumnConfig> mappingsWithoutInputs = new List <ColumnConfig>(); List <ColumnConfig> newMappings = new List <ColumnConfig>(); if (this.ContainsWrongUsageType(vInput.VirtualInputColumnCollection, events)) { ComponentMetaDataTools.SetUsageTypeReadOnly(vInput); } //Writre existing mappings in 2 lists (one with input columns, one without) foreach (ColumnConfig config in this.ColumnConfigList) { if (config.HasInput) { mappingsInput.Add(config.InputColumnId, config); } else { mappingsWithoutInputs.Add(config); } } //Generate new mapping using SSIS input columns foreach (IDTSInputColumn100 inputCol in input.InputColumnCollection) { ColumnConfig config; if (mappingsInput.ContainsKey(inputCol.ID)) { config = mappingsInput[inputCol.ID]; config.InputColumnName = inputCol.Name; config.DataTypeInput = SqlCreator.GetSQLServerDataTypeFromInput(inputCol, config.IsGeometryDataType); } else { config = new ColumnConfig(inputCol.Name, SqlCreator.GetSQLServerDataTypeFromInput(inputCol, isGeometry: false), inputCol); } newMappings.Add(config); } //Add properties to the newly created mapping ColumnConfigList.Clear(); foreach (ColumnConfig config in newMappings) { ColumnConfigList.Add(config); } foreach (ColumnConfig config in mappingsWithoutInputs) { ColumnConfigList.Add(config); } this.Save(componentMetaData); }
/// <summary> /// Provides the component properties /// </summary> public override void ProvideComponentProperties() { base.ProvideComponentProperties(); _IsagCustomProperties = new IsagCustomProperties(); _IsagCustomProperties.SetDefaultValues(); ComponentMetaDataTools.UpdateVersion(this, ComponentMetaData); //Set metadata version to DLL-Version DtsPipelineComponentAttribute componentAttr = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int binaryVersion = componentAttr.CurrentVersion; ComponentMetaData.Version = binaryVersion; //Clear out base implmentation this.ComponentMetaData.RuntimeConnectionCollection.RemoveAll(); this.ComponentMetaData.InputCollection.RemoveAll(); this.ComponentMetaData.OutputCollection.RemoveAll(); //Input IDTSInput100 input = this.ComponentMetaData.InputCollection.New(); input.Name = Constants.INPUT_NAME; input.Description = Constants.INPUT_NAME; input.HasSideEffects = true; //New connection managers IDTSRuntimeConnection100 conn = this.ComponentMetaData.RuntimeConnectionCollection.New(); conn.Name = Constants.CONNECTION_MANAGER_NAME_MAIN; conn.Description = "Main Connection to SQL Server"; //Custom Properties hinzufügen IDTSCustomProperty100 prop = ComponentMetaData.CustomPropertyCollection.New(); prop.Name = Constants.PROP_CONFIG; _IsagCustomProperties.Save(ComponentMetaData); }