SlideShare una empresa de Scribd logo
1 de 13
using System;
using System.Collections;
using System.Data;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace WOTC_Import
{
class Program
{
XmlDocument xDoc;
ArrayList logList = new ArrayList();
static int Main(string[] args)
{
Program prog = new Program();
args = new String[] { "./" };
String[] pathArgs = prog.GetConfig(args[0]);
String inPath = (string)pathArgs[0];
string outPath = (string)pathArgs[1];
string inSsnData = (string)pathArgs[2];
string inIdsData = (string)pathArgs[3];
bool IsSuccess = false;
try
{
IsSuccess = prog.MergeDataFiles(inPath, outPath, inSsnData, inIdsData);
}
catch (Exception ex)
{
Console.WriteLine("WOTC Failure: " + ex.Message);
}
if (IsSuccess == true)
{
Console.WriteLine("Merge success.");
return 0;
}
else
{
Console.WriteLine("Merge failure.");
return 1;
}
}
private DataTable CreateDataTable(int Columns)
{
DataTable tabled = new DataTable();
DataColumn idColumn = new DataColumn();
idColumn.DataType = System.Type.GetType("System.Int32");
idColumn.ColumnName = "cid";
idColumn.AutoIncrement = true;
tabled.Columns.Add(idColumn);
for (int i = 0; i < Columns; i++)
{
DataColumn dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
tabled.Columns.Add(dc);
}
DataColumn[] keys = new DataColumn[2];
keys[0] = tabled.Columns[0];
keys[1] = tabled.Columns[1];
tabled.PrimaryKey = keys;
return tabled;
}
private String[] GetConfig(String configPath)
{
String[] filepathString = new String[] { };
xDoc = new XmlDocument();
xDoc.Load(configPath + "/WOTC_Import_settings.xml");
if (!xDoc.DocumentElement.IsEmpty)
{
XmlNode rootSegments = xDoc.DocumentElement.SelectSingleNode("DataFiles");
XmlNode inNode = rootSegments.ChildNodes[0];
XmlNode outNode = rootSegments.ChildNodes[1];
XmlNode ssnNode = rootSegments.ChildNodes[2];
XmlNode idsNode = rootSegments.ChildNodes[3];
if (!String.IsNullOrWhiteSpace(ssnNode.InnerText) & !String.IsNullOrWhiteSpace(idsNode.InnerText) & !String.IsNullOrWhiteSpace(outNode.InnerText))
{
filepathString = new String[] { inNode.InnerText, outNode.InnerText, ssnNode.InnerText, idsNode.InnerText };
logList.Add("XML Settings document loaded in GetConfig ( ): ");
logList.Add(" Qualified name of XmlDocument node: " + xDoc.Name);
logList.Add(" SSS File : " + ssnNode.InnerText);
logList.Add(" Ids File : " + idsNode.InnerText);
logList.Add(" Output Path: " + outNode.InnerText);
logList.Add("");
return filepathString;
}
else
{
logList.Add("XML Settings document NOT loaded in GetConfig ( ).");
logList.Add("");
return new String[] { };
}
}
else
{
logList.Add("XML Settings document in GetConfig ( ) failed to load.");
logList.Add("");
}
return filepathString;
}
private bool MergeDataFiles(string inPathWOTC, String outPathMerge, string inXSSNXT, string inIds)
{
bool IsSuccessful = false;
logList.Add("Current Date: " + DateTime.Now.ToString());
logList.Add("");
logList.Add("");
if (!string.IsNullOrWhiteSpace(inPathWOTC) & !String.IsNullOrWhiteSpace(outPathMerge) & !string.IsNullOrWhiteSpace(inXSSNXT) & !String.IsNullOrWhiteSpace(inIds))
{
DirectoryInfo diPathWOTC = new DirectoryInfo(inPathWOTC);
DirectoryInfo diPathOut = new DirectoryInfo(outPathMerge);
if (diPathWOTC.Exists & diPathOut.Exists)
{
FileInfo[] fiSSN = diPathWOTC.GetFiles(inXSSNXT);
FileInfo[] fiIds = diPathWOTC.GetFiles(inIds);
if (fiSSN.Length < 1)
{
if (fiIds.Length < 1)
{
logList.Add("SSM and EmployeeId files (" + inXSSNXT + " and " + inIds + ") are missing.");
logList.Add("");
}
else
{
logList.Add("SSN file (" + inXSSNXT + ") is missing.");
logList.Add("");
}
}
else if (fiIds.Length < 1)
{
logList.Add("Ids file (" + fiIds + ") is missing.");
logList.Add("");
}
else if (fiSSN.Length > 1 | fiIds.Length > 1)
{
logList.Add("Multiple data files exist at each input location:");
logList.Add(inPathWOTC);
logList.Add("");
}
else
{
logList.Add("Paths/Files exist: ");
logList.Add(" Employee (SSN) Data: " + inPathWOTC + @"/" + inXSSNXT);
logList.Add(" Organization Data : " + inPathWOTC + @"/" + inIds);
logList.Add(" Output Path : " + outPathMerge + @"/");
logList.Add("");
DataTable matchTable = CreateDataTable(11);
DataTable nomatchTable = CreateDataTable(8);
DataTable tableWOTC = ReadCSVData(fiSSN[0]);
logList.Add("Employee (SSN) Data includes " + tableWOTC.Rows.Count + " records.");
logList.Add("");
DataTable tableXSSNXT = ReadFixedWidthData(fiIds[0]);
logList.Add("Organization Data includes " + tableXSSNXT.Rows.Count + " records.");
logList.Add("");
if (tableWOTC.Rows.Count > 0 & tableXSSNXT.Rows.Count > 0)
{
int matchHeadCount = 0;
int nomatchHeadCount = 0;
for (int i = 0; i < tableWOTC.Rows.Count; i++)
{
DataRow drWOTC = tableWOTC.Rows[i];
string keystringWOTC = (string)drWOTC[1];
string ssnfieldname = tableXSSNXT.Columns[1].ColumnName;
string ssnfieldvalueWOTC = (string)drWOTC[1];
string lnmfieldname = tableXSSNXT.Columns[4].ColumnName;
string lnmfieldvalueWOTC = (string)drWOTC[2];
string sortorder = ssnfieldname + " ASC";
DataRow[] drXSSNXT;
drXSSNXT = null;
String ssnQuery = ssnfieldname + "=" + "'" + ssnfieldvalueWOTC + "'";
drXSSNXT = tableXSSNXT.Select(ssnQuery, sortorder);
if (drXSSNXT.Length == 1)
{
String xssnxtlnmString = (String)drXSSNXT[0][4];
String xssnxtlnmLower = xssnxtlnmString.ToLower();
String xssnxtlnmTrim = xssnxtlnmLower.TrimEnd(new Char[] { ' ' });
if (xssnxtlnmTrim != lnmfieldvalueWOTC)
{
String wotclnmLower = lnmfieldvalueWOTC.ToLower();
String wotclnmTrim = wotclnmLower.TrimEnd(new Char[] { ' ' });
String wotclnmReplaceSQ = wotclnmTrim.Replace(''', ' ');
String wotclnmReplaceH = wotclnmReplaceSQ.Replace('-', ' ');
String wotclnmReplace1 = wotclnmReplaceH.Replace(" jr.", "");
String wotclnmReplace2 = wotclnmReplace1.Replace(" ii", "");
String wotclnmReplace3 = wotclnmReplace2.Replace(" iii", "");
String wotclnmReplace4 = wotclnmReplace3.Replace(" iv", "");
String wotclnmReplace5 = wotclnmReplace4.Replace(". ", "");
if (xssnxtlnmTrim != wotclnmReplace5)
{
String wotclnmSub = "";
String xssnxtlnmSub = "";
if (wotclnmReplace5.Length < xssnxtlnmTrim.Length)
{
xssnxtlnmSub = xssnxtlnmTrim.Substring(0, wotclnmReplace5.Length);
wotclnmSub = wotclnmReplace5;
}
else if (xssnxtlnmTrim.Length < wotclnmReplace4.Length)
{
wotclnmSub = wotclnmReplace5.Substring(0, xssnxtlnmTrim.Length);
xssnxtlnmSub = xssnxtlnmTrim;
}
if (xssnxtlnmSub != wotclnmSub)
{
logList.Add("Matching SSN with different last names: ");
logList.Add(" SSN : " + ssnfieldvalueWOTC);
logList.Add(" Last Name (WOTC) : " + wotclnmReplace4);
logList.Add(" Last Name (XSSNXT: " + (String)drXSSNXT[0][4]);
logList.Add("");
tableXSSNXT.Rows.Remove(drXSSNXT[0]);
drXSSNXT = tableXSSNXT.Select(ssnQuery, sortorder);
}
}
}
}
else if (drXSSNXT.Length > 1)
{
for (int drInt = 0; drInt < drXSSNXT.Length; drInt++)
{
tableXSSNXT.Rows.Remove(drXSSNXT[drInt]);
drXSSNXT = tableXSSNXT.Select(ssnQuery, sortorder);
logList.Add("Matching SSN ( * MULTIPLE * ) with different last names: ");
logList.Add(" SSN : " + ssnfieldvalueWOTC);
logList.Add(" Last Name (WOTC) : " + lnmfieldvalueWOTC);
logList.Add(" Last Name (XSSNXT: " + (String)drXSSNXT[0][4]);
logList.Add("");
//String idslnmString = ( String ) drXSSNXT[drInt][4];
//String idslnmStringLower = idslnmString.ToLower ( );
//String idslnmStringTrim = idslnmStringLower.TrimEnd ( new Char[] { ' ' } );
//if ( idslnmStringTrim != wotclnmTrim )
//{
//}
}
}
if (drXSSNXT.Length > 0)
{
for (int n = 0; n < drXSSNXT.Length; n++)
{
if (matchHeadCount == 0)
{
DataRow headDR = matchTable.NewRow();
//headDR[0] = "ID";
headDR[1] = "SSN";
headDR[2] = "ORGANIZATIONID";
headDR[3] = "EMPLOYEEID";
headDR[4] = "LASTNAME";
headDR[5] = "FIRSTNAME";
headDR[6] = "MIDDLENAME";
headDR[7] = "DATASCREENED";
headDR[8] = "ELIGIBLE";
headDR[9] = "TARGETGROUP";
headDR[10] = "JOBSTARTDATE";
headDR[11] = "MISSING8850";
matchTable.Rows.Add(headDR);
matchHeadCount++;
}
DataRow nowDR = drXSSNXT[n];
DataRow matchDR = matchTable.NewRow();
matchDR[1] = drWOTC[1];
matchDR[2] = nowDR[2];
matchDR[3] = nowDR[3];
matchDR[4] = drWOTC[2];
matchDR[5] = drWOTC[3];
matchDR[6] = nowDR[6];
matchDR[7] = drWOTC[4];
matchDR[8] = drWOTC[5];
matchDR[9] = drWOTC[6];
matchDR[10] = drWOTC[7];
matchDR[11] = drWOTC[8];
matchTable.Rows.Add(matchDR);
}
}
else
{
if (nomatchHeadCount == 0)
{
DataRow headDR = nomatchTable.NewRow();
//headDR[0] = "ID";
headDR[1] = "SSN";
headDR[2] = "LASTNAME";
headDR[3] = "FIRSTNAME";
headDR[4] = "DATASCREENED";
headDR[5] = "ELIGIBLE";
headDR[6] = "TARGETGROUP";
headDR[7] = "JOBSTARTDATE";
headDR[8] = "MISSING8850";
nomatchTable.Rows.Add(headDR);
nomatchHeadCount++;
}
DataRow nomatchDR = nomatchTable.NewRow();
nomatchDR[1] = drWOTC[1];
nomatchDR[2] = drWOTC[2];
nomatchDR[3] = drWOTC[3];
nomatchDR[4] = drWOTC[4];
nomatchDR[5] = drWOTC[5];
nomatchDR[6] = drWOTC[6];
nomatchDR[7] = drWOTC[7];
nomatchDR[8] = drWOTC[8];
nomatchTable.Rows.Add(nomatchDR);
}
}
logList.Add("Data includes " + (matchTable.Rows.Count - 1) + " matching records.");
logList.Add("Data includes " + (nomatchTable.Rows.Count - 1) + " non-matching records.");
logList.Add("");
try
{
string filename = outPathMerge + @"/WOTC_Import_matching.txt";
using (StreamWriter sw = File.CreateText(filename))
{
foreach (DataRow row in matchTable.Rows)
{
sw.WriteLine(row[0] + "," + row[1] + "," + row[2] + "," + row[3] + "," + row[4] + "," + row[5] + "," + row[6] + "," + row[7] + "," + row[8] +
"," + row[9] + "," + row[10] + "," + row[11]);
}
}
logList.Add("Output data file for matching records: " + filename + ": ");
logList.Add("");
filename = outPathMerge + @"/WOTC_Import_nonmatching.txt";
using (StreamWriter sw = File.CreateText(filename))
{
foreach (DataRow row in nomatchTable.Rows)
{
sw.WriteLine(row[0] + "," + row[1] + "," + row[2] + "," + row[3] + "," + row[4] + "," + row[5] + "," + row[6] + "," + row[7] + "," + row[8]);
}
}
logList.Add("Output data file for non-matching records: " + filename + ": ");
logList.Add("");
IsSuccessful = true;
}
catch (Exception ex)
{
logList.Add("");
logList.Add("--------------------------------------------------");
logList.Add("");
logList.Add("Exception from Input Data StreamWriter Try / Catch: ");
logList.Add(" Exception Message: " + ex.Message);
logList.Add(" Exception Data: " + ex.Data);
logList.Add(" Exception HelpLink: " + ex.HelpLink);
logList.Add(" Exception HResult: " + ex.HResult);
logList.Add(" Exception Inner Exception: " + ex.InnerException);
logList.Add(" Exception Source: " + ex.Source);
logList.Add(" Exception StackTrace: " + ex.StackTrace);
logList.Add(" Exception TargetSite: " + ex.TargetSite);
logList.Add("");
}
}
else
{
logList.Add("Input data tables contain no matching records;");
logList.Add("");
}
}
}
else
{
if (!diPathWOTC.Exists)
{
logList.Add("Input paths were not found: " + inPathWOTC);
logList.Add("");
}
else if (!diPathOut.Exists)
{
logList.Add(" Data output path not found: " + outPathMerge);
logList.Add("");
}
else
{
logList.Add(" Un-specified data path error.");
logList.Add("");
}
}
}
else
{
if (string.IsNullOrWhiteSpace(inPathWOTC))
{
logList.Add("Input path is empty: + inPathWOTC ");
logList.Add("");
}
else
{
logList.Add(" Un-specified data input path error.");
logList.Add("");
}
}
try
{
string logname = outPathMerge + @"/LogFile_WOTC_Import_" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year + ".txt";
logList.Add("Output Log File : " + logname);
logList.Add("");
using (StreamWriter sw = File.CreateText(logname))
{
foreach (string entryString in logList)
{
sw.WriteLine(entryString);
}
}
}
catch (Exception ex)
{
logList.Add("");
logList.Add("--------------------------------------------------");
logList.Add("");
logList.Add("Exception from LogFIle StreamWriter Try / Catch: ");
logList.Add(" Exception Message: " + ex.Message);
logList.Add(" Exception Data: " + ex.Data);
logList.Add(" Exception HelpLink: " + ex.HelpLink);
logList.Add(" Exception HResult: " + ex.HResult);
logList.Add(" Exception Inner Exception: " + ex.InnerException);
logList.Add(" Exception Source: " + ex.Source);
logList.Add(" Exception StackTrace: " + ex.StackTrace);
logList.Add(" Exception TargetSite: " + ex.TargetSite);
logList.Add("");
}
return IsSuccessful;
}
private DataTable ReadCSVData(FileInfo infoFile)
{
DataTable ssnTable = CreateDataTable(8);
int skipRecord = 0;
StreamReader reads = new StreamReader(infoFile.FullName);
while (reads.Peek() >= 0)
{
string lineString = reads.ReadLine();
if (skipRecord > 0) //data includes a header row
{
string[] csvSplit = new string[] { "," };
string[] splitLine = lineString.Split(csvSplit, StringSplitOptions.None);
string[] dsvSplit = new string[] { "-" };
string[] splitSSN = splitLine[0].Split(dsvSplit, StringSplitOptions.None);
DataRow dr = ssnTable.NewRow();
dr[1] = splitSSN[0] + splitSSN[1] + splitSSN[2];
dr[2] = splitLine[1];
dr[3] = splitLine[2];
dr[4] = splitLine[3];
dr[5] = splitLine[4];
dr[6] = splitLine[5];
dr[7] = splitLine[6];
dr[8] = splitLine[7];
ssnTable.Rows.Add(dr);
}
else
{
logList.Add("Header row of 'WOTC_File.csv' file has been skipped (this line should only appear once in log file).");
logList.Add("");
skipRecord++;
}
}
return ssnTable;
}
private DataTable ReadFixedWidthData(FileInfo infoFile)
{
DataTable employeeData = CreateDataTable(6);
StreamReader reads = new StreamReader(infoFile.FullName);
while (reads.Peek() >= 0)
{
string lineString = reads.ReadLine();
string ssnString = ReadLine(lineString, 0, 9); //lineString.Substring ( 0, 9 );
string orgString = ReadLine(lineString, 9, 6); //lineString.Substring ( 9, 6 );
string empString = ReadLine(lineString, 15, 10); //lineString.Substring ( 15, 10 );
string lnmString = ReadLine(lineString, 25, 20); //lineString.Substring ( 25, 19 );
string fnmString = ReadLine(lineString, 45, 15); //lineString.Substring ( 45, 14 );
string mnmString = ReadLine(lineString, 60, 15); //lineString.Substring ( 60, (lineString.Length -60) );
DataRow dr = employeeData.NewRow();
dr[1] = ssnString;
dr[2] = orgString;
dr[3] = empString;
dr[4] = lnmString;
dr[5] = fnmString;
dr[6] = mnmString;
employeeData.Rows.Add(dr);
}
return employeeData;
}
private string ReadLine(string stringLine, int iStart, int iLength)
{
string outString = "";
if (stringLine.Length >= iStart)
{
if (stringLine.Length >= iStart + iLength)
{
outString = stringLine.Substring(iStart, iLength);
}
else
{
outString = stringLine.Substring(iStart, (stringLine.Length - iStart));
}
}
else
{
outString = "";
}
return outString;
}
}
}

Más contenido relacionado

La actualidad más candente

Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)
MongoSF
 

La actualidad más candente (20)

20110514 mongo dbチューニング
20110514 mongo dbチューニング20110514 mongo dbチューニング
20110514 mongo dbチューニング
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
P4 2017 io
P4 2017 ioP4 2017 io
P4 2017 io
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
The Ring programming language version 1.6 book - Part 38 of 189
The Ring programming language version 1.6 book - Part 38 of 189The Ring programming language version 1.6 book - Part 38 of 189
The Ring programming language version 1.6 book - Part 38 of 189
 
Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)
 
Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUG
 
D3.js workshop
D3.js workshopD3.js workshop
D3.js workshop
 
MongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() Output
 
The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184
 
GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao Introduction
 
The Ring programming language version 1.8 book - Part 41 of 202
The Ring programming language version 1.8 book - Part 41 of 202The Ring programming language version 1.8 book - Part 41 of 202
The Ring programming language version 1.8 book - Part 41 of 202
 
greenDAO
greenDAOgreenDAO
greenDAO
 
Fast querying indexing for performance (4)
Fast querying   indexing for performance (4)Fast querying   indexing for performance (4)
Fast querying indexing for performance (4)
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)
 
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
An Introduction to RxJava
An Introduction to RxJavaAn Introduction to RxJava
An Introduction to RxJava
 
Green dao
Green daoGreen dao
Green dao
 

Destacado

Situações/Reclamações Oriflame
Situações/Reclamações OriflameSituações/Reclamações Oriflame
Situações/Reclamações Oriflame
Oriflame Portugal
 
Clasicos del Cine Ruso
Clasicos del Cine RusoClasicos del Cine Ruso
Clasicos del Cine Ruso
Cancinoss
 
Trabajo informática Irene Pricel 4ºA.
Trabajo informática Irene Pricel 4ºA.Trabajo informática Irene Pricel 4ºA.
Trabajo informática Irene Pricel 4ºA.
pricelirene
 
Kevon Paynter ePortfolio Career story
Kevon Paynter ePortfolio Career storyKevon Paynter ePortfolio Career story
Kevon Paynter ePortfolio Career story
Kevon Paynter
 
2) Inc in lingua Ginzburg 2015 A3
2) Inc in lingua Ginzburg 2015 A32) Inc in lingua Ginzburg 2015 A3
2) Inc in lingua Ginzburg 2015 A3
Madalina Buzduga
 

Destacado (20)

IDdagen 2013 - W9 - De meervoudige betekenis van vermaatschappelijking
IDdagen 2013 - W9 - De meervoudige betekenis van vermaatschappelijkingIDdagen 2013 - W9 - De meervoudige betekenis van vermaatschappelijking
IDdagen 2013 - W9 - De meervoudige betekenis van vermaatschappelijking
 
Situações/Reclamações Oriflame
Situações/Reclamações OriflameSituações/Reclamações Oriflame
Situações/Reclamações Oriflame
 
Origen del universo
Origen del universoOrigen del universo
Origen del universo
 
IDdagen 2013 - Nieuwe rol en aanpak voor sociale bewegingen
IDdagen 2013 -  Nieuwe rol en aanpak voor sociale bewegingenIDdagen 2013 -  Nieuwe rol en aanpak voor sociale bewegingen
IDdagen 2013 - Nieuwe rol en aanpak voor sociale bewegingen
 
Cresp lbl 1
Cresp lbl 1Cresp lbl 1
Cresp lbl 1
 
toolkit
toolkittoolkit
toolkit
 
Making the Most of Mobile Marketing — EntreFest 2015
Making the Most of Mobile Marketing — EntreFest 2015Making the Most of Mobile Marketing — EntreFest 2015
Making the Most of Mobile Marketing — EntreFest 2015
 
Clasicos del Cine Ruso
Clasicos del Cine RusoClasicos del Cine Ruso
Clasicos del Cine Ruso
 
I have an idea
I have an ideaI have an idea
I have an idea
 
Prémium partner regisztrálása
Prémium partner regisztrálásaPrémium partner regisztrálása
Prémium partner regisztrálása
 
Trabajo informática Irene Pricel 4ºA.
Trabajo informática Irene Pricel 4ºA.Trabajo informática Irene Pricel 4ºA.
Trabajo informática Irene Pricel 4ºA.
 
Presentació1
Presentació1Presentació1
Presentació1
 
Perfilar manual
Perfilar manualPerfilar manual
Perfilar manual
 
Folheto (3) Folheto Português o coração do homem
Folheto  (3)  Folheto Português o coração do homemFolheto  (3)  Folheto Português o coração do homem
Folheto (3) Folheto Português o coração do homem
 
IDdagen 2013 - W6 - Openbaar bestuur
IDdagen 2013 - W6 - Openbaar bestuurIDdagen 2013 - W6 - Openbaar bestuur
IDdagen 2013 - W6 - Openbaar bestuur
 
IDdagen 2013 - W3 - Vredesactie
IDdagen 2013 - W3 - VredesactieIDdagen 2013 - W3 - Vredesactie
IDdagen 2013 - W3 - Vredesactie
 
Kevon Paynter ePortfolio Career story
Kevon Paynter ePortfolio Career storyKevon Paynter ePortfolio Career story
Kevon Paynter ePortfolio Career story
 
IDdagen 2013 - Waar worden we als sociale beweging uitgedaagd?
IDdagen 2013 -  Waar worden we als sociale beweging uitgedaagd?IDdagen 2013 -  Waar worden we als sociale beweging uitgedaagd?
IDdagen 2013 - Waar worden we als sociale beweging uitgedaagd?
 
2) Inc in lingua Ginzburg 2015 A3
2) Inc in lingua Ginzburg 2015 A32) Inc in lingua Ginzburg 2015 A3
2) Inc in lingua Ginzburg 2015 A3
 
IDdagen 2013 - W4 - Vredesactie
IDdagen 2013 - W4 - VredesactieIDdagen 2013 - W4 - Vredesactie
IDdagen 2013 - W4 - Vredesactie
 

Similar a WOTC_Import

Ugly code
Ugly codeUgly code
Ugly code
Odd-e
 
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docx
katherncarlyle
 
String in .net
String in .netString in .net
String in .net
Larry Nung
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
fantasiatheoutofthef
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 

Similar a WOTC_Import (20)

Ugly code
Ugly codeUgly code
Ugly code
 
Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."
Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."
Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."
 
webScrapingFunctions
webScrapingFunctionswebScrapingFunctions
webScrapingFunctions
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docx
 
Programming Java - Lection 07 - Puzzlers - Lavrentyev Fedor
Programming Java - Lection 07 - Puzzlers - Lavrentyev FedorProgramming Java - Lection 07 - Puzzlers - Lavrentyev Fedor
Programming Java - Lection 07 - Puzzlers - Lavrentyev Fedor
 
String in .net
String in .netString in .net
String in .net
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
 
The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4.1 book - Part 13 of 31
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactor
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data Visualisation
 
Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsAutomatically Spotting Cross-language Relations
Automatically Spotting Cross-language Relations
 
jQuery Datatables With MongDb
jQuery Datatables With MongDbjQuery Datatables With MongDb
jQuery Datatables With MongDb
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)
 

WOTC_Import

  • 1. using System; using System.Collections; using System.Data; using System.IO; using System.Text; using System.Threading.Tasks; using System.Xml; namespace WOTC_Import { class Program { XmlDocument xDoc; ArrayList logList = new ArrayList(); static int Main(string[] args) { Program prog = new Program(); args = new String[] { "./" }; String[] pathArgs = prog.GetConfig(args[0]); String inPath = (string)pathArgs[0]; string outPath = (string)pathArgs[1]; string inSsnData = (string)pathArgs[2]; string inIdsData = (string)pathArgs[3]; bool IsSuccess = false; try { IsSuccess = prog.MergeDataFiles(inPath, outPath, inSsnData, inIdsData); } catch (Exception ex) { Console.WriteLine("WOTC Failure: " + ex.Message); } if (IsSuccess == true) { Console.WriteLine("Merge success."); return 0; } else { Console.WriteLine("Merge failure."); return 1;
  • 2. } } private DataTable CreateDataTable(int Columns) { DataTable tabled = new DataTable(); DataColumn idColumn = new DataColumn(); idColumn.DataType = System.Type.GetType("System.Int32"); idColumn.ColumnName = "cid"; idColumn.AutoIncrement = true; tabled.Columns.Add(idColumn); for (int i = 0; i < Columns; i++) { DataColumn dc = new DataColumn(); dc.DataType = System.Type.GetType("System.String"); tabled.Columns.Add(dc); } DataColumn[] keys = new DataColumn[2]; keys[0] = tabled.Columns[0]; keys[1] = tabled.Columns[1]; tabled.PrimaryKey = keys; return tabled; } private String[] GetConfig(String configPath) { String[] filepathString = new String[] { }; xDoc = new XmlDocument(); xDoc.Load(configPath + "/WOTC_Import_settings.xml"); if (!xDoc.DocumentElement.IsEmpty) { XmlNode rootSegments = xDoc.DocumentElement.SelectSingleNode("DataFiles"); XmlNode inNode = rootSegments.ChildNodes[0]; XmlNode outNode = rootSegments.ChildNodes[1]; XmlNode ssnNode = rootSegments.ChildNodes[2]; XmlNode idsNode = rootSegments.ChildNodes[3]; if (!String.IsNullOrWhiteSpace(ssnNode.InnerText) & !String.IsNullOrWhiteSpace(idsNode.InnerText) & !String.IsNullOrWhiteSpace(outNode.InnerText)) { filepathString = new String[] { inNode.InnerText, outNode.InnerText, ssnNode.InnerText, idsNode.InnerText }; logList.Add("XML Settings document loaded in GetConfig ( ): "); logList.Add(" Qualified name of XmlDocument node: " + xDoc.Name); logList.Add(" SSS File : " + ssnNode.InnerText);
  • 3. logList.Add(" Ids File : " + idsNode.InnerText); logList.Add(" Output Path: " + outNode.InnerText); logList.Add(""); return filepathString; } else { logList.Add("XML Settings document NOT loaded in GetConfig ( )."); logList.Add(""); return new String[] { }; } } else { logList.Add("XML Settings document in GetConfig ( ) failed to load."); logList.Add(""); } return filepathString; } private bool MergeDataFiles(string inPathWOTC, String outPathMerge, string inXSSNXT, string inIds) { bool IsSuccessful = false; logList.Add("Current Date: " + DateTime.Now.ToString()); logList.Add(""); logList.Add(""); if (!string.IsNullOrWhiteSpace(inPathWOTC) & !String.IsNullOrWhiteSpace(outPathMerge) & !string.IsNullOrWhiteSpace(inXSSNXT) & !String.IsNullOrWhiteSpace(inIds)) { DirectoryInfo diPathWOTC = new DirectoryInfo(inPathWOTC); DirectoryInfo diPathOut = new DirectoryInfo(outPathMerge); if (diPathWOTC.Exists & diPathOut.Exists) { FileInfo[] fiSSN = diPathWOTC.GetFiles(inXSSNXT); FileInfo[] fiIds = diPathWOTC.GetFiles(inIds); if (fiSSN.Length < 1) { if (fiIds.Length < 1) { logList.Add("SSM and EmployeeId files (" + inXSSNXT + " and " + inIds + ") are missing."); logList.Add(""); } else
  • 4. { logList.Add("SSN file (" + inXSSNXT + ") is missing."); logList.Add(""); } } else if (fiIds.Length < 1) { logList.Add("Ids file (" + fiIds + ") is missing."); logList.Add(""); } else if (fiSSN.Length > 1 | fiIds.Length > 1) { logList.Add("Multiple data files exist at each input location:"); logList.Add(inPathWOTC); logList.Add(""); } else { logList.Add("Paths/Files exist: "); logList.Add(" Employee (SSN) Data: " + inPathWOTC + @"/" + inXSSNXT); logList.Add(" Organization Data : " + inPathWOTC + @"/" + inIds); logList.Add(" Output Path : " + outPathMerge + @"/"); logList.Add(""); DataTable matchTable = CreateDataTable(11); DataTable nomatchTable = CreateDataTable(8); DataTable tableWOTC = ReadCSVData(fiSSN[0]); logList.Add("Employee (SSN) Data includes " + tableWOTC.Rows.Count + " records."); logList.Add(""); DataTable tableXSSNXT = ReadFixedWidthData(fiIds[0]); logList.Add("Organization Data includes " + tableXSSNXT.Rows.Count + " records."); logList.Add(""); if (tableWOTC.Rows.Count > 0 & tableXSSNXT.Rows.Count > 0) { int matchHeadCount = 0; int nomatchHeadCount = 0; for (int i = 0; i < tableWOTC.Rows.Count; i++) { DataRow drWOTC = tableWOTC.Rows[i]; string keystringWOTC = (string)drWOTC[1]; string ssnfieldname = tableXSSNXT.Columns[1].ColumnName; string ssnfieldvalueWOTC = (string)drWOTC[1]; string lnmfieldname = tableXSSNXT.Columns[4].ColumnName;
  • 5. string lnmfieldvalueWOTC = (string)drWOTC[2]; string sortorder = ssnfieldname + " ASC"; DataRow[] drXSSNXT; drXSSNXT = null; String ssnQuery = ssnfieldname + "=" + "'" + ssnfieldvalueWOTC + "'"; drXSSNXT = tableXSSNXT.Select(ssnQuery, sortorder); if (drXSSNXT.Length == 1) { String xssnxtlnmString = (String)drXSSNXT[0][4]; String xssnxtlnmLower = xssnxtlnmString.ToLower(); String xssnxtlnmTrim = xssnxtlnmLower.TrimEnd(new Char[] { ' ' }); if (xssnxtlnmTrim != lnmfieldvalueWOTC) { String wotclnmLower = lnmfieldvalueWOTC.ToLower(); String wotclnmTrim = wotclnmLower.TrimEnd(new Char[] { ' ' }); String wotclnmReplaceSQ = wotclnmTrim.Replace(''', ' '); String wotclnmReplaceH = wotclnmReplaceSQ.Replace('-', ' '); String wotclnmReplace1 = wotclnmReplaceH.Replace(" jr.", ""); String wotclnmReplace2 = wotclnmReplace1.Replace(" ii", ""); String wotclnmReplace3 = wotclnmReplace2.Replace(" iii", ""); String wotclnmReplace4 = wotclnmReplace3.Replace(" iv", ""); String wotclnmReplace5 = wotclnmReplace4.Replace(". ", ""); if (xssnxtlnmTrim != wotclnmReplace5) { String wotclnmSub = ""; String xssnxtlnmSub = ""; if (wotclnmReplace5.Length < xssnxtlnmTrim.Length) { xssnxtlnmSub = xssnxtlnmTrim.Substring(0, wotclnmReplace5.Length); wotclnmSub = wotclnmReplace5; } else if (xssnxtlnmTrim.Length < wotclnmReplace4.Length) { wotclnmSub = wotclnmReplace5.Substring(0, xssnxtlnmTrim.Length); xssnxtlnmSub = xssnxtlnmTrim; } if (xssnxtlnmSub != wotclnmSub) { logList.Add("Matching SSN with different last names: "); logList.Add(" SSN : " + ssnfieldvalueWOTC); logList.Add(" Last Name (WOTC) : " + wotclnmReplace4);
  • 6. logList.Add(" Last Name (XSSNXT: " + (String)drXSSNXT[0][4]); logList.Add(""); tableXSSNXT.Rows.Remove(drXSSNXT[0]); drXSSNXT = tableXSSNXT.Select(ssnQuery, sortorder); } } } } else if (drXSSNXT.Length > 1) { for (int drInt = 0; drInt < drXSSNXT.Length; drInt++) { tableXSSNXT.Rows.Remove(drXSSNXT[drInt]); drXSSNXT = tableXSSNXT.Select(ssnQuery, sortorder); logList.Add("Matching SSN ( * MULTIPLE * ) with different last names: "); logList.Add(" SSN : " + ssnfieldvalueWOTC); logList.Add(" Last Name (WOTC) : " + lnmfieldvalueWOTC); logList.Add(" Last Name (XSSNXT: " + (String)drXSSNXT[0][4]); logList.Add(""); //String idslnmString = ( String ) drXSSNXT[drInt][4]; //String idslnmStringLower = idslnmString.ToLower ( ); //String idslnmStringTrim = idslnmStringLower.TrimEnd ( new Char[] { ' ' } ); //if ( idslnmStringTrim != wotclnmTrim ) //{ //} } } if (drXSSNXT.Length > 0) { for (int n = 0; n < drXSSNXT.Length; n++) { if (matchHeadCount == 0) { DataRow headDR = matchTable.NewRow(); //headDR[0] = "ID"; headDR[1] = "SSN"; headDR[2] = "ORGANIZATIONID"; headDR[3] = "EMPLOYEEID"; headDR[4] = "LASTNAME"; headDR[5] = "FIRSTNAME"; headDR[6] = "MIDDLENAME";
  • 7. headDR[7] = "DATASCREENED"; headDR[8] = "ELIGIBLE"; headDR[9] = "TARGETGROUP"; headDR[10] = "JOBSTARTDATE"; headDR[11] = "MISSING8850"; matchTable.Rows.Add(headDR); matchHeadCount++; } DataRow nowDR = drXSSNXT[n]; DataRow matchDR = matchTable.NewRow(); matchDR[1] = drWOTC[1]; matchDR[2] = nowDR[2]; matchDR[3] = nowDR[3]; matchDR[4] = drWOTC[2]; matchDR[5] = drWOTC[3]; matchDR[6] = nowDR[6]; matchDR[7] = drWOTC[4]; matchDR[8] = drWOTC[5]; matchDR[9] = drWOTC[6]; matchDR[10] = drWOTC[7]; matchDR[11] = drWOTC[8]; matchTable.Rows.Add(matchDR); } } else { if (nomatchHeadCount == 0) { DataRow headDR = nomatchTable.NewRow(); //headDR[0] = "ID"; headDR[1] = "SSN"; headDR[2] = "LASTNAME"; headDR[3] = "FIRSTNAME"; headDR[4] = "DATASCREENED"; headDR[5] = "ELIGIBLE"; headDR[6] = "TARGETGROUP"; headDR[7] = "JOBSTARTDATE"; headDR[8] = "MISSING8850"; nomatchTable.Rows.Add(headDR); nomatchHeadCount++; }
  • 8. DataRow nomatchDR = nomatchTable.NewRow(); nomatchDR[1] = drWOTC[1]; nomatchDR[2] = drWOTC[2]; nomatchDR[3] = drWOTC[3]; nomatchDR[4] = drWOTC[4]; nomatchDR[5] = drWOTC[5]; nomatchDR[6] = drWOTC[6]; nomatchDR[7] = drWOTC[7]; nomatchDR[8] = drWOTC[8]; nomatchTable.Rows.Add(nomatchDR); } } logList.Add("Data includes " + (matchTable.Rows.Count - 1) + " matching records."); logList.Add("Data includes " + (nomatchTable.Rows.Count - 1) + " non-matching records."); logList.Add(""); try { string filename = outPathMerge + @"/WOTC_Import_matching.txt"; using (StreamWriter sw = File.CreateText(filename)) { foreach (DataRow row in matchTable.Rows) { sw.WriteLine(row[0] + "," + row[1] + "," + row[2] + "," + row[3] + "," + row[4] + "," + row[5] + "," + row[6] + "," + row[7] + "," + row[8] + "," + row[9] + "," + row[10] + "," + row[11]); } } logList.Add("Output data file for matching records: " + filename + ": "); logList.Add(""); filename = outPathMerge + @"/WOTC_Import_nonmatching.txt"; using (StreamWriter sw = File.CreateText(filename)) { foreach (DataRow row in nomatchTable.Rows) { sw.WriteLine(row[0] + "," + row[1] + "," + row[2] + "," + row[3] + "," + row[4] + "," + row[5] + "," + row[6] + "," + row[7] + "," + row[8]); } } logList.Add("Output data file for non-matching records: " + filename + ": "); logList.Add(""); IsSuccessful = true; } catch (Exception ex) {
  • 9. logList.Add(""); logList.Add("--------------------------------------------------"); logList.Add(""); logList.Add("Exception from Input Data StreamWriter Try / Catch: "); logList.Add(" Exception Message: " + ex.Message); logList.Add(" Exception Data: " + ex.Data); logList.Add(" Exception HelpLink: " + ex.HelpLink); logList.Add(" Exception HResult: " + ex.HResult); logList.Add(" Exception Inner Exception: " + ex.InnerException); logList.Add(" Exception Source: " + ex.Source); logList.Add(" Exception StackTrace: " + ex.StackTrace); logList.Add(" Exception TargetSite: " + ex.TargetSite); logList.Add(""); } } else { logList.Add("Input data tables contain no matching records;"); logList.Add(""); } } } else { if (!diPathWOTC.Exists) { logList.Add("Input paths were not found: " + inPathWOTC); logList.Add(""); } else if (!diPathOut.Exists) { logList.Add(" Data output path not found: " + outPathMerge); logList.Add(""); } else { logList.Add(" Un-specified data path error."); logList.Add(""); } }
  • 10. } else { if (string.IsNullOrWhiteSpace(inPathWOTC)) { logList.Add("Input path is empty: + inPathWOTC "); logList.Add(""); } else { logList.Add(" Un-specified data input path error."); logList.Add(""); } } try { string logname = outPathMerge + @"/LogFile_WOTC_Import_" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year + ".txt"; logList.Add("Output Log File : " + logname); logList.Add(""); using (StreamWriter sw = File.CreateText(logname)) { foreach (string entryString in logList) { sw.WriteLine(entryString); } } } catch (Exception ex) { logList.Add(""); logList.Add("--------------------------------------------------"); logList.Add(""); logList.Add("Exception from LogFIle StreamWriter Try / Catch: "); logList.Add(" Exception Message: " + ex.Message); logList.Add(" Exception Data: " + ex.Data); logList.Add(" Exception HelpLink: " + ex.HelpLink); logList.Add(" Exception HResult: " + ex.HResult); logList.Add(" Exception Inner Exception: " + ex.InnerException); logList.Add(" Exception Source: " + ex.Source); logList.Add(" Exception StackTrace: " + ex.StackTrace); logList.Add(" Exception TargetSite: " + ex.TargetSite); logList.Add("");
  • 11. } return IsSuccessful; } private DataTable ReadCSVData(FileInfo infoFile) { DataTable ssnTable = CreateDataTable(8); int skipRecord = 0; StreamReader reads = new StreamReader(infoFile.FullName); while (reads.Peek() >= 0) { string lineString = reads.ReadLine(); if (skipRecord > 0) //data includes a header row { string[] csvSplit = new string[] { "," }; string[] splitLine = lineString.Split(csvSplit, StringSplitOptions.None); string[] dsvSplit = new string[] { "-" }; string[] splitSSN = splitLine[0].Split(dsvSplit, StringSplitOptions.None); DataRow dr = ssnTable.NewRow(); dr[1] = splitSSN[0] + splitSSN[1] + splitSSN[2]; dr[2] = splitLine[1]; dr[3] = splitLine[2]; dr[4] = splitLine[3]; dr[5] = splitLine[4]; dr[6] = splitLine[5]; dr[7] = splitLine[6]; dr[8] = splitLine[7]; ssnTable.Rows.Add(dr); } else { logList.Add("Header row of 'WOTC_File.csv' file has been skipped (this line should only appear once in log file)."); logList.Add(""); skipRecord++; } } return ssnTable; } private DataTable ReadFixedWidthData(FileInfo infoFile) {
  • 12. DataTable employeeData = CreateDataTable(6); StreamReader reads = new StreamReader(infoFile.FullName); while (reads.Peek() >= 0) { string lineString = reads.ReadLine(); string ssnString = ReadLine(lineString, 0, 9); //lineString.Substring ( 0, 9 ); string orgString = ReadLine(lineString, 9, 6); //lineString.Substring ( 9, 6 ); string empString = ReadLine(lineString, 15, 10); //lineString.Substring ( 15, 10 ); string lnmString = ReadLine(lineString, 25, 20); //lineString.Substring ( 25, 19 ); string fnmString = ReadLine(lineString, 45, 15); //lineString.Substring ( 45, 14 ); string mnmString = ReadLine(lineString, 60, 15); //lineString.Substring ( 60, (lineString.Length -60) ); DataRow dr = employeeData.NewRow(); dr[1] = ssnString; dr[2] = orgString; dr[3] = empString; dr[4] = lnmString; dr[5] = fnmString; dr[6] = mnmString; employeeData.Rows.Add(dr); } return employeeData; } private string ReadLine(string stringLine, int iStart, int iLength) { string outString = ""; if (stringLine.Length >= iStart) { if (stringLine.Length >= iStart + iLength) { outString = stringLine.Substring(iStart, iLength); } else { outString = stringLine.Substring(iStart, (stringLine.Length - iStart)); } } else { outString = ""; } return outString;
  • 13. } } }