diff --git a/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs b/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs new file mode 100644 index 000000000..47270ae7d --- /dev/null +++ b/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs @@ -0,0 +1,43 @@ +using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Infrastructure; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static BeetleX.Redis.Commands.HSCAN; +using static IRaCIS.Core.Application.Service.Common.SystemMonitor; + +namespace IRaCIS.Core.Application.Helper +{ + public static class InternationalizationHelper + { + + public static void AddOrUpdateJsonKeyValueAsync(string jsonFileFolder,string key ,string value) + { + + + + if (!Directory.Exists(jsonFileFolder) || + Directory.GetFiles(jsonFileFolder).Any(filePath => Path.GetExtension(filePath).Equals(".json", StringComparison.OrdinalIgnoreCase))) + { + throw new BusinessValidationFailedException("国际化Json文件目录有误"); + } + + var json = File.ReadAllText("appsettings.json"); + + JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load }); + + + // 添加或更新指定的键值对 + jsonObject[key] = value; + + //jsonObject["testArray"] = JArray.FromObject(generalRules); + + // 将更改保存回 Json 文件 + File.WriteAllText(jsonFilePath, jsonObject.ToString()); + + } + } +} diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index e4ae123d9..547f7dc5f 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -204,7 +204,7 @@ namespace IRaCIS.Core.Application - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc); + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(CheckToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); var totalToBeCheckedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) .Where(u => u.CheckState == CheckStateEnum.ToCheck).CountAsync(); @@ -246,7 +246,7 @@ namespace IRaCIS.Core.Application }); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc); + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ReReadingApplyToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); var toBeApprovalCount = _visitTaskReReadingRepository @@ -283,7 +283,7 @@ namespace IRaCIS.Core.Application ToBeApprovalCount = t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup).Count() }); - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc); + var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ReviewerSelectToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync();