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); }
/// <summary> /// Add the columns required to the Error Output. /// </summary> /// <param name="errorOutput">The actual error output</param> public static void AddErrorOutputColumns(IDTSOutput100 errorOutput) { IDTSOutputColumnCollection100 outputColumnCollection = errorOutput.OutputColumnCollection; IDTSOutputColumn100 outputColumn = outputColumnCollection.New(); outputColumn.Name = MessageStrings.ErrorMessageColumnName; outputColumn.SetDataTypeProperties(DataType.DT_WSTR, 4000, 0, 0, 0); ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection); outputColumn = outputColumnCollection.New(); outputColumn.Name = MessageStrings.ColumnDataColumnName; outputColumn.SetDataTypeProperties(DataType.DT_WSTR, 4000, 0, 0, 0); ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection); outputColumn = outputColumnCollection.New(); outputColumn.Name = MessageStrings.RowDataColumnName; outputColumn.SetDataTypeProperties(DataType.DT_WSTR, 4000, 0, 0, 0); ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection); }
/// <summary> /// Adds the columns that are required to the Number Of Rows output /// </summary> /// <param name="numberOfRows">the number of rows output</param> public static void AddNumberOfRowsOutputColumns(IDTSOutput100 numberOfRows) { IDTSOutputColumnCollection100 outputColumnCollection = numberOfRows.OutputColumnCollection; IDTSOutputColumn100 outputColumn = outputColumnCollection.New(); outputColumn.Name = MessageStrings.KeyValueColumnName; outputColumn.SetDataTypeProperties(DataType.DT_STR, DefaultStringColumnSize, 0, 0, 1252); outputColumn.Description = MessageStrings.KeyValueColumnDescription; ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection); outputColumn = outputColumnCollection.New(); outputColumn.Name = MessageStrings.NumberOfRowsColumnName; outputColumn.SetDataTypeProperties(DataType.DT_I8, 0, 0, 0, 0); outputColumn.Description = MessageStrings.NumberOfRowsColumnDescription; ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection); outputColumn = outputColumnCollection.New(); outputColumn.Name = MessageStrings.KeyValueStatusColumnName; outputColumn.SetDataTypeProperties(DataType.DT_STR, DefaultStringColumnSize, 0, 0, 1252); outputColumn.Description = MessageStrings.KeyValueStatusColumnDescription; ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection); }
public static void New(this IDTSOutputColumnCollection100 collection, string name, ColumnType columnType, int length = 0, int scale = 0, int precision = 0, int codePage = 0, string description = null) { if (collection.Cast <IDTSOutputColumn100>().Any(col => col.Name == name)) { return; } var issueId = collection.New(); issueId.Name = name; if (!string.IsNullOrWhiteSpace(description)) { issueId.Description = description; } DataType type; switch (columnType) { case ColumnType.String: if (length <= 0 || length > 8000) { throw new Exception($"Для колонки {name} строкового типа указано некорректное значение длины."); } if (length <= 4000) { type = DataType.DT_WSTR; } else { type = DataType.DT_STR; if (codePage == 0) { throw new Exception($"Для колонки {name} строкового типа с длиной более 4000 необходимо указать кодовую страницу."); } } break; case ColumnType.Date: type = DataType.DT_DATE; break; default: throw new Exception($"Неизвестный тип колонки {name}."); } issueId.SetDataTypeProperties(type, length, scale, precision, codePage); }
public void TestBuildOutputColumn(String elementname, BsonValue bsonValue, DataType expectedDataType, int length, int codepage) { PrivateObject p = new PrivateObject(typeof(MongoDataSource.MongoDataSource)); IDTSOutput100 output = Mock.Create <IDTSOutput100>(Constructor.Mocked); IDTSOutputColumnCollection100 outputCollection = Mock.Create <IDTSOutputColumnCollection100>(Constructor.Mocked); IDTSOutputColumn100 expected = Mock.Create <IDTSOutputColumn100>(Constructor.Mocked); Mock.Arrange(() => outputCollection.New()).Returns(expected); Mock.Arrange(() => output.OutputColumnCollection).Returns(outputCollection); Mock.Arrange(() => output.IsErrorOut).Returns(true); BsonElement el = new BsonElement(elementname, bsonValue); Mock.ArrangeSet(() => expected.Name = Arg.Matches <String>(x => x == elementname)); IDTSOutputColumn100 actual = (IDTSOutputColumn100)p.Invoke("BuildOutputColumn", new object[] { output, el }); Mock.Assert(() => expected.SetDataTypeProperties(expectedDataType, length, 0, 0, codepage)); Mock.ArrangeSet(() => expected.ErrorRowDisposition = Arg.Matches <DTSRowDisposition>(x => x == DTSRowDisposition.RD_FailComponent)).OccursOnce(); Mock.ArrangeSet(() => expected.TruncationRowDisposition = Arg.Matches <DTSRowDisposition>(x => x == DTSRowDisposition.RD_FailComponent)).OccursOnce(); }
private IDTSOutputColumn100 BuildOutputColumn(IDTSOutputColumnCollection100 outputColumnCollection, BsonElement bsonElement) { IDTSOutputColumn100 outColumn = outputColumnCollection.New(); // Set the properties of the output column. outColumn.Name = bsonElement.Name; DataType dt = GetColumnDataType(bsonElement.Value); int length = 0; int codepage = 0; if (dt == DataType.DT_STR) { length = 256; codepage = 1252; } outColumn.SetDataTypeProperties(dt, length, 0, 0, codepage); return outColumn; }