整合日志

This commit is contained in:
Colin 2023-08-16 21:23:30 +08:00
parent 673fb4132c
commit ef29d2565b
9 changed files with 158 additions and 54 deletions

View File

@ -8,10 +8,10 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>AIMSControls</RootNamespace> <RootNamespace>AIMSControls</RootNamespace>
<AssemblyName>AIMSControls</AssemblyName> <AssemblyName>AIMSControls</AssemblyName>
<!-- <TargetFramework>.NETFramework,Version=v4.8</TargetFramework> -->
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -34,9 +34,6 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="DCSoft.Writer"> <Reference Include="DCSoft.Writer">
<HintPath>..\AIMS\Extensions\DCSoft.Writer.dll</HintPath> <HintPath>..\AIMS\Extensions\DCSoft.Writer.dll</HintPath>
@ -54,10 +51,6 @@
<EmbedInteropTypes>False</EmbedInteropTypes> <EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>..\AIMS\Extensions\Microsoft.Office.Interop.Excel.dll</HintPath> <HintPath>..\AIMS\Extensions\Microsoft.Office.Interop.Excel.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\AIMS\Extensions\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Net.Http"> <Reference Include="System.Net.Http">
@ -65,7 +58,6 @@
</Reference> </Reference>
<Reference Include="System.Windows.Forms.DataVisualization" /> <Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Deployment" /> <Reference Include="System.Deployment" />
@ -1574,5 +1566,10 @@
<None Include="Resources\GCS分级P1.png" /> <None Include="Resources\GCS分级P1.png" />
<None Include="Resources\GCSusers.png" /> <None Include="Resources\GCSusers.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -12,10 +11,6 @@
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -45,9 +40,6 @@
<StartupObject>AIMS.Program</StartupObject> <StartupObject>AIMS.Program</StartupObject>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
</Reference>
<Reference Include="DCSoft.Writer, Version=1.2015.12.23, Culture=neutral, PublicKeyToken=2e40e961ea876340, processorArchitecture=MSIL"> <Reference Include="DCSoft.Writer, Version=1.2015.12.23, Culture=neutral, PublicKeyToken=2e40e961ea876340, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>DLL\DCSoft.Writer.dll</HintPath> <HintPath>DLL\DCSoft.Writer.dll</HintPath>
@ -60,10 +52,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\DotNetBar for Windows Forms\DevComponents.DotNetBar2.dll</HintPath> <HintPath>..\..\..\..\..\..\..\Program Files (x86)\DotNetBar for Windows Forms\DevComponents.DotNetBar2.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Extensions\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Net.Http"> <Reference Include="System.Net.Http">
@ -92,10 +80,12 @@
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Clear.Bat"> <None Include="Clear.Bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -155,18 +145,25 @@
<Name>DrawGraph</Name> <Name>DrawGraph</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<PackageReference Include="CCIS.Shared">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="Costura.Fody">
<Version>5.7.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Serilog.Sinks.File">
<Version>5.0.0</Version>
</PackageReference>
<PackageReference Include="Serilog.Sinks.Seq">
<Version>5.2.2</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent> <PostBuildEvent>
</PostBuildEvent> </PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<Import Project="..\packages\Fody.6.0.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.0\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.6.0.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.0.0\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
</Target>
</Project> </Project>

View File

@ -11,16 +11,47 @@ using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.IO; using System.IO;
using System.Xml.Linq; using System.Xml.Linq;
using CCIS.Shared;
using Serilog;
using Serilog.Core;
namespace AIMS namespace AIMS
{ {
static class Program static class Program
{ {
static Program()
{
}
/// <summary> /// <summary>
/// 应用程序的主入口点。 /// 应用程序的主入口点。
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main(string[] args) 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(); Application.Exit();
} }
} }
/// <summary>
/// Creates a logger used during application initialisation.
/// <see href="https://nblumhardt.com/2020/10/bootstrap-logger/"/>.
/// </summary>
/// <returns>A logger that can load a new configuration.</returns>
private static Logger CreateBootstrapLogger() =>
new LoggerConfiguration()
//.WriteTo.Console()
.WriteTo.File("logs\\bootstrap.log", rollingInterval: RollingInterval.Day)
.CreateLogger();
#region #region
private static Process RunningInstance() private static Process RunningInstance()
{ {

51
AIMS/appsettings.json Normal file
View File

@ -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"
}
}
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="4.1.0" targetFramework="net40" />
<package id="Fody" version="6.0.0" targetFramework="net40" developmentDependency="true" />
</packages>

View File

@ -38,10 +38,6 @@
<StartupObject /> <StartupObject />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\AIMS\Extensions\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />

View File

@ -37,10 +37,6 @@
<Reference Include="Mono.Security"> <Reference Include="Mono.Security">
<HintPath>..\AIMS\Extensions\Mono.Security.dll</HintPath> <HintPath>..\AIMS\Extensions\Mono.Security.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\AIMS\Extensions\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Npgsql, Version=2.2.7.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL"> <Reference Include="Npgsql, Version=2.2.7.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\AIMS\Extensions\Npgsql.dll</HintPath> <HintPath>..\AIMS\Extensions\Npgsql.dll</HintPath>
@ -49,11 +45,14 @@
<HintPath>..\AIMS\Extensions\Oracle.ManagedDataAccess.dll</HintPath> <HintPath>..\AIMS\Extensions\Oracle.ManagedDataAccess.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Net.Http"> <Reference Include="System.Net.Http">
<HintPath>..\AIMS\Extensions\System.Net.Http.dll</HintPath> <HintPath>..\AIMS\Extensions\System.Net.Http.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Printing" /> <Reference Include="System.Printing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -108,6 +107,14 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="CCIS.Shared">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
@ -22,4 +22,12 @@
<add name="DATAConnectionString" connectionString="Data Source=.;Initial Catalog=OREMR_DATA;User ID=sa;Password=123456;MultipleActiveResultSets=true;" providerName="System.Data.SqlClient" /> <add name="DATAConnectionString" connectionString="Data Source=.;Initial Catalog=OREMR_DATA;User ID=sa;Password=123456;MultipleActiveResultSets=true;" providerName="System.Data.SqlClient" />
<add name="HisConnectionStringOracel" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.100.10)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl))));Persist Security Info=True;User ID=smxt;Password=his;" /> <add name="HisConnectionStringOracel" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.100.10)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl))));Persist Security Info=True;User ID=smxt;Password=his;" />
</connectionStrings> </connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> </configuration>

13
nuget.config Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="gitea" value="https://git.wulvshi.cn/api/packages/aimsbs/nuget/index.json" />
</packageSources>
<!-- <packageSourceCredentials>
<gitea>
<add key="Username" value="colin" />
<add key="Password" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAEBzikdyGfEipqrs9EQ42MgAAAAACAAAAAAAQZgAAAAEAACAAAABvEw6Je2lA3gtu9h3C0Cej4HzOxKMa3wTEuVbyatAT5QAAAAAOgAAAAAIAACAAAADNv5uIEoc0Zt2xBNRVEAuf9F7/PvMTdy1sTXNWAmzfdjAAAABsHTWv2XnOcmLj9Pi8OKOPFA1bdFzpoiivNc0d9q4tcWAMg2wxiURRfa5puYoGMSNAAAAAct4WZ5J7FhvGokYM16iM9KfKzBHKVE/2ZvP2cO+fa7aJapm6pB6xUW7AnxlQJxc40qJmEuHSqJllmY4ilv8pNg==" />
</gitea>
</packageSourceCredentials> -->
</configuration>