HiITEdenX 2 年之前
父節點
當前提交
41877f879a
共有 32 個文件被更改,包括 268 次插入261 次删除
  1. 6 5
      TEAMModelBI/Controllers/BISchool/SchoolController.cs
  2. 7 7
      TEAMModelBI/Controllers/BIServer/BiServersController.cs
  3. 1 1
      TEAMModelBI/Controllers/BISystem/CoreController.cs
  4. 0 4
      TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs
  5. 2 2
      TEAMModelBI/Controllers/BITest/Ies5TestController.cs
  6. 4 4
      TEAMModelBI/Controllers/BITest/TestController.cs
  7. 0 1
      TEAMModelBI/Controllers/LoginController.cs
  8. 2 2
      TEAMModelOS.FunctionV4/HttpTrigger/BIHttpTrigger.cs
  9. 4 4
      TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs
  10. 2 2
      TEAMModelOS.FunctionV4/HttpTrigger/ScsYxptApis.cs
  11. 2 2
      TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs
  12. 4 4
      TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs
  13. 31 25
      TEAMModelOS.SDK/DI/CoreAPI/CoreAPIHttpService.cs
  14. 3 2
      TEAMModelOS.SDK/DI/CoreAPI/NotificationService.cs
  15. 5 4
      TEAMModelOS.SDK/DI/HttpTrigger/WebHookHttpTrigger.cs
  16. 2 2
      TEAMModelOS.SDK/DI/StudyAPI/ScsStudyApisService.cs
  17. 5 4
      TEAMModelOS.SDK/Models/Service/Third/ThirdApisService.cs
  18. 3 3
      TEAMModelOS/Controllers/Client/AClassONEController.cs
  19. 2 3
      TEAMModelOS/Controllers/Common/CommonController.cs
  20. 2 2
      TEAMModelOS/Controllers/OpenApi/IRS/TianboController.cs
  21. 12 9
      TEAMModelOS/Controllers/School/SchoolController.cs
  22. 3 3
      TEAMModelOS/Controllers/System/CoreController.cs
  23. 2 2
      TEAMModelOS/Controllers/Third/Sc/ScApiController.cs
  24. 2 2
      TEAMModelOS/Controllers/Third/Sc/ScDataInitController.cs
  25. 2 2
      TEAMModelOS/Controllers/Third/Sc/ScDataPushController.cs
  26. 3 3
      TEAMModelOS/Controllers/Third/Xkw/Sdk/XkwAPIHttpService.cs
  27. 136 136
      TEAMModelOS/Controllers/Third/Xkw/Sdk/XopHttpClient.cs
  28. 4 4
      TEAMModelOS/Controllers/XTest/FixDataController.cs
  29. 2 2
      TEAMModelOS/Controllers/XTest/FixLessonRecordController.cs
  30. 5 5
      TEAMModelOS/Controllers/XTest/TestController.cs
  31. 2 2
      TEAMModelOS/Startup.cs
  32. 8 8
      TEAMModelOS/appsettings.Development.json

