public override IDTSInputColumn100 SetUsageType(int inputID, IDTSVirtualInput100 virtualInput, int lineageID, DTSUsageType usageType)
        {
            IDTSInputColumn100            inputColumn            = null;
            IDTSOutput100                 output                 = this.ComponentMetaData.OutputCollection[0];
            IDTSOutputColumnCollection100 outputColumnCollection = output.OutputColumnCollection;
            IDTSInput100 input = this.ComponentMetaData.InputCollection[0];
            IDTSInputColumnCollection100 inputColumnCollection = input.InputColumnCollection;

            if (usageType == DTSUsageType.UT_IGNORED)
            {
                inputColumn = inputColumnCollection.GetInputColumnByLineageID(lineageID);

                IDTSOutputColumn100 outputColumn = outputColumnCollection.FindObjectByID(inputColumn.MappedColumnID);
                if (outputColumn != null)
                {
                    outputColumnCollection.RemoveObjectByID(outputColumn.ID);
                }

                inputColumn = base.SetUsageType(inputID, virtualInput, lineageID, usageType);
            }
            else
            {
                inputColumn = base.SetUsageType(inputID, virtualInput, lineageID, usageType);

                IDTSOutputColumn100 outputColumn = outputColumnCollection.New();
                outputColumn.Name = inputColumn.Name;
                outputColumn.SetDataTypeProperties(inputColumn.DataType, inputColumn.Length, inputColumn.Precision, inputColumn.Scale, inputColumn.CodePage);
                outputColumn.MappedColumnID = inputColumn.LineageID;
                inputColumn.MappedColumnID  = outputColumn.LineageID;
                AddInputColumnProperty(inputColumn, GeoColumnPropName, "True if the column holds geometry objects to be joined together.", false);
                AddInputColumnProperty(inputColumn, GroupByColumnPropName, "True if the column holds group by values.", false);
            }

            return(inputColumn);
        }
        private void AddConvertComponent(Hashtable colConvertTable, Hashtable colConnectTable)
        {
            convertComp = pipeline.ComponentMetaDataCollection.New();
            convertComp.ComponentClassID         = DATACONVERT_GUID;
            convertComp.Name                     = "Data Conversion";
            convertComp.ValidateExternalMetadata = true;
            convertDesignTimeComp                = convertComp.Instantiate();
            convertDesignTimeComp.ProvideComponentProperties();
            IDTSInput100  cvtInput  = convertComp.InputCollection[0];
            IDTSOutput100 cvtOutput = convertComp.OutputCollection[0];
            IDTSInputColumnCollection100 cvtInputCols = cvtInput.InputColumnCollection;
            IDTSOutput100 srcOutput = srcComp.OutputCollection[0];

            pipeline.PathCollection.New().AttachPathAndPropagateNotifications(srcOutput, cvtInput);
            IDTSVirtualInput100 cvtVirInput = cvtInput.GetVirtualInput();

            int i = 0;

            foreach (object key in colConvertTable.Keys)
            {
                int srcColID = (int)key;
                cvtVirInput.SetUsageType(srcColID, DTSUsageType.UT_READONLY);
                IDTSInputColumn100 cvtInputCol = cvtInputCols.GetInputColumnByLineageID(srcColID);
                if (cvtInputCol != null)
                {
                    IDTSOutputColumn100           cvtOutputCol = convertDesignTimeComp.InsertOutputColumnAt(cvtOutput.ID, i++, "Convert_" + cvtInputCol.Name, "");
                    IDTSExternalMetadataColumn100 destCol      = (IDTSExternalMetadataColumn100)colConvertTable[key];
                    convertDesignTimeComp.SetOutputColumnDataTypeProperties(cvtOutput.ID,
                                                                            cvtOutputCol.ID, destCol.DataType, destCol.Length, destCol.Precision, destCol.Scale, destCol.CodePage);
                    // map output column and input column
                    convertDesignTimeComp.SetOutputColumnProperty(cvtOutput.ID,
                                                                  cvtOutputCol.ID, "SourceInputColumnLineageID", srcColID);
                    // add match table entry.
                    colConnectTable.Add(cvtOutputCol.ID, destCol);
                }
            }
        }
        public void AddPathsAndConnectColumns(Hashtable colPairs)
        {
            IDTSOutput100 srcOutput = srcComp.OutputCollection[0];
            IDTSOutputColumnCollection100 srcOutputCols = srcOutput.OutputColumnCollection;
            IDTSInput100 destInput = destComp.InputCollection[0];
            IDTSInputColumnCollection100            destInputCols = destInput.InputColumnCollection;
            IDTSExternalMetadataColumnCollection100 destExtCols   = destInput.ExternalMetadataColumnCollection;

            Hashtable destColtable = new Hashtable(destExtCols.Count);

            foreach (IDTSExternalMetadataColumn100 extCol in destExtCols)
            {
                destColtable.Add(extCol.Name, extCol);
            }

            bool useMatch = (colPairs != null && colPairs.Count > 0);
            // colConvertTable stores a pair of columns which need a type conversion
            // colConnectTable stores a pair of columns which dont need a type conversion and can be connected directly.
            Hashtable colConvertTable = new Hashtable(srcOutputCols.Count);
            Hashtable colConnectTable = new Hashtable(srcOutputCols.Count);

            foreach (IDTSOutputColumn100 outputCol in srcOutputCols)
            {
                // Get the column name to look for in the destination.
                // Match column by name if match table is not used.
                String colNameToLookfor = String.Empty;
                if (useMatch)
                {
                    colNameToLookfor = (String)colPairs[outputCol.Name];
                }
                else
                {
                    colNameToLookfor = outputCol.Name;
                }

                IDTSExternalMetadataColumn100 extCol = (String.IsNullOrEmpty(colNameToLookfor)) ? null : (IDTSExternalMetadataColumn100)destColtable[colNameToLookfor];
                // Does the destination column exist?
                if (extCol != null)
                {
                    // Found destination column, but is data type conversion needed?
                    if (NeedConvert(outputCol.DataType, extCol.DataType))
                    {
                        colConvertTable.Add(outputCol.ID, extCol);
                    }
                    else
                    {
                        colConnectTable.Add(outputCol.ID, extCol);
                    }
                }
            }
            if (colConvertTable.Count > 0)
            {
                // add convert component
                AddConvertComponent(colConvertTable, colConnectTable);
                pipeline.PathCollection.New().AttachPathAndPropagateNotifications(convertComp.OutputCollection[0], destInput);
            }
            else
            {
                // Convert transform not needed. Connect src and destination directly.
                pipeline.PathCollection.New().AttachPathAndPropagateNotifications(srcOutput, destInput);
            }

            IDTSVirtualInput100 destVirInput = destInput.GetVirtualInput();

            foreach (object key in colConnectTable.Keys)
            {
                int colID = (int)key;
                IDTSExternalMetadataColumn100 extCol = (IDTSExternalMetadataColumn100)colConnectTable[key];
                // Create an input column from an output col of previous component.
                destVirInput.SetUsageType(colID, DTSUsageType.UT_READONLY);
                IDTSInputColumn100 inputCol = destInputCols.GetInputColumnByLineageID(colID);
                if (inputCol != null)
                {
                    // map the input column with an external metadata column
                    destDesignTimeComp.MapInputColumn(destInput.ID, inputCol.ID, extCol.ID);
                }
            }
        }