소스 검색

修正醍摩豆帳號IOT統計API報錯問題

jeff 3 달 전
부모
커밋
f60e3fb1ed
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      TEAMModelBI/Controllers/BIProductAnalysis/ProductAnalysisController.cs

+ 3 - 3
TEAMModelBI/Controllers/BIProductAnalysis/ProductAnalysisController.cs

@@ -157,10 +157,10 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                             {
                             {
                                 string tmid = obj.GetProperty("id").ToString();
                                 string tmid = obj.GetProperty("id").ToString();
                                 string schoolId = string.Empty;
                                 string schoolId = string.Empty;
-                                var schoolCode = Convert.ToString(obj.GetProperty("schoolCode"));
-                                var schoolCodeW = Convert.ToString(obj.GetProperty("schoolCodeW"));
+                                var schoolCode = (obj.TryGetProperty("schoolCode", out JsonElement _schoolCode)) ? Convert.ToString(_schoolCode) : string.Empty;
+                                var schoolCodeW = (obj.TryGetProperty("schoolCodeW", out JsonElement _schoolCodeW)) ? Convert.ToString(_schoolCodeW) : string.Empty;
                                 if (!string.IsNullOrWhiteSpace(schoolCode)) schoolId = schoolCode;
                                 if (!string.IsNullOrWhiteSpace(schoolCode)) schoolId = schoolCode;
-                                else if(!string.IsNullOrWhiteSpace(schoolCodeW)) schoolId = schoolCodeW;
+                                else if (!string.IsNullOrWhiteSpace(schoolCodeW)) schoolId = schoolCodeW;
                                 if (!string.IsNullOrWhiteSpace(schoolId))
                                 if (!string.IsNullOrWhiteSpace(schoolId))
                                 {
                                 {
                                     tmidSchidDic.Add(tmid, schoolId);
                                     tmidSchidDic.Add(tmid, schoolId);