From 011b588f088ab367c3af9c886c1320b1dcfff278 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Sun, 8 Oct 2023 11:33:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E9=81=97=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessFilter/ProjectExceptionFilter.cs | 11 ++++++++--- IRaCIS.Core.Application/Resources/en-US.json | 5 +++-- IRaCIS.Core.Application/Resources/zh-CN.json | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.Application/BusinessFilter/ProjectExceptionFilter.cs b/IRaCIS.Core.Application/BusinessFilter/ProjectExceptionFilter.cs index e510e44..c4f5ae9 100644 --- a/IRaCIS.Core.Application/BusinessFilter/ProjectExceptionFilter.cs +++ b/IRaCIS.Core.Application/BusinessFilter/ProjectExceptionFilter.cs @@ -2,6 +2,7 @@ using IRaCIS.Core.Infrastructure.Extention; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; namespace IRaCIS.Core.Application.Filter @@ -9,10 +10,14 @@ namespace IRaCIS.Core.Application.Filter public class ProjectExceptionFilter : Attribute, IExceptionFilter { private readonly ILogger _logger; + public readonly IStringLocalizer _localizer; - public ProjectExceptionFilter(ILogger logger) + + public ProjectExceptionFilter(ILogger logger, IStringLocalizer localizer) { _logger = logger; + + _localizer = localizer; } public void OnException(ExceptionContext context) { @@ -22,7 +27,7 @@ namespace IRaCIS.Core.Application.Filter { if (context.Exception.GetType().Name == "DbUpdateConcurrencyException") { - context.Result = new JsonResult(ResponseOutput.NotOk("并发更新,当前不允许该操作" + context.Exception.Message)); + context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["ProjectException_ConcurrentUpdateNotAllowed"] + context.Exception.Message)); } if (context.Exception.GetType() == typeof(BusinessValidationFailedException) || context.Exception.GetType() == typeof(DBSaveFailedException)) @@ -35,7 +40,7 @@ namespace IRaCIS.Core.Application.Filter } else { - context.Result = new JsonResult(ResponseOutput.NotOk("当前操作失败,请联系开发人员查看系统日志排查 ", ApiResponseCodeEnum.ProgramException)); + context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["Project_ExceptionContactDeveloper"] , ApiResponseCodeEnum.ProgramException)); } diff --git a/IRaCIS.Core.Application/Resources/en-US.json b/IRaCIS.Core.Application/Resources/en-US.json index a9b5fe8..593aa01 100644 --- a/IRaCIS.Core.Application/Resources/en-US.json +++ b/IRaCIS.Core.Application/Resources/en-US.json @@ -2,7 +2,7 @@ "RequiredAttribute": "{0} is required", - "TrialService_OnlyInInitOrProgress": "Operations are allowed only when the trial state is Initializing or Ongoing.", + "TrialService_OnlyInInitOrProgress": "Operations are allowed only when the trial state is Initializing or Ongoing.", "TrialService_ExistPN": "The same Trial ID already exists", "SubjectService_ExistSubjectCode": "A patient with the relevant patient ID already exists.", @@ -18,7 +18,8 @@ "SystemAnonymization_InvalidGroupOrElement": "Please check whether the element number or group number configured by DicomTag meets the requirements.", - + "ProjectException_ConcurrentUpdateNotAllowed": "Concurrent update, operation not allowed at this time.", + "Project_ExceptionContactDeveloper": "Your current operation failed, please contact the developer to check the system log for troubleshooting. ", "User_UsernameExist": "The user name already exists.", "User_PhoneDup": "A user with the same phone number already exists in this user type.", diff --git a/IRaCIS.Core.Application/Resources/zh-CN.json b/IRaCIS.Core.Application/Resources/zh-CN.json index d9aa3a0..df27ca1 100644 --- a/IRaCIS.Core.Application/Resources/zh-CN.json +++ b/IRaCIS.Core.Application/Resources/zh-CN.json @@ -19,7 +19,8 @@ "SystemAnonymization_InvalidGroupOrElement": "请核对DicomTag 配置的元素号或者组号是否符合要求", - + "ProjectException_ConcurrentUpdateNotAllowed": "并发更新,当前不允许该操作", + "Project_ExceptionContactDeveloper": "您当前的操作失败,请联系开发人员查看系统日志排查",