修改日志文件函数调用逻辑
This commit is contained in:
commit
6a706ea804
8 files changed
+86
-64
No files matched your search
+8
-50
@@ -27,11 +27,6 @@ namespace formula_manage
|
||||
/// </summary>
|
||||
public partial class Login : Window
|
||||
{
|
||||
|
||||
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
||||
string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\Log.txt";//日志文件
|
||||
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:";
|
||||
|
||||
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径
|
||||
|
||||
DataTable logindataTable = new DataTable(); //建立login缓存
|
||||
@@ -41,31 +36,12 @@ namespace formula_manage
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
InitializeComponent();
|
||||
|
||||
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
||||
if (!File.Exists(logPath))//检查日志文件并写入启动日志
|
||||
{
|
||||
FileStream fs = new FileStream(logPath, FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "FORMULA_start");
|
||||
wr.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "FORMULA_start");
|
||||
wr.Close();
|
||||
}
|
||||
|
||||
UserClass.LogGing.LogGingDATA("FORMULA_start");
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件
|
||||
{
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "FORMULA_LogStop");
|
||||
wr.Close();
|
||||
this.Close();
|
||||
UserClass.LogGing.LogGingDATA("FORMULA_LogStop");
|
||||
}
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e) //登录按钮事件
|
||||
@@ -87,10 +63,7 @@ namespace formula_manage
|
||||
MainWindow Main = new MainWindow();
|
||||
window.Close();
|
||||
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "LOGon = ENGINEER");
|
||||
wr.Close();
|
||||
UserClass.LogGing.LogGingDATA("LOGon = ENGINEER");
|
||||
|
||||
Main.ShowDialog();//实例化并置顶打开窗口
|
||||
}
|
||||
@@ -111,10 +84,7 @@ namespace formula_manage
|
||||
MainWindow Main = new MainWindow();
|
||||
window.Close();
|
||||
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "LOGon = " + user);
|
||||
wr.Close();
|
||||
UserClass.LogGing.LogGingDATA("LOGon = " + user);
|
||||
|
||||
Main.ShowDialog();//实例化并置顶打开窗口
|
||||
}
|
||||
@@ -166,10 +136,7 @@ namespace formula_manage
|
||||
{
|
||||
EXLINK.Background = Brushes.Red;
|
||||
System.Windows.MessageBox.Show("扩展程序未启动");
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "EX = FALL_TO_START");
|
||||
wr.Close();
|
||||
UserClass.LogGing.LogGingDATA("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "EX = FALL_TO_START");
|
||||
}
|
||||
}
|
||||
try
|
||||
@@ -207,10 +174,7 @@ namespace formula_manage
|
||||
//Windows.Sql sql = new Windows.Sql();
|
||||
//sql.ShowDialog();//实例化并置顶打开数据库设置窗口
|
||||
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "DISPENLINK = ConnectFailed");
|
||||
wr.Close();
|
||||
UserClass.LogGing.LogGingDATA("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "DISPENLINK = ConnectFailed");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -244,10 +208,7 @@ namespace formula_manage
|
||||
//Windows.Sql sql = new Windows.Sql();
|
||||
//sql.ShowDialog();//实例化并置顶打开数据库设置窗口
|
||||
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "DBCLINK = ConnectFailed");
|
||||
wr.Close();
|
||||
UserClass.LogGing.LogGingDATA("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "DBCLINK = ConnectFailed");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -275,10 +236,7 @@ namespace formula_manage
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求信息失败,检查连接");
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "USER = NoData");
|
||||
wr.Close();
|
||||
UserClass.LogGing.LogGingDATA("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:" + "USER = NoData");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user