调整日志
This commit is contained in:
parent
3f5ea7a5af
commit
54ec14c527
@ -49,7 +49,7 @@ namespace AIMS
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
Log.Information("Application exiting.");
|
||||||
// Important to call at exit so that batched events are flushed.
|
// Important to call at exit so that batched events are flushed.
|
||||||
Log.CloseAndFlush();
|
Log.CloseAndFlush();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
//"Serilog.Sinks.Console",
|
//"Serilog.Sinks.Console",
|
||||||
//"Serilog.Sinks.Debug",
|
//"Serilog.Sinks.Debug",
|
||||||
"Serilog.Sinks.Seq",
|
"Serilog.Sinks.Seq",
|
||||||
|
"Serilog.Sinks.File",
|
||||||
"Serilog.Settings.Configuration",
|
"Serilog.Settings.Configuration",
|
||||||
"Serilog.Exceptions",
|
"Serilog.Exceptions",
|
||||||
"Serilog.Enrichers.Span",
|
"Serilog.Enrichers.Span",
|
||||||
|
|||||||
@ -11,13 +11,16 @@ using AIMSExtension;
|
|||||||
using AIMSModel;
|
using AIMSModel;
|
||||||
using DevComponents.DotNetBar;
|
using DevComponents.DotNetBar;
|
||||||
using HelperDB;
|
using HelperDB;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AIMS
|
namespace AIMS
|
||||||
{
|
{
|
||||||
public partial class FormLogin : Office2007Form
|
public partial class FormLogin : Office2007Form
|
||||||
{
|
{
|
||||||
|
ILogger<FormLogin> logger;
|
||||||
public FormLogin()
|
public FormLogin()
|
||||||
{
|
{
|
||||||
|
logger = this.GetLogger();
|
||||||
this.FormBorderStyle = FormBorderStyle.None;
|
this.FormBorderStyle = FormBorderStyle.None;
|
||||||
this.EnableGlass = false;
|
this.EnableGlass = false;
|
||||||
|
|
||||||
@ -53,7 +56,8 @@ namespace AIMS
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
txtNo.Text = "admin";
|
txtNo.Text = "admin";
|
||||||
txtPassWord.Text = "1";
|
txtPassWord.Text = "1";
|
||||||
btnOk_Click(null, null);
|
|
||||||
|
btnOk_Click(btnOk, new EventArgs());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
private void btnOk_Click(object sender, EventArgs e)
|
private void btnOk_Click(object sender, EventArgs e)
|
||||||
@ -80,8 +84,8 @@ namespace AIMS
|
|||||||
{
|
{
|
||||||
PublicMethod.LastOperationSite = list[0];
|
PublicMethod.LastOperationSite = list[0];
|
||||||
}
|
}
|
||||||
PublicMethod.WriteLog("登录", PersonObj.Id.Value);
|
using var userScope = logger.BeginScope(new Dictionary<string, object> { { "OperatorId", PersonObj.Id.Value }, { "OperatorNo", PersonObj.No }, { "OperatorName", PersonObj.Name } });
|
||||||
|
logger.LogInformation("登录成功:{userno}",txtNo.Text);
|
||||||
PublicMethod.StartCollectorDataProgram();
|
PublicMethod.StartCollectorDataProgram();
|
||||||
Hide();
|
Hide();
|
||||||
//在这里为编辑器注册
|
//在这里为编辑器注册
|
||||||
@ -91,6 +95,7 @@ namespace AIMS
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
logger.LogInformation("登录失败:{userno}",txtNo.Text);
|
||||||
MessageBox.Show("用户名或密码有错误,请重新输入!", "提示", MessageBoxButtons.OK);
|
MessageBox.Show("用户名或密码有错误,请重新输入!", "提示", MessageBoxButtons.OK);
|
||||||
|
|
||||||
txtPassWord.Text = "";
|
txtPassWord.Text = "";
|
||||||
|
|||||||
@ -16,6 +16,10 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using MaterialSkin;
|
||||||
|
#if MD
|
||||||
|
using MaterialSkin.Controls;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AIMS
|
namespace AIMS
|
||||||
{
|
{
|
||||||
@ -54,6 +58,14 @@ namespace AIMS
|
|||||||
SetGridAlternatingRows(lv4);
|
SetGridAlternatingRows(lv4);
|
||||||
SetGridAlternatingRows(lv5);
|
SetGridAlternatingRows(lv5);
|
||||||
SetGridAlternatingRows(lv6);
|
SetGridAlternatingRows(lv6);
|
||||||
|
#if MD
|
||||||
|
|
||||||
|
var materialSkinManager = MaterialSkinManager.Instance;
|
||||||
|
//materialSkinManager.AddFormToManage(this);
|
||||||
|
materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
|
||||||
|
materialSkinManager.ColorScheme = new MaterialSkin.ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchButton1_ValueChanged(object sender, EventArgs e)
|
private void switchButton1_ValueChanged(object sender, EventArgs e)
|
||||||
@ -388,24 +400,23 @@ namespace AIMS
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (Form frm in Application.OpenForms)
|
var forms = Application.OpenForms.OfType<Form>().ToList() ;
|
||||||
|
foreach (var frm in forms)
|
||||||
{
|
{
|
||||||
if (frm.Name != "frmLogin" && frm.Name != this.Name)
|
if (frm == this)
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (frm is FormLogin fl)
|
||||||
|
{
|
||||||
|
fl.Show();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
frm.Close();
|
frm.Close();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
foreach (Form frm in Application.OpenForms)
|
|
||||||
{
|
|
||||||
if (frm.Name == "frmLogin")
|
|
||||||
{
|
|
||||||
frm.Show();
|
|
||||||
isClose = true;
|
isClose = true;
|
||||||
this.Close();
|
this.Close();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -419,14 +430,35 @@ namespace AIMS
|
|||||||
{
|
{
|
||||||
if (MessageBox.Show(this, "确定要退出当前系统?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show(this, "确定要退出当前系统?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
GC.Collect();
|
isClose = true;
|
||||||
GC.WaitForPendingFinalizers();
|
//关闭所有窗体
|
||||||
this.Dispose();
|
Task.Factory.StartNew(CloseAll);
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CloseAll()
|
||||||
|
{
|
||||||
|
var forms = Application.OpenForms.OfType<Form>().ToList();
|
||||||
|
foreach (var frm in forms)
|
||||||
|
{
|
||||||
|
if (frm == this)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.Close();
|
||||||
|
}
|
||||||
|
await Task.Delay(10 * 1000);//等待10秒
|
||||||
|
logger.LogWarning("等待10秒未能关闭所有窗体,即将强制关闭");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonX1_Click(object sender, EventArgs e)
|
private void buttonX1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user