From 5bed89c1c494f4ebfe1ade187560a6c4ff8e5216 Mon Sep 17 00:00:00 2001 From: lhiven Date: Sun, 28 Jul 2024 09:14:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0summary=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=86=99=E5=85=A5=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=9C=A8?= =?UTF-8?q?=E5=86=99=E5=85=A5=E7=9A=84=E6=97=B6=E5=80=99=E5=8A=A0=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.DeweyTester/Commom/DevLog.cs | 75 ++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/Rs.DeweyTester/Commom/DevLog.cs b/Rs.DeweyTester/Commom/DevLog.cs index 8587d07..bb8457b 100644 --- a/Rs.DeweyTester/Commom/DevLog.cs +++ b/Rs.DeweyTester/Commom/DevLog.cs @@ -18,19 +18,28 @@ namespace Rs.MotionPlat.Commom { lock (lockobj) { - string filename = $"{fileDir}\\{DateTime.Now.ToString("yyyyMMdd")}\\EventTracker_{DateTime.Now.ToString("yyyyMMdd")}.csv"; - string csvTitle = "VERSION,SITEID,PROJECTID,MACHINEID,DATE,TIME,LOT NAME,LOGIN MODE,KEYWORD,ERROR CODE,ERROR MESSAGE,MESSAGE\r\n"; - if (!Directory.Exists(Path.GetDirectoryName(filename))) + try { - Directory.CreateDirectory(Path.GetDirectoryName(filename)); + string filename = $"{fileDir}\\{DateTime.Now.ToString("yyyyMMdd")}\\EventTracker_{DateTime.Now.ToString("yyyyMMdd")}.csv"; + string csvTitle = "VERSION,SITEID,PROJECTID,MACHINEID,DATE,TIME,LOT NAME,LOGIN MODE,KEYWORD,ERROR CODE,ERROR MESSAGE,MESSAGE\r\n"; + if (!Directory.Exists(Path.GetDirectoryName(filename))) + { + Directory.CreateDirectory(Path.GetDirectoryName(filename)); + } + if (!File.Exists(filename)) + { + File.AppendAllText(filename, csvTitle); + } + string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + string content = $"{v},{GlobalVar.SiteID},{GlobalVar.ProjectID},{GlobalVar.MachineID},{DateTime.Now.ToString("yyyy-MM-dd")},{DateTime.Now.ToString("HH:mm:ss")},{GlobalVar.LotName.Replace("\r\n", "")},OP,{keyword},{errorcode},{errormsg},{message}\r\n"; + File.AppendAllText(filename, content); } - if (!File.Exists(filename)) + catch (Exception ex) { - File.AppendAllText(filename, csvTitle); + + LogHelper.Error($"Summary:{ex.Message + ex.StackTrace}"); } - string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - string content = $"{v},{GlobalVar.SiteID},{GlobalVar.ProjectID},{GlobalVar.MachineID},{DateTime.Now.ToString("yyyy-MM-dd")},{DateTime.Now.ToString("HH:mm:ss")},{GlobalVar.LotName.Replace("\r\n", "")},OP,{keyword},{errorcode},{errormsg},{message}\r\n"; - //File.AppendAllText(filename, content); + } } @@ -39,19 +48,27 @@ namespace Rs.MotionPlat.Commom { lock(lockobj) { - string filename = $"{fileDir}\\{DateTime.Now.ToString("yyyyMMdd")}\\Breakdown_{DateTime.Now.ToString("yyyyMMdd")}.csv"; - string csvTitle = "Machin,Tester Category,Tester_Sequence_Item Detail,TimeStamp,Time(ms)\r\n"; - if (!Directory.Exists(Path.GetDirectoryName(filename))) + try { - Directory.CreateDirectory(Path.GetDirectoryName(filename)); + string filename = $"{fileDir}\\{DateTime.Now.ToString("yyyyMMdd")}\\Breakdown_{DateTime.Now.ToString("yyyyMMdd")}.csv"; + string csvTitle = "Machin,Tester Category,Tester_Sequence_Item Detail,TimeStamp,Time(ms)\r\n"; + if (!Directory.Exists(Path.GetDirectoryName(filename))) + { + Directory.CreateDirectory(Path.GetDirectoryName(filename)); + } + if (!File.Exists(filename)) + { + File.AppendAllText(filename, csvTitle); + } + //string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + string content = $"{GlobalVar.MachineID},{category},{detail},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")},0\r\n"; + File.AppendAllText(filename, content); } - if (!File.Exists(filename)) + catch (Exception ex) { - File.AppendAllText(filename, csvTitle); + LogHelper.Error($"Summary:{ex.Message + ex.StackTrace}"); } - string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - string content = $"{GlobalVar.MachineID},{category},{detail},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")},0\r\n"; - //File.AppendAllText(filename, content); + } } @@ -76,17 +93,25 @@ namespace Rs.MotionPlat.Commom { lock (lockobj) { - string filename = $"{fileDir}\\{DateTime.Now.ToString("yyyyMMdd")}\\Summary_{DateTime.Now.ToString("yyyyMMdd")}.csv"; - if (!Directory.Exists(Path.GetDirectoryName(filename))) + try { - Directory.CreateDirectory(Path.GetDirectoryName(filename)); + string filename = $"{fileDir}\\{DateTime.Now.ToString("yyyyMMdd")}\\Summary_{DateTime.Now.ToString("yyyyMMdd")}.csv"; + if (!Directory.Exists(Path.GetDirectoryName(filename))) + { + Directory.CreateDirectory(Path.GetDirectoryName(filename)); + } + if (!File.Exists(filename)) + { + File.AppendAllText(filename, csvTitle); + } + //string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + File.AppendAllText(filename, content); } - if (!File.Exists(filename)) + catch (Exception ex) { - File.AppendAllText(filename, csvTitle); + LogHelper.Error($"Summary:{ex.Message+ex.StackTrace}"); } - string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - //File.AppendAllText(filename, content); + } } }