添加错误写入
This commit is contained in:
commit
4ec1505bc5
2 files changed
+44
-2
No files matched your search
@@ -43,5 +43,45 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
directoryInfo.Create();//创建日志路径
|
||||
}
|
||||
}
|
||||
public static void ERRDATA(System.Exception dat)
|
||||
{
|
||||
string Log_time = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
string logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录
|
||||
// string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件
|
||||
// System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录
|
||||
string log_path = logpath + "\\ERR" + Log_time + ".txt";
|
||||
string Log_timehms = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
if (Directory.Exists(logpath))//检查日志路径
|
||||
{
|
||||
if (!File.Exists(log_path))//检查文件并写入
|
||||
{
|
||||
FileStream fs = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建文件
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.Close();
|
||||
FileStream fil = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件
|
||||
StreamWriter wfil = new StreamWriter(fil);//创建文件
|
||||
wfil.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString());
|
||||
wfil.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.Source.ToString() + Environment.NewLine.ToString());
|
||||
wfil.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString());
|
||||
wfil.WriteLine("[" + Log_timehms + "];[Error area] ||" + dat.StackTrace.ToString());
|
||||
wfil.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
FileStream fs = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString());
|
||||
wr.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.ToString() + Environment.NewLine.ToString());
|
||||
wr.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString());
|
||||
wr.WriteLine("[" + Log_timehms + "];[Error area] ||" + dat.ToString());
|
||||
wr.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DirectoryInfo directoryInfo = new DirectoryInfo(logpath);
|
||||
directoryInfo.Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,7 +465,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
string Connstr_SC;
|
||||
string DYELOTS_sql = "SELECT count(*) FROM [dbo].[DYELOTS] WHERE OrderNo = '" + comboBoxWorkOrder.Text + "'";//单号查询语句
|
||||
string DYELOTS_sql = "SELECT * FROM [dbo].[DYELOTS] WHERE OrderNo = '" + comboBoxWorkOrder.Text + "'";//单号查询语句
|
||||
try
|
||||
{
|
||||
if (MainWindowViewModel.SQMOD == "Windows Authentication")
|
||||
@@ -489,7 +489,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
TEXTColorName.Text = ds.AsEnumerable().Select(row => row.Field<string>("ColorName")).First();
|
||||
TEXTClient.Text = ds.AsEnumerable().Select(row => row.Field<string>("CustomerName")).First();
|
||||
TEXTClothSpecies.Text = ds.AsEnumerable().Select(row => row.Field<string>("FabricName")).First();
|
||||
TEXTClothWeight.Text = ds.AsEnumerable().Select(row => row.Field<string>("TotalWeight")).First();
|
||||
TEXTClothWeight.Text = ds.AsEnumerable().Select(row => row.Field<float>("TotalWeight")).First().ToString();
|
||||
TEXTBathRatio.Text = ds.AsEnumerable().Select(row => row.Field<string>("LiquidRatio")).First();
|
||||
TEXTTotal.Text = ds.AsEnumerable().Select(row => row.Field<string>("TotalVolume")).First();
|
||||
TEXTUSER.Text = ds.AsEnumerable().Select(row => row.Field<string>("UserAccount")).First();
|
||||
@@ -498,6 +498,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user