|
|
@ -1,7 +1,9 @@ |
|
|
using System; |
|
|
using Svg; |
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Configuration; |
|
|
using System.Configuration; |
|
|
using System.Data; |
|
|
using System.Data; |
|
|
|
|
|
using System.IO; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using System.Windows; |
|
|
using System.Windows; |
|
|
@ -42,6 +44,10 @@ namespace formula_manage |
|
|
this.DispatcherUnhandledException += App_DispatcherUnhandledException; |
|
|
this.DispatcherUnhandledException += App_DispatcherUnhandledException; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string Log_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
|
|
|
|
|
//string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件
|
|
|
|
|
|
|
|
|
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) |
|
|
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
@ -63,6 +69,26 @@ namespace formula_manage |
|
|
// + "(5)报错区域:" + e.Exception.InnerException.StackTrace
|
|
|
// + "(5)报错区域:" + e.Exception.InnerException.StackTrace
|
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
|
|
|
|
|
if (!File.Exists(logpath + Log_time + "Log.txt"))//检查日志文件并写入启动日志
|
|
|
|
|
|
{ |
|
|
|
|
|
FileStream fs = new FileStream(logpath + Log_time + "Log.txt", FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
|
|
|
|
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|
|
|
|
|
wr.WriteLine("||["+ Log_time + "];[Error source] ||" + e.Exception.Source + Environment.NewLine); |
|
|
|
|
|
wr.WriteLine("||[" + Log_time + "];[Details] ||" + e.Exception.Source + Environment.NewLine); |
|
|
|
|
|
wr.WriteLine("||[" + Log_time + "];[Error area] ||" + e.Exception.Source + Environment.NewLine); |
|
|
|
|
|
wr.Close(); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
FileStream fs = new FileStream(logpath + Log_time + "Log.txt", FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
|
|
|
|
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|
|
|
|
|
wr.WriteLine("||[" + Log_time + "];[Error source] ||" + e.Exception.Source + Environment.NewLine); |
|
|
|
|
|
wr.WriteLine("||[" + Log_time + "];[Details] ||" + e.Exception.Source + Environment.NewLine); |
|
|
|
|
|
wr.WriteLine("||[" + Log_time + "];[Error area] ||" + e.Exception.Source + Environment.NewLine); |
|
|
|
|
|
wr.Close(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
|