From 3b92aaf61c583d8ea487322b06eaf68d163f287d Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 29 Jul 2024 16:24:34 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=20=E5=92=8C=20scp=20=E7=BC=A9=E7=95=A5=E5=9B=BE?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRC.Core.SCP/Service/CStoreSCPService.cs | 4 + .../BackGroundJob/IRaCISCHangfireJob.cs | 89 +------------------ .../Helper/InternationalizationHelper.cs | 58 ++++++++---- 3 files changed, 47 insertions(+), 104 deletions(-) diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs index 97c2b636c..eb369a966 100644 --- a/IRC.Core.SCP/Service/CStoreSCPService.cs +++ b/IRC.Core.SCP/Service/CStoreSCPService.cs @@ -331,6 +331,10 @@ namespace IRaCIS.Core.SCP.Service } } + else + { + Log.Logger.Information($"ImageResizePath:{series.ImageResizePath} and series is null:{series == null} "); + } await _seriesRepository.SaveChangesAsync(); } diff --git a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs index f135121b6..514df5174 100644 --- a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs +++ b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs @@ -25,8 +25,6 @@ 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; @@ -62,7 +60,7 @@ namespace IRaCIS.Application.Services.BackGroundJob //初始化 - await InitInternationlizationDataAndWatchJsonFileAsync(); + await InternationalizationHelper.InitInternationlizationDataAndWatchJsonFileAsync(_internationalizationRepository); //创建邮件定时任务 await InitSysAndTrialCronJobAsync(); @@ -96,93 +94,8 @@ namespace IRaCIS.Application.Services.BackGroundJob } - #region 国际化 初始化 - public async Task InitInternationlizationDataAndWatchJsonFileAsync() - { - //查询数据库的数据 - var toJsonList = await _internationalizationRepository.Where(t => t.InternationalizationType == 1).Select(t => new - { - t.Code, - t.Value, - t.ValueCN - }).ToListAsync(); - - //组织成json 文件 - - var usJsonPath = Path.Combine(JsonFileFolder, StaticData.En_US_Json); - var cnJsonPath = Path.Combine(JsonFileFolder, StaticData.Zh_CN_Json); - - - //本地静态文件国际化需要 - foreach (var tojsonItem in toJsonList) - { - StaticData.En_US_Dic[tojsonItem.Code] = tojsonItem.Value; - StaticData.Zh_CN_Dic[tojsonItem.Code] = tojsonItem.ValueCN; - } - - File.WriteAllText(usJsonPath, JsonConvert.SerializeObject(StaticData.En_US_Dic)); - File.WriteAllText(cnJsonPath, JsonConvert.SerializeObject(StaticData.Zh_CN_Dic)); - - - //监测Json文件变更 实时刷新数据 - - if (!File.Exists(usJsonPath)|| !File.Exists(cnJsonPath)) - { - throw new BusinessValidationFailedException(StaticData.International("IRaCISCHangfireJob_FileNotFound")); - } - - 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(StaticData.Folder.Resources+"\\"+ StaticData.En_US_Json); - - - 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(StaticData.Folder.Resources + "\\" + StaticData.Zh_CN_Json); - - } - - - - - private void LoadJsonFile(string filePath) - { - Console.WriteLine("刷新json内存数据"); - IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath,false,false); - - IConfigurationRoot enConfiguration = builder.Build(); - - foreach (IConfigurationSection section in enConfiguration.GetChildren()) - { - if (filePath.Contains(StaticData.En_US_Json)) - { - StaticData.En_US_Dic[section.Key] = section.Value; - - } - else - { - StaticData.Zh_CN_Dic[section.Key] = section.Value; - } - } - } - - #endregion - public async Task InitSysAndTrialCronJobAsync() { //var deleteJobIdList = await _trialEmailNoticeConfigRepository.Where(t => t.Trial.TrialStatusStr != StaticData.TrialState.TrialOngoing && t.EmailCron != string.Empty && t.IsAutoSend) diff --git a/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs b/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs index 5d3bfb633..11159c5cd 100644 --- a/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs +++ b/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs @@ -18,6 +18,9 @@ namespace IRaCIS.Core.Application.Helper { 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 static void VerifyFolder() { if (!Directory.Exists(JsonFileFolder) || @@ -107,10 +110,11 @@ namespace IRaCIS.Core.Application.Helper } - public static async Task InitInternationlizationDataAndWatchJsonFileAsync(IRepository _repository) + + public static async Task InitInternationlizationDataAndWatchJsonFileAsync(IRepository _internationalizationRepository) { //查询数据库的数据 - var toJsonList = await _repository.Where(t => t.InternationalizationType == 1).Select(t => new + var toJsonList = await _internationalizationRepository.Where(t => t.InternationalizationType == 1).Select(t => new { t.Code, t.Value, @@ -136,29 +140,45 @@ namespace IRaCIS.Core.Application.Helper //监测Json文件变更 实时刷新数据 - WatchJsonFile(usJsonPath); - WatchJsonFile(cnJsonPath); - - } - - public static void WatchJsonFile(string filePath) - { - if (!File.Exists(filePath)) + if (!File.Exists(usJsonPath) || !File.Exists(cnJsonPath)) { - throw new BusinessValidationFailedException("国际化Json文件不存在"); + 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; + + // //监测Json文件变更 实时刷新数据 + + + 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(StaticData.Folder.Resources + "\\" + StaticData.En_US_Json); + + + 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(StaticData.Folder.Resources + "\\" + StaticData.Zh_CN_Json); } + private static void LoadJsonFile(string filePath) { - - IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath); + Console.WriteLine("刷新json内存数据"); + IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath, false, false); IConfigurationRoot enConfiguration = builder.Build(); @@ -175,5 +195,11 @@ namespace IRaCIS.Core.Application.Helper } } } + + + + + + } } From 942f3adfe0ee54d2c483a47f2e8fcb4f7ac2d8c7 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 29 Jul 2024 16:33:00 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9scp=20=E4=B8=8A=E4=BC=A0b?= =?UTF-8?q?ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRC.Core.SCP/Service/CStoreSCPService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs index eb369a966..fa73a773b 100644 --- a/IRC.Core.SCP/Service/CStoreSCPService.cs +++ b/IRC.Core.SCP/Service/CStoreSCPService.cs @@ -256,8 +256,9 @@ namespace IRaCIS.Core.SCP.Service string seriesInstanceUid = request.Dataset.GetString(DicomTag.SeriesInstanceUID); string sopInstanceUid = request.Dataset.GetString(DicomTag.SOPInstanceUID); - Guid seriesId = IdentifierHelper.CreateGuid(studyInstanceUid, seriesInstanceUid); - Guid instanceId = IdentifierHelper.CreateGuid(studyInstanceUid, seriesInstanceUid, sopInstanceUid); + //Guid studyId = IdentifierHelper.CreateGuid(studyInstanceUid, trialId.ToString()); + Guid seriesId = IdentifierHelper.CreateGuid(studyInstanceUid, seriesInstanceUid, _trialId.ToString()); + Guid instanceId = IdentifierHelper.CreateGuid(studyInstanceUid, seriesInstanceUid, sopInstanceUid, _trialId.ToString()); var ossService = _serviceProvider.GetService(); From 8c94e17c1495c78a57a6adaf6813fd40ede923f9 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 29 Jul 2024 16:33:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRC.Core.SCP/Service/CStoreSCPService.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs index fa73a773b..539e24b36 100644 --- a/IRC.Core.SCP/Service/CStoreSCPService.cs +++ b/IRC.Core.SCP/Service/CStoreSCPService.cs @@ -332,10 +332,7 @@ namespace IRaCIS.Core.SCP.Service } } - else - { - Log.Logger.Information($"ImageResizePath:{series.ImageResizePath} and series is null:{series == null} "); - } + await _seriesRepository.SaveChangesAsync(); } From 633507d4cdae54f6d8020f9fc408278cae2883d8 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 29 Jul 2024 17:59:01 +0800 Subject: [PATCH 4/5] =?UTF-8?q?k8s=20=20docker=20=E6=8C=82=E8=BD=BD?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=83=AD=E6=9B=B4=E6=96=B0?= =?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 --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 1 + IRaCIS.Core.API/Progranm.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index a434c6d2b..8bdddbe5f 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -64,6 +64,7 @@ + true diff --git a/IRaCIS.Core.API/Progranm.cs b/IRaCIS.Core.API/Progranm.cs index 885b11f66..50cb855b4 100644 --- a/IRaCIS.Core.API/Progranm.cs +++ b/IRaCIS.Core.API/Progranm.cs @@ -76,8 +76,8 @@ if (urlsIndex > -1) NewId.SetProcessIdProvider(new CurrentProcessIdProvider()); -builder.Configuration.AddJsonFile("appsettings.json", false, true) - .AddJsonFile($"appsettings.{enviromentName}.json", false, true); +builder.Configuration.AddJsonFile(ConfigMapFileProvider.FromRelativePath(""), "appsettings.json", false, true) + .AddJsonFile(ConfigMapFileProvider.FromRelativePath(""), $"appsettings.{enviromentName}.json", false, true); builder.Host .UseServiceProviderFactory(new AutofacServiceProviderFactory()) From fd9af4760674d83d482ba301512e6fa1b54e72da Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 30 Jul 2024 09:51:48 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/Common/MailService.cs | 8 ++++---- .../Service/Management/UserService.cs | 11 ++++++++++- .../Service/SiteSurvey/TrialSiteSurveyService.cs | 7 +++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 7850b7e38..e2da0075e 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -190,7 +190,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(mfaType == UserMFAType.Login ? EmailBusinessScenario.MFALogin : EmailBusinessScenario.MFAUnlock, messageToSend, emailConfigFunc); - var sucessHandle = GetEmailSuccessHandle(userId, verificationCode); + var sucessHandle = GetEmailSuccessHandle(userId, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); @@ -229,7 +229,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UserResetEmail, messageToSend, emailConfigFunc); - var sucessHandle = GetEmailSuccessHandle(userId, verificationCode); + var sucessHandle = GetEmailSuccessHandle(userId, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); @@ -269,7 +269,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UnloginUseEmailResetPassword, messageToSend, emailConfigFunc); ////此时不知道用户 - var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode); + var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); @@ -355,7 +355,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurveyLogin, messageToSend, emailConfigFunc); //此时不知道用户 - var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode); + var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 151b5c907..f103313cf 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -208,6 +208,11 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk(_localizer["User_VerificationCodeExpired"]); } + else if (verificationRecord.EmailOrPhone.Trim() != newEmail.Trim()) + { + //发送验证嘛的和提交的邮箱不一致 + return ResponseOutput.NotOk(_localizer["User_VerificationEmailNotSameWithBefore"]); + } else //验证码正确 并且 没有超时 { @@ -684,7 +689,7 @@ namespace IRaCIS.Application.Services [AllowAnonymous] public async Task VerifyMFACodeAsync(Guid userId, string Code) { - var verificationRecord = await _repository.GetQueryable().OrderByDescending(x => x.ExpirationTime).Where(t => t.UserId == userId && t.Code == Code && t.CodeType == VerifyType.Email).FirstOrDefaultAsync(); + var verificationRecord = await _verificationCodeRepository.Where(t => t.UserId == userId && t.Code == Code && t.CodeType == VerifyType.Email).OrderByDescending(x => x.ExpirationTime).FirstOrDefaultAsync(); VerifyEmialGetDoctorInfoOutDto result = new VerifyEmialGetDoctorInfoOutDto(); //检查数据库是否存在该验证码 @@ -707,6 +712,10 @@ namespace IRaCIS.Application.Services } else //验证码正确 并且 没有超时 { + + + //删除验证码历史记录 + await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.Id == verificationRecord.Id); await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, OptUserId = userId, OptType = UserOptType.MFALogin }, true); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 9ff013fac..2665746ff 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -117,6 +117,10 @@ namespace IRaCIS.Core.Application.Contracts } else //验证码正确 并且 没有超时 { + + //删除验证码历史记录 + await _repository.BatchDeleteAsync(t => t.Id == verificationRecord.Id); + var dockerInfo = await _repository.Where(t => t.EMail == inDto.EmailOrPhone || t.Phone == inDto.EmailOrPhone).FirstOrDefaultAsync(); if (dockerInfo != null) @@ -192,6 +196,9 @@ namespace IRaCIS.Core.Application.Contracts } else { + //删除验证码历史记录 + await _repository.BatchDeleteAsync(t => t.Id == verifyRecord.Id); + //验证码正确 不处理 }