private bool WriteErrorInHistory(CCurrentErrorDefine err, string dateTimeDay)
{
lock (lockMsg)
{
string saveFullPath = string.Format("{0}/{1}_{2}_ERRORLOG.csv", Config.SaveDirectory, Config.StationID, DateTime.Now.ToString("yyyyMMdd"));
string pathDirec = System.IO.Path.GetDirectoryName(saveFullPath);
try
{
if (!File.Exists(saveFullPath))
{
List<string> title = new List<string> {"StationID" + "," + "Line" + ","+ "OccurrenceTime" + "," + "ResolvedTime" + ","
+ "SN" + "," + "ErrorCode" + "," + "ErrorType" + "," + "ErrorDescription" + "," + "ErrorDescriptionEnglisth" };
File.AppendAllLines(saveFullPath, title, Encoding.Default);
}
List<string> list = new List<string> { Config.StationID + "," + Config.Line + "," + err.StartTime.ToString() + "," + dateTimeDay + "," + SN + "," + err.Error.ErrorID + "," + err.Error.ErrorType + "," + err.Error.AlarmMes + "," + err.Error.EnglishMes };
File.AppendAllLines(saveFullPath, list, Encoding.Default);
return true;
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
return WriteErrorInHistory(err, dateTimeDay);
}
}
}
保存CSV
最新推荐文章于 2024-10-30 16:24:37 发布