You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
6.6 KiB
C#
153 lines
6.6 KiB
C#
using NPOI.OpenXmlFormats.Dml.Chart;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Rs.Framework;
|
|
using Rs.MotionPlat.Entitys;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
|
|
|
|
namespace Rs.MotionPlat.Commom
|
|
{
|
|
public static class DevLog
|
|
{
|
|
private static string fileDir = "D:\\Break_Event_Summary_Unit";
|
|
private static object lockobj = new object();
|
|
public static void EventTracker(string keyword,int errorcode,string errormsg,string message)
|
|
{
|
|
lock (lockobj)
|
|
{
|
|
try
|
|
{
|
|
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 loginmode = "";
|
|
if(GlobalUser.UserName!="")
|
|
{
|
|
loginmode = GlobalUser.UserName;
|
|
}
|
|
string err = errorcode > 0 ? errorcode.ToString() : "";
|
|
string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Replace(".","_");
|
|
string content = $"{v},{GlobalVar.SiteID},{GlobalVar.ProjectID},{GlobalVar.MachineID},{DateTime.Now.ToString("dd/MM/yyyy")},{DateTime.Now.ToString("HH:mm:ss")},{GlobalVar.LotName.Replace("\r\n", "")},{loginmode},{keyword},{err},\"{errormsg}\",\"{message}\"\r\n";
|
|
File.AppendAllText(filename, content);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
LogHelper.Error($"EventTracker:{ex.Message + ex.StackTrace}");
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static void Breakdown(string category,string detail)
|
|
{
|
|
lock(lockobj)
|
|
{
|
|
try
|
|
{
|
|
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);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error($"Breakdown:{ex.Message + ex.StackTrace}");
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public static void UnitTracker(TestFixture fixture)
|
|
{
|
|
lock (lockobj)
|
|
{
|
|
try
|
|
{
|
|
int usage = 0;
|
|
string RetryMode = "T1";
|
|
if (fixture.Product.TestNum > 0)
|
|
{
|
|
RetryMode = $"R{fixture.Product.TestNum}";
|
|
}
|
|
string filename = $"{fileDir}\\{DateTime.Now.ToString("yyyyMMdd")}\\UnitTracker_{DateTime.Now.ToString("yyyyMMdd")}.csv";
|
|
for (int i = 1; i <= 6; i++)
|
|
{
|
|
TestFixture tf = TestFixtureManager.Instance.GetTestFixture(i);
|
|
if (tf.Enable)
|
|
{
|
|
usage |= 1 << (i - 1);
|
|
}
|
|
}
|
|
string trial = string.Join("", Convert.ToString(usage, 2).Reverse());
|
|
string csvTitle = "SiteID,ProjectID,MachineID,Date,Time,LotName,LoginMode,Serial Number,Socker ID,Test Result,Trial,Socket Usage\r\n";
|
|
if (!Directory.Exists(Path.GetDirectoryName(filename)))
|
|
{
|
|
Directory.CreateDirectory(Path.GetDirectoryName(filename));
|
|
}
|
|
if (!File.Exists(filename))
|
|
{
|
|
File.AppendAllText(filename, csvTitle);
|
|
}
|
|
string content = $"{GlobalVar.SiteID},{GlobalVar.ProjectID},{GlobalVar.MachineID},{DateTime.Now.ToString("dd/MM/yyyy")},{DateTime.Now.ToString("HH:mm:ss")},{GlobalVar.LotName},OP,{fixture.Product.SN},{GlobalVar.MachineID}_TC{fixture.Index.ToString().PadLeft(2,'0')},{fixture.Result},{RetryMode},{trial}\r\n";
|
|
File.AppendAllText(filename, content);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error($"UnitTracker:{ex.Message + ex.StackTrace}");
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public static void Summary(string csvTitle,string content)
|
|
{
|
|
lock (lockobj)
|
|
{
|
|
try
|
|
{
|
|
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);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error($"Summary:{ex.Message+ex.StackTrace}");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|