public static void processFileListDelhi(object paramList) { starterParam p = (starterParam)paramList; for (int i = p.startIndex; i <= p.endIndex; i++) { NAMESTASIADataSet ds = new NAMESTASIADataSet(); NAMESTASIADataSetTableAdapters.RAW_NAMESTableAdapter t = new NAMESTASIADataSetTableAdapters.RAW_NAMESTableAdapter(); string f = p.fileList[i]; FileInfo fi = new FileInfo(f); string fileName = fi.Name; int row = 1; StreamReader r = new StreamReader(f); while (r.Peek() >= 0 && row <= 1000) { try { string l = r.ReadLine(); l = l.Trim(); if (l.Length <= 0) continue; string[] tokens = l.Split(','); if (tokens.Length < 3) { Debug.WriteLine("Bad Line: " + l); continue; } WriteToDb(tokens[0], tokens[1], "D", fileName, ds, t); row++; } catch (Exception ex) { Debug.WriteLine(ex.Message); continue; } } r.Close(); ds.AcceptChanges(); } }
public static void WriteToDb(string name, string address, string city, string file, NAMESTASIADataSet ds, NAMESTASIADataSetTableAdapters.RAW_NAMESTableAdapter t) { //NAMESTASIADataSet ds = new NAMESTASIADataSet(); NAMESTASIADataSet.RAW_NAMESRow r = ds.RAW_NAMES.NewRAW_NAMESRow(); r.FULLNAME = name; r.ADDRESS = address; r.CITY = city; r.SOURCE_FILE = file; r.CREATEDON = System.DateTime.Now; ds.RAW_NAMES.Rows.Add(r); t.Update(r); }
public static void processFileListBangaloreMissed(object paramList) { // For bangalore starterParam p = (starterParam)paramList; int[] missedList = { 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450 }; foreach (int i in missedList) { NAMESTASIADataSet ds = new NAMESTASIADataSet(); NAMESTASIADataSetTableAdapters.RAW_NAMESTableAdapter t = new NAMESTASIADataSetTableAdapters.RAW_NAMESTableAdapter(); string f = p.fileList[i]; FileInfo fi = new FileInfo(f); string fileName = fi.Name; int row = 1; StreamReader r = new StreamReader(f); while (r.Peek() >= 0 && row <= 1000) { try { string l = r.ReadLine(); l = l.Trim(); if (l.Length <= 0) continue; string[] tokens = l.Split('|'); if (tokens.Length != 3) continue; WriteToDb(tokens[0], tokens[1], "B", fileName, ds, t); row++; } catch (Exception ex) { Debug.WriteLine(ex.Message); continue; } } r.Close(); ds.AcceptChanges(); } }