public override void PrimeOutput(int outputs, int[] outputIDs, PipelineBuffer[] buffers) { PipelineBuffer mainBuffer = null; PipelineBuffer errorBuffer = null; IDTSOutput100 mainOutput = null; int errorOutID = 0; int errorOutIndex = 0; // If there is an error output, figure out which output is the main // and which is the error if (outputs == 2) { GetErrorOutputInfo(ref errorOutID, ref errorOutIndex); if (outputIDs[0] == errorOutID) { mainBuffer = buffers[1]; errorBuffer = buffers[0]; mainOutput = this.ComponentMetaData.OutputCollection[1]; } else { mainBuffer = buffers[0]; errorBuffer = buffers[1]; mainOutput = this.ComponentMetaData.OutputCollection[0]; } } else { mainBuffer = buffers[0]; mainOutput = this.ComponentMetaData.OutputCollection[0]; } bool firstRowColumnNames = (bool)this.GetComponentPropertyValue(PropertiesManager.ColumnNamesInFirstRowPropName); bool treatNulls = (bool)this.GetComponentPropertyValue(PropertiesManager.TreatEmptyStringsAsNullPropName); FileReader reader = new FileReader(this.fileName, this.GetEncoding()); DelimitedFileParser parser = this.CreateParser(); ComponentBufferService bufferService = new ComponentBufferService(mainBuffer, errorBuffer); BufferSink bufferSink = new BufferSink(bufferService, mainOutput, treatNulls); bufferSink.CurrentRowCount = parser.HeaderRowsToSkip + parser.DataRowsToSkip + (firstRowColumnNames ? 1 : 0); try { parser.SkipInitialRows(reader); RowData rowData = new RowData(); while (!reader.IsEOF) { parser.ParseNextRow(reader, rowData); if (rowData.ColumnCount == 0) { // Last row with no data will be ignored. break; } bufferSink.AddRow(rowData); } } catch (ParsingBufferOverflowException ex) { this.PostErrorAndThrow(MessageStrings.ParsingBufferOverflow(bufferSink.CurrentRowCount + 1, ex.ColumnIndex + 1, FieldParser.ParsingBufferMaxSize)); } catch (RowColumnNumberOverflow) { this.PostErrorAndThrow(MessageStrings.MaximumColumnNumberOverflow(bufferSink.CurrentRowCount + 1, RowParser.MaxColumnNumber)); } finally { reader.Close(); } foreach (PipelineBuffer buffer in buffers) { buffer.SetEndOfRowset(); } }
public void AddRowTestWithException() { OutputTestImpl output = null; ComponentBufferServiceTestImpl bufferService = null; GenerateOutputColumns(new string[] { "A", "B", "C", "D" }, true, DTSRowDisposition.RD_FailComponent, DTSRowDisposition.RD_FailComponent, out output, out bufferService); bufferService.ExceptionToFire = new System.Runtime.InteropServices.COMException(); BufferSink target = new BufferSink(bufferService, output, true); string[] data = new string[] { "1", "", "3", "4" }; RowData rowData = GenerateRowData(data); try { target.AddRow(rowData); } catch (Exception ex) { Assert.AreEqual<Int64>(1, target.CurrentRowCount); Assert.AreEqual<int>(0, bufferService.RowCount); Assert.AreEqual<int>(0, bufferService.ErrorRowCount); throw ex; } }
public void AddRowTestWithOverflowExceptionIgnore() { OutputTestImpl output = null; ComponentBufferServiceTestImpl bufferService = null; GenerateOutputColumns(new string[] { "A", "B", "C", "D" }, true, DTSRowDisposition.RD_IgnoreFailure, DTSRowDisposition.RD_RedirectRow, out output, out bufferService); bufferService.ExceptionToFire = new ArgumentException(); BufferSink target = new BufferSink(bufferService, output, true); // Say we have headers, etc... target.CurrentRowCount = 3; string[] data = new string[] { "1", "", "3", "4" }; RowData rowData = GenerateRowData(data); target.AddRow(rowData); Assert.AreEqual<Int64>(4, target.CurrentRowCount); Assert.AreEqual<int>(0, bufferService.RowCount); Assert.AreEqual<int>(0, bufferService.ErrorRowCount); }
public void AddRowTestWithTooManyColumnsIgnore() { OutputTestImpl output = null; ComponentBufferServiceTestImpl bufferService = null; GenerateOutputColumns(new string[] { "A", "B", "C", "D" }, true, DTSRowDisposition.RD_FailComponent, DTSRowDisposition.RD_FailComponent, out output, out bufferService); output.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure; BufferSink target = new BufferSink(bufferService, output, true); string[] data = new string[] { "1", "", "3", "4", "5", "6" }; RowData rowData = GenerateRowData(data); target.AddRow(rowData); Assert.AreEqual<Int64>(1, target.CurrentRowCount); Assert.AreEqual<int>(0, bufferService.RowCount); Assert.AreEqual<int>(0, bufferService.ErrorRowCount); }
public void AddRowTestWithLessColumns() { OutputTestImpl output = null; ComponentBufferServiceTestImpl bufferService = null; GenerateOutputColumns(new string[] { "A", "B", "C", "D" }, false, DTSRowDisposition.RD_FailComponent, DTSRowDisposition.RD_FailComponent, out output, out bufferService); BufferSink target = new BufferSink(bufferService, output, true); string[] data = new string[] { "1", "", "3" }; RowData rowData = GenerateRowData(data); target.AddRow(rowData); Assert.AreEqual<Int64>(1, target.CurrentRowCount); Assert.AreEqual<int>(1, bufferService.RowCount); Assert.AreEqual<int>(0, bufferService.ErrorRowCount); VerifyAddedRowData(bufferService, new object[] { "1", null, "3" }); }
public void CurrentRowCountTest() { IDTSOutput100 output = new OutputTestImpl(); IComponentBufferService bufferService = new ComponentBufferServiceTestImpl(new string[0], false); BufferSink target = new BufferSink(bufferService, output, false); Assert.AreEqual<Int64>(0, target.CurrentRowCount); }
public void BufferSinkConstructorTest2() { ComponentBufferServiceTestImpl bufferService = new ComponentBufferServiceTestImpl(new string[0], false); BufferSink target = new BufferSink(bufferService, null, false); }
public void BufferSinkConstructorTest1() { BufferSink target = new BufferSink(null, null, false); }