/// <summary> /// React on input path attached /// </summary> /// <param name="inputID">ID of the SSIS input</param> public override void OnInputPathAttached(int inputID) { base.OnInputPathAttached(inputID); IDTSVirtualInput100 virtualInput = ComponentMetaData.InputCollection[Constants.INPUT_NAME].GetVirtualInput(); //set all input column to readwrite for (int i = 0; i < virtualInput.VirtualInputColumnCollection.Count; i++) { virtualInput.SetUsageType(virtualInput.VirtualInputColumnCollection[i].LineageID, DTSUsageType.UT_READWRITE); } // load (will update custom input column properties) & save custom properties InitializeProperties(); _isagCustomProperties.Save(ComponentMetaData); }
/// <summary> /// saves the custom properties /// </summary> /// <returns>saving succesful?</returns> private bool save() { List <int> usedOutputColumns = new List <int>(); int usedValidParameter = 0; int usedMatchParameter = 0; IDTSInputColumn100 inputCol; //save LU2_Validparameter try { //Get input column by name (throw exception if input column does not exist) inputCol = GetInputColumnByName(_metadata.InputCollection[0], _isagCustomProperties.LU2_Validparameter); if (inputCol == null) { throw new Exception(); } _isagCustomProperties.LU2_ValidparameterId = inputCol.ID; Mapping.SetIdProperty(_isagCustomProperties.LU2_ValidparameterCustomId, inputCol.CustomPropertyCollection, Mapping.PropertyType.ValidParamter); usedValidParameter = inputCol.ID; } catch (Exception) { if (_isagCustomProperties.LU2_Validparameter != "") { MessageBox.Show("The LU2_Validparameter " + _isagCustomProperties.LU2_Validparameter + " is not part of the InputColumnCollection and will be removed."); } //input column does not exist -> reset id and name (custom id is necessary and will not be removed!) _isagCustomProperties.LU2_ValidparameterId = 0; _isagCustomProperties.LU2_Validparameter = ""; } //save LU_Matchparameter try { //Get input column by name (throw exception if input column does not exist) inputCol = GetInputColumnByName(_metadata.InputCollection[0], _isagCustomProperties.LU_Matchparameter); if (inputCol == null) { throw new Exception(); } _isagCustomProperties.LU_MatchparameterId = inputCol.ID; Mapping.SetIdProperty(_isagCustomProperties.LU_MatchparameterCustomId, inputCol.CustomPropertyCollection, Mapping.PropertyType.MatchParameter); usedMatchParameter = inputCol.ID; } catch (Exception) { if (_isagCustomProperties.LU_Matchparameter != "") { MessageBox.Show("The LU_Matchparameter " + _isagCustomProperties.LU_Matchparameter + " is not part of the InputColumnCollection and will be removed."); } //input column does not exist -> reset id and name (custom id is necessary and will not be removed!) _isagCustomProperties.LU_MatchparameterId = 0; _isagCustomProperties.LU_Matchparameter = ""; } //save output column configurations for (int i = _isagCustomProperties.OutputConfigList.Count - 1; i >= 0; i--) { OutputConfig outConfig = _isagCustomProperties.OutputConfigList[i]; try { //Get input column by name (throw exception if input column does not exist) inputCol = GetInputColumnByName(_metadata.InputCollection[0], outConfig.DftColumn); if (inputCol == null) { throw new Exception(); } outConfig.DftColumnId = inputCol.ID; Mapping.SetIdProperty(outConfig.CustomId, inputCol.CustomPropertyCollection, Mapping.PropertyType.OutputColumn); usedOutputColumns.Add(inputCol.ID); } catch (Exception) { _isagCustomProperties.OutputConfigList.Remove(outConfig); MessageBox.Show("The output DFT column " + outConfig.DftColumn + " is not part of the InputColumnCollection and will be removed."); } } //save custom properties try { _isagCustomProperties.Save(_metadata); } catch (Exception ex) { ShowMessage("The Custom Properties could not be saved! <br/><br/>" + ex.ToString(), "Lookup2: Save", MessageBoxIcon.Error); CloseConnection(); return(false); } //set connection manager try { _metadata.RuntimeConnectionCollection[Constants.CONNECTION_MANAGER_NAME].ConnectionManagerID = _connections[_connectionManager.ConnectionManager].ID; } catch (Exception ex) { ShowMessage("The ConnectionManager could not be saved! <br/><br/>" + ex.ToString(), "Lookup2: Save", MessageBoxIcon.Error); CloseConnection(); return(false); } //remove configuritions for LU2_Validparameter, LU_Matchparameter and output column configurations in SSIS inputcolumns foreach (IDTSInputColumn100 col in _metadata.InputCollection[0].InputColumnCollection) { if (!usedOutputColumns.Contains(col.ID)) { Mapping.RemoveIdProperty(col.CustomPropertyCollection, Mapping.PropertyType.OutputColumn); } if (usedValidParameter != col.ID) { Mapping.RemoveIdProperty(col.CustomPropertyCollection, Mapping.PropertyType.ValidParamter); } if (usedMatchParameter != col.ID) { Mapping.RemoveIdProperty(col.CustomPropertyCollection, Mapping.PropertyType.MatchParameter); } } CloseConnection(); return(true); }