//Dissallow DT_NTEXT, DT_TEXT and DT_IMAGE data types. public override bool CheckColumnForInputValidity(IDTSVirtualInput vInput, IDTSInput input, FormInputColumn icol) { bool validForInput = false; var dt = icol.DTSVirtualColumn.DataType; if (dt == DataType.DT_NTEXT || dt == DataType.DT_TEXT || dt == DataType.DT_IMAGE) { validForInput = false; } else { if (icol.DTSInputColumn != null) { //IDTSCustomProperty nullCol = icol.DTSInputColumn.CustomPropertyCollection[Resources.LookupErrorAggIsNullColumnName]; //bool isNullCol = (bool)nullCol.Value; IDTSCustomProperty keyCol = icol.DTSInputColumn.CustomPropertyCollection[Resources.LookupErrorAggIsKeyColumnName]; bool isKeyCol = (bool)keyCol.Value; if (!isKeyCol) { DesignTimeComponent.SetUsageType(input.ID, vInput, icol.LineageID, DTSUsageType.UT_IGNORED); icol.DTSInputColumn = null; } } validForInput = true; } return(validForInput); }
/// <summary> /// Creates a new Input Column /// </summary> /// <param name="inputID"></param> /// <param name="virtualInput"></param> /// <param name="lineageID"></param> /// <param name="usageType"></param> /// <returns></returns> public override IDTSInputColumn SetUsageType(int inputID, IDTSVirtualInput virtualInput, int lineageID, DTSUsageType usageType) { DTSUsageType uType = usageType == DTSUsageType.UT_READWRITE ? DTSUsageType.UT_READONLY : usageType; IDTSInputColumn col = base.SetUsageType(inputID, virtualInput, lineageID, uType); return(col); }
private void CreateInputColumns(IDTSVirtualInput virtualInput) { ComponentMetaData.InputCollection[0].InputColumnCollection.RemoveAll(); foreach (IDTSVirtualInputColumn virtualInputColumn in virtualInput.VirtualInputColumnCollection) { var inputColumn = ComponentMetaData.InputCollection[0].InputColumnCollection.New(); inputColumn.LineageID = virtualInputColumn.LineageID; inputColumn.UsageType = DTSUsageType.UT_READONLY; } }
/// <summary> /// Gets InputColumns of Input at selected inde of InputCollection encapsulated in the FormInputColumn class /// </summary> /// <param name="index">Index of the Input to get InputColumns</param> /// <returns>List of FormInputColumn</returns> public virtual List <FormInputColumn> GetFormInputColumns(int index) { List <FormInputColumn> inputCols = new List <FormInputColumn>(); IDTSInput input = GetInput(index); IDTSVirtualInput vInput = GetVirtualInput(index); if (input != null && VirtualInput != null) { for (int i = 0; i < VirtualInput.VirtualInputColumnCollection.Count; i++) //foreach (IDTSVirtualInputColumn vcol in VirtualInput.VirtualInputColumnCollection) { IDTSVirtualInputColumn vcol = VirtualInput.VirtualInputColumnCollection[i]; FormInputColumn icol = new FormInputColumn(vcol, i); if (vcol.UsageType != DTSUsageType.UT_IGNORED) { IDTSInputColumn inputCol = input.InputColumnCollection.GetInputColumnByLineageID(vcol.LineageID); icol.DTSInputColumn = inputCol; } bool isValidForInput = CheckColumnForInputValidity(vInput, input, icol); if (isValidForInput) { inputCols.Add(icol); } } inputCols.Sort((a, b) => a.Name.CompareTo(b.Name)); for (int i = 0; i < inputCols.Count; i++) { if (i >= 0 && i < inputCols.Count - 1 && inputCols[i].Name == inputCols[i + 1].Name) { inputCols[i].DisplayName = string.Format("{0}.{1}", inputCols[i].SourceComponent, inputCols[i].Name); } else if (i > 0 && i < inputCols.Count && inputCols[i].Name == inputCols[i - 1].Name) { inputCols[i].DisplayName = string.Format("{0}.{1}", inputCols[i].SourceComponent, inputCols[i].Name); } } inputCols.Sort((a, b) => a.Index.CompareTo(b.Index)); } return(inputCols); }
protected void AddInputColumnForInput(InputColumn column, string inputName) { GetAllVirtualInputs(); Pipe.IDTSVirtualInput100 virtualInput = VirtualInputs.Where(vi => vi.Description == inputName).First(); Pipe.IDTSInput100 input = SSISInputs.Where(i => i.Name == inputName).First(); for (int i = 0; i < VirtualInputsColumnCollections[virtualInput].Count; i++) { if (column.Name == VirtualInputsColumnCollections[virtualInput][i].Name) { ComponentWrapper.SetUsageType(input.ID, virtualInput, VirtualInputsColumnCollections[virtualInput][i].LineageID, (Pipe.DTSUsageType)column.UsageType); } } ; }
protected void GetAllVirtualInputs() { if (HasAllVirtualInputsInitialized) { return; } VirtualInputs = new List <Pipe.IDTSVirtualInput100>(); VirtualInputsColumnCollections = new Dictionary <Pipe.IDTSVirtualInput100, Pipe.IDTSVirtualInputColumnCollection100>(); foreach (Pipe.IDTSInput100 input in this.SSISInputs) { Pipe.IDTSVirtualInput100 virtualInput = input.GetVirtualInput(); VirtualInputs.Add(virtualInput); VirtualInputsColumnCollections.Add(virtualInput, virtualInput.VirtualInputColumnCollection); } }
/// <summary> /// Reinitialize metadata in case input cvolumns are invalid /// </summary> public override void ReinitializeMetaData() { if (!inputColumnsValid) { IDTSInput input = ComponentMetaData.InputCollection[0]; IDTSVirtualInput vInput = input.GetVirtualInput(); foreach (IDTSInputColumn col in input.InputColumnCollection) { IDTSVirtualInputColumn100 vCol = vInput.VirtualInputColumnCollection.GetVirtualInputColumnByLineageID(col.LineageID); if (vCol == null) { input.InputColumnCollection.RemoveObjectByID(col.ID); } } inputColumnsValid = true; } }
public override void Initialize(IDTSComponentMetaData dtsComponentMetadata, IServiceProvider serviceProvider) { base.Initialize(dtsComponentMetadata, serviceProvider); _inputColumns = new List <ConvertMetadataInputColumn>(); IDTSVirtualInput vInput = GetVirtualInput(0); //Get virtualInput for the RegExExtractionTransformation if (vInput != null) { foreach (IDTSVirtualInputColumn vcol in vInput.VirtualInputColumnCollection) { if (RegExExtractionTransformation.SupportedDataTypes.Contains(vcol.DataType)) { ConvertMetadataInputColumn iCol = new ConvertMetadataInputColumn(vcol); _inputColumns.Add(iCol); } } } //Sort the columns by name _inputColumns.Sort((a, b) => a.Name.CompareTo(b.Name)); //Check if the column names repeats and in that cas set the DisplayName to include also UpstreamComponentname for (int i = 0; i < _inputColumns.Count; i++) { if (i >= 0 && i < _inputColumns.Count - 1 && _inputColumns[i].Name == _inputColumns[i + 1].Name) { _inputColumns[i].DisplayName = string.Format("{0}.{1}", _inputColumns[i].UpstreamComponentName, _inputColumns[i].Name); } else if (i > 0 && i < _inputColumns.Count && _inputColumns[i].Name == _inputColumns[i - 1].Name) { _inputColumns[i].DisplayName = string.Format("{0}.{1}", _inputColumns[i].UpstreamComponentName, _inputColumns[i].Name); } } //add the "Not Specified" column (LineageID = 0) _inputColumns.Insert(0, ConvertMetadataInputColumn.NotSpecifiedInputColumn); }
/// <summary> /// If a path is connected, automatically select all the columns. /// </summary> /// <param name="inputID">The internal id of the input. Should always translate to index 0, but...</param> public override void OnInputPathAttached(int inputID) { // Get the index of the input in the collection int inputIndex = ComponentMetaData.InputCollection.FindObjectIndexByID(inputID); // Remove all the current columns. ComponentMetaData.InputCollection[inputIndex].InputColumnCollection.RemoveAll(); // Loop though all the columns in the input path, and connect them. IDTSVirtualInput virtualInput = ComponentMetaData.InputCollection[inputIndex].GetVirtualInput(); if (virtualInput == null) { throw new ArgumentNullException("virtualInput"); } foreach (IDTSVirtualInputColumn viColumn in virtualInput.VirtualInputColumnCollection) { this.SetUsageType(inputID, virtualInput, viColumn.LineageID, DTSUsageType.UT_READONLY); } }
/// <summary> /// Called repeatedly when the component is edited in the designer, and once at the beginning of execution. /// Verifies the following: /// 1. Check that there are no outputs /// 2. Check that there is only one input /// 3. Check that all upstream columns are present. /// </summary> /// <returns>The status of the validation</returns> public override DTSValidationStatus Validate() { bool cancel = false; if (ComponentMetaData.InputCollection.Count != 1) { ComponentMetaData.FireError(0, ComponentMetaData.Name, "The input collection count is not 1.", String.Empty, 0, out cancel); return(DTSValidationStatus.VS_ISCORRUPT); } if (ComponentMetaData.OutputCollection.Count != 0) { ComponentMetaData.FireError(0, ComponentMetaData.Name, "The output collection count is not 0.", String.Empty, 0, out cancel); return(DTSValidationStatus.VS_ISCORRUPT); } IDTSInput input = ComponentMetaData.InputCollection[0]; IDTSVirtualInput vInput = input.GetVirtualInput(); if (input.HasSideEffects == false) { ComponentMetaData.FireError(0, ComponentMetaData.Name, "The input does not have HasSideEffects set.", String.Empty, 0, out cancel); return(DTSValidationStatus.VS_ISCORRUPT); } foreach (IDTSInputColumn inputColumn in input.InputColumnCollection) { try { IDTSVirtualInputColumn vColumn = vInput.VirtualInputColumnCollection.GetVirtualInputColumnByLineageID(inputColumn.LineageID); } catch { ComponentMetaData.FireError(0, ComponentMetaData.Name, "The input column " + inputColumn.IdentificationString + " does not match a column in the upstream output.", String.Empty, 0, out cancel); areInputColumnsValid = false; return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } } //return base.Validate(); return(DTSValidationStatus.VS_ISVALID); }
private void btnOk_Click(object sender, EventArgs e) { if (properties.NullColumnLineageId != -1) { IDTSInput input = UIHelper.GetInput(0); IDTSVirtualInput vInput = UIHelper.GetVirtualInput(0); IDTSVirtualInputColumn vCol = vInput.VirtualInputColumnCollection.GetVirtualInputColumnByLineageID(properties.NullColumnLineageId);; IDTSInputColumn col; if (vCol.UsageType != DTSUsageType.UT_IGNORED) { col = input.InputColumnCollection.GetInputColumnByLineageID(vCol.LineageID); } else { col = UIHelper.DesignTimeComponent.SetUsageType(input.ID, vInput, properties.NullColumnLineageId, DTSUsageType.UT_READONLY); } IDTSCustomProperty nullCol = col.CustomPropertyCollection[Resources.LookupErrorAggIsNullColumnName]; nullCol.Value = true; } this.Close(); }
/// <summary> /// If there are validation issues, then repair them! /// The only issue that can be repaired is when there are missing upstream columns. /// </summary> public override void ReinitializeMetaData() { if (!areInputColumnsValid) { int inputID = ComponentMetaData.InputCollection[0].ID; // Remove all the current columns. ComponentMetaData.InputCollection[0].InputColumnCollection.RemoveAll(); // Loop though all the columns in the input path, and connect them. IDTSVirtualInput virtualInput = ComponentMetaData.InputCollection[0].GetVirtualInput(); if (virtualInput == null) { throw new ArgumentNullException("virtualInput"); } foreach (IDTSVirtualInputColumn viColumn in virtualInput.VirtualInputColumnCollection) { this.SetUsageType(inputID, virtualInput, viColumn.LineageID, DTSUsageType.UT_READONLY); } areInputColumnsValid = true; } base.ReinitializeMetaData(); }
public override void Initialize(IDTSComponentMetaData dtsComponentMetadata, IServiceProvider serviceProvider) { base.Initialize(dtsComponentMetadata, serviceProvider); _inputColumns = new List <ConvertMetadataInputColumn>(); _lookupColumns = new List <ConvertMetadataInputColumn>(); _inputDateColumns = new List <ConvertMetadataInputColumn>(); _lookupDateColumns = new List <ConvertMetadataInputColumn>(); //Load InputColumns if (ComponentMetadata != null && ComponentMetadata.InputCollection.Count > 0) { IDTSVirtualInput vInput = GetVirtualInput(0); //Get virtualInput for the Data Input if (vInput != null) { foreach (IDTSVirtualInputColumn vcol in vInput.VirtualInputColumnCollection) { if (CheckColumnForInputValidity(vcol)) { ConvertMetadataInputColumn iCol = new ConvertMetadataInputColumn(vcol); _inputColumns.Add(iCol); } } } //Sort the columns by name _inputColumns.Sort((a, b) => a.Name.CompareTo(b.Name)); //Check if teh column names repeats and in that cas set the DisplayName tto include also UpstreamComponentname for (int i = 0; i < _inputColumns.Count; i++) { if (i >= 0 && i < _inputColumns.Count - 1 && _inputColumns[i].Name == _inputColumns[i + 1].Name) { _inputColumns[i].DisplayName = string.Format("{0}.{1}", _inputColumns[i].UpstreamComponentName, _inputColumns[i].Name); } else if (i > 0 && i < _inputColumns.Count && _inputColumns[i].Name == _inputColumns[i - 1].Name) { _inputColumns[i].DisplayName = string.Format("{0}.{1}", _inputColumns[i].UpstreamComponentName, _inputColumns[i].Name); } } //add the "Not Specified" column (LineageID = 0) _inputColumns.Insert(0, ConvertMetadataInputColumn.NotSpecifiedInputColumn); } //Load LookupColumns if (ComponentMetadata != null && ComponentMetadata.InputCollection.Count > 1) { IDTSVirtualInput vInput = GetVirtualInput(1); //Get virtualInput for the Data Input if (vInput != null) { foreach (IDTSVirtualInputColumn vcol in vInput.VirtualInputColumnCollection) { if (CheckColumnForInputValidity(vcol)) { ConvertMetadataInputColumn iCol = new ConvertMetadataInputColumn(vcol); _lookupColumns.Add(iCol); } } } //Sort the columns by name _lookupColumns.Sort((a, b) => a.Name.CompareTo(b.Name)); //Check if teh column names repeats and in that cas set the DisplayName tto include also UpstreamComponentname for (int i = 0; i < _lookupColumns.Count; i++) { if (i >= 0 && i < _lookupColumns.Count - 1 && _lookupColumns[i].Name == _lookupColumns[i + 1].Name) { _lookupColumns[i].DisplayName = string.Format("{0}.{1}", _lookupColumns[i].UpstreamComponentName, _lookupColumns[i].Name); } else if (i > 0 && i < _lookupColumns.Count && _lookupColumns[i].Name == _lookupColumns[i - 1].Name) { _lookupColumns[i].DisplayName = string.Format("{0}.{1}", _lookupColumns[i].UpstreamComponentName, _lookupColumns[i].Name); } } //add the "Not Specified" column (LineageID = 0) _lookupColumns.Insert(0, ConvertMetadataInputColumn.NotSpecifiedInputColumn); } }
/// <summary> /// Validate HashColumnsTransform metadata /// </summary> /// <returns></returns> public override DTSValidationStatus Validate() { if (ComponentMetaData.InputCollection.Count != 1) { FireComponentMetadataError(0, Resources.ErrorIncorrectNumberOfInputs); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } if (ComponentMetaData.OutputCollection.Count != 1) { FireComponentMetadataError(0, Resources.ErrorIncorrectNumberOfOutputs); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } IDTSInput input = ComponentMetaData.InputCollection[0]; IDTSVirtualInput vInput = input.GetVirtualInput(); foreach (IDTSInputColumn column in input.InputColumnCollection) { try { IDTSVirtualInputColumn100 vColumn = vInput.VirtualInputColumnCollection.GetVirtualInputColumnByLineageID(column.LineageID); } catch { FireComponentMetadataError(0, string.Format(Resources.ErrorInputColumnNotInUpstreamComponent, column.IdentificationString)); inputColumnsValid = false; return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } } IDTSOutput output = ComponentMetaData.OutputCollection[0]; List <IDTSOutputColumn> redundantColumns = new List <IDTSOutputColumn>(output.OutputColumnCollection.Count); bool xmlColumnExists = false; List <int> missingLineages = new List <int>(); List <int> missingInputLineages = new List <int>(); bool missingError = false; foreach (IDTSOutputColumn outputColumn in output.OutputColumnCollection) { bool isRendundant = true; bool isInputColumn = false; foreach (IDTSInputColumn inputColumn in input.InputColumnCollection) { if (inputColumn.Name == outputColumn.Name) { isRendundant = false; isInputColumn = true; break; } } //Check if XML Column; if (!isInputColumn) { foreach (IDTSCustomProperty prop in outputColumn.CustomPropertyCollection) { if (prop.Name == Resources.XmlInputColumnsPropertyname) { isRendundant = false; xmlColumnExists = true; var lineages = InputColumns.ParseInputLineages(prop.Value.ToString()); foreach (IDTSInputColumn icol in input.InputColumnCollection) { int l = icol.LineageID; lineages.Remove(l); if (lineages.Count == 0) { break; } } if (lineages.Count > 0) { foreach (int l in lineages) { if (!missingInputLineages.Contains(l)) { missingInputLineages.Add(l); } } foreach (IDTSVirtualInputColumn vcol in vInput.VirtualInputColumnCollection) { int l = vcol.LineageID; lineages.Remove(l); if (lineages.Count == 0) { break; } } if (lineages.Count > 0) { foreach (int l in lineages) { if (!missingLineages.Contains(l)) { missingLineages.Add(l); } } } } } if (prop.Name == Resources.XmlSaveOptionPropertyName) { isRendundant = false; xmlColumnExists = true; if (!Enum.IsDefined(typeof(SaveOptions), prop.Value)) { FireComponentMetadataError(0, string.Format(Resources.ErrorInvalidSaveOption, outputColumn.Name)); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } else { if (outputColumn.DataType != DataType.DT_NTEXT && outputColumn.DataType != DataType.DT_WSTR) { FireComponentMetadataError(0, string.Format(Resources.ErrorInvalidDataType, outputColumn.Name)); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } } } } } //add redundand column to redundand list if (isRendundant) { redundantColumns.Add(outputColumn); } } if (missingLineages.Count > 0) { string ml = string.Join(", ", missingLineages.ConvertAll <string>(l => l.ToString()).ToArray()); FireComponentMetadataError(0, string.Format("Output columns are referencing input column lineages which do not exists: {0}", ml)); missingError = true; } if (missingInputLineages.Count > 0) { string ml = string.Join(", ", missingInputLineages.ConvertAll <string>(l => l.ToString()).ToArray()); FireComponentMetadataError(0, string.Format("Output columns are referencing input column lineages which are not selected as Input columns: {0}", ml)); missingError = true; } if (missingError) { return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } //remove redundand output columns foreach (IDTSOutputColumn col in redundantColumns) { output.OutputColumnCollection.RemoveObjectByID(col.ID); } //If XmlColumn does not exists, create a default one if (!xmlColumnExists) { IDTSOutputColumn xmlCol = output.OutputColumnCollection.New(); xmlCol.Name = Resources.XmlColumnDefaultName; xmlCol.Description = Resources.XmlColumnDefaultDesccription; SetXmlColumnProperties(xmlCol); } return(DTSValidationStatus.VS_ISVALID); }
public virtual bool CheckColumnForInputValidity(IDTSVirtualInput vInput, IDTSInput input, FormInputColumn icol) { return(CheckColumnForInputValidity(icol != null ? icol.DTSVirtualColumn : null)); }
/// <summary> /// Validate HashColumnsTransform metadata /// </summary> /// <returns></returns> public override DTSValidationStatus Validate() { //Check that we have only one input if (ComponentMetaData.InputCollection.Count != 1) { FireComponentMetadataError(0, Resources.ErrorIncorrectNumberOfInputs); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } //Check that we have only one output if (ComponentMetaData.OutputCollection.Count != 1) { FireComponentMetadataError(0, Resources.ErrorIncorrectNumberOfOutputs); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } IDTSInput input = ComponentMetaData.InputCollection[0]; IDTSVirtualInput vInput = input.GetVirtualInput(); //Check Input columns that they exists foreach (IDTSInputColumn column in input.InputColumnCollection) { try { IDTSVirtualInputColumn100 vColumn = vInput.VirtualInputColumnCollection.GetVirtualInputColumnByLineageID(column.LineageID); } catch { inputColumnsValid = false; FireComponentMetadataError(0, string.Format(Resources.ErrorInputColumnNotInUpstreamComponent, column.IdentificationString)); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } } IDTSOutput output = ComponentMetaData.OutputCollection[0]; List <IDTSOutputColumn> redundantColumns = new List <IDTSOutputColumn>(output.OutputColumnCollection.Count); bool rowNumberColumnExists = false; foreach (IDTSOutputColumn outputColumn in output.OutputColumnCollection) { bool isRendundant = true; foreach (IDTSCustomProperty prop in outputColumn.CustomPropertyCollection) { if (prop.Name == Resources.RowNumberIncrementByPropertyName) { isRendundant = false; rowNumberColumnExists = true; } //TODO: Here will be checks for proper properties settings } //add redundand column to redundand list if (isRendundant) { redundantColumns.Add(outputColumn); } } //remove redundand output columns foreach (IDTSOutputColumn100 col in redundantColumns) { output.OutputColumnCollection.RemoveObjectByID(col.ID); } if (!rowNumberColumnExists) { rowNumberColumnExists = true; output = ComponentMetaData.OutputCollection[0]; IDTSOutputColumn rowNumberColumn = output.OutputColumnCollection.New(); rowNumberColumn.Name = Resources.RowNumberDefaultColumnName; rowNumberColumn.Description = Resources.RowNumberDefaultColumnDescription; SetRowNumberColumnProperties(rowNumberColumn); } return(DTSValidationStatus.VS_ISVALID); }