From c63251b832471ff171ca7cfd56afd7fb01f2df26 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 28 Jun 2023 10:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Helper/InternationalizationHelper.cs | 23 ++++++++++--------- .../Service/Doctor/TrialExperienceService.cs | 2 -- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs b/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs index 8b09c78cb..e1feefcea 100644 --- a/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs +++ b/IRaCIS.Core.Application/Helper/InternationalizationHelper.cs @@ -14,29 +14,30 @@ namespace IRaCIS.Core.Application.Helper public static class InternationalizationHelper { - public static void AddOrUpdateJsonKeyValueAsync(string jsonFileFolder,string key ,string value) + public static async void AddOrUpdateJsonKeyValueAsync(string key, string value) { + var jsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources); - - if (!Directory.Exists(jsonFileFolder) || + 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"); + // + foreach (var filePath in Directory.GetFiles(jsonFileFolder).Where(filePath => Path.GetExtension(filePath).Equals(".json", StringComparison.OrdinalIgnoreCase))) + { + var json = await File.ReadAllTextAsync(filePath); - JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load }); + JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load }); + // 添加或更新指定的键值对 + jsonObject[key] = value; - // 添加或更新指定的键值对 - jsonObject[key] = value; + await File.WriteAllTextAsync(filePath, jsonObject.ToString()); - //jsonObject["testArray"] = JArray.FromObject(generalRules); - - // 将更改保存回 Json 文件 - //File.WriteAllText(jsonFilePath, jsonObject.ToString()); + } } } diff --git a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs b/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs index 16a7a2ee1..6f629e9db 100644 --- a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs @@ -155,8 +155,6 @@ namespace IRaCIS.Application.Services await _repository.BatchDeleteAsync(a => a.Id == updateGCPExperienceParam.GCPId); } - - return ResponseOutput.Result(successs, updateGCPExperienceParam.GCPId.ToString()); }