From 292bcd71009e98c0ed10deafd75b1f081e84a6db Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 21 Feb 2024 13:58:34 +0800 Subject: [PATCH 1/9] =?UTF-8?q?[=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=97=B6=E5=8C=BA=E4=B8=8A=E7=BA=BF=E6=B5=8B=E8=AF=95?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.xml | 5 + .../TimeZoneAdjustmentMiddleware.cs | 115 ++++++++++++++++++ .../NewtonsoftJson/JSONCustomDateConverter.cs | 88 ++++++++------ .../NewtonsoftJson/NewtonsoftJsonSetup.cs | 7 +- .../Service/Common/ExcelExportService.cs | 103 ++++++++++------ .../TrialSiteUser/DTO/UserTrialViewModel.cs | 4 +- IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs | 4 +- .../ConvertToClientTimeResultFilter.cs | 60 +++++++++ .../Extention/ExportExcelDateConverter.cs | 83 +++++++++++++ 9 files changed, 391 insertions(+), 78 deletions(-) create mode 100644 IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs create mode 100644 IRaCIS.Core.Infrastructure/Extention/ConvertToClientTimeResultFilter.cs create mode 100644 IRaCIS.Core.Infrastructure/Extention/ExportExcelDateConverter.cs diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index 008e1add6..cc66c1c02 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -365,6 +365,11 @@ IPLimit限流 启动服务 + + + 废弃,没用,不用这种处理方式 + + 创建属性 diff --git a/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs b/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs new file mode 100644 index 000000000..d7975a395 --- /dev/null +++ b/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs @@ -0,0 +1,115 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Primitives; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading.Tasks; + +public class TimeZoneAdjustmentMiddleware +{ + private readonly RequestDelegate _next; + + public TimeZoneAdjustmentMiddleware(RequestDelegate next) + { + _next = next; + } + + public async Task Invoke(HttpContext context) + { + if (string.IsNullOrEmpty(context.Request.ContentType)) + { + // 请求没有内容体,可能是一个没有请求体的请求,比如 GET 请求 + await _next(context); + return; + } + + + var timeZoneId = "Asia/Shanghai"; // 客户端默认时区 + + var timeZoneIdHeaderValue = context.Request.Headers["TimeZoneId"]; + + if (!string.IsNullOrEmpty(timeZoneIdHeaderValue)) + { + timeZoneId = timeZoneIdHeaderValue; + } + + var timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); + + + + // 处理 JSON 请求体中的时间字段 + if (context.Request.ContentType.StartsWith("application/json")) + { + var requestBody = await new StreamReader(context.Request.Body).ReadToEndAsync(); + + // 使用 JSON.NET 或 System.Text.Json 解析 JSON 请求体 + // 假设请求体中有一个名为 "dateTime" 的时间字段 + dynamic jsonData = JsonConvert.DeserializeObject(requestBody); + + if (jsonData.dateTime != null) + { + if (DateTime.TryParse((string)jsonData.dateTime, out DateTime dateTime)) + { + // 将 JSON 请求体中的时间字段转换为服务器时区的时间 + var serverTime = TimeZoneInfo.ConvertTime(dateTime, timeZone); + jsonData.dateTime = serverTime; + } + } + + // 将修改后的 JSON 请求体重新写入请求流中 + var jsonBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(jsonData)); + context.Request.Body = new MemoryStream(jsonBytes); + context.Request.ContentLength = jsonBytes.Length; + } + + + // 处理 URL 表单参数 + var modifiedQuery = new Dictionary(); + + foreach (var key in context.Request.Query.Keys) + { + if (DateTime.TryParse(context.Request.Query[key], out DateTime dateTime)) + { + // 将 URL 表单参数中的时间转换为服务器时区的时间 + var serverTime = TimeZoneInfo.ConvertTime(dateTime, timeZone); + modifiedQuery[key] = new StringValues(serverTime.ToString()); + } + else + { + modifiedQuery[key] = context.Request.Query[key]; + } + } + + context.Request.Query = new QueryCollection(modifiedQuery); + + // 处理Form请求体中的参数 + if (context.Request.HasFormContentType) + { + var modifiedForm = new Dictionary(); + + foreach (var key in context.Request.Form.Keys) + { + if (DateTime.TryParse(context.Request.Form[key], out DateTime dateTime)) + { + // 将请求体中的时间转换为服务器时区的时间 + var serverTime = TimeZoneInfo.ConvertTime(dateTime, timeZone); + modifiedForm[key] = new StringValues(serverTime.ToString()); + } + else + { + modifiedForm[key] = context.Request.Form[key]; + } + } + + var newFormCollection = new FormCollection(modifiedForm); + + // 将新的表单集合设置回请求对象 + context.Request.Form = newFormCollection; + } + + await _next(context); + } + +} diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONCustomDateConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONCustomDateConverter.cs index 388f7053a..0bb4eb356 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONCustomDateConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONCustomDateConverter.cs @@ -1,69 +1,87 @@ using IRaCIS.Core.Domain.Share; +using Microsoft.AspNetCore.Http; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using StackExchange.Redis; using System; +using System.Globalization; namespace IRaCIS.Core.API { + /// + /// 废弃,没用,不用这种处理方式 + /// public class JSONCustomDateConverter : DateTimeConverterBase { - private TimeZoneInfo _timeZoneInfo; - private string _dateFormat; + private readonly IHttpContextAccessor _httpContextAccessor; - private IUserInfo _userInfo; - public JSONCustomDateConverter(string dateFormat, TimeZoneInfo timeZoneInfo, IUserInfo userInfo) + private readonly string timeZoneId; + + private readonly TimeZoneInfo _clientTimeZone; + public JSONCustomDateConverter(IHttpContextAccessor httpContextAccessor) { - _dateFormat = dateFormat; - _timeZoneInfo = timeZoneInfo; + _httpContextAccessor = httpContextAccessor; + + //默认是UTC + //var timeZoneId = "Etc/UTC"; + var timeZoneId = "Asia/Shanghai"; + + var timeZoneIdHeader = _httpContextAccessor?.HttpContext?.Request?.Headers["TimeZoneId"]; + + if (timeZoneIdHeader is not null && !string.IsNullOrEmpty(timeZoneIdHeader.Value)) + { + timeZoneId = timeZoneIdHeader.Value; + } + + _clientTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); - _userInfo = userInfo; } - private static readonly TimeZoneInfo ChinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Asia/Shanghai"); + private static readonly TimeZoneInfo ChinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Etc/UTC"); + + public override bool CanConvert(Type objectType) + { + // 仅支持 DateTime 类型的转换 + return objectType == typeof(DateTime)|| objectType == typeof(DateTime?); + } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - - - if (reader.ValueType == typeof(DateTime)) - { - DateTime dateTime = (DateTime)reader.Value; - - var zoneTime = TimeZoneInfo.ConvertTime(dateTime, ChinaTimeZone); - - return zoneTime; - } + if (reader.Value == null) + return null; else { - return reader.Value; - } + var dateTime = (DateTime)reader.Value; + // 将客户端时间转换为服务器时区的时间 + var serverZoneTime = TimeZoneInfo.ConvertTime(dateTime, _clientTimeZone, TimeZoneInfo.Local); + + return serverZoneTime; + } + + // 在反序列化时,我们不需要此转换器,因此不实现此方法 + //throw new NotImplementedException(); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - var timeZoneId = _userInfo.TimeZoneId; - //var needConvertUtcDateTime = Convert.ToDateTime(value); + + - //var tz = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); + DateTime? nullableDateTime = value as DateTime?; - - //var dateTimeOffset = new DateTimeOffset(needConvertUtcDateTime); - - //var time = TimeZoneInfo.ConvertTimeFromUtc(needConvertUtcDateTime, tz).ToString(_dateFormat); - - //writer.WriteValue(time); - //writer.Flush(); - - - if (value is DateTime dateTime) + if (nullableDateTime != null && nullableDateTime.HasValue) { - DateTime chinaTime = TimeZoneInfo.ConvertTime(dateTime, ChinaTimeZone); + //第一个参数默认使用系统本地时区 也就是应用服务器的时区 + DateTime chinaTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, _clientTimeZone); writer.WriteValue(chinaTime); } - + else + { + writer.WriteNull(); + } } } diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs index df8aad91f..0ffcf0384 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs @@ -10,7 +10,8 @@ namespace IRaCIS.Core.API { public static void AddNewtonsoftJsonSetup(this IMvcBuilder builder, IServiceCollection services) { - services.AddScoped(); + services.AddHttpContextAccessor(); + services.AddScoped(); builder.AddNewtonsoftJson(options => { @@ -24,8 +25,10 @@ namespace IRaCIS.Core.API // 设置时间格式 options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; + //options.SerializerSettings.Converters.Add(new JSONCustomDateConverter()) ; - //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/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index f24d6bad2..6ccb8d139 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -3,6 +3,7 @@ using DocumentFormat.OpenXml.Presentation; using DocumentFormat.OpenXml.Spreadsheet; using IRaCIS.Application.Contracts; using IRaCIS.Application.Interfaces; +using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson; using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Contracts.DTO; using IRaCIS.Core.Application.Service.Reading.Dto; @@ -59,7 +60,7 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == param.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = await _trialUseRepository.Where(t => t.TrialId == param.TrialId).IgnoreQueryFilters() + var list = await _trialUseRepository.Where(t => t.TrialId == param.TrialId).IgnoreQueryFilters() .WhereIf(param.UserTypeId != null, t => t.User.UserTypeId == param.UserTypeId) .WhereIf(!string.IsNullOrWhiteSpace(param.UserName), t => t.User.UserName.Contains(param.UserName)) @@ -70,8 +71,10 @@ namespace IRaCIS.Core.Application.Service.Common t => (t.User.FullName).Contains(param.UserRealName)) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialUserList_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(TrialMaintenanceDTO)); @@ -90,7 +93,7 @@ namespace IRaCIS.Core.Application.Service.Common [HttpPost] [AllowAnonymous] public async Task TrialSiteUserListExport(SiteCRCExportQueryDTO param, - [FromServices] IRepository _commonDocumentRepository, + [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _trialRepository, [FromServices] IRepository _trialSiteUserRepository @@ -100,21 +103,26 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == param.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = await _trialSiteUserRepository.Where(t => t.TrialId == param.TrialId).IgnoreQueryFilters() - .WhereIf(param.IsDeleted != null, t => t.IsDeleted == param.IsDeleted) - .WhereIf(!string.IsNullOrWhiteSpace(param.SiteName), t => t.Site.SiteName.Contains(param.SiteName)) - .WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteAliasName), - t => t.TrialSite.TrialSiteAliasName.Contains(param.TrialSiteAliasName)) - .WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteCode), - t => t.TrialSite.TrialSiteCode.Contains(param.TrialSiteCode)) - .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator, - t => t.UserId == _userInfo.Id) - .WhereIf(!string.IsNullOrWhiteSpace(param.UserKeyInfo), t => (t.User.FullName).Contains(param.UserKeyInfo) - || t.User.UserName.Contains(param.UserKeyInfo) || t.User.EMail.Contains(param.UserKeyInfo)) + var list = await _trialSiteUserRepository.Where(t => t.TrialId == param.TrialId).IgnoreQueryFilters() + .WhereIf(param.IsDeleted != null, t => t.IsDeleted == param.IsDeleted) + .WhereIf(!string.IsNullOrWhiteSpace(param.SiteName), t => t.Site.SiteName.Contains(param.SiteName)) + .WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteAliasName), + t => t.TrialSite.TrialSiteAliasName.Contains(param.TrialSiteAliasName)) + .WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteCode), + t => t.TrialSite.TrialSiteCode.Contains(param.TrialSiteCode)) + .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator, + t => t.UserId == _userInfo.Id) + .WhereIf(!string.IsNullOrWhiteSpace(param.UserKeyInfo), t => (t.User.FullName).Contains(param.UserKeyInfo) + || t.User.UserName.Contains(param.UserKeyInfo) || t.User.EMail.Contains(param.UserKeyInfo)) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; + + + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSiteUserList_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SiteUserExportDTO)); } @@ -161,13 +169,14 @@ namespace IRaCIS.Core.Application.Service.Common .WhereIf(!string.IsNullOrEmpty(queryParam.OrganizationName), t => t.OrganizationName.Contains(queryParam.OrganizationName)) .ProjectTo(_mapper.ConfigurationProvider); - data.List = await query.ToListAsync(); - - + var list = await query.ToListAsync(); + data.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); var exportInfo = data; exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSiteUserSummary_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(TrialSiteUserSummaryDto)); } @@ -230,8 +239,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == visitSearchDTO.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialCRCUploadImageList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CRCVisitExportDTO)); @@ -280,8 +290,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == challengeQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialQCImageChanllengeList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(QCChanllengeExportDto)); } @@ -317,8 +328,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == param.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSubjectList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SubjectExportDTO)); @@ -425,8 +437,9 @@ namespace IRaCIS.Core.Application.Service.Common exportInfo.CriterionName = await _repository.Where(u => u.TrialId == dto.TrialId && u.IsConfirm && u.Id == dto.TrialReadingCriterionId).Select(t => t.CriterionName).FirstOrDefaultAsync(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(StaticData.Export.TrialSubjectProgressList_Export, exportInfo, /*"", */_commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SubjectProgressDto)); @@ -491,7 +504,7 @@ namespace IRaCIS.Core.Application.Service.Common } var memoryStream2 = new MemoryStream(); - wb.Write(memoryStream2,true); + wb.Write(memoryStream2, true); memoryStream2.Seek(0, SeekOrigin.Begin); return new FileStreamResult(memoryStream2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @@ -565,8 +578,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == studyQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialStudyUploadMonitor_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(UnionStudyMonitorExportDto)); @@ -601,8 +615,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == param.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSubjectReadingPeriodList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(ReadPeriodExportDto)); @@ -690,8 +705,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == studyQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialStudyList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(UnionStudyExportDTO)); } @@ -729,8 +745,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == checkQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSubjectVisitCheckList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(PMKCheckEXportDTO)); } @@ -780,8 +797,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialReadingTaskList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(ReadingTaskExportDto)); } @@ -831,8 +849,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialReReadingTaskList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(ReReadingTaskExportDto)); } @@ -873,8 +892,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialMedicalReviewList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(TaskMedicalReviewExportDto)); } @@ -957,8 +977,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.CriterionName = await _repository.Where(u => u.TrialId == queryVisitTask.TrialId && u.IsConfirm && u.Id == queryVisitTask.TrialReadingCriterionId).Select(t => t.CriterionName).FirstOrDefaultAsync(); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSelfAnalysisList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SelftAnalysisExport)); } @@ -1060,8 +1081,9 @@ namespace IRaCIS.Core.Application.Service.Common var exportInfo = (await _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.CriterionName = await _repository.Where(u => u.TrialId == queryVisitTask.TrialId && u.IsConfirm && u.Id == queryVisitTask.TrialReadingCriterionId).Select(t => t.CriterionName).FirstOrDefaultAsync(); - exportInfo.List = newList; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(newList, _userInfo.TimeZoneId); ; exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialGroupAnalysisList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(GroupAnalysisExport)); } @@ -1145,7 +1167,7 @@ namespace IRaCIS.Core.Application.Service.Common { foreach (var item in resultList) { - item.IsGenerateJudge = list.Where(t => t.ReadingCategory == ReadingCategory.Judge && t.SubjectCode == item.SubjectCode && t.VisitTaskNum>item.VisitTaskNum + item.IsGenerateJudge = list.Where(t => t.ReadingCategory == ReadingCategory.Judge && t.SubjectCode == item.SubjectCode && t.VisitTaskNum > item.VisitTaskNum ).OrderByDescending(t => t.VisitTaskNum).FirstOrDefault()?.JudgeArmEnum == item.ArmEnum ? true : false; } } @@ -1213,8 +1235,9 @@ namespace IRaCIS.Core.Application.Service.Common //处理裁判标记 list = DealJudgeMark(criterion.ArbitrationRule, list); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.OverallTumorEvaluation_Export, exportInfo, $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(OverallTumorEvaluationExport), criterion.CriterionType); @@ -1272,8 +1295,9 @@ namespace IRaCIS.Core.Application.Service.Common //处理裁判标记 list = DealJudgeMark(criterion.ArbitrationRule, list); - exportInfo.List = list; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.RECIST1Point1EvaluationOfTumorEfficacy_Export, exportInfo, $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(RECIST1Point1EvaluationOfTumorEfficacyExport), criterion.CriterionType); @@ -1305,7 +1329,7 @@ namespace IRaCIS.Core.Application.Service.Common { //每次查询必须是单标准的 - var criterion = await _repository.Where(t => t.Id == queryVisitTask.TrialReadingCriterionId).Select(t => new { t.CriterionType, t.CriterionName,t.ArbitrationRule }).FirstOrDefaultAsync(); + var criterion = await _repository.Where(t => t.Id == queryVisitTask.TrialReadingCriterionId).Select(t => new { t.CriterionType, t.CriterionName, t.ArbitrationRule }).FirstOrDefaultAsync(); var query = _repository.Where(t => t.TrialId == queryVisitTask.TrialId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && t.ReadingTaskState == ReadingTaskState.HaveSigned) @@ -1363,8 +1387,9 @@ namespace IRaCIS.Core.Application.Service.Common //处理裁判标记 list = DealJudgeMark(criterion.ArbitrationRule, list); - exportInfo.List = exportList; + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(exportList, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.RECIST1Point1DetailedOfEvaluatedLesion_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(RECIST1Point1DetailedOfEvaluatedLesionExport), criterion.CriterionType); @@ -1396,8 +1421,10 @@ namespace IRaCIS.Core.Application.Service.Common //处理裁判标记 list = DealJudgeMark(criterion.ArbitrationRule, list); - exportInfo.List = exportList; + + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(exportList, _userInfo.TimeZoneId); ; exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; return await ExcelExportHelper.DataExportAsync(StaticData.Export.PCWG3Point1DetailedOfEvaluatedLesion_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(PCWG3DetailedOfEvaluatedLesionExport), criterion.CriterionType); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs index 6e0e3fe84..c403bbce3 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs @@ -6,6 +6,7 @@ using MiniExcelLibs.Attributes; using Newtonsoft.Json; using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Helper; +using System; namespace IRaCIS.Application.Contracts { @@ -119,10 +120,11 @@ namespace IRaCIS.Application.Contracts public class ExcelExportInfo : TrialSelectDTO { - public string CurrentTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + public string CurrentTime => TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById(ClientZoneId)).ToString("yyyy-MM-dd HH:mm:ss"); public bool IsEn_US { get; set; } + public string ClientZoneId { get; set; } = string.Empty; public object List { get; set; } } diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs index 45e0ab3ec..61521c667 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs +++ b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs @@ -278,8 +278,8 @@ namespace IRaCIS.Core.Domain.Share return timeZoneId.Value; } - return "Etc/UTC"; - //return "Asia/Shanghai"; + //return "Etc/UTC"; + return "Asia/Shanghai"; } diff --git a/IRaCIS.Core.Infrastructure/Extention/ConvertToClientTimeResultFilter.cs b/IRaCIS.Core.Infrastructure/Extention/ConvertToClientTimeResultFilter.cs new file mode 100644 index 000000000..5126ae86f --- /dev/null +++ b/IRaCIS.Core.Infrastructure/Extention/ConvertToClientTimeResultFilter.cs @@ -0,0 +1,60 @@ +//using Microsoft.AspNetCore.Mvc.Filters; +//using Microsoft.AspNetCore.Mvc; +//using Newtonsoft.Json; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; +//using System.Text.RegularExpressions; + +//namespace IRaCIS.Core.Application.BusinessFilter +//{ +// public class ConvertToClientTimeResultFilter : IAsyncResultFilter +// { + + +// public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) +// { + +// //JsonConvert.DeserializeObject(jsonStr, new JsonSerializerSettings +// //{ +// // DateTimeZoneHandling = DateTimeZoneHandling.Local +// //}); + +// if (context.Result is ObjectResult objectResult) +// { +// var statusCode = objectResult.StatusCode ?? context.HttpContext.Response.StatusCode; + +// if (statusCode == 200) +// { +// var result = objectResult.Value; + +// // 将数据中的 DateTime 值转换为 DateTimeOffset,指定时区为东八区 +// ConvertDateTimeToDateTimeOffset(result); + +// // 使用 Newtonsoft.Json 序列化转换后的数据 +// string json = JsonConvert.SerializeObject(result); + +// // 重新设置 JsonResult 的值为处理后的数据 +// context.Result = new JsonResult(json); + +// } +// } + + +// // 执行动作方法 +// await next(); +// } + +// private void ConvertDateTimeToDateTimeOffset(object data) +// { +// // 假设客户端时区为东八区 +// TimeZoneInfo clientTimeZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"); + +// // 将对象中的 DateTime 值转换为 DateTimeOffset,指定时区为东八区 +// string json = JsonConvert.SerializeObject(data); +// data = json.Replace("\"DateTime\":", "\"DateTimeOffset\":"); +// } +// } +//} diff --git a/IRaCIS.Core.Infrastructure/Extention/ExportExcelDateConverter.cs b/IRaCIS.Core.Infrastructure/Extention/ExportExcelDateConverter.cs new file mode 100644 index 000000000..434152ca4 --- /dev/null +++ b/IRaCIS.Core.Infrastructure/Extention/ExportExcelDateConverter.cs @@ -0,0 +1,83 @@ +using Newtonsoft.Json.Converters; +using Newtonsoft.Json; +using System; +using SharpCompress.Writers; + +namespace IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson +{ + + + public class ExportExcelDateConverter : DateTimeConverterBase + { + private readonly TimeZoneInfo _clientTimeZone; + + public ExportExcelDateConverter(TimeZoneInfo clientTimeZone) + { + _clientTimeZone = clientTimeZone; + } + public override bool CanConvert(Type objectType) + { + + return objectType == typeof(DateTime) || objectType == typeof(DateTime?); + } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + DateTime? nullableDateTime = value as DateTime?; + + if (nullableDateTime != null && nullableDateTime.HasValue) + { + // 将服务器时间转换为客户端时间 + DateTime clientTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, TimeZoneInfo.Local, _clientTimeZone); + writer.WriteValue(clientTime); + } + else + { + writer.WriteNull(); + } + + + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + DateTime? nullableDateTime = reader.Value as DateTime?; + + if (nullableDateTime != null && nullableDateTime.HasValue) + + { // 服务器时区的时间转为客户端时间 + var clientZoneTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, TimeZoneInfo.Local, _clientTimeZone); + + return clientZoneTime; + } + return reader.Value; + + + } + + + } + public class ExportExcelConverterDate + { + public static T ConvertToClientTimeInObject(T obj, string timeZoneId) + { + var clientTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); + if (obj == null) + return obj; + + // 将对象序列化为 JSON 字符串 + string json = JsonConvert.SerializeObject(obj); + + // 将 JSON 字符串反序列化回对象 + var deserializedObj = JsonConvert.DeserializeObject(json, new JsonSerializerSettings + { + Converters = { new ExportExcelDateConverter(clientTimeZone) } + }); + + return deserializedObj!; + } + } +} + + + + From a5899023b90a933e2a5a422e367be4534a0b6f60 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 21 Feb 2024 14:33:38 +0800 Subject: [PATCH 2/9] =?UTF-8?q?[=E6=97=B6=E5=8C=BA=E4=BF=AE=E6=94=B9-?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8D=E7=A7=B0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimeZoneAdjustmentMiddleware.cs | 3 +++ ...eConverter.cs => JSONTimeZoneConverter.cs} | 21 ++++++------------- .../NewtonsoftJson/NewtonsoftJsonSetup.cs | 4 ++-- 3 files changed, 11 insertions(+), 17 deletions(-) rename IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/{JSONCustomDateConverter.cs => JSONTimeZoneConverter.cs} (81%) diff --git a/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs b/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs index d7975a395..c3c71da2a 100644 --- a/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs +++ b/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs @@ -7,6 +7,9 @@ using System.IO; using System.Text; using System.Threading.Tasks; +/// +/// 废弃,没用 +/// public class TimeZoneAdjustmentMiddleware { private readonly RequestDelegate _next; diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONCustomDateConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs similarity index 81% rename from IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONCustomDateConverter.cs rename to IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index 0bb4eb356..75c5525ab 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONCustomDateConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -9,16 +9,14 @@ using System.Globalization; namespace IRaCIS.Core.API { /// - /// 废弃,没用,不用这种处理方式 + /// 序列化,反序列化的时候,处理时间 时区转换 /// - public class JSONCustomDateConverter : DateTimeConverterBase + public class JSONTimeZoneConverter : DateTimeConverterBase { private readonly IHttpContextAccessor _httpContextAccessor; - private readonly string timeZoneId; - private readonly TimeZoneInfo _clientTimeZone; - public JSONCustomDateConverter(IHttpContextAccessor httpContextAccessor) + public JSONTimeZoneConverter(IHttpContextAccessor httpContextAccessor) { _httpContextAccessor = httpContextAccessor; @@ -37,8 +35,6 @@ namespace IRaCIS.Core.API } - private static readonly TimeZoneInfo ChinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Etc/UTC"); - public override bool CanConvert(Type objectType) { // 仅支持 DateTime 类型的转换 @@ -64,19 +60,14 @@ namespace IRaCIS.Core.API } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - - - - - + { DateTime? nullableDateTime = value as DateTime?; if (nullableDateTime != null && nullableDateTime.HasValue) { //第一个参数默认使用系统本地时区 也就是应用服务器的时区 - DateTime chinaTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, _clientTimeZone); - writer.WriteValue(chinaTime); + DateTime clientZoneTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, _clientTimeZone); + writer.WriteValue(clientZoneTime); } else { diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs index 0ffcf0384..853afe9d3 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs @@ -11,7 +11,7 @@ namespace IRaCIS.Core.API public static void AddNewtonsoftJsonSetup(this IMvcBuilder builder, IServiceCollection services) { services.AddHttpContextAccessor(); - services.AddScoped(); + services.AddScoped(); builder.AddNewtonsoftJson(options => { @@ -28,7 +28,7 @@ namespace IRaCIS.Core.API options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; //options.SerializerSettings.Converters.Add(new JSONCustomDateConverter()) ; - options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); + options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); //IsoDateTimeConverter //options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; From cef07a5bff3e43b65356b0b35e88270d821f2810 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 21 Feb 2024 15:28:08 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E3=80=90=E6=97=B6=E5=8C=BA=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B93=20=20=E5=89=8D=E7=AB=AF=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E2=80=9C=E2=80=9D=20=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewtonsoftJson/JSONTimeZoneConverter.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index 75c5525ab..af0b905b6 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -43,20 +43,22 @@ namespace IRaCIS.Core.API public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if (reader.Value == null) - return null; - else + 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; } - - // 在反序列化时,我们不需要此转换器,因此不实现此方法 - //throw new NotImplementedException(); + else + { + return null; + } + } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) From 110ea953c49e3a1eaf2b459af082245d13fe182c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 21 Feb 2024 16:01:34 +0800 Subject: [PATCH 4/9] =?UTF-8?q?[=E5=9B=BD=E9=99=85=E5=8C=96-=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E4=B9=9F=E4=BD=BF=E7=94=A8code=EF=BC=8C=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E6=A0=87=E8=AF=86]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UploadDownLoadController.cs | 1 - .../Service/Common/InternationalizationService.cs | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index 711c0940d..68ecb45ec 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -585,7 +585,6 @@ namespace IRaCIS.Core.API.Controllers var etcCheckList = new List(); - #region MiniExcel 需要自己验证数据格式规范 //if (fileName.EndsWith(".csv")) diff --git a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs index ab310ac26..4a0b29158 100644 --- a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs +++ b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs @@ -164,17 +164,17 @@ namespace IRaCIS.Core.Application.Service VerifyExp = t => t.Code == addOrEditInternationalization.Code && t.InternationalizationType == addOrEditInternationalization.InternationalizationType, VerifyMsg = $"该类型已有{addOrEditInternationalization.Code}名称的国际化标识", - IsVerify = internationalizationType == 1 + IsVerify = true /*internationalizationType == 1*/ }; //前端验证标识重复与否 - var verifyExp2 = new EntityVerifyExp() - { - VerifyExp = t => t.Code == addOrEditInternationalization.Code && t.InternationalizationType == addOrEditInternationalization.InternationalizationType && t.Description == addOrEditInternationalization.Description, + //var verifyExp2 = new EntityVerifyExp() + //{ + // VerifyExp = t => t.Code == addOrEditInternationalization.Code && t.InternationalizationType == addOrEditInternationalization.InternationalizationType && t.Description == addOrEditInternationalization.Description, - VerifyMsg = $"该类型已有{addOrEditInternationalization.Description}下的{addOrEditInternationalization.Code}名称的国际化标识", - IsVerify = internationalizationType == 0 - }; + // VerifyMsg = $"该类型已有{addOrEditInternationalization.Description}下的{addOrEditInternationalization.Code}名称的国际化标识", + // IsVerify = internationalizationType == 0 + //}; var entity = await _internationalizationRepository.InsertOrUpdateAsync(addOrEditInternationalization, true, verifyExp1, verifyExp2); From 67f8e57ab64e64e692ac2ab475df16027c6de50b Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 22 Feb 2024 09:56:18 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.xml | 9 +++++++-- .../Service/Common/InternationalizationService.cs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index cc66c1c02..9f901627f 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -365,9 +365,9 @@ IPLimit限流 启动服务 - + - 废弃,没用,不用这种处理方式 + 序列化,反序列化的时候,处理时间 时区转换 @@ -385,6 +385,11 @@ + + + 废弃,没用 + + 对称可逆加密 diff --git a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs index 4a0b29158..fae26204d 100644 --- a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs +++ b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs @@ -176,7 +176,7 @@ namespace IRaCIS.Core.Application.Service // IsVerify = internationalizationType == 0 //}; - var entity = await _internationalizationRepository.InsertOrUpdateAsync(addOrEditInternationalization, true, verifyExp1, verifyExp2); + var entity = await _internationalizationRepository.InsertOrUpdateAsync(addOrEditInternationalization, true, verifyExp1/*, verifyExp2*/); if (addOrEditInternationalization.InternationalizationType == 1) { From 9c26745c2a01dcbc428cf321e75ee2fe18e5b537 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 22 Feb 2024 13:28:57 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=20=E5=85=B3=E9=97=AD=20=E6=97=B6=E5=8C=BA?= =?UTF-8?q?=20=E5=8F=91=E5=B8=83aws?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs index 853afe9d3..96383d8c4 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/NewtonsoftJsonSetup.cs @@ -28,7 +28,8 @@ namespace IRaCIS.Core.API options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; //options.SerializerSettings.Converters.Add(new JSONCustomDateConverter()) ; - options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); + + //options.SerializerSettings.Converters.Add(services.BuildServiceProvider().GetService()); //IsoDateTimeConverter //options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; From b7d9009ff40429f9ae14bb539760df1e98dfb294 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 22 Feb 2024 14:02:51 +0800 Subject: [PATCH 7/9] =?UTF-8?q?[=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81?= =?UTF-8?q?=EF=BC=8C=E9=85=8D=E7=BD=AE=E5=8A=A8=E6=80=81=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E5=90=8D=E7=A7=B0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/Progranm.cs | 2 +- IRaCIS.Core.API/appsettings.Prod_IRC.json | 4 ++- IRaCIS.Core.API/appsettings.Test_IRC.json | 4 ++- IRaCIS.Core.API/appsettings.US_IRC.json | 4 ++- IRaCIS.Core.API/appsettings.Uat_IRC.json | 4 ++- .../Service/Common/MailService.cs | 25 ++++++++++++------- IRaCIS.Core.Domain/_Config/_AppSettings.cs | 4 +++ 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/IRaCIS.Core.API/Progranm.cs b/IRaCIS.Core.API/Progranm.cs index fbbab47e5..fc92f97ee 100644 --- a/IRaCIS.Core.API/Progranm.cs +++ b/IRaCIS.Core.API/Progranm.cs @@ -26,7 +26,7 @@ using IRaCIS.Application.Services.BackGroundJob; using LogDashboard; using OfficeOpenXml.Utils; - +Console.WriteLine("这是一个示例文本,示例文本中会出现示例多次。".Replace("示例", "替换")); #region 获取环境变量 //以配置文件为准,否则 从url中取环境值(服务以命令行传递参数启动,配置文件配置了就不需要传递环境参数) diff --git a/IRaCIS.Core.API/appsettings.Prod_IRC.json b/IRaCIS.Core.API/appsettings.Prod_IRC.json index e811769da..d727b4e79 100644 --- a/IRaCIS.Core.API/appsettings.Prod_IRC.json +++ b/IRaCIS.Core.API/appsettings.Prod_IRC.json @@ -51,6 +51,8 @@ "FromEmail": "IRC@extimaging.com", "FromName": "IRC", "AuthorizationCode": "ExtImg@2022", - "SiteUrl": "http://irc.extimaging.com/login" + "SiteUrl": "http://irc.extimaging.com/login", + "CompanyName": "Extensive Imaging", + "CompanyNameCN": "上海展影医疗科技有限公司" } } diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index 6b46f8159..251a33369 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -69,7 +69,9 @@ "FromName": "Test_IRC", "AuthorizationCode": "SHzyyl2021", - "SiteUrl": "http://irc.test.extimaging.com/login" + "SiteUrl": "http://irc.test.extimaging.com/login", + "CompanyName": "Extensive Imaging", + "CompanyNameCN": "上海展影医疗科技有限公司" } } diff --git a/IRaCIS.Core.API/appsettings.US_IRC.json b/IRaCIS.Core.API/appsettings.US_IRC.json index e04b507e6..834a44da2 100644 --- a/IRaCIS.Core.API/appsettings.US_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_IRC.json @@ -68,7 +68,9 @@ "Host": "smtp.qiye.aliyun.com", "FromEmail": "test@extimaging.com", "FromName": "Test_IRC", - "AuthorizationCode": "SHzyyl2021" + "AuthorizationCode": "SHzyyl2021", + "CompanyName": "Extensive Imaging", + "CompanyNameCN": "上海展影医疗科技有限公司" } } diff --git a/IRaCIS.Core.API/appsettings.Uat_IRC.json b/IRaCIS.Core.API/appsettings.Uat_IRC.json index 4bd7f8248..2ee6cf6bf 100644 --- a/IRaCIS.Core.API/appsettings.Uat_IRC.json +++ b/IRaCIS.Core.API/appsettings.Uat_IRC.json @@ -53,7 +53,9 @@ "FromEmail": "uat@extimaging.com", "FromName": "UAT_IRC", "AuthorizationCode": "SHzyyl2021", - "SiteUrl": "http://irc.uat.extimaging.com/login" + "SiteUrl": "http://irc.uat.extimaging.com/login", + "CompanyName": "Extensive Imaging", + "CompanyNameCN": "上海展影医疗科技有限公司" } diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 7a785f1b7..752d2e666 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -8,6 +8,7 @@ using AutoMapper; using IRaCIS.Application.Contracts; using Microsoft.Extensions.Options; using Medallion.Threading; +using System.Text.RegularExpressions; namespace IRaCIS.Application.Services { @@ -82,6 +83,12 @@ namespace IRaCIS.Application.Services _distributedLockProvider = distributedLockProvider; } + + private string ReplaceCompanyName(string needDealtxt) + { + return needDealtxt.Replace("{*}", _userInfo.IsEn_Us ? _systemEmailConfig.CompanyName : _systemEmailConfig.CompanyNameCN); + } + //重置邮箱 public async Task SendMailEditEmail(Guid userId, string userName, string emailAddress, int verificationCode) { @@ -112,7 +119,7 @@ namespace IRaCIS.Application.Services var templateInfo = SourceReader.ReadToEnd(); - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), //---尊敬的 _localizer["Mail_Dear", userName], @@ -179,7 +186,7 @@ namespace IRaCIS.Application.Services var templateInfo = SourceReader.ReadToEnd(); - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), "", //---您正在进行邮箱重置密码操作 _localizer["Mail_ResettingPassword"], @@ -247,7 +254,7 @@ namespace IRaCIS.Application.Services var templateInfo = SourceReader.ReadToEnd(); - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), "", //---您正在参与展影医疗IRC项目 _localizer["Mail_IRCProject"], @@ -314,7 +321,7 @@ namespace IRaCIS.Application.Services var templateInfo = SourceReader.ReadToEnd(); - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), "", //---您正在参与展影医疗IRC项目中心调研工作 _localizer["Mail_CenterResearchReminder"], @@ -403,7 +410,7 @@ namespace IRaCIS.Application.Services var templateInfo = SourceReader.ReadToEnd(); - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), sysUserInfo.FullName, sysUserInfo.UserName, sysUserInfo.UserTypeRole.UserTypeShortName, @@ -450,7 +457,7 @@ namespace IRaCIS.Application.Services var templateInfo = SourceReader.ReadToEnd(); - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), sysUserInfo.FullName, sysUserInfo.UserName, sysUserInfo.UserTypeRole.UserTypeShortName, @@ -512,7 +519,7 @@ namespace IRaCIS.Application.Services var redirectUrl = $"{domain}/api/User/UserRedirect?url={System.Web.HttpUtility.UrlEncode(routeUrl)}"; - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), sysUserInfo.FullName, trialInfo.ExperimentName, trialInfo.ResearchProgramNo, @@ -574,7 +581,7 @@ namespace IRaCIS.Application.Services var redirectUrl = $"{domain}/api/User/UserRedirect?url={System.Web.HttpUtility.UrlEncode(routeUrl)}"; - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), sysUserInfo.FullName, trialInfo.ExperimentName, trialInfo.ResearchProgramNo, @@ -696,7 +703,7 @@ namespace IRaCIS.Application.Services var redirectUrl = $"{domain}/api/User/UserRedirect?url={System.Web.HttpUtility.UrlEncode(routeUrl)}"; - builder.HtmlBody = string.Format(templateInfo, + builder.HtmlBody = string.Format(ReplaceCompanyName(templateInfo), sysUserInfo.FullName, trialInfo.ExperimentName, trialInfo.ResearchProgramNo, diff --git a/IRaCIS.Core.Domain/_Config/_AppSettings.cs b/IRaCIS.Core.Domain/_Config/_AppSettings.cs index 698f8a10b..2008be937 100644 --- a/IRaCIS.Core.Domain/_Config/_AppSettings.cs +++ b/IRaCIS.Core.Domain/_Config/_AppSettings.cs @@ -37,6 +37,10 @@ namespace IRaCIS.Core.Domain.Share public string AuthorizationCode { get; set; } public string SiteUrl { get; set; } + + public string CompanyName { get; set; } + + public string CompanyNameCN { get; set; } } From b7585fe022a5cea436b0651d14bd8d7eb5e0cb33 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 22 Feb 2024 14:31:45 +0800 Subject: [PATCH 8/9] =?UTF-8?q?[=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF-=20=E6=9B=BF=E6=8D=A2=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/appsettings.Prod_IRC.json | 4 +++- IRaCIS.Core.API/appsettings.Test_IRC.json | 5 ++++- IRaCIS.Core.API/appsettings.US_IRC.json | 6 ++++-- IRaCIS.Core.API/appsettings.Uat_IRC.json | 4 +++- .../wwwroot/EmailTemplate/AdminAddUser.html | 6 +++--- .../wwwroot/EmailTemplate/AdminAddUser_US.html | 12 ++++++------ .../wwwroot/EmailTemplate/AdminResetUser.html | 4 ++-- .../wwwroot/EmailTemplate/AdminResetUser_US.html | 6 +++--- .../SubjectEnrollConfirmOrPDProgress.html | 2 +- .../SubjectEnrollConfirmOrPDProgress_US.html | 4 ++-- .../EmailTemplate/TrialDoctorExistJoin.html | 6 +++--- .../EmailTemplate/TrialDoctorExistJoin_US.html | 13 ++++++++----- .../EmailTemplate/TrialDoctorFirstJoin.html | 6 +++--- .../EmailTemplate/TrialDoctorFirstJoin_US.html | 14 +++++++------- .../EmailTemplate/TrialSiteSurveyReject.html | 4 ++-- .../EmailTemplate/TrialSiteSurveyReject_US.html | 4 ++-- .../wwwroot/EmailTemplate/TrialUserExistJoin.html | 6 +++--- .../EmailTemplate/TrialUserExistJoin_US.html | 13 ++++++++----- .../wwwroot/EmailTemplate/TrialUserFirstJoin.html | 6 +++--- .../EmailTemplate/TrialUserFirstJoin_US.html | 14 +++++++------- .../wwwroot/EmailTemplate/UserOptCommon.html | 4 ++-- .../wwwroot/EmailTemplate/UserOptCommon_US.html | 10 +++++----- .../Service/Common/MailService.cs | 3 ++- IRaCIS.Core.Domain/_Config/_AppSettings.cs | 6 ++++++ 24 files changed, 92 insertions(+), 70 deletions(-) diff --git a/IRaCIS.Core.API/appsettings.Prod_IRC.json b/IRaCIS.Core.API/appsettings.Prod_IRC.json index d727b4e79..11b9ff698 100644 --- a/IRaCIS.Core.API/appsettings.Prod_IRC.json +++ b/IRaCIS.Core.API/appsettings.Prod_IRC.json @@ -53,6 +53,8 @@ "AuthorizationCode": "ExtImg@2022", "SiteUrl": "http://irc.extimaging.com/login", "CompanyName": "Extensive Imaging", - "CompanyNameCN": "上海展影医疗科技有限公司" + "CompanyNameCN": "上海展影医疗科技有限公司", + "CompanyShortName": "Extensive Imaging", + "CompanyShortNameCN": "展影医疗" } } diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index 251a33369..c25e9e021 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -70,8 +70,11 @@ "AuthorizationCode": "SHzyyl2021", "SiteUrl": "http://irc.test.extimaging.com/login", + "CompanyName": "Extensive Imaging", - "CompanyNameCN": "上海展影医疗科技有限公司" + "CompanyNameCN": "上海展影医疗科技有限公司", + "CompanyShortName": "Extensive Imaging", + "CompanyShortNameCN": "展影医疗" } } diff --git a/IRaCIS.Core.API/appsettings.US_IRC.json b/IRaCIS.Core.API/appsettings.US_IRC.json index 834a44da2..654637a8c 100644 --- a/IRaCIS.Core.API/appsettings.US_IRC.json +++ b/IRaCIS.Core.API/appsettings.US_IRC.json @@ -69,8 +69,10 @@ "FromEmail": "test@extimaging.com", "FromName": "Test_IRC", "AuthorizationCode": "SHzyyl2021", - "CompanyName": "Extensive Imaging", - "CompanyNameCN": "上海展影医疗科技有限公司" + "CompanyName": "Elevate Imaging", + "CompanyNameCN": "上海展影医疗科技有限公司", + "CompanyShortName": "Elevate Imaging", + "CompanyShortNameCN": "展影医疗" } } diff --git a/IRaCIS.Core.API/appsettings.Uat_IRC.json b/IRaCIS.Core.API/appsettings.Uat_IRC.json index 2ee6cf6bf..aff99beba 100644 --- a/IRaCIS.Core.API/appsettings.Uat_IRC.json +++ b/IRaCIS.Core.API/appsettings.Uat_IRC.json @@ -55,7 +55,9 @@ "AuthorizationCode": "SHzyyl2021", "SiteUrl": "http://irc.uat.extimaging.com/login", "CompanyName": "Extensive Imaging", - "CompanyNameCN": "上海展影医疗科技有限公司" + "CompanyNameCN": "上海展影医疗科技有限公司", + "CompanyShortName": "Extensive Imaging", + "CompanyShortNameCN": "展影医疗" } diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser.html index 92d97da7b..9a6dc6f9d 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser.html @@ -11,7 +11,7 @@ 尊敬的 {0} ,您好:
- 展影医疗为您添加了账户,账户信息如下: + {company abbreviation}为您添加了账户,账户信息如下:
@@ -23,7 +23,7 @@
首次登陆前,请通过该链接修改您的账户信息: - + 初始化账号信息
@@ -32,7 +32,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser_US.html index cc724e76f..04453f355 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminAddUser_US.html @@ -11,20 +11,20 @@ Dear {0} ,
- Extimaging has added an account for you. The account information is as follows: + {company abbreviation} has created an account for you. The account information is as follows:
- User name: {1} + User ID: {1}
Role: {2}
@@ -32,7 +32,7 @@
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser.html index 3816a3a56..3354b1a34 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser.html @@ -11,7 +11,7 @@ 尊敬的 {0} ,您好:
- 展影医疗将您的账户密码已重置,账户信息如下: + {company abbreviation}将您的账户密码已重置,账户信息如下:
@@ -29,7 +29,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser_US.html index 7fae1aeeb..7d515cabb 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/AdminResetUser_US.html @@ -11,12 +11,12 @@ Dear {0} ,
- Extimaging has reset your account password, and the account information is as follows: + {company abbreviation} has reset your account password, and the account information is as follows:
- User name: {1} + User ID: {1}
Role: {2} @@ -29,7 +29,7 @@
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress.html index 227adf6d7..1becb5c55 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress.html @@ -19,7 +19,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress_US.html index 977a6ac01..e5d5f6b58 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/SubjectEnrollConfirmOrPDProgress_US.html @@ -11,7 +11,7 @@ Dear:
- Thank you for using Extensive Imaging Cloud System. + Thank you for using {company abbreviation} Cloud System.
{0}。 @@ -19,7 +19,7 @@
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin.html index 0f913d003..c56b85bc7 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin.html @@ -11,7 +11,7 @@ 尊敬的 {0} ,您好:
- 展影医疗作为 [{1} (试验方案号:{2 })] 项目的供应商,诚邀您参加该项目阅片相关工作。 + {company abbreviation}作为 [{1} (试验方案号:{2 })] 项目的供应商,诚邀您参加该项目阅片相关工作。
该项目采用电子化工作流,系统及您的账号信息如下: @@ -35,7 +35,7 @@
系统登录地址: - + 点击跳转
@@ -43,7 +43,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin_US.html index 2d8c51598..302210a88 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorExistJoin_US.html @@ -11,10 +11,10 @@ Dear {0},
- As the service provider of {1} trial(Protocol ID is {2}), Extensive Imaging invites you to participate in the independent assessment work of this trial. + {company abbreviation} invites you to participate in the IRC work of a trial ({1} , {2}).
- This project adopts electronic workflow. The system and your account information are as follows: + Your account information is as follows:
@@ -28,20 +28,23 @@ Study name: {1}
- User name: {4} + User ID: {4}
Role: {5}
- Login URL: {6} + Login URL: + + Click to login +
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin.html index f89d659b7..1ac10ce08 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin.html @@ -11,7 +11,7 @@ 尊敬的 {0} ,您好:
- 展影医疗作为 [{1} (试验方案号:{2 })] 项目的IRC供应商,诚邀您参加该项目IRC阅片相关工作,欢迎您提供指导和建议,非常感谢! + {company abbreviation}作为 [{1} (试验方案号:{2 })] 项目的IRC供应商,诚邀您参加该项目IRC阅片相关工作,欢迎您提供指导和建议,非常感谢!
该项目采用电子化工作流,系统及您的账号信息如下: @@ -35,7 +35,7 @@
首次登陆前,请通过该链接修改您的账户信息: - + 初始化账号信息
@@ -44,7 +44,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin_US.html index 5728072f0..16ffaaeb4 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialDoctorFirstJoin_US.html @@ -11,10 +11,10 @@ Dear {0},
- Hello, as the IRC supplier of [ {1} (Protocol ID is {2}) ] project,Extiming sincerely invites you to participate in the IRC related work of this project. Your guidance and suggestions are welcome. + {company abbreviation} invites you to participate in the IRC work of a trial ({1}, {2}).
- This project adopts electronic workflow. The system and your account information are as follows: + Your account information is as follows:
@@ -28,15 +28,15 @@ Study name: {1}
- User name: {4} + User ID: {4}
Role: {5}
@@ -44,7 +44,7 @@
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html index b04039562..70cf1bdec 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html @@ -11,7 +11,7 @@ 尊敬的 {0} ,您好:
- 您好, 您填写的中心调研表被驳回,详细信息如下: + 您填写的中心调研表被驳回,详细信息如下:
@@ -41,7 +41,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject_US.html index 1d716e828..077163e5f 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject_US.html @@ -11,7 +11,7 @@ Dear {0} ,
- Hello, the center survey form you filled in has been rejected. The details are as follows: + The site survey form you filled in has been rejected. The details are as follows:
@@ -41,7 +41,7 @@
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin.html index 96aab00aa..f3d816b3c 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin.html @@ -11,7 +11,7 @@ 尊敬的 {0} ,您好:
- 展影医疗作为 [{1} (试验方案号:{2 })] 项目的供应商,诚邀您参加该项目相关工作,欢迎您提供指导和建议,非常感谢! + {company abbreviation}作为 [{1} (试验方案号:{2 })] 项目的供应商,诚邀您参加该项目相关工作,欢迎您提供指导和建议,非常感谢!
该项目采用电子化工作流,系统及您的账号信息如下: @@ -35,7 +35,7 @@
系统登录地址: - + 点击跳转
@@ -44,7 +44,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin_US.html index b0df12ba0..519e9ab19 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserExistJoin_US.html @@ -11,10 +11,10 @@ Dear {0},
- As the service provider of {1} trial (Protocol ID is {2}), Extensive Imaging invites you to participate in related work of this trial. + {company abbreviation} invites you to participate in the IRC work of a trial ({1}, {2}).
- This project adopts electronic workflow. The system and your account information are as follows: + Your account information is as follows:
@@ -28,20 +28,23 @@ Study name: {1}
- User name: {4} + User ID: {4}
Role: {5}
- Login URL: {6} + Login URL: + + Click to login +
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin.html index 47be25687..3fa857aa3 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin.html @@ -11,7 +11,7 @@ 尊敬的 {0} ,您好:
- 展影医疗作为 [{1} (试验方案号:{2 })] 项目的IRC供应商,诚邀您参加该项目IRC相关工作,欢迎您提供指导和建议,非常感谢! + {company abbreviation}作为 [{1} (试验方案号:{2 })] 项目的IRC供应商,诚邀您参加该项目IRC相关工作,欢迎您提供指导和建议,非常感谢!
该项目采用电子化工作流,系统及您的账号信息如下: @@ -35,7 +35,7 @@
首次登陆前,请通过该链接修改您的账户信息: - + 初始化账号信息
@@ -44,7 +44,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin_US.html index 5728072f0..8bbd27dc5 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialUserFirstJoin_US.html @@ -11,10 +11,10 @@ Dear {0},
- Hello, as the IRC supplier of [ {1} (Protocol ID is {2}) ] project,Extiming sincerely invites you to participate in the IRC related work of this project. Your guidance and suggestions are welcome. + {company abbreviation} invites you to participate in the IRC work of a trial ({1}, {2}).
- This project adopts electronic workflow. The system and your account information are as follows: + Your account information is as follows:
@@ -28,15 +28,15 @@ Study name: {1}
- User name: {4} + User ID: {4}
Role: {5}
@@ -44,7 +44,7 @@
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html index 335aa4ca9..26ca6ecd3 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html @@ -8,7 +8,7 @@
- Hello {0}, + Dear {0},
感谢您使用展影云平台。 @@ -21,7 +21,7 @@
祝您顺利!
-
上海展影医疗科技有限公司
+
{company}
diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon_US.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon_US.html index 55f3fe6a6..2d4abdab8 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon_US.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon_US.html @@ -8,21 +8,21 @@
- Hello {0}, + Dear {0},
- Thank you for using Extensive Imaging’s cloud system! + {1}
- {1}, and the verification code is {2}. + The verification code is {2}.
- Please enter this verification code within 3 minutes for subsequent operations. + This code will expire in 3 minutes.
Best regards,
-
Extensive Imaging
+
{company}
diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 752d2e666..531be07e9 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -86,7 +86,8 @@ namespace IRaCIS.Application.Services private string ReplaceCompanyName(string needDealtxt) { - return needDealtxt.Replace("{*}", _userInfo.IsEn_Us ? _systemEmailConfig.CompanyName : _systemEmailConfig.CompanyNameCN); + return needDealtxt.Replace("{company}", _userInfo.IsEn_Us ? _systemEmailConfig.CompanyName : _systemEmailConfig.CompanyNameCN) + .Replace("{{company abbreviation}}", _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN); } //重置邮箱 diff --git a/IRaCIS.Core.Domain/_Config/_AppSettings.cs b/IRaCIS.Core.Domain/_Config/_AppSettings.cs index 2008be937..c612541f4 100644 --- a/IRaCIS.Core.Domain/_Config/_AppSettings.cs +++ b/IRaCIS.Core.Domain/_Config/_AppSettings.cs @@ -41,6 +41,12 @@ namespace IRaCIS.Core.Domain.Share public string CompanyName { get; set; } public string CompanyNameCN { get; set; } + + public string CompanyShortName { get; set; } + + public string CompanyShortNameCN { get; set; } + + } From 38383f34ffb74b62d16f923b14974111afec4eb3 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 22 Feb 2024 14:41:03 +0800 Subject: [PATCH 9/9] =?UTF-8?q?[=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=20-3]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html index 26ca6ecd3..db42758d2 100644 --- a/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html @@ -8,7 +8,7 @@
- Dear {0}, + {0}您好,
感谢您使用展影云平台。