diff --git a/AIMS/Program.cs b/AIMS/Program.cs index 3d54681..06729db 100644 --- a/AIMS/Program.cs +++ b/AIMS/Program.cs @@ -49,7 +49,7 @@ namespace AIMS } finally { - + Log.Information("Application exiting."); // Important to call at exit so that batched events are flushed. Log.CloseAndFlush(); } diff --git a/AIMS/appsettings.json b/AIMS/appsettings.json index bf744f9..d605014 100644 --- a/AIMS/appsettings.json +++ b/AIMS/appsettings.json @@ -10,6 +10,7 @@ //"Serilog.Sinks.Console", //"Serilog.Sinks.Debug", "Serilog.Sinks.Seq", + "Serilog.Sinks.File", "Serilog.Settings.Configuration", "Serilog.Exceptions", "Serilog.Enrichers.Span", diff --git a/AIMSControls/FormLogin.cs b/AIMSControls/FormLogin.cs index f568625..a81b590 100644 --- a/AIMSControls/FormLogin.cs +++ b/AIMSControls/FormLogin.cs @@ -11,13 +11,16 @@ using AIMSExtension; using AIMSModel; using DevComponents.DotNetBar; using HelperDB; +using Microsoft.Extensions.Logging; namespace AIMS { public partial class FormLogin : Office2007Form { + ILogger logger; public FormLogin() { + logger = this.GetLogger(); this.FormBorderStyle = FormBorderStyle.None; this.EnableGlass = false; @@ -31,7 +34,7 @@ namespace AIMS AIMSExtension.PublicMethod.SetLocalDateTime(); AIMSExtension.PublicMethod.HospitalName = PublicMethod.GetHospital(); //label1.Text = AIMSExtension.PublicMethod.GetSystemName(); - label2.Text = PublicMethod.HospitalName + " V" + PublicMethod.NowVersion; + label2.Text = PublicMethod.HospitalName + " V" + PublicMethod.NowVersion; txtNo.Select(); txtNo.Focus(); List list = xmlUse.GetNode("LastLoginNo"); @@ -53,7 +56,8 @@ namespace AIMS #if DEBUG txtNo.Text = "admin"; txtPassWord.Text = "1"; - btnOk_Click(null, null); + + btnOk_Click(btnOk, new EventArgs()); #endif } private void btnOk_Click(object sender, EventArgs e) @@ -80,8 +84,8 @@ namespace AIMS { PublicMethod.LastOperationSite = list[0]; } - PublicMethod.WriteLog("登录", PersonObj.Id.Value); - + using var userScope = logger.BeginScope(new Dictionary { { "OperatorId", PersonObj.Id.Value }, { "OperatorNo", PersonObj.No }, { "OperatorName", PersonObj.Name } }); + logger.LogInformation("登录成功:{userno}",txtNo.Text); PublicMethod.StartCollectorDataProgram(); Hide(); //在这里为编辑器注册 @@ -91,6 +95,7 @@ namespace AIMS } else { + logger.LogInformation("登录失败:{userno}",txtNo.Text); MessageBox.Show("用户名或密码有错误,请重新输入!", "提示", MessageBoxButtons.OK); txtPassWord.Text = ""; diff --git a/AIMSControls/FormMainManage.cs b/AIMSControls/FormMainManage.cs index fc2873e..6dc9d54 100644 --- a/AIMSControls/FormMainManage.cs +++ b/AIMSControls/FormMainManage.cs @@ -16,6 +16,10 @@ using System.Linq; using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; +using MaterialSkin; +#if MD +using MaterialSkin.Controls; +#endif namespace AIMS { @@ -54,6 +58,14 @@ namespace AIMS SetGridAlternatingRows(lv4); SetGridAlternatingRows(lv5); 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) @@ -388,24 +400,23 @@ namespace AIMS { try { - foreach (Form frm in Application.OpenForms) + var forms = Application.OpenForms.OfType
().ToList() ; + foreach (var frm in forms) { - if (frm.Name != "frmLogin" && frm.Name != this.Name) + if (frm == this) { - frm.Close(); - break; + continue; } - } - foreach (Form frm in Application.OpenForms) - { - if (frm.Name == "frmLogin") + if (frm is FormLogin fl) { - frm.Show(); - isClose = true; - this.Close(); - break; + fl.Show(); + continue; } + + frm.Close(); } + isClose = true; + this.Close(); } catch (Exception ex) { @@ -419,15 +430,36 @@ namespace AIMS { if (MessageBox.Show(this, "ȷҪ˳ǰϵͳ", "ϵͳʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - GC.Collect(); - GC.WaitForPendingFinalizers(); - this.Dispose(); - Environment.Exit(0); + isClose = true; + //رд + Task.Factory.StartNew(CloseAll); + + } + else + { + + e.Cancel = true; } - e.Cancel = true; } } + private async Task CloseAll() + { + var forms = Application.OpenForms.OfType().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) { AIMS.PublicUI.UI.frmAbout frmEditPassWord = new PublicUI.UI.frmAbout();