From 64b750b06eba521494aed149bfd31c71c1590dc0 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 14 Mar 2024 14:18:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=9A=E6=97=B6=E5=8C=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewtonsoftJson/JSONTimeZoneConverter.cs | 12 ++---------- .../BackGroundJob/IRaCISCHangfireJob.cs | 13 ++++++++++--- .../Service/Visit/SubjectService.cs | 4 ---- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index 5e12ded31..cd4e942e8 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -50,18 +50,10 @@ namespace IRaCIS.Core.API DateTime dateTime; - if (reader.ValueType == typeof(string)) + if (DateTime.TryParse((string)reader.Value, out dateTime) == false) { - if (DateTime.TryParse((string)reader.Value, out dateTime) == false) - { - throw new JsonSerializationException("Unable to parse DateTime value."); - } + return null; } - else - { - dateTime = (DateTime)reader.Value; - } - // 将客户端时间转换为服务器时区的时间 var serverZoneTime = TimeZoneInfo.ConvertTime(dateTime, _clientTimeZone, TimeZoneInfo.Local); diff --git a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs index 39a80d307..984e30ce5 100644 --- a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs +++ b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs @@ -136,16 +136,23 @@ namespace IRaCIS.Application.Services.BackGroundJob throw new BusinessValidationFailedException(StaticData.International("IRaCISCHangfireJob_FileNotFound")); } - FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath)); + var watcher = new FileSystemWatcher + { + Path = Path.GetDirectoryName(filePath)!, + NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size|NotifyFilters.LastAccess, + Filter = Path.GetFileName(filePath), + EnableRaisingEvents = true, + + }; + watcher.Changed += (sender, e) => LoadJsonFile(filePath); - watcher.EnableRaisingEvents = true; } private void LoadJsonFile(string filePath) { - + Console.WriteLine("刷新json内存数据"); IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath,false,true); IConfigurationRoot enConfiguration = builder.Build(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs index 539cb3ba7..d9b8039c3 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs @@ -45,8 +45,6 @@ namespace IRaCIS.Application.Services }; - - Subject? mapedSubject = null; if (subjectCommand.Id == null) //insert @@ -64,8 +62,6 @@ namespace IRaCIS.Application.Services } - - await _subjectRepository.SaveChangesAsync(); return ResponseOutput.Ok(mapedSubject.Id.ToString());