From ef29d2565b82d7ae1da3b6426f42c1ad21c39e62 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 16 Aug 2023 21:23:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=90=88=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AIMS.UI/AIMSControls.csproj | 15 ++++----- AIMS/AIMS.csproj | 41 +++++++++++------------- AIMS/Program.cs | 42 +++++++++++++++++++++++- AIMS/appsettings.json | 51 ++++++++++++++++++++++++++++++ AIMS/packages.config | 5 --- AIMSEntity/AIMSEntity.csproj | 4 --- AIMSExtension/AIMSExtension.csproj | 15 ++++++--- DrawGraphManagement/app.config | 26 +++++++++------ nuget.config | 13 ++++++++ 9 files changed, 158 insertions(+), 54 deletions(-) create mode 100644 AIMS/appsettings.json delete mode 100644 AIMS/packages.config create mode 100644 nuget.config diff --git a/AIMS.UI/AIMSControls.csproj b/AIMS.UI/AIMSControls.csproj index fe90194..489a403 100644 --- a/AIMS.UI/AIMSControls.csproj +++ b/AIMS.UI/AIMSControls.csproj @@ -8,10 +8,10 @@ Library AIMSControls AIMSControls + v4.8 512 true - AnyCPU @@ -34,9 +34,6 @@ 4 false - - - ..\AIMS\Extensions\DCSoft.Writer.dll @@ -54,10 +51,6 @@ False ..\AIMS\Extensions\Microsoft.Office.Interop.Excel.dll - - False - ..\AIMS\Extensions\Newtonsoft.Json.dll - @@ -65,7 +58,6 @@ - @@ -1574,5 +1566,10 @@ + + + 13.0.3 + + \ No newline at end of file diff --git a/AIMS/AIMS.csproj b/AIMS/AIMS.csproj index 86bd875..3c34c69 100644 --- a/AIMS/AIMS.csproj +++ b/AIMS/AIMS.csproj @@ -1,6 +1,5 @@  - Debug @@ -12,10 +11,6 @@ v4.8 512 true - - - - AnyCPU @@ -45,9 +40,6 @@ AIMS.Program - - ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll - False DLL\DCSoft.Writer.dll @@ -60,10 +52,6 @@ False ..\..\..\..\..\..\..\Program Files (x86)\DotNetBar for Windows Forms\DevComponents.DotNetBar2.dll - - False - Extensions\Newtonsoft.Json.dll - @@ -92,10 +80,12 @@ Resources.resx True + + PreserveNewest + Always - SettingsSingleFileGenerator Settings.Designer.cs @@ -155,18 +145,25 @@ DrawGraph - + + + 1.0.0 + + + 5.7.0 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + 5.0.0 + + + 5.2.2 + + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/AIMS/Program.cs b/AIMS/Program.cs index c4ee89e..25c33db 100644 --- a/AIMS/Program.cs +++ b/AIMS/Program.cs @@ -11,16 +11,47 @@ using System.Diagnostics; using System.Reflection; using System.IO; using System.Xml.Linq; +using CCIS.Shared; +using Serilog; +using Serilog.Core; namespace AIMS { static class Program { + static Program() + { + + } + /// /// 应用程序的主入口点。 /// [STAThread] static void Main(string[] args) + { + + try + { + Log.Logger = CreateBootstrapLogger(); + Log.Information("Hello, {Name}!", Environment.UserName); + SharedContext.CreateDefault(args); + Log.Information("Initialising."); + MainStart(args); + Log.Information("Finsh."); + } + catch (Exception e) + { + Log.Error(e, "Application terminated unexpectedly."); + } + finally + { + + // Important to call at exit so that batched events are flushed. + Log.CloseAndFlush(); + } + } + static void MainStart(string[] args) { /** * 当前用户是管理员的时候,直接启动应用程序 @@ -160,7 +191,16 @@ namespace AIMS Application.Exit(); } } - + /// + /// Creates a logger used during application initialisation. + /// . + /// + /// A logger that can load a new configuration. + private static Logger CreateBootstrapLogger() => + new LoggerConfiguration() + //.WriteTo.Console() + .WriteTo.File("logs\\bootstrap.log", rollingInterval: RollingInterval.Day) + .CreateLogger(); #region 确保程序只运行一个实例 private static Process RunningInstance() { diff --git a/AIMS/appsettings.json b/AIMS/appsettings.json new file mode 100644 index 0000000..c0dd3ed --- /dev/null +++ b/AIMS/appsettings.json @@ -0,0 +1,51 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Seq", "Serilog.Settings.Configuration", "Serilog.Exceptions", "Serilog.Enrichers.Span", "Serilog.Enrichers.Thread", "Serilog.Enrichers.Process" ], + "Enrich": [ + "FromLogContext", + // Add full exception details using Serilog.Exceptions https://github.com/RehanSaeed/Serilog.Exceptions. + "WithExceptionDetails", + // Add the username and machine name to the logs using Serilog.Enrichers.Environment https://github.com/serilog/serilog-enrichers-environment. + "WithEnvironmentUserName", + "WithMachineName", + // Add the process ID and name to the logs using Serilog.Enrichers.Process https://github.com/serilog/serilog-enrichers-process. + "WithProcessId", + "WithProcessName", + // Add open telemetry span details using Serilog.Enrichers.Span https://github.com/RehanSaeed/Serilog.Enrichers.Span + "WithSpan", + // Add the current thread ID to the logs using Serilog.Enrichers.Thread https://github.com/serilog/serilog-enrichers-thread. + "WithThreadId" + ], + + "MinimumLevel": { + "Default": "Verbose", + "Override": { + "Microsoft": "Warning", + "System": "Warning" + } + }, + "WriteTo": [ + { + "Name": "Seq", + "Args": { + "serverUrl": "http://10.129.131.128:7000/", + "apiKey": "rMuLOepTw0LLF3z5ZqVW" + } + }, + { + "Name": "File", + "Args": { + "path": "logs/log.txt", + "outputTemplate": "{Timestamp:MM-dd HH:mm:ss}[{Level:u3}]{Message}|{Scope}|{ThreadId}|{ThreadName}|{SourceContext:l}{NewLine}{Exception}", + "rollingInterval": "Day" + } + } + ] + }, + "Logging": { + "LogLevel": { + "Default": "Trace", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/AIMS/packages.config b/AIMS/packages.config deleted file mode 100644 index f9dfbde..0000000 --- a/AIMS/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AIMSEntity/AIMSEntity.csproj b/AIMSEntity/AIMSEntity.csproj index 87efea1..84c4ebe 100644 --- a/AIMSEntity/AIMSEntity.csproj +++ b/AIMSEntity/AIMSEntity.csproj @@ -38,10 +38,6 @@ - - False - ..\AIMS\Extensions\Newtonsoft.Json.dll - diff --git a/AIMSExtension/AIMSExtension.csproj b/AIMSExtension/AIMSExtension.csproj index c143483..a0a2b78 100644 --- a/AIMSExtension/AIMSExtension.csproj +++ b/AIMSExtension/AIMSExtension.csproj @@ -37,10 +37,6 @@ ..\AIMS\Extensions\Mono.Security.dll - - False - ..\AIMS\Extensions\Newtonsoft.Json.dll - False ..\AIMS\Extensions\Npgsql.dll @@ -49,11 +45,14 @@ ..\AIMS\Extensions\Oracle.ManagedDataAccess.dll + + ..\AIMS\Extensions\System.Net.Http.dll + @@ -108,6 +107,14 @@ Designer + + + 1.0.0 + + + 13.0.3 + + - + - + - + - + - + - - + + + + + + + + + + diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..24f10dc --- /dev/null +++ b/nuget.config @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file