+ 6 - 5
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -51,9 +51,9 @@ namespace TEAMModelBI.Controllers.BISchool
         private readonly NotificationService _notificationService;
         private readonly NotificationService _notificationService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly IWebHostEnvironment _environment; //读取文件
         private readonly IWebHostEnvironment _environment; //读取文件
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
 
 
-        public SchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis, IConfiguration configuration, NotificationService notificationService, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient, IWebHostEnvironment hostingEnvironment)
+        public SchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis, IConfiguration configuration, NotificationService notificationService, CoreAPIHttpService coreAPIHttpService, IHttpClientFactory httpClient, IWebHostEnvironment hostingEnvironment)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;
@@ -2483,10 +2483,11 @@ namespace TEAMModelBI.Controllers.BISchool
             {
             {
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreBBAPI") + "/ies5/get-school-order";
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreBBAPI") + "/ies5/get-school-order";
                 string AccessToken = await getCoreAccessToken();
                 string AccessToken = await getCoreAccessToken();
-                _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                var client = _httpClient.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
                 string paramJson = JsonConvert.SerializeObject(new { school_code = schoolCode });
                 string paramJson = JsonConvert.SerializeObject(new { school_code = schoolCode });
                 var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
                 var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
-                HttpResponseMessage responseMessage = await _httpClient.PostAsync(url, content);
+                HttpResponseMessage responseMessage = await client.PostAsync(url, content);
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     string responseBody = responseMessage.Content.ReadAsStringAsync().Result;
                     string responseBody = responseMessage.Content.ReadAsStringAsync().Result;
@@ -2510,7 +2511,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 string ClientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
                 string ClientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
                 string Secret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
                 string Secret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
                 var content = new { grant_type = GrantType, client_id = ClientID, client_secret = Secret };
                 var content = new { grant_type = GrantType, client_id = ClientID, client_secret = Secret };
-                var response = await _httpClient.PostAsJsonAsync($"{Url}", content);
+                var response = await _httpClient.CreateClient().PostAsJsonAsync($"{Url}", content);
                 if (response.IsSuccessStatusCode)
                 if (response.IsSuccessStatusCode)
                 {
                 {
                     string responseBody = response.Content.ReadAsStringAsync().Result;
                     string responseBody = response.Content.ReadAsStringAsync().Result;

+ 7 - 7
TEAMModelBI/Controllers/BIServer/BiServersController.cs

@@ -37,7 +37,7 @@ namespace TEAMModelBI.Controllers.BIServer
         //读取配置信息
         //读取配置信息
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
 
 
-        private readonly IHttpClientFactory _http;
+        private readonly IHttpClientFactory httpClient;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
 
 
 
 
@@ -48,7 +48,7 @@ namespace TEAMModelBI.Controllers.BIServer
             _dingDing = dingDing;
             _dingDing = dingDing;
             _option = option?.Value;
             _option = option?.Value;
             _configuration = configuration;
             _configuration = configuration;
-            _http = http;
+            httpClient = http;
             _coreAPIHttpService = coreAPIHttpService;
             _coreAPIHttpService = coreAPIHttpService;
         }
         }
 
 
@@ -91,7 +91,7 @@ namespace TEAMModelBI.Controllers.BIServer
                     return Ok(new { state = 200, coreUser });
                     return Ok(new { state = 200, coreUser });
                 else return Ok(new { state = 404, msg = "未找到改账户" });
                 else return Ok(new { state = 404, msg = "未找到改账户" });
 
 
-                //HttpClient httpClient = _http.CreateClient();
+                //HttpClient IHttpClientFactory = _http.CreateClient();
                 //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
                 //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
                 //HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, jsonElment);
                 //HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync(url, jsonElment);
                 //List<userInfo> userInfos = new List<userInfo>();
                 //List<userInfo> userInfos = new List<userInfo>();
@@ -136,8 +136,8 @@ namespace TEAMModelBI.Controllers.BIServer
                 if (!jsonElement.TryGetProperty("HasUser", out JsonElement HasUser)) return BadRequest();
                 if (!jsonElement.TryGetProperty("HasUser", out JsonElement HasUser)) return BadRequest();
 
 
                 string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
                 string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
-                HttpClient httpClient = _http.CreateClient();
-                HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync($"{smsurl}/service/sandsms/pin", jsonElement);
+                 
+                HttpResponseMessage responseMessage = await httpClient.CreateClient().PostAsJsonAsync($"{smsurl}/service/sandsms/pin", jsonElement);
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     string str_json = await responseMessage.Content.ReadAsStringAsync();
                     string str_json = await responseMessage.Content.ReadAsStringAsync();
@@ -176,9 +176,9 @@ namespace TEAMModelBI.Controllers.BIServer
                 if (!jsonElement.TryGetProperty("Authorization_Pin", out JsonElement sms)) return BadRequest();
                 if (!jsonElement.TryGetProperty("Authorization_Pin", out JsonElement sms)) return BadRequest();
 
 
                 string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
                 string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
-                HttpClient httpClient = _http.CreateClient();
+      
                 var temp_job = new { Authorization_Pin = sms };
                 var temp_job = new { Authorization_Pin = sms };
-                HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync($"{smsurl}/service/verifiy/pin", temp_job);
+                HttpResponseMessage responseMessage = await httpClient.CreateClient().PostAsJsonAsync($"{smsurl}/service/verifiy/pin", temp_job);
 
 
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 {
                 {

+ 1 - 1
TEAMModelBI/Controllers/BISystem/CoreController.cs

@@ -28,7 +28,7 @@ namespace TEAMModelBI.Controllers.BISystem
         private readonly Option _option;
         private readonly Option _option;
 
 
 
 
-        public CoreController(AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IPSearcher searcher, HttpClient httpClient)
+        public CoreController(AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IPSearcher searcher, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureRedis = azureRedis;
             _azureRedis = azureRedis;

+ 0 - 4
TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs

@@ -90,8 +90,6 @@ namespace TEAMModelBI.Controllers.BITable
 
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
 
 
-                //HttpClient httpClient = _http.CreateClient();
-                //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
 
 
                 //获取access_token
                 //获取access_token
                 IDingTalkClient tokenClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
                 IDingTalkClient tokenClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
@@ -916,8 +914,6 @@ namespace TEAMModelBI.Controllers.BITable
 
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
 
 
-                //HttpClient httpClient = _http.CreateClient();
-                //string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
 
 
                 //获取access_token
                 //获取access_token
                 IDingTalkClient tokenClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
                 IDingTalkClient tokenClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");

+ 2 - 2
TEAMModelBI/Controllers/BITest/Ies5TestController.cs

@@ -37,9 +37,9 @@ namespace TEAMModelBI.Controllers.BITest
         //读取配置文件
         //读取配置文件
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
 
 
-        public Ies5TestController(AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient)
+        public Ies5TestController(AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;

+ 4 - 4
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -71,9 +71,9 @@ namespace TEAMModelBI.Controllers.BITest
         //读取配置文件
         //读取配置文件
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         private IPSearcher _ipSearcher;
         private IPSearcher _ipSearcher;
-        public TestController(IPSearcher ipSearcher, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient)
+        public TestController(IPSearcher ipSearcher, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;
@@ -1387,7 +1387,7 @@ namespace TEAMModelBI.Controllers.BITest
 
 
                 try
                 try
                 {
                 {
-                    string strs = await _httpClient.GetStringAsync(ulr);
+                    string strs = await _httpClient.CreateClient().GetStringAsync(ulr);
                     if (!string.IsNullOrWhiteSpace(strs))
                     if (!string.IsNullOrWhiteSpace(strs))
                     {
                     {
                         JsonElement json = strs.ToObject<JsonElement>();
                         JsonElement json = strs.ToObject<JsonElement>();
@@ -1422,7 +1422,7 @@ namespace TEAMModelBI.Controllers.BITest
                     string dayUrl = $"http://cdhabook.teammodel.cn:8805/screen/screenshot-png?width=1920&height=1450&url={HttpUtility.UrlEncode(dayUrls, Encoding.UTF8)}&delay=6000";
                     string dayUrl = $"http://cdhabook.teammodel.cn:8805/screen/screenshot-png?width=1920&height=1450&url={HttpUtility.UrlEncode(dayUrls, Encoding.UTF8)}&delay=6000";
                     string dayImage = "";
                     string dayImage = "";
 
 
-                    string dayStr = await _httpClient.GetStringAsync(dayUrl);
+                    string dayStr = await _httpClient.CreateClient().GetStringAsync(dayUrl);
                     if (!string.IsNullOrWhiteSpace(dayStr))
                     if (!string.IsNullOrWhiteSpace(dayStr))
                     {
                     {
                         JsonElement dayJson = dayStr.ToObject<JsonElement>();
                         JsonElement dayJson = dayStr.ToObject<JsonElement>();

+ 0 - 1
TEAMModelBI/Controllers/LoginController.cs

@@ -355,7 +355,6 @@ namespace TEAMModelBI.Controllers
                 //    Website = BIConst.Global;
                 //    Website = BIConst.Global;
                 //}
                 //}
 
 
-                HttpClient httpClient = _http.CreateClient();
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                 var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "userId", $"{userId}" } });
                 var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "userId", $"{userId}" } });
 
 

+ 2 - 2
TEAMModelOS.FunctionV4/HttpTrigger/BIHttpTrigger.cs

@@ -25,9 +25,9 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
         private readonly DingDing _dingDing;
         private readonly DingDing _dingDing;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
 
 
-        public BIHttpTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, HttpClient httpClient)
+        public BIHttpTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;

+ 4 - 4
TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs

@@ -37,9 +37,9 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
         private readonly DingDing _dingDing;
         private readonly DingDing _dingDing;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         public IESHttpTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage
         public IESHttpTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage
-      , AzureRedisFactory azureRedis, HttpClient httpClient)
+      , AzureRedisFactory azureRedis, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;
@@ -916,7 +916,7 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
                     };
                     };
                     var st = screenshot.ToJsonString();
                     var st = screenshot.ToJsonString();
                     await _dingDing.SendBotMsg($"艺术评测报告生成中:\n{st}", GroupNames.成都开发測試群組);
                     await _dingDing.SendBotMsg($"艺术评测报告生成中:\n{st}", GroupNames.成都开发測試群組);
-                    var httpResponse = await _httpClient.PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/screen/screenshot-pdf",
+                    var httpResponse = await _httpClient.CreateClient().PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/screen/screenshot-pdf",
                        screenshot
                        screenshot
                     );
                     );
                    
                    
@@ -944,7 +944,7 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
                         };
                         };
                         var st = screenshot.ToJsonString();
                         var st = screenshot.ToJsonString();
                         //  await _dingDing.SendBotMsg($"艺术评测报告生成中:\n{st}", GroupNames.成都开发測試群組);
                         //  await _dingDing.SendBotMsg($"艺术评测报告生成中:\n{st}", GroupNames.成都开发測試群組);
-                        var httpResponse = await _httpClient.PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/screen/screenshot-pdf",
+                        var httpResponse = await _httpClient.CreateClient().PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/screen/screenshot-pdf",
                            screenshot
                            screenshot
                         );
                         );
                         if (httpResponse.StatusCode == HttpStatusCode.OK)
                         if (httpResponse.StatusCode == HttpStatusCode.OK)

+ 2 - 2
TEAMModelOS.FunctionV4/HttpTrigger/ScsYxptApis.cs

@@ -24,10 +24,10 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
         private readonly DingDing _dingDing;
         private readonly DingDing _dingDing;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         public static string Code { get; set; }
         public static string Code { get; set; }
         public static Dictionary<string, object> parameterMap = null;
         public static Dictionary<string, object> parameterMap = null;
-        public ScsYxptApis(HttpClient httpClient,AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage 
+        public ScsYxptApis(IHttpClientFactory httpClient,AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage 
            , AzureRedisFactory azureRedis)
            , AzureRedisFactory azureRedis)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;

