Skip to content

Instantly share code, notes, and snippets.

@tdmitch
Last active August 22, 2017 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdmitch/78d3209895dd8954b1513834c8297783 to your computer and use it in GitHub Desktop.
Save tdmitch/78d3209895dd8954b1513834c8297783 to your computer and use it in GitHub Desktop.
public override void CreateNewOutputRows()
{
// Create the StreamReader object to read the input file
System.IO.StreamReader reader = new System.IO.StreamReader(this.Variables.vInputFilename);
// Loop through the file to read each line
while (!reader.EndOfStream)
{
// Read one line
string line = reader.ReadLine();
// Break the file apart into atomic elements
string[] items = line.Split('|');
/*
Each line should match one of three record types. When matched to
the correct type, a new row in that output will be created and the
columns from the file will be written to the appropriate output cols
*/
// Record type 1 is Manager
if (items[0] == "1")
{
ManagerOutputBuffer.AddRow();
ManagerOutputBuffer.ManagerID = int.Parse(items[1]);
ManagerOutputBuffer.ManagerName = items[2];
ManagerOutputBuffer.ManagerRole = items[3];
ManagerOutputBuffer.Location = items[4];
}
// Record type 2 is Employee
else if (items[0] == "2")
{
EmployeeOutputBuffer.AddRow();
EmployeeOutputBuffer.EmployeeID = int.Parse(items[1]);
EmployeeOutputBuffer.ManagerID = int.Parse(items[2]);
EmployeeOutputBuffer.EmployeeName = items[3];
EmployeeOutputBuffer.EmployeeRole = items[4];
}
// Record type 3 is Client
else if (items[0] == "3")
{
ClientOutputBuffer.AddRow();
ClientOutputBuffer.SalespersonID = int.Parse(items[1]);
ClientOutputBuffer.ClientID = int.Parse(items[2]);
ClientOutputBuffer.ClientName = items[3];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment