From dc10030a6757dd0a9244bf6e58bf79eeceaf7554 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 6 Apr 2023 11:17:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/appsettings.json | 43 ++++-------- .../Service/Common/SystemMonitor.cs | 66 +++++++++---------- 2 files changed, 43 insertions(+), 66 deletions(-) diff --git a/IRaCIS.Core.API/appsettings.json b/IRaCIS.Core.API/appsettings.json index c200d0770..791297540 100644 --- a/IRaCIS.Core.API/appsettings.json +++ b/IRaCIS.Core.API/appsettings.json @@ -1,16 +1,13 @@ { - "ConnectionStrings": { - "hang": "Server=ZHOU;Database=IRaCIS;User ID=sa;Password=sa123456;" - }, "JwtSetting": { - "SecurityKey": "3e6dbfa227234a03977a2f421bdb7f4f", // 密钥 - "Issuer": "IRaCIS", // 颁发者 - "Audience": "ZhiZhun", // 接收者 - "TokenExpireDays": "7" // 过期时间(7day) + "SecurityKey": "3e6dbfa227234a03977a2f421bdb7f4f", + "Issuer": "IRaCIS", + "Audience": "ZhiZhun", + "TokenExpireDays": "7" }, "IpRateLimiting": { - "EnableEndpointRateLimiting": true, //False: globally executed, true: executed for each - "StackBlockedRequests": false, // set to false, rejected calls are not added to the throttle counter + "EnableEndpointRateLimiting": true, + "StackBlockedRequests": false, "RealIpHeader": "X-Real-IP", "ClientIdHeader": "X-ClientId", "QuotaExceededResponse": { @@ -19,12 +16,10 @@ "StatusCode": 429 }, "HttpStatusCode": 429, - //"IpWhitelist": [ "127.0.0.1", "::1/10", "192.168.0.0/24" ], - "EndpointWhitelist": [ "post:/study/archivestudy/*" ], - //"EndpointWhitelist": [ ], - //"EndpointWhitelist": ["post:/trial/getTrialList"], //demo + "EndpointWhitelist": [ + "post:/study/archivestudy/*" + ], "IpWhitelist": [], - //"ClientWhitelist": [ "dev-id-1", "dev-id-2" ], "GeneralRules": [ { "Endpoint": "*", @@ -48,7 +43,6 @@ } ] }, - "easycaching": { "inmemory": { "MaxRdSecond": 120, @@ -63,30 +57,19 @@ } } }, - + "UpdateConfig": { + "test": "123456", + "test1": "12345678" + }, "IRaCISBasicConfig": { - "DoctorCodePrefix": "RE", - "UserCodePrefix": "U", - "QCChallengeCodePrefix": "Q", - "NoneDicomStudyCodePrefix": "NST", - "DicomStudyCodePrefix": "ST", - "SystemSiteCodePrefix": "S", - "DefaultPassword": "123456", - "DefaultInternalOrganizationName": "ExtImaging", - "ImageShareExpireDays": 10 } - - //网站根地址,为了访问文件 dicom 和上传的文档... 实测发现不用将域名拼接返回,浏览器会自动加上当前ip,避免了多环境读取环境配置文件 - - - } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Common/SystemMonitor.cs b/IRaCIS.Core.Application/Service/Common/SystemMonitor.cs index 004aff76f..80e6973fb 100644 --- a/IRaCIS.Core.Application/Service/Common/SystemMonitor.cs +++ b/IRaCIS.Core.Application/Service/Common/SystemMonitor.cs @@ -109,9 +109,7 @@ namespace IRaCIS.Core.Application.Service.Common //jObject.WriteTo(jsonTextWriter); #endregion - - - + #region test //var json = File.ReadAllText("appsettings.json"); //var jObject = JToken.Parse(json, new JsonLoadSettings { CommentHandling = CommentHandling.Load,DuplicatePropertyNameHandling=DuplicatePropertyNameHandling.Ignore }); @@ -149,7 +147,7 @@ namespace IRaCIS.Core.Application.Service.Common //File.WriteAllText("appsettings.json", updatedJson); - // string json = @"{ + //string json = @"{ // // This is a comment // ""Name"": ""John Smith"", // ""Age"": 30, @@ -162,21 +160,19 @@ namespace IRaCIS.Core.Application.Service.Common // } //}"; - // // 使用 Json.NET 库解析 JSON 字符串 - // JObject jObject = JObject.Parse(json,new JsonLoadSettings() { CommentHandling=CommentHandling.Load}); + //// 使用 Json.NET 库解析 JSON 字符串 + //JObject jObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load }); - // // 修改属性 - // jObject["Name"] = "Jane Smith"; - - // // 将修改后的 JObject 对象序列化为 JSON 字符串并保留注释 - // string newJson = jObject.ToString(Formatting.Indented); - - - // // 打印修改后的 JSON 字符串 - // Console.WriteLine(newJson); + //// 修改属性 + //jObject["Name"] = "Jane Smith"; + //// 将修改后的 JObject 对象序列化为 JSON 字符串并保留注释 + //string newJson = jObject.ToString(Newtonsoft.Json.Formatting.Indented); + //// 打印修改后的 JSON 字符串 + //Console.WriteLine(newJson); + #endregion // 读取 Json 文件 @@ -184,40 +180,38 @@ namespace IRaCIS.Core.Application.Service.Common var json = File.ReadAllText("appsettings.json"); - JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling=CommentHandling.Load}); + JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load }); // 获取 UpdateConfig 属性所在的节点 JToken updateConfigNode = jsonObject.SelectToken("UpdateConfig"); JProperty updateConfigProperty = (JProperty)updateConfigNode.Parent; JObject updateConfigParent = (JObject)updateConfigProperty.Value; - - // 向 updateConfigParent 添加或者属性 updateConfigParent[key] = newValue; // 将更改保存回 Json 文件 - //File.WriteAllText(jsonFilePath, jsonObject.ToString()); + File.WriteAllText(jsonFilePath, jsonObject.ToString()); - using (var reader = new JsonTextReader(new StringReader(json))) - using (var writer = new JsonTextWriter(new StreamWriter("appsettings.json"))) - { - while (reader.Read()) - { - if (reader.TokenType == JsonToken.PropertyName && (string)reader.Value == key) - { - // Write the updated property value - writer.WritePropertyName(key); - writer.WriteValue(newValue); - - continue; - } + //using (var reader = new JsonTextReader(new StringReader(json))) + //using (var writer = new JsonTextWriter(new StreamWriter("appsettings.json"))) + //{ + // while (reader.Read()) + // { + // if (reader.TokenType == JsonToken.PropertyName && (string)reader.Value == key) + // { + // // Write the updated property value + // writer.WritePropertyName(key); + // writer.WriteValue(newValue); + // reader.Read(); + // continue; + // } - // Write all other tokens - writer.WriteToken(reader.TokenType, reader.Value); - } - } + // // Write all other tokens + // writer.WriteToken(reader.TokenType, reader.Value); + // } + //}