private void SaveDB(Database db, TAttLog attLog, int MacSN) { if (attLog.CardTime.ToOADate() == 0) { return; } DateTime t = attLog.CardTime; int KQTime = t.Hour * 60 * 60 + t.Minute * 60 + t.Second; List <string> sql = new List <string>(); sql.Clear(); if (attLog.IsOrder == 0 || attLog.IsOrder == 1) { sql.Add(Pub.GetSQL(DBCode.DB_002001, new string[] { "105", SystemInfo.CardType.ToString(), attLog.CardID, t.ToString(SystemInfo.SQLDateFMT), KQTime.ToString(), MacSN.ToString(), "0", "", OprtInfo.OprtSysID, attLog.ReadMark.ToString() })); } if ((attLog.IsOrder == 1 || attLog.IsOrder == 2) && attLog.OrderDate.ToOADate() != 0) { sql.Add(Pub.GetSQL(DBCode.DB_002001, new string[] { "203", attLog.CardID, attLog.OrderDate.ToString(SystemInfo.SQLDateFMT), attLog.MealType.ToString(), OprtInfo.OprtSysID, "0", MacSN.ToString() })); } db.ExecSQL(sql); }
private void WriteTextFile(TAttLog attLog, int MacSN) { if (attLog.CardTime == null || attLog.CardTime.ToOADate() == 0) { return; } string fileName = SystemInfo.DataFilePath + "KQ" + DateTime.Now.ToString(SystemInfo.DateFormatLog) + ".dat"; DateTime t = Convert.ToDateTime(attLog.CardTime); string msg = attLog.ReadMark.ToString("00") + attLog.CardID + attLog.PhyID + attLog.MacTAG + t.ToString(SystemInfo.DateTimeFormatLog) + MacSN.ToString("00000"); Pub.WriteTextFile(fileName, msg); }
private void WriteTextFormat(Database db, KQTextFormatInfo textFormat, TAttLog attLog, int MacSN) { if (attLog.CardTime == null || attLog.CardTime.ToOADate() == 0) { return; } DataTableReader dr = null; string EmpNo = ""; string EmpName = ""; bool IsError = false; try { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "106", SystemInfo.CardType.ToString(), attLog.CardID })); if (dr.Read()) { EmpNo = dr["EmpNo"].ToString(); EmpName = dr["EmpName"].ToString(); } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return; } DateTime t = Convert.ToDateTime(attLog.CardTime); string fileName = SystemInfo.DataFilePath + "KQ" + t.ToString(SystemInfo.DateFormatLog) + "_Format.txt"; string msg = textFormat.GetKQFormatText(MacSN, EmpNo, EmpName, attLog.CardID, t); Pub.WriteTextFile(fileName, msg); }
public bool ReadDataText(string textFile, Database db, KQTextFormatInfo textFormat, ref int RecordCount, ref int RecordIndex, ProcessReadData prog) { bool ret = false; RecordCount = 0; RecordIndex = 0; StreamReader sr = null; string line; List <TAttLog> logList = new List <TAttLog>(); List <int> snList = new List <int>(); int MacSN = 0; try { sr = new StreamReader(textFile); while (!sr.EndOfStream) { line = sr.ReadLine(); if (line != "") { attLog = new TAttLog(); attLog.ReadMark = Convert.ToByte(line.Substring(0, 2)); attLog.CardID = line.Substring(2, 10); if (line.Length == 45) { attLog.PhyID = line.Substring(12, 10); attLog.MacTAG = line.Substring(22, 4); attLog.CardTime = new DateTime(Convert.ToInt16(line.Substring(26, 4)), Convert.ToByte(line.Substring(30, 2)), Convert.ToByte(line.Substring(32, 2)), Convert.ToByte(line.Substring(34, 2)), Convert.ToByte(line.Substring(36, 2)), Convert.ToByte(line.Substring(38, 2))); MacSN = Convert.ToInt32(line.Substring(40, 5)); } else { attLog.PhyID = ""; attLog.MacTAG = ""; attLog.CardTime = new DateTime(Convert.ToInt16(line.Substring(12, 4)), Convert.ToByte(line.Substring(16, 2)), Convert.ToByte(line.Substring(18, 2)), Convert.ToByte(line.Substring(20, 2)), Convert.ToByte(line.Substring(22, 2)), Convert.ToByte(line.Substring(24, 2))); MacSN = Convert.ToInt32(line.Substring(26, 5)); } logList.Add(attLog); snList.Add(MacSN); RecordCount++; } } for (int i = 0; i < RecordCount; i++) { attLog = logList[i]; MacSN = snList[i]; SaveDB(db, attLog, MacSN); RecordIndex = RecordIndex + 1; if (RecordIndex > RecordCount) { RecordIndex = RecordCount; } prog(RecordCount, RecordIndex); } ret = true; } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (sr != null) { sr.Close(); } } return(ret); }