Merge branch 'Test_IRC_Net8' of http://192.168.3.68:2000/XCKJ/irc-netcore-api into Test_IRC_Net8

IRC_NewDev
he 2024-03-15 10:30:29 +08:00
commit a61d9ae4d1
8 changed files with 82 additions and 35 deletions

View File

@ -43,22 +43,44 @@ namespace IRaCIS.Core.API
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{ {
DateTime? nullableDateTime = reader.Value as DateTime?; if (reader.Value == null)
if (nullableDateTime != null && nullableDateTime.HasValue)
{
var dateTime = (DateTime)reader.Value;
// 将客户端时间转换为服务器时区的时间
var serverZoneTime = TimeZoneInfo.ConvertTime(dateTime, _clientTimeZone, TimeZoneInfo.Local);
return serverZoneTime;
}
else
{ {
return 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;
} }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)

View File

@ -8,6 +8,7 @@ using IRaCIS.Core.Infrastructure;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using SharpCompress.Common;
namespace IRaCIS.Application.Services.BackGroundJob 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 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<Trial> _trialRepository; private readonly IRepository<Trial> _trialRepository;
private readonly IEasyCachingProvider _provider; private readonly IEasyCachingProvider _provider;
private readonly ILogger<IRaCISCHangfireJob> _logger; private readonly ILogger<IRaCISCHangfireJob> _logger;
@ -124,29 +127,43 @@ namespace IRaCIS.Application.Services.BackGroundJob
//监测Json文件变更 实时刷新数据 //监测Json文件变更 实时刷新数据
WatchJsonFile(usJsonPath);
WatchJsonFile(cnJsonPath);
} if (!File.Exists(usJsonPath)|| !File.Exists(cnJsonPath))
public void WatchJsonFile(string filePath)
{
if (!File.Exists(filePath))
{ {
throw new BusinessValidationFailedException(StaticData.International("IRaCISCHangfireJob_FileNotFound")); throw new BusinessValidationFailedException(StaticData.International("IRaCISCHangfireJob_FileNotFound"));
} }
FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath)); FileSystemWatcher_US = new FileSystemWatcher
watcher.Changed += (sender, e) => LoadJsonFile(filePath); {
watcher.EnableRaisingEvents = true; 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) private void LoadJsonFile(string filePath)
{ {
Console.WriteLine("刷新json内存数据");
IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath); IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath,false,true);
IConfigurationRoot enConfiguration = builder.Build(); IConfigurationRoot enConfiguration = builder.Build();

View File

@ -181,9 +181,7 @@ namespace IRaCIS.Core.Application.Service
if (addOrEditInternationalization.InternationalizationType == 1) if (addOrEditInternationalization.InternationalizationType == 1)
{ {
await InternationalizationHelper.AddOrUpdateJsonKeyValueAsync(entity.Code, addOrEditInternationalization.Value, addOrEditInternationalization.ValueCN); await InternationalizationHelper.AddOrUpdateJsonKeyValueAsync(entity.Code, addOrEditInternationalization.Value, addOrEditInternationalization.ValueCN);
} }
return ResponseOutput.Ok(entity.Id.ToString()); return ResponseOutput.Ok(entity.Id.ToString());
} }

View File

@ -759,7 +759,7 @@ namespace IRaCIS.Core.Application.Image.QA
[HttpGet("{subjectVisitId:guid}")] [HttpGet("{subjectVisitId:guid}")]
public async Task<(List<QAStudyInfoDTO>,object)> GetSubjectVisitUploadedStudyList(Guid subjectVisitId) public async Task<(List<QAStudyInfoDTO>,object)> GetSubjectVisitUploadedStudyList(Guid subjectVisitId)
{ {
var list= await _repository.Where<DicomStudy>(s => s.SubjectVisitId == subjectVisitId).IgnoreQueryFilters().ProjectTo<QAStudyInfoDTO>(_mapper.ConfigurationProvider).ToListAsync(); var list= await _repository.Where<DicomStudy>(s => s.SubjectVisitId == subjectVisitId).IgnoreQueryFilters().ProjectTo<QAStudyInfoDTO>(_mapper.ConfigurationProvider).OrderBy(t=>t.StudyCode).ToListAsync();
var config = await _repository.Where<SubjectVisit>(t => t.Id == subjectVisitId).Select(t=>t.Trial).ProjectTo<TrialSubjectAndSVConfig>(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); var config = await _repository.Where<SubjectVisit>(t => t.Id == subjectVisitId).Select(t=>t.Trial).ProjectTo<TrialSubjectAndSVConfig>(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException();

View File

@ -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 = 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(); var success = await _repository.SaveChangesAsync();

View File

@ -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(); return ResponseOutput.Ok();
} }

View File

@ -45,8 +45,6 @@ namespace IRaCIS.Application.Services
}; };
Subject? mapedSubject = null; Subject? mapedSubject = null;
if (subjectCommand.Id == null) //insert if (subjectCommand.Id == null) //insert
@ -64,8 +62,6 @@ namespace IRaCIS.Application.Services
} }
await _subjectRepository.SaveChangesAsync(); await _subjectRepository.SaveChangesAsync();
return ResponseOutput.Ok(mapedSubject.Id.ToString()); return ResponseOutput.Ok(mapedSubject.Id.ToString());