From 19d719284249072bc2fe9dd6910b47464e578b6c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 14 Mar 2024 10:37:21 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BF=E8=A7=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index e1452059b..8097c71a5 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -216,7 +216,7 @@ namespace IRaCIS.Application.Services //添加访视 await _repository.AddAsync(new VisitStage { TrialId = trial.Id, VisitNum = 0, BlindName = "B" + 0.ToString("D3"), VisitDay = 0, VisitName = "Baseline", IsBaseLine = true,VisitWindowLeft=-28,VisitWindowRight=0 }); - await _repository.AddAsync(new VisitStage { TrialId = trial.Id, VisitNum = 1, BlindName = "B" + 10.ToString("D3"), VisitDay = 30, VisitName = "Visit 1", VisitWindowLeft = -3, VisitWindowRight = 3 }); + await _repository.AddAsync(new VisitStage { TrialId = trial.Id, VisitNum = 1, BlindName = "B" + 10.ToString("D3"), VisitDay = 30, VisitName = "Visit 1", VisitWindowLeft = -5, VisitWindowRight = 5 }); var success = await _repository.SaveChangesAsync(); From 664b308e31411ebf4271e7f73c3ce7b607e67b69 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 14 Mar 2024 13:25:51 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E6=97=B6=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs | 2 +- IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs | 2 +- .../Service/Common/InternationalizationService.cs | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs index 130d8b122..5a6d1eb30 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs @@ -33,7 +33,7 @@ namespace IRaCIS.Core.API //options.SerializerSettings.Converters.Add(new JSONCustomDateConverter()) ; - options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); + //options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); //options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); diff --git a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs index b5bcb0565..39a80d307 100644 --- a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs +++ b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs @@ -146,7 +146,7 @@ namespace IRaCIS.Application.Services.BackGroundJob private void LoadJsonFile(string filePath) { - IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath); + IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath,false,true); IConfigurationRoot enConfiguration = builder.Build(); diff --git a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs index fae26204d..5ac456822 100644 --- a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs +++ b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs @@ -181,9 +181,7 @@ namespace IRaCIS.Core.Application.Service if (addOrEditInternationalization.InternationalizationType == 1) { await InternationalizationHelper.AddOrUpdateJsonKeyValueAsync(entity.Code, addOrEditInternationalization.Value, addOrEditInternationalization.ValueCN); - - } - + } return ResponseOutput.Ok(entity.Id.ToString()); } From ca90736366547f458c2eacb6c1777f4de5ca4389 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 14 Mar 2024 13:48:27 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E5=8C=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewtonsoftJson/JSONTimeZoneConverter.cs | 35 ++++++++++++------- .../NewtonsoftJson/NewtonsoftJsonSetup.cs | 4 +-- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index af0b905b6..5e12ded31 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -43,21 +43,32 @@ namespace IRaCIS.Core.API public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - DateTime? nullableDateTime = reader.Value as DateTime?; - - if (nullableDateTime != null && nullableDateTime.HasValue) - { - var dateTime = (DateTime)reader.Value; - - // 将客户端时间转换为服务器时区的时间 - var serverZoneTime = TimeZoneInfo.ConvertTime(dateTime, _clientTimeZone, TimeZoneInfo.Local); - - return serverZoneTime; - } - else + if (reader.Value == null) { return null; } + + DateTime dateTime; + + if (reader.ValueType == typeof(string)) + { + if (DateTime.TryParse((string)reader.Value, out dateTime) == false) + { + throw new JsonSerializationException("Unable to parse DateTime value."); + } + } + else + { + dateTime = (DateTime)reader.Value; + } + + + // 将客户端时间转换为服务器时区的时间 + var serverZoneTime = TimeZoneInfo.ConvertTime(dateTime, _clientTimeZone, TimeZoneInfo.Local); + + return serverZoneTime; + + } diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs index 5a6d1eb30..c23963a5d 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs @@ -33,10 +33,10 @@ namespace IRaCIS.Core.API //options.SerializerSettings.Converters.Add(new JSONCustomDateConverter()) ; - //options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); + options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); //options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); - + //IsoDateTimeConverter //options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; 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 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=9A=E6=97=B6?= =?UTF-8?q?=E5=8C=BA=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()); From 41e5f9fd7866aa9c358c5224ebba4dc5a2227f67 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 14 Mar 2024 15:59:13 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E5=8C=BA=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewtonsoftJson/JSONTimeZoneConverter.cs | 23 ++++++++++- .../BackGroundJob/IRaCISCHangfireJob.cs | 38 ++++++++++++------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index cd4e942e8..0968daf29 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -50,10 +50,29 @@ namespace IRaCIS.Core.API DateTime dateTime; - if (DateTime.TryParse((string)reader.Value, out dateTime) == false) + if (reader.ValueType == typeof(DateTime) || reader.ValueType == typeof(DateTime?)) { - return null; + DateTime? nullableDateTime = reader.Value as DateTime?; + + + if (nullableDateTime != null && nullableDateTime.HasValue) + { + dateTime = nullableDateTime.Value; + } + else + { + return null; + } } + else + { + if (DateTime.TryParse((string)reader.Value, out dateTime) == false) + { + return null; + } + } + + // 将客户端时间转换为服务器时区的时间 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 984e30ce5..81da08136 100644 --- a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs +++ b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs @@ -8,6 +8,7 @@ using IRaCIS.Core.Infrastructure; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using SharpCompress.Common; namespace IRaCIS.Application.Services.BackGroundJob { @@ -24,6 +25,8 @@ namespace IRaCIS.Application.Services.BackGroundJob { public static string JsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources); + public static FileSystemWatcher FileSystemWatcher_US { get; set; } + public static FileSystemWatcher FileSystemWatcher_CN { get; set; } private readonly IRepository _trialRepository; private readonly IEasyCachingProvider _provider; private readonly ILogger _logger; @@ -124,32 +127,39 @@ namespace IRaCIS.Application.Services.BackGroundJob //监测Json文件变更 实时刷新数据 - WatchJsonFile(usJsonPath); - WatchJsonFile(cnJsonPath); - } - - public void WatchJsonFile(string filePath) - { - if (!File.Exists(filePath)) + if (!File.Exists(usJsonPath)|| !File.Exists(cnJsonPath)) { throw new BusinessValidationFailedException(StaticData.International("IRaCISCHangfireJob_FileNotFound")); } - var watcher = new FileSystemWatcher + FileSystemWatcher_US = new FileSystemWatcher { - Path = Path.GetDirectoryName(filePath)!, - NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size|NotifyFilters.LastAccess, - Filter = Path.GetFileName(filePath), + Path = Path.GetDirectoryName(usJsonPath)!, + NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size, + Filter = Path.GetFileName(usJsonPath), EnableRaisingEvents = true, - - }; - watcher.Changed += (sender, e) => LoadJsonFile(filePath); + }; + // 添加文件更改事件的处理程序 + FileSystemWatcher_US.Changed += (sender, e) => LoadJsonFile(usJsonPath); + + + FileSystemWatcher_CN = new FileSystemWatcher + { + Path = Path.GetDirectoryName(cnJsonPath)!, + NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size, + Filter = Path.GetFileName(cnJsonPath), + EnableRaisingEvents = true, + + }; + FileSystemWatcher_CN.Changed += (sender, e) => LoadJsonFile(cnJsonPath); } + + private void LoadJsonFile(string filePath) { Console.WriteLine("刷新json内存数据"); From 16a2e0b53fe962a21ed991935ef8c53ad998c497 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 14 Mar 2024 16:36:17 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9site=20user=20=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/TrialSiteService.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index 4ce4e99b1..7820cd673 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -323,7 +323,21 @@ namespace IRaCIS.Core.Application.Services { - await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.Id == id, u => new TrialSiteUser() { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null }, true, true); + await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.Id == id, u => new TrialSiteUser() { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null }, true, true); + + //删除又启用改授权时间 + if (isDelete == false) + { + await _trialSiteUserRepository.BatchUpdateNoTrackingAsync(t => t.Id == id, u => new TrialSiteUser() { CreateTime = DateTime.Now }); + } + + ////不跟踪 + //await _trialSiteUserRepository.ExecuteUpdateAsync(t => t.Id == id, s=>s.SetProperty(t=>t.IsDeleted,u=>isDelete) + // .SetProperty(t=>t.DeletedTime,u=> isDelete ? DateTime.Now : null) + // .SetProperty(t=>t.CreateTime,u=>isDelete?u.CreateTime:DateTime.Now)); + + + return ResponseOutput.Ok(); } From e3607895b4dd03b1a673c58e108b6634484835db Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 14 Mar 2024 17:10:25 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9study=20=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/QC/QCListService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/QC/QCListService.cs b/IRaCIS.Core.Application/Service/QC/QCListService.cs index e3d5a858c..60d2bfdc1 100644 --- a/IRaCIS.Core.Application/Service/QC/QCListService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCListService.cs @@ -759,7 +759,7 @@ namespace IRaCIS.Core.Application.Image.QA [HttpGet("{subjectVisitId:guid}")] public async Task<(List,object)> GetSubjectVisitUploadedStudyList(Guid subjectVisitId) { - var list= await _repository.Where(s => s.SubjectVisitId == subjectVisitId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var list= await _repository.Where(s => s.SubjectVisitId == subjectVisitId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).OrderBy(t=>t.StudyCode).ToListAsync(); var config = await _repository.Where(t => t.Id == subjectVisitId).Select(t=>t.Trial).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException();