private List <ATT_IO_Temp> processFileData(string fileContent, string fullFileName) { List <ATT_IO_Temp> items = new List <ATT_IO_Temp>(); if (fileContent.IsNotNullOrEmpty()) { DateTime attDate = DateTime.Now; string[] str = fileContent.Replace("\n", ",").Split(','); int atoms = str.Count(); int counter = 0; foreach (string s in str) { if (counter < str.Length - 1) { ATT_IO_Temp newObj = new ATT_IO_Temp(); string[] item = s.Split(':'); newObj.DeviceID = item[0]; newObj.PunchCardNo = item[1]; newObj.WorkDate = DateTime.ParseExact(item[2].Substring(0, 4) + "-" + item[2].Substring(4, 2) + "-" + item[2].Substring(6, 2), "yyyy-MM-dd", null); newObj.PTime = new TimeSpan(int.Parse(item[3].Substring(0, 2)), int.Parse(item[3].Substring(2, 2)), int.Parse(item[3].Substring(4, 2))).ToString(); items.Add(newObj); counter++; } } } else { throw new Exception("Empty file"); } return(items); }
private List <ATT_IO_Temp> processFileDataComaSeparated(string fileContent, string fullFileName) { List <ATT_IO_Temp> items = new List <ATT_IO_Temp>(); if (fileContent.IsNotNullOrEmpty()) { DateTime attDate = DateTime.Now; string[] str = fileContent.Replace("\n", ";").Split(';'); int atoms = str.Count(); int counter = 0; foreach (string s in str) { if (counter < str.Length - 1) { ATT_IO_Temp newObj = new ATT_IO_Temp(); string[] item = s.Split(','); if (item.Count() == 1) { break; } counter++; newObj.DeviceID = item[8].ToString(); newObj.PunchCardNo = item[4]; newObj.WorkDate = DateTime.ParseExact(item[5].Substring(0, 4) + "-" + item[5].Substring(5, 2) + "-" + item[5].Substring(8, 2), "yyyy-MM-dd", null); if (!(newObj.WorkDate >= txtFromDate.Text.ToDateTime() && newObj.WorkDate <= txtToDate.Text.ToDateTime())) { continue; } newObj.PTime = (item[7] + ":00").ToString(); items.Add(newObj); } } } else { throw new Exception("Empty file"); } return(items); }