10 changed files with 186 additions and 16 deletions
@ -0,0 +1,118 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
|
||||
|
namespace SunlightAggregationManager.UserClass |
||||
|
{ |
||||
|
public class LogGing |
||||
|
{ |
||||
|
public static void LogGingDATA(string dat) |
||||
|
{ |
||||
|
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
||||
|
string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";//日志文件
|
||||
|
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:"; |
||||
|
|
||||
|
if (Directory.Exists(logpath))//检查日志路径
|
||||
|
{ |
||||
|
if (!File.Exists(logPath))//检查日志文件并写入启动日志
|
||||
|
{ |
||||
|
FileStream fs = new FileStream(logPath, FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
||||
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
|
wr.WriteLine(Log_time + dat); |
||||
|
wr.Close(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write); |
||||
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
|
wr.WriteLine(Log_time + dat); |
||||
|
wr.Close(); |
||||
|
} |
||||
|
catch { } |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(logpath); |
||||
|
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.CreateNew, 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(); |
||||
|
} |
||||
|
} |
||||
|
public static void ExchangeDATA(string dat) |
||||
|
{ |
||||
|
string Log_time = DateTime.Now.ToString("yyyy-MM-dd"); |
||||
|
string logpath = System.Environment.CurrentDirectory + "\\Exchange";//日志文件目录
|
||||
|
// string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件
|
||||
|
// System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录
|
||||
|
string log_path = logpath + "\\Exchange" + 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.CreateNew, FileAccess.Write);//创建写入文件
|
||||
|
StreamWriter wfil = new StreamWriter(fil);//创建文件
|
||||
|
wfil.WriteLine("[" + Log_timehms + "];[Exchange] ||" + dat); |
||||
|
wfil.Close(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
FileStream fs = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件
|
||||
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
|
wr.WriteLine("[" + Log_timehms + "];[Exchange] ||" + dat); |
||||
|
wr.Close(); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(logpath); |
||||
|
directoryInfo.Create(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<UserControl x:Class="SunlightAggregationManager.View.ExtendPage" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:local="clr-namespace:SunlightAggregationManager.View" |
||||
|
mc:Ignorable="d" |
||||
|
d:DesignHeight="450" d:DesignWidth="800"> |
||||
|
<Grid> |
||||
|
|
||||
|
</Grid> |
||||
|
</UserControl> |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows.Documents; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
using System.Windows.Navigation; |
||||
|
using System.Windows.Shapes; |
||||
|
|
||||
|
namespace SunlightAggregationManager.View |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// ExtendPage.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class ExtendPage : UserControl |
||||
|
{ |
||||
|
public ExtendPage() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue