CrazyIter_Bin 2 năm trước cách đây
mục cha
commit
fa6062a8e6

+ 14 - 18
TEAMModelOS.SDK/DI/StudyAPI/ScsStudyApisService.cs

@@ -31,12 +31,12 @@ namespace TEAMModelOS.SDK.DI
         //private readonly IWebHostEnvironment _environment;
         public bool check = true;
         private SnowflakeId _snowflakeId;
-        private readonly IHttpClientFactory _httpClient;
+        private readonly HttpClient _httpClient;
       
         //private readonly IConfiguration _configuration;
         // private readonly DI.DingDing _dingDing;
         //public readonly Option _option;
-        public ScsStudyApisService(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage,   AzureRedisFactory azureRedis, IHttpClientFactory httpClient,   SnowflakeId snowflakeId)
+        public ScsStudyApisService(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage,   AzureRedisFactory azureRedis, HttpClient httpClient,   SnowflakeId snowflakeId)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
@@ -507,32 +507,28 @@ namespace TEAMModelOS.SDK.DI
             parameterMap.Add("Tid", $"{tid}");
             ScsResult result = new ScsResult { bizcode = Code, title = "5.3.1.11获取跳转学员信息,用于sso单点,后端验证。" };
             try
-            {
-                ///{“result”:true,”reason”:null,”content”:”{“PXID”:””,”TID”:””,”TeacherName”:””,”ProjectTitle”:””,”ProjectItemTitle”:””,”CityName”:””,
-                ///”DisName”:””,”SchoolName”:””,”Sex”:””,”PXXK”:””,”PXXD”:””,”TeacherXK”:””,”TeacherXD”:””,”Email”:””}”,”pagecount”:1}
-                result = await ThirdApisService.Post(_httpClient,config.url, Code, config.passKey, config.privateKey, parameterMap);
-                if (result.result)
-                {
-                    teacher = result.content;
-                }
-                //await response.WriteAsJsonAsync(new { data = teacher });
-                return (200, teacher);
-            }
-            catch (Exception ex)
             {
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
                 List<ScTeacher> teachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "RowKey", $"{pxid}" } });
                 if (teachers.IsNotEmpty())
                 {
                     teacher = teachers[0].ToJsonString();
-                    return (200, teacher);
                 }
                 else {
-                    await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSingleTeacherByProject\n{ex.Message}\n{ex.StackTrace}\n{result.ToJsonString()}\n", GroupNames.醍摩豆服務運維群組);
-                    return (500, teacher);
+                    result = await ThirdApisService.Post(_httpClient, config.url, Code, config.passKey, config.privateKey, parameterMap);
+                    if (result.result)
+                    {
+                        teacher = result.content;
+                    }
                 }
+                return (200, teacher);
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSingleTeacherByProject\n{ex.Message}\n{ex.StackTrace}\n{result.ToJsonString()}\n", GroupNames.醍摩豆服務運維群組);
+                return (500, teacher);
                 //await response.WriteAsJsonAsync(new { data = teacher });
-               
+
             }
         }
 

+ 2 - 2
TEAMModelOS.SDK/Models/Service/Third/ThirdApisService.cs

@@ -17,7 +17,7 @@ namespace TEAMModelOS.SDK
     {
        
      //   private readonly IHttpClientFactory _httpClient;
-        public async static   Task<ScsResult> Post(IHttpClientFactory  _httpClient, string url, string Code, string PassKey,string privateKey, Dictionary<string ,object> data)
+        public async static   Task<ScsResult> Post(HttpClient _httpClient, string url, string Code, string PassKey,string privateKey, Dictionary<string ,object> data)
         {
             string result = "";
             HttpResponseMessage response=null;
@@ -35,7 +35,7 @@ namespace TEAMModelOS.SDK
                 string signatureStr = signatureDC.ToJsonString();
                 string signature = AESHelper.AESEncrypt(signatureStr, privateKey);
                 #endregion
-                var client = _httpClient.CreateClient();
+                var client = _httpClient;
                 client.DefaultRequestHeaders.Add("Signature", signature);
                 var request = new HttpRequestMessage();
                 request.Method = new HttpMethod("POST");

+ 1 - 5
TEAMModelOS/Controllers/Third/Sc/ScController.cs

@@ -55,13 +55,11 @@ namespace TEAMModelOS.Controllers
         private readonly AzureRedisFactory _azureRedis;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         public readonly string type = "scsyxpt";
-        private readonly HttpTrigger _httpTrigger;
-        private readonly IWebHostEnvironment _environment;
         private readonly ScsStudyApisService _scsStudyApisService;
 
         public IConfiguration _configuration { get; set; }
         public ScController(ScsStudyApisService scsStudyApisService, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
-          AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService,  HttpTrigger httpTrigger)
+          AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService )
         {
             _azureCosmos = azureCosmos;
             _snowflakeId = snowflakeId;
@@ -72,8 +70,6 @@ namespace TEAMModelOS.Controllers
             _configuration = configuration;
             _azureRedis = azureRedis;
             _coreAPIHttpService = coreAPIHttpService;
-            _httpTrigger = httpTrigger;
-            _environment = environment;
             _scsStudyApisService = scsStudyApisService;
         }
 

+ 1 - 1
TEAMModelOS/Startup.cs

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