From 551c2388d5135be44050f3e86080d1fa7ffb31f6 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Fri, 7 Jun 2024 19:10:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppointPatientRegisterAppService.cs | 3 +- .../AppointPatientRegisterManager.cs | 2 +- src/Shentun.WebPeis.HttpApi.Host/Program.cs | 8 ++ src/Shentun.WebPeis.HttpApi.Host/Serilog.json | 111 ++++++++++++++++++ .../Shentun.WebPeis.HttpApi.Host.csproj | 2 + 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 src/Shentun.WebPeis.HttpApi.Host/Serilog.json diff --git a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index 1a1f3a7..fc33cb2 100644 --- a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -487,7 +487,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters patientRegisterDto.CustomerOrgName = customerOrgEntity.CustomerOrgName; var appointPatientRegisters = await _repository.GetListAsync(o => o.PersonId == input.PersonId && - o.AppointDate >= DateTime.Now.Date && o.CustomerOrgRegisterId == patientRegisterDto.CustomerOrgRegisterId); + o.AppointDate >= DateTime.Now.Date && o.CustomerOrgRegisterId == patientRegisterDto.CustomerOrgRegisterId + && o.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint); if (appointPatientRegisters .Any()) { throw new UserFriendlyException("已有今天及之后的团检预约订单,必须先取消订单才能重新预约"); diff --git a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs index c539f05..bf30a95 100644 --- a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs +++ b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs @@ -238,7 +238,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters } var appoentPatientRegisters = await _repository.GetListAsync(o => o.PersonId == entity.PersonId && - o.AppointDate >= DateTime.Now.Date); + o.AppointDate >= DateTime.Now.Date && o.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint); if(appoentPatientRegisters.Count >= 1) { throw new UserFriendlyException("已有今天及之后的预约订单,必须先取消订单才能重新预约"); diff --git a/src/Shentun.WebPeis.HttpApi.Host/Program.cs b/src/Shentun.WebPeis.HttpApi.Host/Program.cs index 223f10e..065e0a8 100644 --- a/src/Shentun.WebPeis.HttpApi.Host/Program.cs +++ b/src/Shentun.WebPeis.HttpApi.Host/Program.cs @@ -2,10 +2,12 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; +using Shentun.Utilities; namespace Shentun.WebPeis; @@ -13,6 +15,11 @@ public class Program { public async static Task Main(string[] args) { + var configuration = new ConfigurationBuilder() + .SetBasePath(DirectoryHelper.GetAppDirectory()) + .AddJsonFile("Serilog.json", false, reloadOnChange: true) + .Build(); + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() @@ -24,6 +31,7 @@ public class Program .Enrich.FromLogContext() .WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.Console()) + //.ReadFrom.Configuration(configuration) .CreateLogger(); try diff --git a/src/Shentun.WebPeis.HttpApi.Host/Serilog.json b/src/Shentun.WebPeis.HttpApi.Host/Serilog.json new file mode 100644 index 0000000..b7d35c3 --- /dev/null +++ b/src/Shentun.WebPeis.HttpApi.Host/Serilog.json @@ -0,0 +1,111 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Settings.Configuration", "Serilog.Sinks.PostgreSQL" ], + "MinimumLevel": { + "Default": "Debug", + "Override": { + "Default": "Warning", + "System": "Warning", + "Microsoft": "Warning" + } + }, + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Information", + "theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console" + } + }, + { + "Name": "File", + "Args": { + "path": "{CurrentDirectory}/logs/trace/trace-.log", + "rollingInterval": "Day", + "fileSizeLimitBytes": 52428800, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{ThreadId} {Level:u3}] {Message:lj} {NewLine}{Exception}", + "restrictedToMinimumLevel": "Verbose" + } + }, + { + "Name": "File", + "Args": { + "path": "{CurrentDirectory}/logs/debug/debug-.log", + "rollingInterval": "Day", + "fileSizeLimitBytes": 52428800, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{ThreadId} {Level:u3}] {Message:lj} {NewLine}{Exception}", + "restrictedToMinimumLevel": "Debug" + } + }, + { + "Name": "File", + "Args": { + "path": "{CurrentDirectory}/logs/info/info-.log", + "rollingInterval": "Day", + "fileSizeLimitBytes": 52428800, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{ThreadId} {Level:u3}] {Message:lj} {NewLine}{Exception}", + "restrictedToMinimumLevel": "Information" + } + }, + { + "Name": "File", + "Args": { + "path": "{CurrentDirectory}/logs/warning/warning-.log", + "rollingInterval": "Day", + "fileSizeLimitBytes": 52428800, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{ThreadId} {Level:u3}] {Message:lj} {NewLine}{Exception}", + "restrictedToMinimumLevel": "Warning" + } + }, + { + "Name": "PostgreSQL", + "Args": { + "connectionString": "Server=62.156.10.86;Port=5432;Database=WebPeis0520;User Id=postgres;Password=st123;", + "tableName": "logs", + "needAutoCreateTable": true, + //"columnOptionsSection": { + // "disableTriggers": true, + // "standardColumnOptions": { + // "additionalInformation": true, + // "properties": { + // "additionalInformation": true + // } + // } + //}, + "restrictedToMinimumLevel": "Warning", + "batchPostingLimit": 100, + "period": "0.00:00:30", + "formatProvider": "Serilog.Sinks.PostgreSQL.ColumnWriterSettingsColumnWriterSettings, Serilog.Sinks.PostgreSQL" + } + }, + { + "Name": "File", + "Args": { + "path": "{CurrentDirectory}/logs/fatal/fatal-.log", + "rollingInterval": "Day", + "fileSizeLimitBytes": 52428800, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{ThreadId} {Level:u3}] {Message:lj} {NewLine}{Exception}", + "restrictedToMinimumLevel": "Fatal" + } + } + ] + //"Filter": [ + // { + // "Name": "With", + // "Args": { + // "filter": { + // "type": "SpaceNation.GameServer.Utility.Serilog.CustomFilter, spacenation.game.application.server", + // "levelFilter": "Verbose" + // } + // } + // } + //], + //"LogFilterKeys": [ + // "Orleans", + // "Microsoft.AspNetCore", + // "Microsoft.Hosting", + // "Microsoft.Extensions" + //] + } +} \ No newline at end of file diff --git a/src/Shentun.WebPeis.HttpApi.Host/Shentun.WebPeis.HttpApi.Host.csproj b/src/Shentun.WebPeis.HttpApi.Host/Shentun.WebPeis.HttpApi.Host.csproj index 0ccf589..53f534c 100644 --- a/src/Shentun.WebPeis.HttpApi.Host/Shentun.WebPeis.HttpApi.Host.csproj +++ b/src/Shentun.WebPeis.HttpApi.Host/Shentun.WebPeis.HttpApi.Host.csproj @@ -13,6 +13,7 @@ + @@ -25,6 +26,7 @@ +