CrazyIter_Bin 3 years ago
parent
commit
e758555b92

+ 2 - 2
TEAMModelFunction/ScsApisHttpTrigger.cs

@@ -76,7 +76,7 @@ namespace TEAMModelFunction
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"IES5.ScApisService:getDiagnosisListByProject_V2\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:getDiagnosisListByProject_V2\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}", GroupNames.成都开发測試群組);
                 return new OkObjectResult(abilityNos);
             }
         }
@@ -114,7 +114,7 @@ namespace TEAMModelFunction
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"IES5.ScApisService:GetSingleTeacherByProject\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSingleTeacherByProject\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}", GroupNames.成都开发測試群組);
                 return new OkObjectResult(teacher);
             }
         }

+ 5 - 0
TEAMModelOS.SDK/DI/CoreAPI/CoreAPIHttpService.cs

@@ -37,6 +37,11 @@ namespace TEAMModelOS.SDK.Models.Service
                 location = "Global";
             }
             var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
+            if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
+            {
+                _httpClient.DefaultRequestHeaders.Remove("Authorization");
+               
+            }
             _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
             HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(url, data);
             if (responseMessage.StatusCode == HttpStatusCode.OK)

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

@@ -58,7 +58,7 @@ namespace TEAMModelOS.SDK
                 }
                 return scsResult;
             } catch (Exception ex ) {
-                throw new Exception(ex.StackTrace);
+                throw new Exception($"{ex.Message}\n{ex.StackTrace}\n{data.ToJsonString()}\n{url}\n {Code}\n{PassKey}\n{privateKey}");
             }
             
         }

+ 29 - 5
TEAMModelOS/Controllers/Third/ScController.cs

@@ -107,23 +107,47 @@ namespace TEAMModelOS.Controllers.Third
             {
                 teachers.Add(item);
             }
+            var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+            var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
+            var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
+            var location = _option.Location;
             List<string> unbind = new List<string>();
+            List<string> list = new List<string>();
+            (int code, string content) = await _accountHttpService.Implicit(clientID, clientSecret, location, $"{url}/oauth2/implicit",
+                       new Dictionary<string, string>()
+                       {
+                        { "grant_type", "implicit" },
+                        { "client_id",clientID },
+                        { "account","1639025968" },
+                        { "nonce",Guid.NewGuid().ToString()}
+                       });
+             
             foreach (var teacher in teachers)
             {
                 var a = teacher.binds.SelectMany(y => y.data).ToList().Find(x => !string.IsNullOrEmpty(x));
                 if (a != null)
                 {
-                    await _azureStorage.UploadFileByContainer("teammodelos", a, $"yxpt/scpjx/scbind", $"{teacher.id}.json");
+                  //  await _azureStorage.UploadFileByContainer("teammodelos", a, $"yxpt/scpjx/scbind", $"{teacher.id}.json");
                 }
                 else
                 {
-                   // unbind.
+                   unbind.Add(teacher.id);
                     }
-
+                //(int code, string content) = await _accountHttpService.Implicit(clientID, clientSecret, location, $"{url}/oauth2/implicit",
+                //       new Dictionary<string, string>()
+                //       {
+                //        { "grant_type", "implicit" },
+                //        { "client_id",clientID },
+                //        { "account",teacher.id },
+                //        { "nonce",Guid.NewGuid().ToString()}
+                //       });
+                //if (content.Contains("error")) {
+                //    unbind.Add(teacher.id);
+                //}
+                //list.Add(content);
             }
             await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败,出现的原因可能是 参数异常:\n{unbind.ToJsonString()}", GroupNames.成都开发測試群組);
-
-            return Ok();
+            return Ok(new { unbind ,list});
         }
 
         /// <summary>