private static void AddColumn(IDTSDesigntimeComponent100 designtimeComponent, IDTSConnectionManagerFlatFileColumn100 column, int outputID, int columnIndex, int codePage) { IDTSName100 nameID = column as IDTSName100; IDTSOutputColumn100 outputColumn = designtimeComponent.InsertOutputColumnAt(outputID, columnIndex, nameID.Name, nameID.Description); int codePageValue = (column.DataType == DataType.DT_STR || column.DataType == DataType.DT_TEXT) ? codePage : 0; designtimeComponent.SetOutputColumnDataTypeProperties(outputID, outputColumn.ID, column.DataType, column.MaximumWidth, column.DataPrecision, column.DataScale, codePageValue); }
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); } } }