diff --git a/App.xaml.cs b/App.xaml.cs index 89104d2..7c4ca37 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -54,39 +54,44 @@ namespace formula_manage e.Handled = true; if (e.Exception.InnerException == null) { - MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" + Environment.NewLine - // + "(2)错误源:" + e.Exception.Source + Environment.NewLine - + "详细信息:" + e.Exception.Message + Environment.NewLine - // + "(4)报错区域:" + e.Exception.StackTrace + MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" + + "(1)错误" + Environment.NewLine + + "(2)错误源:" + e.Exception.Source + Environment.NewLine + // + (3)详细信息:" + e.Exception.Message + Environment.NewLine + // + "(4)报错区域:" + e.Exception.StackTrace ); } else { - MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" + Environment.NewLine - // + "(2)错误源:" + e.Exception.InnerException.Source + Environment.NewLine - + "错误信息:" + e.Exception.Message + Environment.NewLine - // + "(4)详细信息:" + e.Exception.InnerException.Message + Environment.NewLine - // + "(5)报错区域:" + e.Exception.InnerException.StackTrace + MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" + + "(1)错误" + Environment.NewLine + // + "(2)错误源:" + e.Exception.InnerException.Source + Environment.NewLine + + "(3)错误信息:" + e.Exception.Message + Environment.NewLine + // + "(4)详细信息:" + e.Exception.InnerException.Message + Environment.NewLine + // + "(5)报错区域:" + e.Exception.InnerException.StackTrace ); } System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录 - if (!File.Exists(logpath + Log_time + "Log.txt"))//检查日志文件并写入启动日志 + string log_path = logpath +"\\ERR" +Log_time + ".txt"; + if (!File.Exists(log_path))//检查日志文件并写入启动日志 { - FileStream fs = new FileStream(logpath + Log_time + "Log.txt", FileMode.CreateNew, FileAccess.Write);//创建写入文件 + FileStream fs = new FileStream(log_path, 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.WriteLine("[" + Log_time + "];[Error source] ||" + e.Exception.Source.ToString() + Environment.NewLine.ToString()); + wr.WriteLine("[" + Log_time + "];[Error message] ||" + e.Exception.Message.ToString() + Environment.NewLine.ToString()); + wr.WriteLine("[" + Log_time + "];[Detailed] ||" + e.Exception.Message.ToString() + Environment.NewLine.ToString()); + wr.WriteLine("[" + Log_time + "];[Error area] ||" + e.Exception.StackTrace.ToString()); wr.Close(); } else { - FileStream fs = new FileStream(logpath + Log_time + "Log.txt", FileMode.CreateNew, FileAccess.Write);//创建写入文件 + FileStream fs = new FileStream(log_path, FileMode.Append, 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.WriteLine("[" + Log_time + "];[Error source] ||" + e.Exception.Source.ToString() + Environment.NewLine.ToString()); + wr.WriteLine("[" + Log_time + "];[Error message] ||" + e.Exception.Message.ToString() + Environment.NewLine.ToString()); + wr.WriteLine("[" + Log_time + "];[Detailed] ||" + e.Exception.Message.ToString() + Environment.NewLine.ToString()); + wr.WriteLine("[" + Log_time + "];[Error area] ||" + e.Exception.StackTrace.ToString()); wr.Close(); } } diff --git a/EX/Exchange.xaml b/EX/Exchange.xaml index da405cb..e2d6a7a 100644 --- a/EX/Exchange.xaml +++ b/EX/Exchange.xaml @@ -7,16 +7,17 @@ mc:Ignorable="d" Title="Exchange" Height="720" Width="1280" MinHeight="720" MinWidth="1280" Background="#FFE0E0E0"> - + - + - - + diff --git a/EX/Exchange.xaml.cs b/EX/Exchange.xaml.cs index 3686041..893ec70 100644 --- a/EX/Exchange.xaml.cs +++ b/EX/Exchange.xaml.cs @@ -29,17 +29,32 @@ namespace formula_manage.EX InitializeComponent(); logdataTable.Columns.Add("Name", typeof(string)); - logdataTable.Columns.Add("length", typeof(int)); + logdataTable.Columns.Add("Length", typeof(int)); LOG_file(); } private void LOG_file()//建立列表 { DirectoryInfo loginfo = new DirectoryInfo(System.Environment.CurrentDirectory + "\\Exchange"); //new文件夹 - FileInfo[] logFile = loginfo.GetFiles("*.log");//生成文件夹中的文件名合集 - // logdataTable.ItemsSource = logFile;//加载合集 - // logFile.fill() - //gridLog.DisplayMemberPath = "Name"; // 显示文件名 + DataRow FileRow = logdataTable.NewRow(); + foreach (var item in loginfo.GetFiles()) + { + // DataRow FileRow = logdataTable.NewRow(); + + FileRow["Name"] = item.Name; + FileRow["Length"] = item.Length/1024; + logdataTable.Rows.Add(FileRow); + } + + gridLog.ItemsSource = logdataTable.DefaultView; + // FileInfo[] logFile = loginfo.GetFiles("*.log");//生成文件夹中的文件名合集 + //gridLog.ItemsSource = logFile;//加载合集 + // DataRow row = logdataTable.NewRow(); //ID列 + //logdataTable. = + // logFile.fill() + // //gridLog.DataContext = "Name"; // 显示文件名 + + // gridLog.ItemsSource = logFile;//加载合集 } } }