+ 2 - 2
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -62,11 +62,11 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly IConverter _converter;
         private readonly IConverter _converter;
         private readonly SnowflakeId _snowflakeId;
         private readonly SnowflakeId _snowflakeId;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         public ActiveTaskTopic(SnowflakeId snowflakeId, IConverter converter, CoreAPIHttpService coreAPIHttpService,
         public ActiveTaskTopic(SnowflakeId snowflakeId, IConverter converter, CoreAPIHttpService coreAPIHttpService,
             AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis,
             AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis,
             AzureServiceBusFactory serviceBus, IOptionsSnapshot<Option> option,
             AzureServiceBusFactory serviceBus, IOptionsSnapshot<Option> option,
-            NotificationService notificationService, IConfiguration configuration, HttpClient httpClient)
+            NotificationService notificationService, IConfiguration configuration, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;

+ 4 - 4
TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs

@@ -42,9 +42,9 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
         private readonly IConverter _converter;
         private readonly IConverter _converter;
         private readonly SnowflakeId _snowflakeId;
         private readonly SnowflakeId _snowflakeId;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         private IPSearcher _ipSearcher;
         private IPSearcher _ipSearcher;
-        public IESTimerTrigger(IPSearcher ipSearcher,HttpClient httpClient,SnowflakeId snowflakeId,IConverter converter, AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis)
+        public IESTimerTrigger(IPSearcher ipSearcher, IHttpClientFactory httpClient,SnowflakeId snowflakeId,IConverter converter, AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;
@@ -93,7 +93,7 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
                         string image = "";
                         string image = "";
                         try
                         try
                         {
                         {
-                            string strs = await _httpClient.GetStringAsync(ulr);
+                            string strs = await _httpClient.CreateClient().GetStringAsync(ulr);
                             if (!string.IsNullOrWhiteSpace(strs)) {
                             if (!string.IsNullOrWhiteSpace(strs)) {
                                 JsonElement json = strs.ToObject<JsonElement>();
                                 JsonElement json = strs.ToObject<JsonElement>();
                                 json.TryGetProperty("url", out JsonElement base64);
                                 json.TryGetProperty("url", out JsonElement base64);
@@ -131,7 +131,7 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
 
 
                             try
                             try
                             {
                             {
-                                string dayStr = await _httpClient.GetStringAsync(dayUrl);
+                                string dayStr = await _httpClient.CreateClient().GetStringAsync(dayUrl);
                                 if (!string.IsNullOrWhiteSpace(dayStr)) 
                                 if (!string.IsNullOrWhiteSpace(dayStr)) 
                                 {
                                 {
                                     JsonElement dayJson = dayStr.ToObject<JsonElement>();
                                     JsonElement dayJson = dayStr.ToObject<JsonElement>();

+ 31 - 25
TEAMModelOS.SDK/DI/CoreAPI/CoreAPIHttpService.cs

@@ -34,7 +34,7 @@ namespace TEAMModelOS.SDK
             string url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
             string url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
             var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
             var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
             var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
             var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
-            services.AddHttpClient<CoreAPIHttpService>();
+            services.AddSingleton<CoreAPIHttpService>();
             services.Configure<CoreAPIHttpServiceOptions>(name  , o => { o.location = location;o.url =url;o.clientID = clientID; o.clientSecret = clientSecret; });
             services.Configure<CoreAPIHttpServiceOptions>(name  , o => { o.location = location;o.url =url;o.clientID = clientID; o.clientSecret = clientSecret; });
             return services;
             return services;
         }
         }
@@ -92,13 +92,14 @@ namespace TEAMModelOS.SDK
                 {
                 {
                     location = "Global";
                     location = "Global";
                 }
                 }
+                var client = _httpClient ;
                 var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
                 var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
-                if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
+                if (client.DefaultRequestHeaders.Contains("Authorization"))
                 {
                 {
-                    _httpClient.DefaultRequestHeaders.Remove("Authorization");
+                    client.DefaultRequestHeaders.Remove("Authorization");
                 }
                 }
-                _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
-                HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(url, data);
+                client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+                HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, data);
                 if (responseMessage.Content != null)
                 if (responseMessage.Content != null)
                 {
                 {
                     string content = await responseMessage.Content.ReadAsStringAsync();
                     string content = await responseMessage.Content.ReadAsStringAsync();
@@ -231,15 +232,16 @@ namespace TEAMModelOS.SDK
                     replaceData.Add("scope", "school");
                     replaceData.Add("scope", "school");
                 }
                 }
                 else { replaceData.Add("scope", "private"); }
                 else { replaceData.Add("scope", "private"); }
+                var client = _httpClient;
                 var token = CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location).Result;
                 var token = CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location).Result;
-                if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
+                if (client.DefaultRequestHeaders.Contains("Authorization"))
                 {
                 {
-                    _httpClient.DefaultRequestHeaders.Remove("Authorization");
-                    _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+                    client.DefaultRequestHeaders.Remove("Authorization");
+                    client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
                 }
                 }
                 else
                 else
                 {
                 {
-                    _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+                    client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
                 }
                 }
                 foreach (var group in groups)
                 foreach (var group in groups)
                 {
                 {
@@ -371,14 +373,15 @@ namespace TEAMModelOS.SDK
                 {
                 {
                     location = "Global";
                     location = "Global";
                 }
                 }
+                var client = _httpClient;
                 var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
                 var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
-                if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
+                if (client.DefaultRequestHeaders.Contains("Authorization"))
                 {
                 {
-                    _httpClient.DefaultRequestHeaders.Remove("Authorization");
+                    client.DefaultRequestHeaders.Remove("Authorization");
 
 
                 }
                 }
-                _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
-                HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(url, data);
+                client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+                HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, data);
                 if (responseMessage.Content != null)
                 if (responseMessage.Content != null)
                 {
                 {
                     string content = await responseMessage.Content.ReadAsStringAsync();
                     string content = await responseMessage.Content.ReadAsStringAsync();
@@ -429,14 +432,15 @@ namespace TEAMModelOS.SDK
             {
             {
                 location = "Global";
                 location = "Global";
             }
             }
+            var client = _httpClient;
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
-            if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
+            if (client.DefaultRequestHeaders.Contains("Authorization"))
             {
             {
-                _httpClient.DefaultRequestHeaders.Remove("Authorization");
+                client.DefaultRequestHeaders.Remove("Authorization");
                
                
             }
             }
-            _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
-            HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(url, data);
+            client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+            HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, data);
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             {
             {
                 string content=await responseMessage.Content.ReadAsStringAsync();
                 string content=await responseMessage.Content.ReadAsStringAsync();
@@ -484,13 +488,14 @@ namespace TEAMModelOS.SDK
                 location = "Global";
                 location = "Global";
             }
             }
             url = $"{url}/oauth2/getuserinfos";
             url = $"{url}/oauth2/getuserinfos";
+            var client = _httpClient;
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
-            if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
+            if (client.DefaultRequestHeaders.Contains("Authorization"))
             {
             {
-                _httpClient.DefaultRequestHeaders.Remove("Authorization");
+                client.DefaultRequestHeaders.Remove("Authorization");
             }
             }
-            _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
-            HttpResponseMessage responseMessage = await _httpClient.PostAsync(url, scontent);
+            client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+            HttpResponseMessage responseMessage = await client.PostAsync(url, scontent);
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             {
             {
                 string content = await responseMessage.Content.ReadAsStringAsync();
                 string content = await responseMessage.Content.ReadAsStringAsync();
@@ -536,14 +541,15 @@ namespace TEAMModelOS.SDK
             {
             {
                 location = "Global";
                 location = "Global";
             }
             }
+            var client = _httpClient;
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
-            if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
+            if (client.DefaultRequestHeaders.Contains("Authorization"))
             {
             {
-                _httpClient.DefaultRequestHeaders.Remove("Authorization");
+                client.DefaultRequestHeaders.Remove("Authorization");
 
 
             }
             }
-            _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
-            HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(url, data);
+            client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+            HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, data);
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             {
             {
                 string content = await responseMessage.Content.ReadAsStringAsync();
                 string content = await responseMessage.Content.ReadAsStringAsync();

+ 3 - 2
TEAMModelOS.SDK/DI/CoreAPI/NotificationService.cs

@@ -28,9 +28,10 @@ namespace TEAMModelOS.SDK.DI.CoreAPI
                 {
                 {
                     location = "Global";
                     location = "Global";
                 }
                 }
+                var client = _httpClient;
                 var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
                 var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
-                _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
-                HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(url, notification);
+                client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
+                HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, notification);
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     return 200;
                     return 200;

+ 5 - 4
TEAMModelOS.SDK/DI/HttpTrigger/WebHookHttpTrigger.cs

@@ -33,8 +33,8 @@ namespace TEAMModelOS.SDK.DI
         private readonly DingDing _dingDing;
         private readonly DingDing _dingDing;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
-        private readonly HttpClient _httpClient;
-        public WebHookHttpTrigger(HttpClient httpClient,AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage  , AzureRedisFactory azureRedis)
+        private readonly IHttpClientFactory _httpClient;
+        public WebHookHttpTrigger(IHttpClientFactory httpClient,AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage  , AzureRedisFactory azureRedis)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;
@@ -141,8 +141,9 @@ namespace TEAMModelOS.SDK.DI
         /// <param name="notice"></param>
         /// <param name="notice"></param>
         public    async Task<HttpStatusCode> send (dynamic data,string domain, string notice) {
         public    async Task<HttpStatusCode> send (dynamic data,string domain, string notice) {
             var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
             var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-            _httpClient.Timeout=new TimeSpan(0,0,10);
-            HttpResponseMessage httpResponse =await  _httpClient.PostAsJsonAsync($"{domain}/webhook", new
+            var client = _httpClient.CreateClient();
+            client.Timeout=new TimeSpan(0,0,10);
+            HttpResponseMessage httpResponse =await client.PostAsJsonAsync($"{domain}/webhook", new
             {
             {
                 time = timestamp,
                 time = timestamp,
                 notice =notice,
                 notice =notice,

+ 2 - 2
TEAMModelOS.SDK/DI/StudyAPI/ScsStudyApisService.cs

@@ -31,12 +31,12 @@ namespace TEAMModelOS.SDK.DI
         //private readonly IWebHostEnvironment _environment;
         //private readonly IWebHostEnvironment _environment;
         public bool check = true;
         public bool check = true;
         private SnowflakeId _snowflakeId;
         private SnowflakeId _snowflakeId;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
       
       
         //private readonly IConfiguration _configuration;
         //private readonly IConfiguration _configuration;
         // private readonly DI.DingDing _dingDing;
         // private readonly DI.DingDing _dingDing;
         //public readonly Option _option;
         //public readonly Option _option;
-        public ScsStudyApisService(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage,   AzureRedisFactory azureRedis, HttpClient httpClient,   SnowflakeId snowflakeId)
+        public ScsStudyApisService(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage,   AzureRedisFactory azureRedis, IHttpClientFactory httpClient,   SnowflakeId snowflakeId)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _dingDing = dingDing;

+ 5 - 4
TEAMModelOS.SDK/Models/Service/Third/ThirdApisService.cs

@@ -16,8 +16,8 @@ namespace TEAMModelOS.SDK
     public static class ThirdApisService
     public static class ThirdApisService
     {
     {
        
        
-     //   private readonly HttpClient _httpClient;
-        public async static   Task<ScsResult> Post(HttpClient _httpClient, string url, string Code, string PassKey,string privateKey, Dictionary<string ,object> data)
+     //   private readonly IHttpClientFactory _httpClient;
+        public async static   Task<ScsResult> Post(IHttpClientFactory  _httpClient, string url, string Code, string PassKey,string privateKey, Dictionary<string ,object> data)
         {
         {
             string result = "";
             string result = "";
             HttpResponseMessage response=null;
             HttpResponseMessage response=null;
@@ -35,13 +35,14 @@ namespace TEAMModelOS.SDK
                 string signatureStr = signatureDC.ToJsonString();
                 string signatureStr = signatureDC.ToJsonString();
                 string signature = AESHelper.AESEncrypt(signatureStr, privateKey);
                 string signature = AESHelper.AESEncrypt(signatureStr, privateKey);
                 #endregion
                 #endregion
-                _httpClient.DefaultRequestHeaders.Add("Signature", signature);
+                var client = _httpClient.CreateClient();
+                client.DefaultRequestHeaders.Add("Signature", signature);
                 var request = new HttpRequestMessage();
                 var request = new HttpRequestMessage();
                 request.Method = new HttpMethod("POST");
                 request.Method = new HttpMethod("POST");
                 request.RequestUri = new Uri(url);
                 request.RequestUri = new Uri(url);
                 request.Content = new StringContent(sendMsg);
                 request.Content = new StringContent(sendMsg);
                 request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
                 request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
-                response = await _httpClient.SendAsync(request);
+                response = await client.SendAsync(request);
                 result = await response.Content.ReadAsStringAsync();
                 result = await response.Content.ReadAsStringAsync();
                 if (!result.Contains("操作失败"))
                 if (!result.Contains("操作失败"))
                 {
                 {

+ 3 - 3
TEAMModelOS/Controllers/Client/AClassONEController.cs

@@ -42,7 +42,7 @@ namespace TEAMModelOS.Controllers
     [ApiController]
     [ApiController]
     public class AClassONEController : ControllerBase
     public class AClassONEController : ControllerBase
     {
     {
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureCosmosFactory _azureCosmos;
         private readonly AzureCosmosFactory _azureCosmos;
@@ -56,7 +56,7 @@ namespace TEAMModelOS.Controllers
             AzureCosmosFactory azureCosmos,
             AzureCosmosFactory azureCosmos,
             DingDing dingDing,
             DingDing dingDing,
             SnowflakeId snowflakeId,
             SnowflakeId snowflakeId,
-            IOptionsSnapshot<Option> option, HttpClient httpClient, IConfiguration configuration)
+            IOptionsSnapshot<Option> option, IHttpClientFactory httpClient, IConfiguration configuration)
         {
         {
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;
             _azureRedis = azureRedis;
             _azureRedis = azureRedis;
@@ -96,7 +96,7 @@ namespace TEAMModelOS.Controllers
             //return Ok(new { token = new { token.TokenType,token.AccessToken } });
             //return Ok(new { token = new { token.TokenType,token.AccessToken } });
             if (!json.TryGetProperty("js_code", out JsonElement js_code)) return BadRequest("js_code is null");
             if (!json.TryGetProperty("js_code", out JsonElement js_code)) return BadRequest("js_code is null");
             string url = $"https://api.weixin.qq.com/sns/jscode2session?appid={wxappid}&secret={wxsecret}&js_code={js_code}&grant_type=authorization_code";
             string url = $"https://api.weixin.qq.com/sns/jscode2session?appid={wxappid}&secret={wxsecret}&js_code={js_code}&grant_type=authorization_code";
-            HttpResponseMessage responseMessage = await _httpClient.GetAsync(url);
+            HttpResponseMessage responseMessage = await _httpClient.CreateClient().GetAsync(url);
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             {
             {
                 JsonDocument document = JsonDocument.Parse(responseMessage.Content.ReadAsStream());
                 JsonDocument document = JsonDocument.Parse(responseMessage.Content.ReadAsStream());

+ 2 - 3
TEAMModelOS/Controllers/Common/CommonController.cs

@@ -35,7 +35,7 @@ namespace TEAMModelOS.Controllers.Common
         private readonly DingDing _dingDing;
         private readonly DingDing _dingDing;
         private readonly Option _option;
         private readonly Option _option;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
-        private readonly IHttpClientFactory _clientFactory;
+        private readonly IHttpClientFactory _httpClient;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         public CommonController(CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage, IHttpClientFactory clientFactory)
         public CommonController(CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage, IHttpClientFactory clientFactory)
         {
         {
@@ -45,7 +45,7 @@ namespace TEAMModelOS.Controllers.Common
             _dingDing = dingDing;
             _dingDing = dingDing;
             _option = option?.Value;
             _option = option?.Value;
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;
-            _clientFactory = clientFactory;
+            _httpClient = clientFactory;
             _coreAPIHttpService = coreAPIHttpService;
             _coreAPIHttpService = coreAPIHttpService;
         }
         }
 
 
@@ -172,7 +172,6 @@ namespace TEAMModelOS.Controllers.Common
                     }
                     }
                 }
                 }
                 await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Dictionary<string, object>>(dy, dy["id"].ToString(), new Azure.Cosmos.PartitionKey(dy["code"].ToString()));
                 await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Dictionary<string, object>>(dy, dy["id"].ToString(), new Azure.Cosmos.PartitionKey(dy["code"].ToString()));
-                var httpClient = _clientFactory.CreateClient();
                 var content = new { id = $"{id}", code = $"{code}" };
                 var content = new { id = $"{id}", code = $"{code}" };
                 await ActivityService.RefreshStuActivity(_coreAPIHttpService, client, _dingDing, $"{id}", $"{code}");
                 await ActivityService.RefreshStuActivity(_coreAPIHttpService, client, _dingDing, $"{id}", $"{code}");
                 return Ok(new { code=200, isScore });
                 return Ok(new { code=200, isScore });

+ 2 - 2
TEAMModelOS/Controllers/OpenApi/IRS/TianboController.cs

@@ -34,8 +34,8 @@ namespace TEAMModelOS.Controllers
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly NotificationService _notificationService;
         private readonly NotificationService _notificationService;
-        private readonly HttpClient _httpClient;
-        public TianboController(CoreAPIHttpService coreAPIHttpService, NotificationService notificationService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, AzureSignalRFactory azureSignalR, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, HttpClient httpClient)
+        private readonly IHttpClientFactory _httpClient;
+        public TianboController(CoreAPIHttpService coreAPIHttpService, NotificationService notificationService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, AzureSignalRFactory azureSignalR, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;

+ 12 - 9
TEAMModelOS/Controllers/School/SchoolController.cs

@@ -53,10 +53,10 @@ namespace TEAMModelOS.Controllers
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly NotificationService _notificationService;
         private readonly NotificationService _notificationService;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         private readonly HttpTrigger _httpTrigger;
         private readonly HttpTrigger _httpTrigger;
         private readonly IWebHostEnvironment _environment;
         private readonly IWebHostEnvironment _environment;
-        public SchoolController(IWebHostEnvironment environment,HttpTrigger httpTrigger,CoreAPIHttpService coreAPIHttpService, NotificationService notificationService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, HttpClient httpClient)
+        public SchoolController(IWebHostEnvironment environment,HttpTrigger httpTrigger,CoreAPIHttpService coreAPIHttpService, NotificationService notificationService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;
@@ -633,10 +633,11 @@ namespace TEAMModelOS.Controllers
             {
             {
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreService:deviceinfo");
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreService:deviceinfo");
                 string AccessToken = await getCoreAccessToken();
                 string AccessToken = await getCoreAccessToken();
-                _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                var client = _httpClient.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
                 string uuidListJson = JsonConvert.SerializeObject(uuidList);
                 string uuidListJson = JsonConvert.SerializeObject(uuidList);
                 var content = new StringContent(uuidListJson, Encoding.UTF8, "application/json");
                 var content = new StringContent(uuidListJson, Encoding.UTF8, "application/json");
-                HttpResponseMessage responseMessage = await _httpClient.PostAsync(url, content);
+                HttpResponseMessage responseMessage = await client.PostAsync(url, content);
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     string responseBody = responseMessage.Content.ReadAsStringAsync().Result;
                     string responseBody = responseMessage.Content.ReadAsStringAsync().Result;
@@ -662,10 +663,11 @@ namespace TEAMModelOS.Controllers
             {
             {
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreBBAPI") + "/ies5/get-school-order";
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreBBAPI") + "/ies5/get-school-order";
                 string AccessToken = await getCoreAccessToken();
                 string AccessToken = await getCoreAccessToken();
-                _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                var client = _httpClient.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
                 string paramJson = JsonConvert.SerializeObject(new { school_code = schoolCode });
                 string paramJson = JsonConvert.SerializeObject(new { school_code = schoolCode });
                 var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
                 var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
-                HttpResponseMessage responseMessage = await _httpClient.PostAsync(url, content);
+                HttpResponseMessage responseMessage = await client.PostAsync(url, content);
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     string responseBody = responseMessage.Content.ReadAsStringAsync().Result;
                     string responseBody = responseMessage.Content.ReadAsStringAsync().Result;
@@ -689,7 +691,7 @@ namespace TEAMModelOS.Controllers
                 string ClientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
                 string ClientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
                 string Secret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
                 string Secret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
                 var content = new { grant_type = GrantType, client_id = ClientID, client_secret = Secret };
                 var content = new { grant_type = GrantType, client_id = ClientID, client_secret = Secret };
-                var response = await _httpClient.PostAsJsonAsync($"{Url}", content);
+                var response = await _httpClient.CreateClient().PostAsJsonAsync($"{Url}", content);
                 if (response.IsSuccessStatusCode)
                 if (response.IsSuccessStatusCode)
                 {
                 {
                     string responseBody = response.Content.ReadAsStringAsync().Result;
                     string responseBody = response.Content.ReadAsStringAsync().Result;
@@ -822,8 +824,9 @@ namespace TEAMModelOS.Controllers
                 bool unbindFlg = false; //解綁是否成功 true:成功 false:失敗
                 bool unbindFlg = false; //解綁是否成功 true:成功 false:失敗
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreBBAPI") + "/bbauthapi/srunbind";
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreBBAPI") + "/bbauthapi/srunbind";
                 string AccessToken = await getCoreAccessToken();
                 string AccessToken = await getCoreAccessToken();
-                _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
-                HttpResponseMessage response = await _httpClient.PostAsJsonAsync(url, content);
+                var client = _httpClient.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                HttpResponseMessage response = await client.PostAsJsonAsync(url, content);
                 if (response.StatusCode == HttpStatusCode.OK)
                 if (response.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     string responseBody = await response.Content.ReadAsStringAsync();
                     string responseBody = await response.Content.ReadAsStringAsync();

+ 3 - 3
TEAMModelOS/Controllers/System/CoreController.cs

@@ -45,23 +45,23 @@ namespace TEAMModelOS.Controllers
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly DingDing _dingDing;
         private readonly DingDing _dingDing;
         private readonly Option _option;
         private readonly Option _option;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClientFactory;
         private readonly IPSearcher _searcher;
         private readonly IPSearcher _searcher;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly SnowflakeId _snowflakeId;
         private readonly SnowflakeId _snowflakeId;
-        public CoreController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId,CoreAPIHttpService coreAPIHttpService,IConfiguration configuration,IPSearcher searcher, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, HttpClient httpClient)
+        public CoreController(IHttpClientFactory httpClientFactory,AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId,CoreAPIHttpService coreAPIHttpService,IConfiguration configuration,IPSearcher searcher, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _searcher = searcher;
             _searcher = searcher;
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;
             _dingDing = dingDing;
             _dingDing = dingDing;
             _option = option?.Value;
             _option = option?.Value;
-            _httpClient = httpClient;
             _azureRedis = azureRedis;
             _azureRedis = azureRedis;
             _configuration = configuration;
             _configuration = configuration;
             _coreAPIHttpService = coreAPIHttpService;
             _coreAPIHttpService = coreAPIHttpService;
             _snowflakeId = snowflakeId;
             _snowflakeId = snowflakeId;
+            _httpClientFactory = httpClientFactory;
         }
         }
 
 
         public class NotifyData {
         public class NotifyData {

+ 2 - 2
TEAMModelOS/Controllers/Third/Sc/ScApiController.cs

@@ -55,12 +55,12 @@ namespace TEAMModelOS.Controllers
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
         private readonly CoreAPIHttpService _accountHttpService;
         private readonly CoreAPIHttpService _accountHttpService;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         public readonly string type = "scsyxpt";
         public readonly string type = "scsyxpt";
         private readonly HttpTrigger _httpTrigger;
         private readonly HttpTrigger _httpTrigger;
          private List<ScComConfig> scsyxptConfigs { get; set; }
          private List<ScComConfig> scsyxptConfigs { get; set; }
         public IConfiguration _configuration { get; set; }
         public IConfiguration _configuration { get; set; }
-        public ScApiController(HttpClient httpClient,AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
+        public ScApiController(IHttpClientFactory httpClient,AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
          AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService accountHttpService, HttpTrigger httpTrigger)
          AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService accountHttpService, HttpTrigger httpTrigger)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;

+ 2 - 2
TEAMModelOS/Controllers/Third/Sc/ScDataInitController.cs

@@ -59,9 +59,9 @@ namespace TEAMModelOS.Controllers.Third
         public readonly string type = "scsyxpt";
         public readonly string type = "scsyxpt";
         private readonly HttpTrigger _httpTrigger;
         private readonly HttpTrigger _httpTrigger;
         private readonly IWebHostEnvironment _environment;
         private readonly IWebHostEnvironment _environment;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         public IConfiguration _configuration { get; set; }
         public IConfiguration _configuration { get; set; }
-        public ScDataInitController(HttpClient httpClient,  IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
+        public ScDataInitController(IHttpClientFactory httpClient,  IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
           AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ScsStudyApisService scsStudyApis,  HttpTrigger httpTrigger)
           AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ScsStudyApisService scsStudyApis,  HttpTrigger httpTrigger)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;

+ 2 - 2
TEAMModelOS/Controllers/Third/Sc/ScDataPushController.cs

@@ -158,11 +158,11 @@ namespace TEAMModelOS.Controllers
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly IConverter _converter;
         private readonly IConverter _converter;
         public readonly string type = "scsyxpt";
         public readonly string type = "scsyxpt";
-        public readonly HttpClient _httpClient;
+        public readonly IHttpClientFactory _httpClient;
  
  
         public IConfiguration _configuration { get; set; }
         public IConfiguration _configuration { get; set; }
 
 
-        public ScDataPushController(HttpClient httpClient,IConverter converter,  AzureCosmosFactory azureCosmos,   AzureStorageFactory azureStorage,  IConfiguration configuration)
+        public ScDataPushController(IHttpClientFactory httpClient,IConverter converter,  AzureCosmosFactory azureCosmos,   AzureStorageFactory azureStorage,  IConfiguration configuration)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;

+ 3 - 3
TEAMModelOS/Controllers/Third/Xkw/Sdk/XkwAPIHttpService.cs

@@ -41,9 +41,9 @@ namespace TEAMModelOS.Controllers.Third.Xkw.Sdk
         private String appId;
         private String appId;
         private String secret;
         private String secret;
         public int TimeoutInSeconds { get; set; } = DEFAULT_TIMEOUT;
         public int TimeoutInSeconds { get; set; } = DEFAULT_TIMEOUT;
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         public readonly IOptionsMonitor<XkwAPIHttpServiceOptions> options;
         public readonly IOptionsMonitor<XkwAPIHttpServiceOptions> options;
-        public XkwAPIHttpService(HttpClient httpClient, IOptionsMonitor<XkwAPIHttpServiceOptions> optionsMonitor, AzureStorageFactory _azureStorageFactory)
+        public XkwAPIHttpService(IHttpClientFactory httpClient, IOptionsMonitor<XkwAPIHttpServiceOptions> optionsMonitor, AzureStorageFactory _azureStorageFactory)
         {
         {
 
 
             _httpClient = httpClient;
             _httpClient = httpClient;
@@ -115,7 +115,7 @@ namespace TEAMModelOS.Controllers.Third.Xkw.Sdk
             HttpResponseMessage response = null;
             HttpResponseMessage response = null;
             using (CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutInSeconds)))
             using (CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutInSeconds)))
             {
             {
-                response = _httpClient.SendAsync(request, cts.Token).Result;
+                response = _httpClient.CreateClient().SendAsync(request, cts.Token).Result;
             }
             }
             String responseText = response.Content.ReadAsStringAsync().Result;
             String responseText = response.Content.ReadAsStringAsync().Result;
             if (response.StatusCode != HttpStatusCode.OK)
             if (response.StatusCode != HttpStatusCode.OK)

+ 136 - 136
TEAMModelOS/Controllers/Third/Xkw/Sdk/XopHttpClient.cs

@@ -10,142 +10,142 @@ using System.Web;
 
 
 namespace TEAMModelOS.Controllers.Third.Xkw
 namespace TEAMModelOS.Controllers.Third.Xkw
 {
 {
-    public class XopHttpClient : IDisposable
-    {
-        private static int DEFAULT_TIMEOUT = 5;
-
-        private String baseUrl;
-        private String appId;
-        private String secret;
-
-        public int TimeoutInSeconds { get; set; } = DEFAULT_TIMEOUT;
-
-        private HttpClient httpClient;
-
-
-        public void Dispose()
-        {
-            this.httpClient?.Dispose();
-        }
-
-        public XopHttpClient(String baseUrl, String appId, String secret) : this(baseUrl, appId, secret, null)
-        {
-        }
-
-        public XopHttpClient(String baseUrl, String appId, String secret, WebProxy proxy) : this(baseUrl, appId, secret, DEFAULT_TIMEOUT, proxy)
-        {
-        }
-
-        public XopHttpClient(String baseUrl, String appId, String secret, int timeout) : this(baseUrl, appId, secret, timeout, null)
-        {
-        }
-
-        public XopHttpClient(String baseUrl, String appId, String secret, int timeout, WebProxy proxy)
-        {
-            this.baseUrl = baseUrl;
-            this.appId = appId;
-            this.secret = secret;
-            if (proxy != null)
-            {
-                var httpClientHandler = new HttpClientHandler
-                {
-                    Proxy = proxy
-                };
-                this.httpClient = new HttpClient(httpClientHandler, true);
-            }
-            else
-            {
-                this.httpClient = new HttpClient();
-            }
-            this.httpClient.DefaultRequestHeaders.Add(HmacConst.KEY_APP_ID, appId);
-        }
-
-        public T Get<T>(String uri)
-        {
-            return Get<T>(uri, null);
-        }
-
-        public T Get<T>(String uri, Dictionary<String, String> parameters)
-        {
-            return SendRequest<T>(HttpMethod.Get, uri, parameters, null, null, this.TimeoutInSeconds);
-        }
-
-        public T Post<T>(String uri, Dictionary<String, String> parameters, String text, String contentType)
-        {
-            return SendRequest<T>(HttpMethod.Post, uri, parameters, text, "application/json", this.TimeoutInSeconds);
-        }
-
-        public T PostAsText<T>(String uri, Dictionary<String, String> parameters, String text)
-        {
-            return SendRequest<T>(HttpMethod.Post, uri, parameters, text, "text/plain", this.TimeoutInSeconds);
-        }
-
-        public T PostAsJson<T>(String uri, Dictionary<String, String> parameters, Object data)
-        {
+    //public class XopHttpClient : IDisposable
+    //{
+    //    private static int DEFAULT_TIMEOUT = 5;
+
+    //    private String baseUrl;
+    //    private String appId;
+    //    private String secret;
+
+    //    public int TimeoutInSeconds { get; set; } = DEFAULT_TIMEOUT;
+
+    //    private IHttpClientFactory httpClient;
+
+
+    //    public void Dispose()
+    //    {
+    //        this.httpClient?.Dispose();
+    //    }
+
+    //    public XopHttpClient(String baseUrl, String appId, String secret) : this(baseUrl, appId, secret, null)
+    //    {
+    //    }
+
+    //    public XopHttpClient(String baseUrl, String appId, String secret, WebProxy proxy) : this(baseUrl, appId, secret, DEFAULT_TIMEOUT, proxy)
+    //    {
+    //    }
+
+    //    public XopHttpClient(String baseUrl, String appId, String secret, int timeout) : this(baseUrl, appId, secret, timeout, null)
+    //    {
+    //    }
+
+    //    public XopHttpClient(String baseUrl, String appId, String secret, int timeout, WebProxy proxy)
+    //    {
+    //        this.baseUrl = baseUrl;
+    //        this.appId = appId;
+    //        this.secret = secret;
+    //        if (proxy != null)
+    //        {
+    //            var httpClientHandler = new HttpClientHandler
+    //            {
+    //                Proxy = proxy
+    //            };
+    //            this.httpClient = new HttpClient(httpClientHandler, true);
+    //        }
+    //        else
+    //        {
+    //            this.httpClient = new HttpClient();
+    //        }
+    //        this.httpClient.DefaultRequestHeaders.Add(HmacConst.KEY_APP_ID, appId);
+    //    }
+
+    //    public T Get<T>(String uri)
+    //    {
+    //        return Get<T>(uri, null);
+    //    }
+
+    //    public T Get<T>(String uri, Dictionary<String, String> parameters)
+    //    {
+    //        return SendRequest<T>(HttpMethod.Get, uri, parameters, null, null, this.TimeoutInSeconds);
+    //    }
+
+    //    public T Post<T>(String uri, Dictionary<String, String> parameters, String text, String contentType)
+    //    {
+    //        return SendRequest<T>(HttpMethod.Post, uri, parameters, text, "application/json", this.TimeoutInSeconds);
+    //    }
+
+    //    public T PostAsText<T>(String uri, Dictionary<String, String> parameters, String text)
+    //    {
+    //        return SendRequest<T>(HttpMethod.Post, uri, parameters, text, "text/plain", this.TimeoutInSeconds);
+    //    }
+
+    //    public T PostAsJson<T>(String uri, Dictionary<String, String> parameters, Object data)
+    //    {
             
             
-           string json = JsonConvert.SerializeObject(data);
-            return SendRequest<T>(HttpMethod.Post, uri, parameters, json, "application/json", this.TimeoutInSeconds);
-        }
-
-        //public T PostAsForm<T>(String uri, Dictionary<String, String> parameters, Dictionary<String, String> formData)
-        //{
-        //    if (formData == null)
-        //    {
-        //        formData = new Dictionary<string, string>();
-        //    }
-        //    using (HttpContent requestContent = new FormUrlEncodedContent(formData.ToList()))
-        //    {
-        //        return SendRequest<T>(HttpMethod.Post, uri, parameters, requestContent, this.TimeoutInSeconds);
-        //    }
-        //}
-
-        public T SendRequest<T>(HttpMethod method, String path, Dictionary<String, String> parameters, String requestBodyStr, String requestContentType, int timeoutInSeconds)
-        {
-            Dictionary<String, String> dic = new Dictionary<string, string>();
-            if (parameters != null)
-            {
-                foreach (var item in parameters)
-                {
-                    dic.Add(item.Key, item.Value);
-                }
-            }
-            // 不对body验签,添加url验签
-            //UriIdentifier uriIdentifier = HmacCommonUtils.SplitUriPrefix(path);
-            dic.Add(HmacConst.KEY_URL, path);
-            HmacResult signRlt = HmacUtils.Sign(appId, secret, dic, requestBodyStr);
-
-            String pathWithQuery = path;
-            if (parameters?.Count > 0)
-            {
-                pathWithQuery = path + "?" + String.Join("&", parameters.Select(i => $"{i.Key}={HttpUtility.UrlEncode(i.Value)}"));
-            }
-
-            HttpRequestMessage request = new HttpRequestMessage(method, baseUrl + pathWithQuery);
-            if (requestBodyStr != null)
-            {
-                StringContent requestContent = new StringContent(requestBodyStr, Encoding.UTF8, requestContentType);
-                request.Content = requestContent;
-            }
-            request.Headers.Add(HmacConst.KEY_TIMESTAMP, signRlt.TimeStamp.ToString());
-            request.Headers.Add(HmacConst.KEY_SIGN, signRlt.Sign);
-            request.Headers.Add(HmacConst.KEY_NONCE, signRlt.Nonce);
-
-            HttpResponseMessage response = null;
-            using (CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutInSeconds)))
-            {
-                response = this.httpClient.SendAsync(request, cts.Token).Result;
-            }
-            String responseText = response.Content.ReadAsStringAsync().Result;
-            if (response.StatusCode != HttpStatusCode.OK)
-            {
-                String message = $"服务错误: 状态码: {(int)response.StatusCode}, resposneText: {responseText}";
-                XopException bapiException = new XopException(message, response);
-                throw bapiException;
-            }
-
-            return JsonConvert.DeserializeObject<T>(responseText);
-        }
-
-    }
+    //       string json = JsonConvert.SerializeObject(data);
+    //        return SendRequest<T>(HttpMethod.Post, uri, parameters, json, "application/json", this.TimeoutInSeconds);
+    //    }
+
+    //    //public T PostAsForm<T>(String uri, Dictionary<String, String> parameters, Dictionary<String, String> formData)
+    //    //{
+    //    //    if (formData == null)
+    //    //    {
+    //    //        formData = new Dictionary<string, string>();
+    //    //    }
+    //    //    using (HttpContent requestContent = new FormUrlEncodedContent(formData.ToList()))
+    //    //    {
+    //    //        return SendRequest<T>(HttpMethod.Post, uri, parameters, requestContent, this.TimeoutInSeconds);
+    //    //    }
+    //    //}
+
+    //    public T SendRequest<T>(HttpMethod method, String path, Dictionary<String, String> parameters, String requestBodyStr, String requestContentType, int timeoutInSeconds)
+    //    {
+    //        Dictionary<String, String> dic = new Dictionary<string, string>();
+    //        if (parameters != null)
+    //        {
+    //            foreach (var item in parameters)
+    //            {
+    //                dic.Add(item.Key, item.Value);
+    //            }
+    //        }
+    //        // 不对body验签,添加url验签
+    //        //UriIdentifier uriIdentifier = HmacCommonUtils.SplitUriPrefix(path);
+    //        dic.Add(HmacConst.KEY_URL, path);
+    //        HmacResult signRlt = HmacUtils.Sign(appId, secret, dic, requestBodyStr);
+
+    //        String pathWithQuery = path;
+    //        if (parameters?.Count > 0)
+    //        {
+    //            pathWithQuery = path + "?" + String.Join("&", parameters.Select(i => $"{i.Key}={HttpUtility.UrlEncode(i.Value)}"));
+    //        }
+
+    //        HttpRequestMessage request = new HttpRequestMessage(method, baseUrl + pathWithQuery);
+    //        if (requestBodyStr != null)
+    //        {
+    //            StringContent requestContent = new StringContent(requestBodyStr, Encoding.UTF8, requestContentType);
+    //            request.Content = requestContent;
+    //        }
+    //        request.Headers.Add(HmacConst.KEY_TIMESTAMP, signRlt.TimeStamp.ToString());
+    //        request.Headers.Add(HmacConst.KEY_SIGN, signRlt.Sign);
+    //        request.Headers.Add(HmacConst.KEY_NONCE, signRlt.Nonce);
+
+    //        HttpResponseMessage response = null;
+    //        using (CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutInSeconds)))
+    //        {
+    //            response = this.httpClient.SendAsync(request, cts.Token).Result;
+    //        }
+    //        String responseText = response.Content.ReadAsStringAsync().Result;
+    //        if (response.StatusCode != HttpStatusCode.OK)
+    //        {
+    //            String message = $"服务错误: 状态码: {(int)response.StatusCode}, resposneText: {responseText}";
+    //            XopException bapiException = new XopException(message, response);
+    //            throw bapiException;
+    //        }
+
+    //        return JsonConvert.DeserializeObject<T>(responseText);
+    //    }
+
+    //}
 
 
 }
 }

+ 4 - 4
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -48,7 +48,7 @@ namespace TEAMModelOS.Controllers
     [ApiController]
     [ApiController]
     public class FixDataController : ControllerBase
     public class FixDataController : ControllerBase
     {
     {
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
@@ -59,7 +59,7 @@ namespace TEAMModelOS.Controllers
         private readonly HttpTrigger _httpTrigger;
         private readonly HttpTrigger _httpTrigger;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly ScsStudyApisService _scsStudyApisService;
         private readonly ScsStudyApisService _scsStudyApisService;
-        public FixDataController(HttpClient httpClient, HttpTrigger httpTrigger, AzureServiceBusFactory serviceBus, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ScsStudyApisService scsStudyApisService)
+        public FixDataController(IHttpClientFactory httpClient, HttpTrigger httpTrigger, AzureServiceBusFactory serviceBus, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ScsStudyApisService scsStudyApisService)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureRedis = azureRedis;
             _azureRedis = azureRedis;
@@ -307,10 +307,10 @@ namespace TEAMModelOS.Controllers
             jsons = Regex.Replace(jsons, @"\s", "");
             jsons = Regex.Replace(jsons, @"\s", "");
             List<JoinSchool> joins = jsons.ToObject<List<JoinSchool>>();
             List<JoinSchool> joins = jsons.ToObject<List<JoinSchool>>();
             string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
             string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
-            HttpClient client = new HttpClient();
+          
             var tmdids = joins.Select(x => x.tmdid).ToList();
             var tmdids = joins.Select(x => x.tmdid).ToList();
             var content = new StringContent(tmdids.ToJsonString(), Encoding.UTF8, "application/json");
             var content = new StringContent(tmdids.ToJsonString(), Encoding.UTF8, "application/json");
-            HttpResponseMessage responseMessage = await client.PostAsync(url, content);
+            HttpResponseMessage responseMessage = await _httpClient.CreateClient().PostAsync(url, content);
             List<Teacher> ids = null;
             List<Teacher> ids = null;
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             {
             {

+ 2 - 2
TEAMModelOS/Controllers/XTest/FixLessonRecordController.cs

@@ -46,7 +46,7 @@ namespace TEAMModelOS.Controllers.XTest
     [ApiController]
     [ApiController]
     public class FixLessonRecordController : ControllerBase
     public class FixLessonRecordController : ControllerBase
     {
     {
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         private readonly IConfiguration _configuration;
         private readonly IConfiguration _configuration;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
@@ -56,7 +56,7 @@ namespace TEAMModelOS.Controllers.XTest
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly HttpTrigger _httpTrigger;
         private readonly HttpTrigger _httpTrigger;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
-        public FixLessonRecordController(HttpClient httpClient, HttpTrigger httpTrigger, AzureServiceBusFactory serviceBus, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService)
+        public FixLessonRecordController(IHttpClientFactory httpClient, HttpTrigger httpTrigger, AzureServiceBusFactory serviceBus, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureRedis = azureRedis;
             _azureRedis = azureRedis;

+ 5 - 5
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -44,7 +44,7 @@ namespace TEAMModelOS.Controllers
     [ApiController]
     [ApiController]
     public class TestController : ControllerBase
     public class TestController : ControllerBase
     {
     {
-        private readonly HttpClient _httpClient;
+        private readonly IHttpClientFactory _httpClient;
         public IWebHostEnvironment _environment { get; set; }
         public IWebHostEnvironment _environment { get; set; }
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureRedisFactory _azureRedis;
@@ -56,7 +56,7 @@ namespace TEAMModelOS.Controllers
         private readonly IPSearcher _searcher;
         private readonly IPSearcher _searcher;
         public IConfiguration _configuration { get; set; }
         public IConfiguration _configuration { get; set; }
         private readonly IConverter _converter;
         private readonly IConverter _converter;
-        public TestController(IConverter converter, IPSearcher searcher, IOptionsSnapshot<Option> option, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, IConfiguration configuration, AzureServiceBusFactory serviceBus, DingDing dingDing)
+        public TestController(IConverter converter, IPSearcher searcher, IOptionsSnapshot<Option> option, CoreAPIHttpService coreAPIHttpService, IHttpClientFactory httpClient, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, IConfiguration configuration, AzureServiceBusFactory serviceBus, DingDing dingDing)
         {
         {
             _converter = converter;
             _converter = converter;
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
@@ -392,7 +392,7 @@ namespace TEAMModelOS.Controllers
                 Dictionary<string, object> data = new Dictionary<string, object>();
                 Dictionary<string, object> data = new Dictionary<string, object>();
                 data.Add("method", "api/School/getSchool");
                 data.Add("method", "api/School/getSchool");
                 data.Add("params", new { CountryId = "CN", CityId = region });
                 data.Add("params", new { CountryId = "CN", CityId = region });
-                HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync("https://contest.teammodel.cn/api/School/getSchool", data);
+                HttpResponseMessage responseMessage = await _httpClient.CreateClient().PostAsJsonAsync("https://contest.teammodel.cn/api/School/getSchool", data);
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 if (responseMessage.StatusCode == HttpStatusCode.OK)
                 {
                 {
                     string Content = await responseMessage.Content.ReadAsStringAsync();
                     string Content = await responseMessage.Content.ReadAsStringAsync();
@@ -504,10 +504,10 @@ namespace TEAMModelOS.Controllers
         {
         {
 
 
 
 
-            HttpClient _httpClient = new HttpClient();
+            
             //  _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
             //  _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
             var pa = new { grant_type = "device", client_id = "9794e418-c4ef-4fd5-a42d-accaa2d96d6e", client_secret = "ruL?I79h0w1AZaZXtBaZeZuQLQXLa=:-" };
             var pa = new { grant_type = "device", client_id = "9794e418-c4ef-4fd5-a42d-accaa2d96d6e", client_secret = "ruL?I79h0w1AZaZXtBaZeZuQLQXLa=:-" };
-            HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync("https://api2-rc.teammodel.net/oauth2/token", pa);
+            HttpResponseMessage responseMessage = await _httpClient.CreateClient().PostAsJsonAsync("https://api2-rc.teammodel.net/oauth2/token", pa);
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             if (responseMessage.StatusCode == HttpStatusCode.OK)
             {
             {
                 return 200;
                 return 200;

+ 2 - 2
TEAMModelOS/Startup.cs

@@ -111,8 +111,8 @@ namespace TEAMModelOS
             services.AddHttpClient<DingDing>();
             services.AddHttpClient<DingDing>();
             services.AddHttpClient<NotificationService>();
             services.AddHttpClient<NotificationService>();
             services.AddCoreAPIHttpService(Configuration);
             services.AddCoreAPIHttpService(Configuration);
-           // services.AddHttpClient<CoreAPIHttpService>();
-            services.AddHttpClient<ScsStudyApisService>();
+           //services.AddHttpClient<CoreAPIHttpService>();
+            services.AddSingleton <ScsStudyApisService>();
             services.AddHttpClient<HttpTrigger>();
             services.AddHttpClient<HttpTrigger>();
             services.AddMemoryCache();
             services.AddMemoryCache();
             services.AddSpaStaticFiles(opt => opt.RootPath = "ClientApp/dist");
             services.AddSpaStaticFiles(opt => opt.RootPath = "ClientApp/dist");

+ 8 - 8
TEAMModelOS/appsettings.Development.json

@@ -21,22 +21,22 @@
   },
   },
   "Azure": {
   "Azure": {
     "Storage": {
     "Storage": {
-      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn"
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn"
     },
     },
     "Cosmos": {
     "Cosmos": {
-      "ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;"
+      "ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;"
     },
     },
     "Redis": {
     "Redis": {
-      "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
+      "ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False"
     },
     },
     "ServiceBus": {
     "ServiceBus": {
-      "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
-      "ActiveTask": "dep-active-task",
-      "ItemCondQueue": "dep-itemcond",
-      "GenPdfQueue": "dep-genpdf"
+      "ConnectionString": "Endpoint=sb://coreiotservicebuscnpro.servicebus.chinacloudapi.cn/;SharedAccessKeyName=TEAMModelOS;SharedAccessKey=llRPBMDJG9w1Nnifj+pGhV0g4H2REcq0PjvX2qqpcOg=",
+      "ActiveTask": "active-task",
+      "ItemCondQueue": "itemcond",
+      "GenPdfQueue": "genpdf"
     },
     },
     "SignalR": {
     "SignalR": {
-      "ConnectionString": "Endpoint=https://channel.service.signalr.net;AccessKey=KrblW06tuA4a/GyqRPDU0ynFFmAWxbAvyJihHclSXbQ=;Version=1.0;"
+      "ConnectionString": "Endpoint=https://channel.signalr.azure.cn;AccessKey=AtcB7JYFNUbUXb1rGxa3PVksQ2X5YSv3JOHZR9J88tw=;Version=1.0;"
     }
     }
   },
   },
   "HaBookAuth": {
   "HaBookAuth": {