diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index af0b905b6..0968daf29 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -43,21 +43,43 @@ 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(DateTime) || reader.ValueType == typeof(DateTime?)) + { + 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); + + return serverZoneTime; + + } diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs index 130d8b122..c23963a5d 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs @@ -36,7 +36,7 @@ namespace IRaCIS.Core.API options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); //options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); - + //IsoDateTimeConverter //options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; diff --git a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs index b5bcb0565..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,29 +127,43 @@ 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")); } - FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath)); - watcher.Changed += (sender, e) => LoadJsonFile(filePath); - watcher.EnableRaisingEvents = true; + FileSystemWatcher_US = new FileSystemWatcher + { + Path = Path.GetDirectoryName(usJsonPath)!, + NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size, + Filter = Path.GetFileName(usJsonPath), + EnableRaisingEvents = true, + + }; + // 添加文件更改事件的处理程序 + 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) { - - IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath); + Console.WriteLine("刷新json内存数据"); + 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()); } 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(); 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(); 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(); } 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());