Parcourir la source

Merge branch 'develop' into develop_local

jeff il y a 11 mois
Parent
commit
b218c65f06
100 fichiers modifiés avec 1373 ajouts et 1152 suppressions
  1. 1 1
      TEAMModelBI/ClientApp/package.json
  2. 41 11
      TEAMModelBI/ClientApp/src/view/issueCoupons/crteadCoupon.vue
  3. 3 3
      TEAMModelBI/ClientApp/src/view/product/details.vue
  4. 2 2
      TEAMModelBI/ClientApp/src/view/product/index.vue
  5. 3 3
      TEAMModelBI/ClientApp/src/view/userInquire/iot.vue
  6. 6 6
      TEAMModelBI/Controllers/BICommon/BINoticeController.cs
  7. 3 3
      TEAMModelBI/Controllers/BICommon/BIProductUseRecordController.cs
  8. 6 9
      TEAMModelBI/Controllers/BICommon/JointlyController.cs
  9. 2 2
      TEAMModelBI/Controllers/BICommon/StatsNoticeController.cs
  10. 10 10
      TEAMModelBI/Controllers/BIHome/HomeStatisController.cs
  11. 3 3
      TEAMModelBI/Controllers/BIHome/OnLineController.cs
  12. 6 6
      TEAMModelBI/Controllers/BINormal/AbilityMgmtController.cs
  13. 8 8
      TEAMModelBI/Controllers/BINormal/AbilityTaskMgmtController.cs
  14. 21 21
      TEAMModelBI/Controllers/BINormal/AreaRelevantController.cs
  15. 61 61
      TEAMModelBI/Controllers/BINormal/BatchAreaController.cs
  16. 14 14
      TEAMModelBI/Controllers/BINormal/BusinessConfigController.cs
  17. 11 11
      TEAMModelBI/Controllers/BINormal/BusinessUsersController.cs
  18. 14 14
      TEAMModelBI/Controllers/BIProductAnalysis/ProductAnalysisController.cs
  19. 63 63
      TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs
  20. 3 3
      TEAMModelBI/Controllers/BISchool/RoomController.cs
  21. 92 92
      TEAMModelBI/Controllers/BISchool/SchoolController.cs
  22. 1 1
      TEAMModelBI/Controllers/BIStudent/StuActivityController.cs
  23. 5 5
      TEAMModelBI/Controllers/BIStudent/StudentController.cs
  24. 4 4
      TEAMModelBI/Controllers/BITable/BIOpenApiController.cs
  25. 9 10
      TEAMModelBI/Controllers/BITable/DDStructController.cs
  26. 2 2
      TEAMModelBI/Controllers/BITable/IES5OAuthController.cs
  27. 2 2
      TEAMModelBI/Controllers/BITable/OperateLogController.cs
  28. 18 18
      TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs
  29. 5 5
      TEAMModelBI/Controllers/BITeacher/TeacherController.cs
  30. 13 12
      TEAMModelBI/Controllers/BITest/Ies5TestController.cs
  31. 26 26
      TEAMModelBI/Controllers/BITest/TestController.cs
  32. 32 30
      TEAMModelBI/Controllers/BITmid/TmidController.cs
  33. 18 18
      TEAMModelBI/Controllers/Census/ActivitySticsController.cs
  34. 2 2
      TEAMModelBI/Controllers/Census/BlobLogController.cs
  35. 21 21
      TEAMModelBI/Controllers/Census/ItemSticsController.cs
  36. 35 35
      TEAMModelBI/Controllers/Census/LessonSticsController.cs
  37. 18 18
      TEAMModelBI/Controllers/Census/PaperController.cs
  38. 26 26
      TEAMModelBI/Controllers/Census/ProductStatisController.cs
  39. 48 48
      TEAMModelBI/Controllers/Census/SchoolController.cs
  40. 3 3
      TEAMModelBI/Controllers/LoginController.cs
  41. 8 8
      TEAMModelBI/Controllers/RepairApi/InitialAreaController.cs
  42. 2 2
      TEAMModelBI/Controllers/RepairApi/NormalController.cs
  43. 15 15
      TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs
  44. 5 5
      TEAMModelBI/Controllers/RepairApi/TeacherREPController.cs
  45. 0 1
      TEAMModelBI/Filter/RequestAuditFilter.cs
  46. 0 1
      TEAMModelBI/Startup.cs
  47. 22 21
      TEAMModelBI/Tool/CommonFind.cs
  48. 8 7
      TEAMModelBI/Tool/CosmosBank/ActivityWay.cs
  49. 5 4
      TEAMModelBI/Tool/CosmosBank/JointlySingleQuery1.cs
  50. 4 3
      TEAMModelBI/Tool/CosmosBank/ProductWay.cs
  51. 4 3
      TEAMModelBI/Tool/CosmosBank/SchoolWay.cs
  52. 11 10
      TEAMModelBI/Tool/CosmosBank/StatsWay.cs
  53. 19 19
      TEAMModelOS.Function/CosmosDBTriggers/TriggerArt.cs
  54. 17 17
      TEAMModelOS.Function/CosmosDBTriggers/TriggerCorrect.cs
  55. 31 31
      TEAMModelOS.Function/CosmosDBTriggers/TriggerExam.cs
  56. 1 1
      TEAMModelOS.Function/CosmosDBTriggers/TriggerExamImport.cs
  57. 7 6
      TEAMModelOS.Function/CosmosDBTriggers/TriggerExamLite.cs
  58. 8 8
      TEAMModelOS.Function/CosmosDBTriggers/TriggerHomework.cs
  59. 1 1
      TEAMModelOS.Function/CosmosDBTriggers/TriggerQuotaImport.cs
  60. 9 9
      TEAMModelOS.Function/CosmosDBTriggers/TriggerStudy.cs
  61. 8 8
      TEAMModelOS.Function/CosmosDBTriggers/TriggerSurvey.cs
  62. 6 6
      TEAMModelOS.Function/CosmosDBTriggers/TriggerVote.cs
  63. 1 1
      TEAMModelOS.Function/IESCosmosDBTrigger.cs
  64. 9 9
      TEAMModelOS.Function/IESHttpTrigger.cs
  65. 36 36
      TEAMModelOS.Function/IESServiceBusTrigger.cs
  66. 3 3
      TEAMModelOS.Function/IESTimerTrigger.cs
  67. 1 1
      TEAMModelOS.Function/TEAMModelOS.Function.csproj
  68. 6 6
      TEAMModelOS.SDK/Context/Attributes/Filter/ApiTokenAttribute.cs
  69. 217 86
      TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosExtensions.cs
  70. 63 15
      TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosFactory.cs
  71. 1 1
      TEAMModelOS.SDK/DI/AzureCosmos/Inner/AzureCosmosQuery.cs
  72. 0 1
      TEAMModelOS.SDK/DI/AzureRedis/AzureRedisExtensions.cs
  73. 5 4
      TEAMModelOS.SDK/DI/AzureStorage/AzureStorageBlobExtensions.cs
  74. 2 1
      TEAMModelOS.SDK/DI/AzureStorage/AzureStorageTableExtensions.cs
  75. 4 4
      TEAMModelOS.SDK/DI/Mail/MailFactory.cs
  76. 1 1
      TEAMModelOS.SDK/Models/Cosmos/School/Class.cs
  77. 6 1
      TEAMModelOS.SDK/Models/Cosmos/School/ScoreCalc.cs
  78. 6 6
      TEAMModelOS.SDK/Models/Service/ArtService.cs
  79. 9 9
      TEAMModelOS.SDK/Models/Service/BI/BILeesonService.cs
  80. 13 13
      TEAMModelOS.SDK/Models/Service/BI/BIProdAnalysis.cs
  81. 1 1
      TEAMModelOS.SDK/Models/Service/BI/BISchoolService.cs
  82. 24 23
      TEAMModelOS.SDK/Models/Service/BI/BIStats.cs
  83. 6 6
      TEAMModelOS.SDK/Models/Service/BI/BIStatsNotice.cs
  84. 23 22
      TEAMModelOS.SDK/Models/Service/BI/CosmosQueryHelper.cs
  85. 5 5
      TEAMModelOS.SDK/Models/Service/BI/JointlySingleQuery.cs
  86. 9 9
      TEAMModelOS.SDK/Models/Service/BI/LessonStatisWay.cs
  87. 4 4
      TEAMModelOS.SDK/Models/Service/BI/ProductUseRecordService.cs
  88. 6 6
      TEAMModelOS.SDK/Models/Service/BIStatsWay/ActivityStatsWay.cs
  89. 3 3
      TEAMModelOS.SDK/Models/Service/BIStatsWay/LessonRecordStatsWay.cs
  90. 3 3
      TEAMModelOS.SDK/Models/Service/BIStatsWay/SchoolStatsWay.cs
  91. 6 6
      TEAMModelOS.SDK/Models/Service/BIStatsWay/StudyStatsWay.cs
  92. 3 3
      TEAMModelOS.SDK/Models/Service/BIStatsWay/UserStatsWay.cs
  93. 9 9
      TEAMModelOS.SDK/Models/Service/Common/ActivityService.cs
  94. 10 10
      TEAMModelOS.SDK/Models/Service/Common/ActivityStudentService.cs
  95. 5 5
      TEAMModelOS.SDK/Models/Service/Common/BlobService.cs
  96. 4 4
      TEAMModelOS.SDK/Models/Service/Common/SheetService.cs
  97. 3 3
      TEAMModelOS.SDK/Models/Service/Common/SyllabusService.cs
  98. 11 11
      TEAMModelOS.SDK/Models/Service/Common/TeacherService.cs
  99. 3 3
      TEAMModelOS.SDK/Models/Service/Common/WebHookService.cs
  100. 0 0
      TEAMModelOS.SDK/Models/Service/ErrorItemsService.cs

+ 1 - 1
TEAMModelBI/ClientApp/package.json

@@ -4,7 +4,7 @@
     "private": true,
     "scripts": {
         "serve": "vue-cli-service serve",
-        "build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
+        "build": "vue-cli-service build",
         "lint": "vue-cli-service lint"
     },
     "dependencies": {

+ 41 - 11
TEAMModelBI/ClientApp/src/view/issueCoupons/crteadCoupon.vue

@@ -11,20 +11,21 @@
             </el-form-item>
             <el-form-item v-if="!detailSettingFlag" label="活動票券" prop="eventType">
                 <el-radio-group v-model="eventType" @change="setEventType" style="max-width: 1000px;max-height: 115px;overflow-y:scroll;">
-                    <el-radio label="hiteach50-3"  border>Hiteach 50 第三階段</el-radio>
-                    <el-radio label="hiteach333-1"  border>HiTeach 333 第一階段</el-radio>
-                    <el-radio label="hiteach333-3"  border>HiTeach 333 第三階段</el-radio>
-                    <el-radio label="hiteachBookSPLicense"  border>HiTeach專書贈送授權</el-radio>
-                    <el-radio label="fbGroupOpening"  border>HiTeach社團開幕活動</el-radio>
-                    <el-radio label="giftWebIRS501M"  border>贈送WEBIRS50一個月</el-radio>
-                    <el-radio label="giftWebIRS503M"  border>贈送WEBIRS50三個月</el-radio>
-                    <el-radio label="giftSmart3M"  border>贈送智慧評分三個月</el-radio>
-                    <el-radio label="giftSmart1Y"  border>贈送智慧評分一年</el-radio>
-                    <el-radio label="gifCollaboration3M"  border>贈送協作三個月</el-radio>
-                    <el-radio label="gifCollaboration1Y"  border>贈送協作一年</el-radio>
+                    <el-radio class="event1" label="hiteach50-3"  border>Hiteach 50 第三階段</el-radio>
+                    <el-radio class="event1" label="hiteach333-1"  border>HiTeach 333 第一階段</el-radio>
+                    <el-radio class="event1" label="hiteach333-3"  border>HiTeach 333 第三階段</el-radio>                    
+                    <el-radio class="event2" label="giftWebIRS501M"  border>贈送WEBIRS50一個月</el-radio>
+                    <el-radio class="event2" label="giftWebIRS503M"  border>贈送WEBIRS50三個月</el-radio>
+                    <el-radio class="event2" label="giftWebIRS501Y"  border>贈送WEBIRS50一年</el-radio>
+                    <el-radio class="event3" label="giftSmart3M"  border>贈送智慧評分三個月</el-radio>
+                    <el-radio class="event3" label="giftSmart1Y"  border>贈送智慧評分一年</el-radio>
+                    <el-radio class="event4" label="gifCollaboration3M"  border>贈送協作三個月</el-radio>
+                    <el-radio class="event4" label="gifCollaboration1Y"  border>贈送協作一年</el-radio>
                     <el-radio label="gifAIGPT1Y"  border>贈送AIGPT一年</el-radio>
                     <el-radio label="gifVoiceToText1Y"  border>贈送語音轉錄文字一年</el-radio>
                     <el-radio label="gifAITXTAnalysis3M"  border>贈送AI文句分析三個月</el-radio>
+                    <el-radio label="hiteachBookSPLicense"  border>HiTeach專書贈送授權</el-radio>
+                    <el-radio label="fbGroupOpening"  border>HiTeach社團開幕活動</el-radio>
                 </el-radio-group>
             </el-form-item>
             <el-form-item v-if="detailSettingFlag" label="票券類型" prop="couponType" >
@@ -387,6 +388,17 @@ const setEventType = (type)=>{
             crtCouponForm.info[2].l = 'en-us'
             crtCouponForm.info[2].u = 'https://www.habook.com/en/'
         break
+        case 'giftWebIRS501Y':
+            crtCouponForm.couponType =  'Event'
+            crtCouponForm.eventName = 'giftWebIRS501Y'
+            crtCouponForm.rule[0].b = '901013'
+            crtCouponForm.info[0].l = 'zh-tw' 
+            crtCouponForm.info[0].u = 'https://www.habook.com/zh-tw'
+            crtCouponForm.info[1].l = 'zh-cn'
+            crtCouponForm.info[1].u = 'https://www.habook.com.cn/'
+            crtCouponForm.info[2].l = 'en-us'
+            crtCouponForm.info[2].u = 'https://www.habook.com/en/'
+        break
         case 'giftSmart3M':
             crtCouponForm.couponType =  'Event'
             crtCouponForm.eventName = 'giftSmart3M'
@@ -520,6 +532,7 @@ const ruleBList = [
     { label: "Web IRS 50人(3個月+75天- 50券STEP3專用)", val: "901009"},
     { label: "小組協作(三個月)", val: "901011"},
     { label: "AI文句分析(三個月)", val: "901012"},
+    { label: "Web IRS 50人 (一年)", val: "901013"},
 ]
 
 const crtCouponForm = reactive({
@@ -1014,6 +1027,23 @@ const copyDocument = (data) => {
 </script>
 
 <style scoped>
+.event1{
+    background-color: #03a9f4;
+    color: #fff;
+}
+.event2{
+    background-color: #26c6da;
+    color: #fff;
+}
+.event3{
+    background-color: #7986cb;
+    color: #fff;
+}
+.event4{
+    background-color: #66bb6a;
+    color: #fff;
+}
+
 .ruleBox{
     display: flex;
     flex-direction: row;

+ 3 - 3
TEAMModelBI/ClientApp/src/view/product/details.vue

@@ -719,8 +719,8 @@ let classType = ref([
   { name: '测验型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
   { name: '协作型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
   { name: '互评型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
-  { name: '无型态课堂', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
-  { name: '未上课', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+  { name: '教材展示', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+  { name: '白板应用', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
 ])
 let echartData = ref({
   total: 0,
@@ -771,7 +771,7 @@ let echartData = ref({
         }
       },
       boundaryGap: true, // 坐标轴两边是否留白
-      data: ['合作型态', '互动型态', '任务型态', '差异化型态', '测验型态', '协作', '互评', '无型态', '未上课']
+      data: ['合作型态', '互动型态', '任务型态', '差异化型态', '测验型态', '协作', '互评', '教材展示', '白板应用']
     },
     yAxis: [
       {

+ 2 - 2
TEAMModelBI/ClientApp/src/view/product/index.vue

@@ -1291,8 +1291,8 @@ function exportExcel () {
     { label: '任务型态', key: 'lTypeMis' },
     { label: '差异化型态', key: 'lTypeDif' },
     { label: '测验型态', key: 'lTypeTst' },
-    { label: '无型态', key: 'lTypeNone' },
-    { label: '未上课', key: 'lTypeNone' },
+    { label: '教材展示', key: 'lTypeNone' },
+    { label: '白板应用', key: 'lTypeNone' },
   ]
   fieldList.value.forEach((item) => {
     exportList.value.forEach((items) => {

+ 3 - 3
TEAMModelBI/ClientApp/src/view/userInquire/iot.vue

@@ -516,8 +516,8 @@
     { name: '差异化形态课堂', value: 20, percent: '5%', class: 'interaction', textClass: 'interaction-text' },
     { name: '协作型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
     { name: '互评型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
-    { name: '无型态课堂', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
-    { name: '未上课', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+    { name: '教材展示', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+    { name: '白板应用', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
   ])
   let echartData = ref({
     total: 0,
@@ -568,7 +568,7 @@
           }
         },
         boundaryGap: true, // 坐标轴两边是否留白
-        data: ['合作', '互动', '任务', '差异化', '协作','互评', '无型态', '未上课']
+        data: ['合作', '互动', '任务', '差异化', '协作','互评', '教材展示', '白板应用']
       },
       yAxis: [
         {

+ 6 - 6
TEAMModelBI/Controllers/BICommon/BINoticeController.cs

@@ -17,7 +17,7 @@ using TEAMModelBI.Models;
 using System.Linq;
 using TEAMModelBI.Filter;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
@@ -103,7 +103,7 @@ namespace TEAMModelBI.Controllers.BICommon
             List<IdInfo> idInfos = new();
             var cosmosClient = _azureCosmos.GetCosmosClient();
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<IdInfo>(queryText: "select c.id,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<IdInfo>(queryText: "select c.id,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
             {
                 idInfos.Add(item);
             }
@@ -174,7 +174,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     if (tmdIds.Count > 0)
                     {
                         tchSql.Append(BICommonWay.ManyScSql(" where c.id ", tmdIds.Select(s => s.id).ToList()));
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<IdNameCode>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<IdNameCode>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item.id)).ToList();
                             if (tempId.Count == 0)
@@ -189,7 +189,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     if (schoolIds.Count > 0)
                     {
                         scAreaSql.Append(BICommonWay.ManyScSql(" where c.areaId", areaIds.Select(s => s.id).ToList()));
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: scAreaSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: scAreaSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             var tempScId = schoolIds.FindAll(fa => fa.Equals(item)).ToList();
                             if (tempScId.Count == 0)
@@ -204,7 +204,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     if (schoolIds.Count > 0)
                     {
                         scTchSql.Append(BICommonWay.ManyScSql(" and c.code", schoolIds.Select(s => s.id).ToList(), $"Teacher-"));
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<IdNameCode>(queryText: scTchSql.ToString(), requestOptions: new QueryRequestOptions() { }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<IdNameCode>(queryText: scTchSql.ToString(), requestOptions: new QueryRequestOptions() { }))
                         {
                             var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item.id)).ToList();
                             if (tempId.Count == 0)
@@ -266,7 +266,7 @@ namespace TEAMModelBI.Controllers.BICommon
                 sql.Append($" where c.id='{id}'");
 
             sql.Append($" order by c.sendTime desc ");
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<BINotice>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BINotice") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<BINotice>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BINotice") }))
             {
                 bINotices.Add(item);
             }

+ 3 - 3
TEAMModelBI/Controllers/BICommon/BIProductUseRecordController.cs

@@ -12,7 +12,7 @@ using TEAMModelOS.SDK.Context.Constant;
 using System.Threading.Tasks;
 using System;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Extension;
 using System.Collections.Generic;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
@@ -70,9 +70,9 @@ namespace TEAMModelBI.Controllers.BICommon
             ProductUseRecord productUseRecord = null;
             UseRecord useRecord = new();
             var resUseRecord = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{year}", new PartitionKey("ProductUseRecord"));
-            if (resUseRecord.Status == 200)
+            if (resUseRecord.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(resUseRecord.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(resUseRecord.Content);
                 productUseRecord = fileJson.ToObject<ProductUseRecord>();
             }
 

+ 6 - 9
TEAMModelBI/Controllers/BICommon/JointlyController.cs

@@ -1,5 +1,4 @@
-using Azure.Cosmos;
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using System.Collections.Generic;
@@ -8,7 +7,7 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
-
+using Microsoft.Azure.Cosmos;
 namespace TEAMModelBI.Controllers.BICommon
 {
     [Route("jointly")]
@@ -49,9 +48,9 @@ namespace TEAMModelBI.Controllers.BICommon
             {
                 foreach (var temp in types)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", _containers[temp]).GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", _containers[temp]).GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -66,9 +65,9 @@ namespace TEAMModelBI.Controllers.BICommon
             {
                 foreach (var contaoner in _containers)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", contaoner).GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", contaoner).GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -79,9 +78,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     }
                 }
             }
-
             return Ok(new { state = 200, infos = objs });
         }
-
     }
 }

+ 2 - 2
TEAMModelBI/Controllers/BICommon/StatsNoticeController.cs

@@ -11,7 +11,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Context.Constant;
 using System;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
 using System.Collections.Generic;
@@ -80,7 +80,7 @@ namespace TEAMModelBI.Controllers.BICommon
                 }
                 List<StatsNotice> statsNotices = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<StatsNotice>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StatsNotice") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<StatsNotice>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StatsNotice") }))
                 {
                     statsNotices.Add(item);
                 }

+ 10 - 10
TEAMModelBI/Controllers/BIHome/HomeStatisController.cs

@@ -6,7 +6,7 @@ using System.Linq;
 using System.Threading.Tasks;
 using System.Text.Json;
 using TEAMModelOS.SDK.DI;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.Extensions.Options;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.Models;
@@ -88,9 +88,9 @@ namespace TEAMModelBI.Controllers.BIHome
                 //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
                 List<ProvinceStandard> standards = new();
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: $"select c.provCode,c.provName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIteratorSql(queryText: $"select c.provCode,c.provName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
@@ -199,7 +199,7 @@ namespace TEAMModelBI.Controllers.BIHome
 
                 List<CityStandard> standards = new();
                 //查询省份区域
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select c.id,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     CityStandard Citystics = new CityStandard
                     {
@@ -268,7 +268,7 @@ namespace TEAMModelBI.Controllers.BIHome
 
                 List<DistrictStandard> districtStandards = new();
                 //查询省份区域
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select c.id,c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     DistrictStandard districtStandard = new()
                     {
@@ -340,7 +340,7 @@ namespace TEAMModelBI.Controllers.BIHome
 
                 List<AllCityStics> tempAllCityStics = new();
                 //查询省份区域
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.name,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select c.id,c.name,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     AllCityStics Citystics = new()
                     {
@@ -473,10 +473,10 @@ namespace TEAMModelBI.Controllers.BIHome
                 //查询学校已使用空间大小
                 foreach (var itemId in schoolId)
                 {
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{itemId}") }))
                     {
-                        var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
@@ -591,9 +591,9 @@ namespace TEAMModelBI.Controllers.BIHome
                 ////教师数据
                 //List<string> teacherId = new List<string>(); //教师Id集合
                 ////查询教师的大小和教师集合信息
-                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorSql(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 //{
-                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(item.Content);
                 //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 //    {
                 //        totalSize += obj.GetProperty("size").GetInt64();

+ 3 - 3
TEAMModelBI/Controllers/BIHome/OnLineController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Models;
 using Microsoft.AspNetCore.Http;
@@ -521,12 +521,12 @@ namespace TEAMModelBI.Controllers.BIHome
          
 
             var ScSql = $"select c.id,c.name,c.size,c.scale, c.edition, c.service from c";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
             {
                 scEdCnt.Add(item);
             }
             
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
             {
                 scEdCnt.Add(item);
             }          

+ 6 - 6
TEAMModelBI/Controllers/BINormal/AbilityMgmtController.cs

@@ -10,7 +10,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using System.Text.Json;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelBI.Filter;
@@ -62,7 +62,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                 List<Ability> abilities = new();
                 string sqltxt = "select value(c) from c";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
                 {
                     abilities.Add(item);
                 }
@@ -140,7 +140,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 List<AbilityTask> syllabus = new();
                 string sql = $"select value(c) from c where c.abilityId='{id}'";
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Ability-{standard}"));
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
                 {
                     syllabus.Add(item);
                 }
@@ -149,14 +149,14 @@ namespace TEAMModelBI.Controllers.BINormal
                     var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"AbilityTask-{standard}");
                 }
 
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     //保存操作记录
                     await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "abilityTask-del", $"{_tmdName}【{_tmdId}】删除册别,删除ID:{id}", _dingDing, httpContext: HttpContext);
 
                     return Ok(new { state = 200 });
                 }
-                else return Ok(new { state = response.Status });
+                else return Ok(new { state = response.StatusCode });
             }
             catch (Exception ex)
             {
@@ -213,7 +213,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     {
                         sqltxt.Append($" and c.dimension = '{ability.dimension}' and c.name = '{ability.name}'  and c.no = '{ability.no}' ");
                         List<Ability> abilities = new List<Ability>();
-                        await foreach (var item in azureClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: sqltxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(ability.code) }))
+                        await foreach (var item in azureClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: sqltxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(ability.code) }))
                         {
                             abilities.Add(item);
                         }

+ 8 - 8
TEAMModelBI/Controllers/BINormal/AbilityTaskMgmtController.cs

@@ -10,7 +10,6 @@ using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using System.Text.Json;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using System.Text;
 using TEAMModelBI.Filter;
@@ -19,6 +18,7 @@ using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK;
+using Microsoft.Azure.Cosmos;
 
 namespace TEAMModelBI.Controllers.BINormal
 {
@@ -76,7 +76,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 {
                     return Ok(new { state = 400,message="该ID未找到章节" });
                 }
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c where c.abilityId='{abilityId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c where c.abilityId='{abilityId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
                 {
                     var rns = item.children.Select(x => x.rnodes);
                     if (rns != null)
@@ -174,7 +174,7 @@ namespace TEAMModelBI.Controllers.BINormal
                             abilityTask.scope = abilityTaskTree.scope;
                             abilityTask.codeval = $"{recordAbilityTask.standard}";
                             abilityTask.standard = $"{recordAbilityTask.standard}";
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
                             msgBuilder.Append($"新增章节功能,章节ID:{abilityTask.id} 分区键:{abilityTask.code}");
                             type = "abilityTask-add";
                         }
@@ -188,7 +188,7 @@ namespace TEAMModelBI.Controllers.BINormal
                             AbilityService.TreeToList(abilityTaskTree.trees, nodes, now);
                             abilityTask.children = nodes;
                             abilityTaskTree.auth = abilityTask.auth;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<AbilityTask>(abilityTask, abilityTask.id, new Azure.Cosmos.PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<AbilityTask>(abilityTask, abilityTask.id, new PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
                             msgBuilder.Append($"修改章节功能,章节ID:{abilityTask.id} 分区键:{abilityTask.code}");
                             type = "abilityTask-update";
                         }
@@ -215,7 +215,7 @@ namespace TEAMModelBI.Controllers.BINormal
                             codeval = $"{recordAbilityTask.standard}",
                             standard = $"{recordAbilityTask.standard}"
                         };
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
+                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
 
                         msgBuilder.Append($"新增章节功能,章节ID:{abilityTask.id} 分区键:{abilityTask.code}");
                         type = "abilityTask-add";
@@ -263,14 +263,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 //}
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"AbilityTask-{standard}"));
 
-                string msg = $"{_tmdName}【{_tmdId}】删除册别,删除状态:{response.Status},删除ID:{id}";
+                string msg = $"{_tmdName}【{_tmdId}】删除册别,删除状态:{response.StatusCode},删除ID:{id}";
 
                 //保存操作记录
                 await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "abilitytask-del", msg, _dingDing, httpContext: HttpContext);
-                if (response.Status == 204)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     return Ok(new { state = 200 });
                 else
-                    return Ok(new { state = response.Status });
+                    return Ok(new { state = response.StatusCode });
             }
             catch (Exception ex)
             {

+ 21 - 21
TEAMModelBI/Controllers/BINormal/AreaRelevantController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
@@ -79,9 +79,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     sqltxt = $"SELECT c.code,c.id,c.name,c.schoolCode,c.province,c.city,c.dist,c.picture,c.period,c.areaId,c.standard,c.manyAreas FROM c join m in c.manyAreas WHERE (c.areaId ='{_areaId}' or m.areaId='{_areaId}')";
                 }
                 //IES5實體學校
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")})) 
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")})) 
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0) 
                     {
                         foreach(var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -118,9 +118,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
                 }
                 //虛擬學校
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -185,9 +185,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 //}
 
                 var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey("AreaSetting"));
-                if (responseSet.Status == 200)
+                if (responseSet.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     if (!string.IsNullOrEmpty(delSet.accessConfig))
                         return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -200,7 +200,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     tempSchool.standard = null;
 
                     List<Teacher> teachers = new();
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{schoolId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{schoolId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     {
                         teachers.Add(item);
                     }
@@ -291,9 +291,9 @@ namespace TEAMModelBI.Controllers.BINormal
 
             Teacher teacher = new();
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 teacher = json.ToObject<Teacher>();
                 var existArea = teacher.areas.Find(f => f.areaId.Equals($"{areaId}"));
                 if (existArea == null)
@@ -331,13 +331,13 @@ namespace TEAMModelBI.Controllers.BINormal
                         foreach (var item in schoolMs)
                         {
                             var resSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{item.id}", new PartitionKey($"Base"));
-                            if (resSc.Status == 200)
+                            if (resSc.StatusCode == System.Net.HttpStatusCode.OK)
                             {
                                 SchoolTeacher schoolTeacher = null;
                                 var resScTch = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{item.id}"));
-                                if (resScTch.Status == 200)
+                                if (resScTch.StatusCode == System.Net.HttpStatusCode.OK)
                                 {
-                                    using var json = await JsonDocument.ParseAsync(resScTch.ContentStream);
+                                    using var json = await JsonDocument.ParseAsync(resScTch.Content);
                                     schoolTeacher = json.ToObject<SchoolTeacher>();
                                     if (!schoolTeacher.roles.Contains("admin"))
                                     {
@@ -414,7 +414,7 @@ namespace TEAMModelBI.Controllers.BINormal
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             
             List<BaseInfo> areaManages = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<BaseInfo>(queryText:$"select c.id,c.name,c.picture from c join a in c.areas where a.areaId ='{areaId}' and c.code='Base'",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<BaseInfo>(queryText:$"select c.id,c.name,c.picture from c join a in c.areas where a.areaId ='{areaId}' and c.code='Base'",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 areaManages.Add(item);
             }
@@ -443,9 +443,9 @@ namespace TEAMModelBI.Controllers.BINormal
 
             Teacher teacher = null;
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 teacher = json.ToObject<Teacher>();
                 var existArea = teacher.areas.Find(f => f.areaId.Equals($"{areaId}"));
                 if (existArea != null)
@@ -488,7 +488,7 @@ namespace TEAMModelBI.Controllers.BINormal
             else
                 areaScSql.Append(" where c.areaId = null or c.areaId = ''");
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AreaSchool>(queryText: areaScSql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AreaSchool>(queryText: areaScSql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 areaSchool.Add(item);
             }
@@ -496,9 +496,9 @@ namespace TEAMModelBI.Controllers.BINormal
             areaSchool.ForEach(async areaSc =>
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(areaSc.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     {
                         areaSc.serial = serial.ToObject<List<SchoolProductSumData>>().Count;//.Select(x => x.prodCode).ToList();
@@ -551,7 +551,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 scIdsSql = "select value(c.id) from c where c.areaId = null or c.areaId = ''";
             scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scIdsSql, "Base");
 
-            //await foreach (var itemId in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scIdsSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
+            //await foreach (var itemId in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scIdsSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
             //{
             //    scIds.Add(itemId);
             //}
@@ -559,7 +559,7 @@ namespace TEAMModelBI.Controllers.BINormal
             foreach (var scId in scIds)
             {
                 string tchIdSql = $"select value(c.id) from c where array_contains(c.roles,'assist',true) and c.pk='Teacher'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: tchIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: tchIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
                 {
                     tchIds.Add(item);
                 }

+ 61 - 61
TEAMModelBI/Controllers/BINormal/BatchAreaController.cs

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
@@ -131,9 +131,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
                 }
 
-                await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: areaSql.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base-Area") })) 
+                await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIteratorSql(queryText: areaSql.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base-Area") })) 
                 {
-                    using var json = await JsonDocument.ParseAsync(itemArea.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(itemArea.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0) 
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -141,9 +141,9 @@ namespace TEAMModelBI.Controllers.BINormal
                             areas.Add(obj.ToObject<RecArea>());
                         }
 
-                        if (iscontinuation) 
+                        if (iscontinuation)
                         {
-                            continuationToken = itemArea.GetContinuationToken();
+                            continuationToken = itemArea.ContinuationToken;
                             break;
                         }
                     } 
@@ -157,7 +157,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 //    //List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and  areaId eq '{area.id}'");
                 //    //aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
 
-                //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                 //    {
                 //        if (string.IsNullOrEmpty(item))
                 //            area.cutArea = false;
@@ -176,7 +176,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     //List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and  areaId eq '{area.id}'");
                     //aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                     {
                         if (string.IsNullOrEmpty(item))
                             area.cutArea = false;
@@ -247,7 +247,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 queryText += $"WHERE c.standard='{standard}'";
                 queryText += $" OR c.name='{name}'";
                 if(!string.IsNullOrWhiteSpace(shortCode)) queryText += $" OR c.shortCode='{shortCode}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     //查询新的是否存在
                     if (item.standard.Equals($"{standard}"))
@@ -261,14 +261,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
 
                 //查询新的是否存在
-                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 //{
                 //    if (item.standard.Equals($"{standard}"))
                 //        return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
                 //}
 
                 //查询新的区级名称是否存在
-                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.name='{name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.name='{name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 //{
                 //    if (item.name.Equals($"{name}"))
                 //        return Ok(new { state = 1, message = "区级名称相同,请检测区级名称!" });
@@ -368,7 +368,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (!string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}"))
                 {
                     //查询要复制区域的能力标准点 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{oldStandard}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{oldStandard}") }))
                     {
                         if (!string.IsNullOrEmpty(item.blob))
                         {
@@ -406,7 +406,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     try
                     {
                         //微能力点
-                        await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{oldStandard}") }))
+                        await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{oldStandard}") }))
                         {
                             List<Tnode> tnodes = new List<Tnode>();
                             foreach (Tnode tnode in atask.children)
@@ -452,7 +452,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     //}
 
                     //新政策文件
-                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                     {
                         if (standardFile != null)
                         {
@@ -463,7 +463,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
 
                     //新的区域设置
-                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                     {
                         if (areaSetting != null)
                         {
@@ -476,14 +476,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 else
                 {
                     Area area = null;
-                    await foreach (var tempArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                    await foreach (var tempArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                     {
                         area = tempArea;
                     }
                     if (area != null)
                     {
                         //查询要复制区域的能力标准点 
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                         {
                             if (!string.IsNullOrEmpty(item.blob))
                             {
@@ -522,7 +522,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         try
                         {
                             //微能力点
-                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                             {
                                 List<Tnode> tnodes = new List<Tnode>();
                                 foreach (Tnode tnode in atask.children)
@@ -569,7 +569,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         //}
 
                         //新政策文件
-                        await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                        await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                         {
                             if (standardFile != null)
                             {
@@ -580,7 +580,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         }
 
                         //新的区域设置
-                        await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                        await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                         {
                             if (areaSetting != null)
                             {
@@ -667,7 +667,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
                 queryWhere = $"WHERE ({queryWhere}) AND c.id != '{id}'";
                 queryText = $"{queryText}{queryWhere}";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     //查询区级名称是否存在
                     if (item.name.Equals($"{name}"))
@@ -687,18 +687,18 @@ namespace TEAMModelBI.Controllers.BINormal
                 var _azureCosmosClientCsv2Read = _azureCosmos.GetCosmosClient(name: "CoreServiceV2CnRead");
                 //學校資料庫驗證 [式樣待確認,先封印]
                 ///學區簡碼重複驗證
-                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIterator(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("district") })) 
+                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIteratorSql(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("district") })) 
                 //{
-                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(item.Content);
                 //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 //    {
                 //        return Ok(new { state = 1, message = "此学区简码与其他 [学区] 简码相同请检查!" });
                 //    }                    
                 //}
                 ///學校簡碼重複驗證
-                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIterator(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIteratorSql(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
                 //{
-                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(item.Content);
                 //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 //    {
                 //        return Ok(new { state = 1, message = "此学区简码与其他 [学校] 简码相同请检查!" });
@@ -766,9 +766,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 var table = tableClient.GetTableReference("IESLogin");
 
                 var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_oldId}", new PartitionKey("AreaSetting"));
-                if (responseSet.Status == 200)
+                if (responseSet.StatusCode == HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     if (!string.IsNullOrEmpty(delSet.accessConfig))
                         return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -780,7 +780,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 List<string> abilityIds = new();  //册别的ID集合
 
                 //查询册别信息
-                await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
+                await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
                 {
                     abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
                 }
@@ -791,7 +791,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
 
                 List<string> abilityTaskIds = new();  //章节ID集合
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
                 {
                     abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
                 }
@@ -805,7 +805,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 List<Task<ItemResponse<AbilityTask>>> abilityTasks = new();  //存储章节
 
                 //查询要复制区域的能力标准点 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_newStandard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_newStandard}") }))
                 {
                     if (!string.IsNullOrEmpty(item.blob))
                     {
@@ -844,7 +844,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 try
                 {
                     //微能力点
-                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_newStandard}") }))
+                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_newStandard}") }))
                     {
                         List<Tnode> tnodes = new();
                         foreach (Tnode tnode in atask.children)
@@ -883,7 +883,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 StandardFile saveFile = new();
 
                 //新政策文件
-                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                 {
                     if (standardFile != null)
                     {
@@ -897,9 +897,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (saveFile.id != null)
                 {
                     var respFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveFile.id, new PartitionKey("StandardFile"));
-                    if (respFile.Status == 200)
+                    if (respFile.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(respFile.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(respFile.Content);
                         tempFile = json.ToObject<StandardFile>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(tempFile.id, new PartitionKey("StandardFile"));
                     }
@@ -909,7 +909,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                 //新的区域设置
                 AreaSetting saveSetting = new AreaSetting();
-                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                 {
                     if (areaSetting != null)
                     {
@@ -924,9 +924,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (saveSetting.id != null)
                 {
                     var respSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveSetting.id, new PartitionKey("AreaSetting"));
-                    if (respSetting.Status == 200)
+                    if (respSetting.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(respSetting.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(respSetting.Content);
                         tempSetting = json.ToObject<AreaSetting>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(tempFile.id, new PartitionKey("AreaSetting"));
                     }
@@ -1003,16 +1003,16 @@ namespace TEAMModelBI.Controllers.BINormal
             //}
 
             var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey("Base-Area"));
-            if (response.Status == 200)
+            if (response.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 Area area = json.ToObject<Area>();
                 if (area.standard == $"{standard}") 
                 {
                     await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<Area>(area.id, new PartitionKey("Base-Area")); //删除区
 
                     List<Teacher> teachers = new();
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT distinct value(c) FROM c join a in c.areas join s in c.schools where a.areaId='{area.id}' or s.areaId='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT distinct value(c) FROM c join a in c.areas join s in c.schools where a.areaId='{area.id}' or s.areaId='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
                     {
                         teachers.Add(item);
                     }
@@ -1042,7 +1042,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     List<string> abilityTaskIds = new();  //章节ID集合
 
                     //查询册别信息
-                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                     {
                         abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
                     }
@@ -1052,7 +1052,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityIds, $"Ability-{area.standard}");
                     }
 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                     {
                         abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
                     }
@@ -1064,9 +1064,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     //区域政策文件
                     StandardFile delFile = new();
                     var responseFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("StandardFile"));
-                    if(responseFile.Status == 200)
+                    if(responseFile.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseFile.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseFile.Content);
                         delFile = fileJson.ToObject<StandardFile>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(delFile.id, new PartitionKey("StandardFile"));
                     }
@@ -1074,16 +1074,16 @@ namespace TEAMModelBI.Controllers.BINormal
                     //区域设置
                     AreaSetting delSet = new();
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         delSet = fileJson.ToObject<AreaSetting>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(delSet.id, new PartitionKey("AreaSetting"));
                     }
 
                     List<object> fileobj = new();
                     //先删除原有的文件
-                    List<Task<Response<bool>>> DelList = new();
+                    List<Task<Azure.Response<bool>>> DelList = new();
                     await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{area.standard}/"))
                     {
                         fileobj.Add(blobItem.Name);
@@ -1099,7 +1099,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         int pages = (DelList.Count + 255) / 256;
                         for (int i = 0; i < pages; i++)
                         {
-                            List<Task<Response<bool>>> delList = DelList.Skip((i) * 256).Take(256).ToList();
+                            List<Task<Azure.Response<bool>>> delList = DelList.Skip((i) * 256).Take(256).ToList();
                             await Task.WhenAll(delList);
                         }
                     }
@@ -1148,9 +1148,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (area != null)
                 {
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_oldId}", new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                         if (!string.IsNullOrEmpty(delSet.accessConfig))
                             return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -1159,7 +1159,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     List<string> abilityIds = new();  //册别的ID集合
 
                     //查询册别信息
-                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                     {
                         abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
                     }
@@ -1170,7 +1170,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
 
                     List<string> abilityTaskIds = new List<string>();  //章节ID集合
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                     {
                         abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
                     }
@@ -1190,7 +1190,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         try
                         {
                             //查询要复制区域的能力标准点 
-                            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{newstand.standard}") }))
+                            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{newstand.standard}") }))
                             {
                                 if (!string.IsNullOrEmpty(item.blob))
                                     item.blob = item.blob.Replace($"/{newstand.standard}/", $"/{area.standard}/");
@@ -1204,7 +1204,7 @@ namespace TEAMModelBI.Controllers.BINormal
                                 //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}"));
 
                                 var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(item.id, new PartitionKey(item.code));
-                                if (respond.Status != 200)
+                                if (respond.StatusCode != HttpStatusCode.OK)
                                     abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{area.standard}")));
                                 else
                                     repeatAbilityId.Add(item.id);
@@ -1239,7 +1239,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         try
                         {
                             //微能力点
-                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{newstand.standard}") }))
+                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{newstand.standard}") }))
                             {
                                 List<Tnode> tnodes = new();
                                 foreach (Tnode tnode in atask.children)
@@ -1266,7 +1266,7 @@ namespace TEAMModelBI.Controllers.BINormal
                                 atask.codeval = $"{area.standard}";
 
                                 var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(atask.id, new PartitionKey(atask.code));
-                                if (respond.Status != 200)
+                                if (respond.StatusCode != HttpStatusCode.OK)
                                     ////添加区能力标准点中的节点 
                                     //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}")));
                                     await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{area.standard}"));
@@ -1307,7 +1307,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                     StandardFile saveFile = new();
                     //新政策文件
-                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                     {
                         if (standardFile != null)
                         {
@@ -1322,9 +1322,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     if (saveFile.id != null)
                     {
                         var respFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveFile.id, new PartitionKey("StandardFile"));
-                        if (respFile.Status == 200)
+                        if (respFile.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(respFile.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(respFile.Content);
                             tempFile = json.ToObject<StandardFile>();
                             await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(tempFile.id, new PartitionKey("StandardFile"));
                         }
@@ -1342,7 +1342,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                     //新的区域设置
                     AreaSetting saveSetting = new();
-                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                     {
                         if (areaSetting != null)
                         {
@@ -1357,9 +1357,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     if (saveSetting.id != null)
                     {
                         var respSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveSetting.id, new PartitionKey("AreaSetting"));
-                        if (respSetting.Status == 200)
+                        if (respSetting.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(respSetting.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(respSetting.Content);
                             tempSetting = json.ToObject<AreaSetting>();
                             await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(saveSetting.id, new PartitionKey("AreaSetting"));
                         }

+ 14 - 14
TEAMModelBI/Controllers/BINormal/BusinessConfigController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -71,7 +71,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                 await cosmosClient.GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizConfig>(bizConfig, new PartitionKey("BizConfig"));
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: $"select value(c) from c where c.mobile ={bizConfig.mobile}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) 
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: $"select value(c) from c where c.mobile ={bizConfig.mobile}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) 
                 {
                     bizUsers.Add(item);
                 }
@@ -103,9 +103,9 @@ namespace TEAMModelBI.Controllers.BINormal
             else
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(bizConfig.id, new PartitionKey("BizConfig"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     BizConfig tempBizConfig = json.ToObject<BizConfig>();
 
                     bizConfig.pk = "BizConfig";
@@ -146,7 +146,7 @@ namespace TEAMModelBI.Controllers.BINormal
             }
 
             List<Business> businesses = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<Business>(queryText: sqlTxt.ToString(), requestOptions:  new QueryRequestOptions() { PartitionKey = new PartitionKey("BizConfig") }))
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<Business>(queryText: sqlTxt.ToString(), requestOptions:  new QueryRequestOptions() { PartitionKey = new PartitionKey("BizConfig") }))
             {
                 businesses.Add(items);
             }
@@ -172,14 +172,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 //企業聯絡人 刪除該企業聯絡資訊
                 List<string> bizUsersIdList = new List<string>();
                 StringBuilder sql = new($"SELECT VALUE c.id FROM c JOIN r IN c.relation WHERE r.bizId = '{id}'");
-                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<string>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) {
+                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<string>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) {
                     bizUsersIdList.Add(items);
                 }
                 if(bizUsersIdList.Count > 0)
                 {
                     string bizUsersIdListStr = JsonSerializer.Serialize(bizUsersIdList);
                     sql = new($"SELECT * FROM c WHERE ARRAY_CONTAINS({bizUsersIdListStr}, c.id, true)");
-                    await foreach (BizUsers item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+                    await foreach (BizUsers item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
                     {
                         item.relation.RemoveAll(r => r.bizId == $"{id}");
                         await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(item, item.id, new PartitionKey("BizUsers"));
@@ -229,9 +229,9 @@ namespace TEAMModelBI.Controllers.BINormal
             BizConfig bizConfig = new();
 
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizConfig = json.ToObject<BizConfig>();
                 var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey, bizConfig.isCustomize);
                 bizConfig.jti = auth_token.jti;
@@ -284,9 +284,9 @@ namespace TEAMModelBI.Controllers.BINormal
             List<BizSchool> noBizSc = new();
             BizConfig bizConfig = new();
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
-            if (response.Status == RespondCode.Ok)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizConfig = json.ToObject<BizConfig>();
                 foreach (var item in bizSchool)
                 {
@@ -345,7 +345,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
             List<OpenSchool> openSchools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<OpenSchool>(queryText: "select c.id,c.code,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<OpenSchool>(queryText: "select c.id,c.code,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 openSchools.Add(item);
             }
@@ -353,9 +353,9 @@ namespace TEAMModelBI.Controllers.BINormal
             if (!string.IsNullOrEmpty($"id"))
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
-                if (response.Status == RespondCode.Ok)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     bizConfig = json.ToObject<BizConfig>();
                     if (bizConfig.schools.Count > 0)
                     {

+ 11 - 11
TEAMModelBI/Controllers/BINormal/BusinessUsersController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
@@ -64,7 +64,7 @@ namespace TEAMModelBI.Controllers.BINormal
             }
 
             List<BizUsers> bizUsers = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(items);
             }
@@ -112,9 +112,9 @@ namespace TEAMModelBI.Controllers.BINormal
             else 
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(bizUsers.id, new PartitionKey("BizUsers"));
-                if (response.Status == RespondCode.Ok)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     BizUsers tempbizUsers = json.ToObject<BizUsers>();
 
                     bizUsers.pk = "BizUsers";
@@ -152,7 +152,7 @@ namespace TEAMModelBI.Controllers.BINormal
             string sql = $"select value(c) from c where c.mobile ={mobile}";
 
             List<BizUsers> bizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"Normal").GetItemQueryIterator<BizUsers>(queryText:sql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"Normal").GetItemQueryIteratorSql<BizUsers>(queryText:sql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(item);
             }
@@ -193,9 +193,9 @@ namespace TEAMModelBI.Controllers.BINormal
             StringBuilder strMsg = new($"{tmdName}[{tmdId}]操作:");
             string salt = Utils.CreatSaltString(8);
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizUsers"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizUsers = json.ToObject<BizUsers>();
                 bizUsers.salt = salt;
                 bizUsers.pwd = Utils.HashedPassword(bizUsers.mobile.ToString(), salt);
@@ -279,9 +279,9 @@ namespace TEAMModelBI.Controllers.BINormal
             else { return Ok(new { state = RespondCode.ParamsError, msg = "类型错误" }); }
 
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizUsers"));
-            if (response.Status == RespondCode.Ok)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizUsers = json.ToObject<BizUsers>();
             }
 
@@ -310,7 +310,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
             }
 
-            if (response.Status == RespondCode.Ok) 
+            if (response.StatusCode == System.Net.HttpStatusCode.OK) 
             {
                 bizUsers = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(bizUsers, bizUsers.id, new PartitionKey("BizUsers"));
             }
@@ -345,7 +345,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
             List<BizUsers> businessUsers = new();
             string sql = $"select value(c) from c join s in c.relation  where c.code='BizUsers' and s.bizId = '{id}'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 businessUsers.Add(item);
             }

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

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using DingTalk.Api.Request;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
@@ -23,8 +23,8 @@ using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Service.BI;
-using PartitionKey = Azure.Cosmos.PartitionKey;
-using QueryRequestOptions = Azure.Cosmos.QueryRequestOptions;
+using PartitionKey = Microsoft.Azure.Cosmos.PartitionKey;
+using QueryRequestOptions = Microsoft.Azure.Cosmos.QueryRequestOptions;
 
 namespace TEAMModelBI.Controllers.ProductAnalysis
 {
@@ -98,9 +98,9 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                     string schIdListStr = JsonSerializer.Serialize(schoolIds);
                     SqlSch += $" AND ARRAY_CONTAINS({schIdListStr}, c.id, true)";
                 }
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: SqlSch, requestOptions: null))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: SqlSch, requestOptions: null))
                 {
-                    var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         string schId = obj.GetProperty("id").GetString();
@@ -128,7 +128,7 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                         //服務
                         string schoolIdsStr = JsonSerializer.Serialize(schoolIds);
                         string SqlSchProdSoervice = $"SELECT * FROM c WHERE ARRAY_CONTAINS({schoolIdsStr}, c.id)";
-                        await foreach (SchoolProductSum schProductSum in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolProductSum>(queryText: SqlSchProdSoervice, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
+                        await foreach (SchoolProductSum schProductSum in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<SchoolProductSum>(queryText: SqlSchProdSoervice, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
                         {
                             if (schProductSum != null && schProductSum.service != null && schProductSum.service.Count > 0)
                             {
@@ -153,9 +153,9 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                         string SqlSchProdSoft = $"SELECT * FROM c WHERE c.dataType = 'serial' AND c.expireStatus = 'A' AND ARRAY_CONTAINS({schoolCodesStr}, c.code, true)";
                         try
                         {
-                            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: SqlSchProdSoft, requestOptions: null ))
+                            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: SqlSchProdSoft, requestOptions: null ))
                             {
-                                var json = await JsonDocument.ParseAsync(item.ContentStream);
+                                var json = await JsonDocument.ParseAsync(item.Content);
                                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                                 {
                                     SchoolProductSerial serialRow = obj.ToObject<SchoolProductSerial>();
@@ -207,9 +207,9 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                     string schIdListStr = JsonSerializer.Serialize(schoolIds);
                     Sql += $" AND ARRAY_CONTAINS({schIdListStr}, c.schoolId, true)";
                 }
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: Sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProdAnalysis") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: Sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProdAnalysis") }))
                 {
-                    var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         ProdAnalysisApiResult resultRow = obj.ToObject<ProdAnalysisApiResult>();
@@ -385,9 +385,9 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                 if (!string.IsNullOrWhiteSpace(dist)) Sql += $" AND CONTAINS(c.dist, '{dist}')";
                 if (areaIds.Count > 0) Sql += $" AND ARRAY_CONTAINS({areaIdsListStr}, c.areaId, true)";
                 //實體學校
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: Sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: Sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -400,9 +400,9 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                 //虛擬學校
                 if (hasVirtual)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: Sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"VirtualBase") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: Sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"VirtualBase") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())

+ 63 - 63
TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -112,7 +112,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                     var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                    if (schoolStatu.Status != 200) tempStaus = false;
+                    if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                     else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                 } while (tempStaus);
                 createScInfo.Add(createSchoolInfo);
@@ -161,9 +161,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         Area area = null;
                         //查询区是否存在
                         var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("Base-Area"));
-                        if (respAreaId.Status == 200)
+                        if (respAreaId.StatusCode == HttpStatusCode.OK)
                         {
-                            using var areaBase = await JsonDocument.ParseAsync(respAreaId.ContentStream);
+                            using var areaBase = await JsonDocument.ParseAsync(respAreaId.Content);
                             area = areaBase.ToObject<Area>();
                         }
 
@@ -183,7 +183,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         {
                             createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                             var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                            if (schoolStatu.Status != 200) tempStaus = false;
+                            if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                             else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                         } while (tempStaus);
 
@@ -244,9 +244,9 @@ namespace TEAMModelBI.Controllers.BISchool
                             {
                                 Teacher teacher = new();
                                 var resTeache = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{tmdIndo.id}", new PartitionKey("Base"));
-                                if (resTeache.Status == 200)
+                                if (resTeache.StatusCode == HttpStatusCode.OK)
                                 {
-                                    using var tchJson = await JsonDocument.ParseAsync(resTeache.ContentStream);
+                                    using var tchJson = await JsonDocument.ParseAsync(resTeache.Content);
                                     teacher = tchJson.ToObject<Teacher>();
                                     Teacher.TeacherSchool tchSc = null;
                                     //var tempTch = teacher.schools.Select(x => x.schoolId.Equals(upSchool.id)).ToString();
@@ -326,7 +326,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //{
                     //    List<string> scName = new();
                     //    //查询学校名称是否全字段匹配
-                    //    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{bischool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    //    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{bischool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     //    {
                     //        scName.Add(item);
                     //    }
@@ -336,7 +336,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //    var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("Base-Area"));
                     //    if (respAreaId.Status == 200)
                     //    {
-                    //        using var areaBase = await JsonDocument.ParseAsync(respAreaId.ContentStream);
+                    //        using var areaBase = await JsonDocument.ParseAsync(respAreaId.Content);
                     //        area = areaBase.ToObject<Area>();
                     //    }
 
@@ -345,7 +345,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //    var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("AreaSetting"));
                     //    if (responseSet.Status == 200)
                     //    {
-                    //        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    //        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     //        AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     //        if (!string.IsNullOrEmpty(delSet.accessConfig))
                     //            isSYNCArea = true;
@@ -417,7 +417,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //                    var resTeache = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{coreUser.id}", new PartitionKey("Base"));
                     //                    if (resTeache.Status == 200)
                     //                    {
-                    //                        using var tchJson = await JsonDocument.ParseAsync(resTeache.ContentStream);
+                    //                        using var tchJson = await JsonDocument.ParseAsync(resTeache.Content);
                     //                        teacher = tchJson.ToObject<Teacher>();
                     //                        //教师存在,在该教师信息中添加要管理的学校信息
                     //                        teacher.schools.Add(new Teacher.TeacherSchool { areaId = string.IsNullOrEmpty(bischool.areaId) ? "" : bischool.areaId, schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
@@ -610,7 +610,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         else
                             sqlTxt.Append(" order by c.createTime asc");
 
-                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             schoolAssists.Add(itemSchool);
                         }
@@ -620,9 +620,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
 
-                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemSchool.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -631,7 +631,7 @@ namespace TEAMModelBI.Controllers.BISchool
                             }
                             if (iscontinuation)
                             {
-                                continuationToken = itemSchool.GetContinuationToken();
+                                continuationToken = itemSchool.ContinuationToken;
                                 break;
                             }
                         }
@@ -648,7 +648,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //        if ($"{order}".Equals("desc"))
                 //            sqlTxt.Append(" order by c.createTime desc");
 
-                //        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 //        {
                 //            schoolAssists.Add(itemSchool);
                 //        }
@@ -687,9 +687,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 //    scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
 
-                //    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+                //    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
                 //    {
-                //        using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                //        using var json = await JsonDocument.ParseAsync(itemSchool.Content);
                 //        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 //        {
                 //            foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -698,7 +698,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //            }
                 //            if (iscontinuation)
                 //            {
-                //                continuationToken = itemSchool.GetContinuationToken();
+                //                continuationToken = itemSchool.ContinuationToken;
                 //                break;
                 //            }
                 //        }
@@ -708,9 +708,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 foreach (var item in schoolAssists)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(item.id, new PartitionKey("ProductSum"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             item.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
                         if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
@@ -729,7 +729,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //    var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
                 //    if (response.Status == 200)
                 //    {
-                //        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                //        using var json = await JsonDocument.ParseAsync(response.Content);
                 //        if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                 //        {
                 //            school.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -830,7 +830,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         if ($"{order}".Equals("desc"))
                             sqlTxt.Append(" order by c.createTime desc");
 
-                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             schoolAssists.Add(itemSchool);
                         }
@@ -843,9 +843,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                     scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
 
-                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemSchool.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -859,9 +859,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 foreach (var item in schoolAssists)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(item.id, new PartitionKey("ProductSum"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             item.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
                         if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
@@ -896,9 +896,9 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (var temp in schoolAssists)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     {
                         temp.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -941,9 +941,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 //if ($"{site}".Equals(BIConst.Global))
                 //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         string id = obj.GetProperty("id").GetString(); //管理员ID
@@ -968,9 +968,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //管理模组学校
                 List<string> baseModuleSchoos = new List<string>();
                 string baseWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" and c.id='{schoolId}'" : string.Empty;
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         string tempSchoolId = obj.GetProperty("id").GetString();  //学校ID
@@ -981,9 +981,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //学校信息
                 List<object> schools = new List<object>();
                 string schoolWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" where c.id='{schoolId}'" : string.Empty;
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         dynamic schoolExpando = new ExpandoObject();
@@ -1104,8 +1104,8 @@ namespace TEAMModelBI.Controllers.BISchool
                         
                         //計算學校版本
                         List<SchoolProductSumData> services = new List<SchoolProductSumData>();
-                        Azure.Response productSumResponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{_schoolId}", new PartitionKey("ProductSum"));
-                        if (productSumResponse.Status == 200)
+                        ResponseMessage productSumResponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{_schoolId}", new PartitionKey("ProductSum"));
+                        if (productSumResponse.StatusCode == HttpStatusCode.OK)
                         {
                             var doc = JsonDocument.Parse(productSumResponse.Content);
                             if (doc.RootElement.TryGetProperty("service", out JsonElement service))
@@ -1126,7 +1126,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         //修改学校教师关联的信息
                         string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{tempShool.id}'";
                         List<Teacher> teachers = new();
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
                         {
                             teachers.Add(item);
                         }
@@ -1145,9 +1145,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         //学校信息中间件更新
                         BIRelation biRel = new();
                         var respRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(tempShool.id, new PartitionKey("BIRel"));
-                        if (respRel.Status == 200)
+                        if (respRel.StatusCode == HttpStatusCode.OK)
                         {
-                            using var fileJson = await JsonDocument.ParseAsync(respRel.ContentStream);
+                            using var fileJson = await JsonDocument.ParseAsync(respRel.Content);
                             biRel = fileJson.ToObject<BIRelation>();
                         }
                         else
@@ -1188,7 +1188,7 @@ namespace TEAMModelBI.Controllers.BISchool
                             biRel.assists = idInfos;
                         }
 
-                        if (respRel.Status == 200)
+                        if (respRel.StatusCode == HttpStatusCode.OK)
                         {
                             await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<BIRelation>(biRel, biRel.id, new PartitionKey("BIRel"));
                         }
@@ -1261,7 +1261,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 List<School> schools = new List<School>();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     schools.Add(item);
                 }
@@ -1295,7 +1295,7 @@ namespace TEAMModelBI.Controllers.BISchool
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             string sqltxt = $"SELECT * FROM c order by c.id offset {endPosition} limit {pageSize}";
 
-            await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 AssistSchool schoolAssist = new()
                 {
@@ -1359,7 +1359,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 foreach (var item in scNames)
                 {
                     //查询学校名称是否全字段匹配
-                    await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     {
                         existScNames.Add(item);
                     }
@@ -1399,16 +1399,16 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     //查询区是否存在
                     var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("Base-Area"));
-                    if (respAreaId.Status != 200)
+                    if (respAreaId.StatusCode != HttpStatusCode.OK)
                     {
                         noAreaIds.Add(item);
                     }
 
                     //查询去是否同步省平台
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                         if (!string.IsNullOrEmpty(delSet.accessConfig))
                             synPro.Add(item);
@@ -1425,7 +1425,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                     var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                    if (schoolStatu.Status != 200) tempStaus = false;
+                    if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                     else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                 } while (tempStaus);
                 createScInfo.Add(createSchoolInfo);
@@ -1459,7 +1459,7 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (BISchool bISchool in bISchools)
             {
                 //查询学校名称是否全字段匹配
-                await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{bISchool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{bISchool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     existScNames.Add(bISchool);
                 }
@@ -1492,16 +1492,16 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     //查询区是否存在
                     var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bISchool.areaId}", new PartitionKey("Base-Area"));
-                    if (respAreaId.Status != 200)
+                    if (respAreaId.StatusCode != HttpStatusCode.OK)
                     {
                         noAreaIds.Add(bISchool);
                     }
 
                     //查询去是否同步省平台
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bISchool.areaId}", new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                         if (!string.IsNullOrEmpty(delSet.accessConfig))
                             synPro.Add(bISchool);
@@ -1524,7 +1524,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                     var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                    if (schoolStatu.Status != 200) tempStaus = false;
+                    if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                     else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                 } while (tempStaus);
                 bISchool.id = createSchoolInfo.id;
@@ -1566,9 +1566,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         if (tempTeacher != null)
                         {
                             var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{msId}", new PartitionKey($"Teacher-{scId}"));
-                            if (response.Status == 200)
+                            if (response.StatusCode == HttpStatusCode.OK)
                             {
-                                using var tchJson = await JsonDocument.ParseAsync(response.ContentStream);
+                                using var tchJson = await JsonDocument.ParseAsync(response.Content);
                                 SchoolTeacher tchSc = tchJson.ToObject<SchoolTeacher>();
                                 if (tchSc.roles.Contains("admin"))
                                 {
@@ -1614,9 +1614,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                             Teacher teacher = new() { id = coreUser.id, name = coreUser.name, picture = coreUser.picture, pk = "Base", code = "Base", size = 1, createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() };
                             var responseSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
-                            if (responseSc.Status == 200)
+                            if (responseSc.StatusCode == HttpStatusCode.OK)
                             {
-                                using var tchJson = await JsonDocument.ParseAsync(responseSc.ContentStream);
+                                using var tchJson = await JsonDocument.ParseAsync(responseSc.Content);
                                 School scInfo = tchJson.ToObject<School>();
                                 teacher.schools.Add(new() { schoolId = scInfo.id, name = scInfo.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = scInfo.picture, areaId = scInfo.areaId });
                             }
@@ -1668,9 +1668,9 @@ namespace TEAMModelBI.Controllers.BISchool
             {
                 School school = new();
                 var resSc = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{item.id}", new PartitionKey("Base"));
-                if (resSc.Status == 200)
+                if (resSc.StatusCode == HttpStatusCode.OK)
                 {
-                    using var sJson = await JsonDocument.ParseAsync(resSc.ContentStream);
+                    using var sJson = await JsonDocument.ParseAsync(resSc.Content);
                     school = sJson.ToObject<School>();
                     //CoreUser coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"19940828843" } }, _option.Location, _configuration);
                     var content = new StringContent(item.mobiles.ToArray().ToJsonString(), Encoding.UTF8, "application/json");
@@ -1680,14 +1680,14 @@ namespace TEAMModelBI.Controllers.BISchool
                     foreach (var tmd in tmdInfos)
                     {
                         var respone = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{tmd.id}", new PartitionKey("Base"));
-                        if (respone.Status == 200)
+                        if (respone.StatusCode == HttpStatusCode.OK)
                         {
-                            using var tchJson = await JsonDocument.ParseAsync(respone.ContentStream);
+                            using var tchJson = await JsonDocument.ParseAsync(respone.Content);
                             teacher = tchJson.ToObject<Teacher>();
                             var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{tmd.id}", new PartitionKey($"Teacher-{item.id}"));
-                            if (response.Status == 200)
+                            if (response.StatusCode == HttpStatusCode.OK)
                             {
-                                using var scTchJson = await JsonDocument.ParseAsync(response.ContentStream);
+                                using var scTchJson = await JsonDocument.ParseAsync(response.Content);
                                 SchoolTeacher tchSc = scTchJson.ToObject<SchoolTeacher>();
                                 if (tchSc.roles.Contains("admin"))
                                 {

+ 3 - 3
TEAMModelBI/Controllers/BISchool/RoomController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
@@ -70,9 +70,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //}
 
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{roomId}", new PartitionKey($"{roomCode}"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     Room roomInfo = json.ToObject<Room>();
                     roomInfo.serial = string.IsNullOrEmpty($"{serial}") ? null : $"{serial}";
 

+ 92 - 92
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using MathNet.Numerics.LinearAlgebra.Double;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
@@ -106,9 +106,9 @@ namespace TEAMModelBI.Controllers.BISchool
                     sqltxt.Append($" WHERE c.pk='School' and (c.areaId = '' or c.areaId = null or IS_DEFINED(c.areaId) = false)");
 
                 List<NotAreaSchool> tempNotAreaSchools = new();
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -136,7 +136,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                         if (iscontinuation)
                         {
-                            continuationToken = item.GetContinuationToken();
+                            continuationToken = item.ContinuationToken;
                             break;
                         }
                     }
@@ -186,9 +186,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 List<NotAreaSchool> notAreaSchools = new();
                 foreach (string pk in partitionKeys)
                 {
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -275,9 +275,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //}
 
                 var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_areaId}", new PartitionKey("AreaSetting"));
-                if (responseSet.Status == 200)
+                if (responseSet.StatusCode == HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     if (!string.IsNullOrEmpty(delSet.accessConfig))
                         return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -308,7 +308,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                             msg.Append($"{school.name}【{school.id}】学校移除多区域的名单:");
                             List<Teacher> teachers = new();
-                            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{school.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{school.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                             {
                                 teachers.Add(item);
                             }
@@ -368,7 +368,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 AssistSchool schoolAssists = new(); //返回学校列表集合
                 string sqlTxt = $"select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard,c.period,c.campuses from c where c.id='{schoolId}'";
-                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     schoolAssists = itemSchool;
                 }
@@ -376,9 +376,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (schoolAssists.id != null)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolAssists.id, new PartitionKey("ProductSum"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                         {
                             schoolAssists.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -401,7 +401,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //無實體學校 => 取得虛擬學校
                 else
                 {
-                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
                     {
                         schoolAssists = itemSchool;
                     }
@@ -442,11 +442,11 @@ namespace TEAMModelBI.Controllers.BISchool
                 string _auth = HttpContext.GetXAuth("AuthToken");
                 var (tmdId, tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(_auth, _option);
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey($"Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
                     string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{school.id}'";
                     List<Teacher> teachers = new();
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
                     {
                         teachers.Add(item);
                     }
@@ -499,16 +499,16 @@ namespace TEAMModelBI.Controllers.BISchool
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(sid, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
                 long teach = 0;
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{sid}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{sid}") }))
                 {
-                    var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
@@ -719,7 +719,7 @@ namespace TEAMModelBI.Controllers.BISchool
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
             List<BaseInfo> scManages = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<BaseInfo>(queryText: $"select c.id,c.name,c.picture from c where ARRAY_CONTAINS(c.roles,'admin',true) and c.code='Teacher-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<BaseInfo>(queryText: $"select c.id,c.name,c.picture from c where ARRAY_CONTAINS(c.roles,'admin',true) and c.code='Teacher-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
             {
                 scManages.Add(item);
             }
@@ -767,9 +767,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     var resScInfo = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
 
-                    if (resScInfo.Status == 200)
+                    if (resScInfo.StatusCode == HttpStatusCode.OK)
                     {
-                        using var tchJson = await JsonDocument.ParseAsync(resScInfo.ContentStream);
+                        using var tchJson = await JsonDocument.ParseAsync(resScInfo.Content);
                         School scInfo = tchJson.ToObject<School>();
                         areaId = scInfo.areaId;
                     }
@@ -780,9 +780,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 Teacher teacher = new();
                 SchoolTeacher schoolTeacher = new();
                 var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-                if (resTeacher.Status == 200)
+                if (resTeacher.StatusCode == HttpStatusCode.OK)
                 {
-                    using var tchJson = await JsonDocument.ParseAsync(resTeacher.ContentStream);
+                    using var tchJson = await JsonDocument.ParseAsync(resTeacher.Content);
                     teacher = tchJson.ToObject<Teacher>();
 
                     var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
@@ -811,9 +811,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (teacher != null)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{schoolId}"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         schoolTeacher = json.ToObject<SchoolTeacher>();
                         if (!schoolTeacher.roles.Contains("admin"))
                         {
@@ -893,9 +893,9 @@ namespace TEAMModelBI.Controllers.BISchool
             if (rmvFromSc) //從老師的學校列表移除該學校
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     Teacher teacher = json.ToObject<Teacher>();
                     teacher.schools.RemoveAll(s => scIds.Contains(s.schoolId));
                     await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
@@ -906,7 +906,7 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (var scId in scIds)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
                     if (rmvFromSc) //將該老師從學校的老師名單中移除
                     {
@@ -916,7 +916,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     }
                     else
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         scTeacher = json.ToObject<SchoolTeacher>();
                         if (scTeacher.roles.Contains("admin"))
                         {
@@ -968,9 +968,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (schools.Count > 0)
                 {
                     var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-                    if (resTeacher.Status == 200)
+                    if (resTeacher.StatusCode == HttpStatusCode.OK)
                     {
-                        using var tchJson = await JsonDocument.ParseAsync(resTeacher.ContentStream);
+                        using var tchJson = await JsonDocument.ParseAsync(resTeacher.Content);
                         teacher = tchJson.ToObject<Teacher>();
                     }
                     else
@@ -997,9 +997,9 @@ namespace TEAMModelBI.Controllers.BISchool
                             existSchool.name = school.name;
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{school.id}"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             schoolTeacher = json.ToObject<SchoolTeacher>();
                             if (!schoolTeacher.roles.Contains("admin"))
                             {
@@ -1030,7 +1030,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         msg.Append($"{school.name}[{school.id}]");
                     }
 
-                    if (resTeacher.Status == 200)
+                    if (resTeacher.StatusCode == HttpStatusCode.OK)
                         teacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
                     else
                         teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
@@ -1097,44 +1097,44 @@ namespace TEAMModelBI.Controllers.BISchool
                         List<string> scTchIds = new();
                         List<string> scStuIds = new();
                         string scTecSql = $"select value(c.id) from c where ARRAY_LENGTH(c.roles) > 0 and c.status = 'join'";
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempId}") }))
                         {
                             scTchIds.Add(item);
                         }
 
                         string scStuSql = $"select value(c.id) from c";
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{tempId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIteratorSql<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{tempId}") }))
                         {
                             scStuIds.Add(item);
                         }
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"Base"));
-                        if (response.Status == 204)
-                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.Status},删除ID:{tempId}");
+                        if (response.StatusCode == HttpStatusCode.NoContent)
+                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.StatusCode},删除ID:{tempId}");
                         else
-                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = response.Status });
+                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = (int)HttpStatusCode.NoContent });
 
                         //删除学校信息中间
                         var resBiRel = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"BIRel"));
-                        if (resBiRel.Status == 204)
-                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校信息中间件,删除状态:{resBiRel.Status},删除ID:{tempId}");
+                        if (resBiRel.StatusCode == HttpStatusCode.NoContent)
+                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校信息中间件,删除状态:{resBiRel.StatusCode},删除ID:{tempId}");
                         else
-                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = response.Status });
+                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = (int)response.StatusCode });
 
                         foreach (var item in scTchIds)
                         {
                             //学校教师信息
                             var tchRespnse = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{item}", new PartitionKey($"Teacher-{tempId}"));
-                            if (tchRespnse.Status == 204)
-                                msg.AppendLine($"删除教师,删除状态:{tchRespnse.Status},删除ID:{item}");
+                            if (tchRespnse.StatusCode == HttpStatusCode.NoContent)
+                                msg.AppendLine($"删除教师,删除状态:{tchRespnse.StatusCode},删除ID:{item}");
                             else
-                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Teacher-{tempId}", type = 2, status = response.Status });
+                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Teacher-{tempId}", type = 2, status = (int)response.StatusCode });
 
                             //教师基础信息
                             var tchBaseResponse = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{item}", new PartitionKey("Base"));
-                            if (tchBaseResponse.Status == 200)
+                            if (tchBaseResponse.StatusCode == HttpStatusCode.OK)
                             {
-                                using var json = await JsonDocument.ParseAsync(tchBaseResponse.ContentStream);
+                                using var json = await JsonDocument.ParseAsync(tchBaseResponse.Content);
                                 Teacher teacher = json.ToObject<Teacher>();
                                 var tempSc = teacher.schools.Find(f => f.schoolId.Equals($"{tempId}"));
                                 if (tempSc != null)
@@ -1144,38 +1144,38 @@ namespace TEAMModelBI.Controllers.BISchool
                                 }
                             }
                             else
-                                delSchoolRels.Add(new DelSchoolRel { id = $"{item}", code = "Base", type = 2, status = response.Status });
+                                delSchoolRels.Add(new DelSchoolRel { id = $"{item}", code = "Base", type = 2, status = (int)response.StatusCode });
                         }
                         //删除学校学生
                         foreach (var item in scStuIds)
                         {
                             var stuRespnse = await cosmosClient.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync($"{item}", new PartitionKey($"Base-{tempId}"));
-                            if (stuRespnse.Status == 204)
-                                msg.AppendLine($"删除学生,删除状态:{stuRespnse.Status},删除ID:{item}");
+                            if (stuRespnse.StatusCode == HttpStatusCode.NoContent)
+                                msg.AppendLine($"删除学生,删除状态:{stuRespnse.StatusCode},删除ID:{item}");
                             else
-                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Base-{tempId}", type = 3, status = response.Status });
+                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Base-{tempId}", type = 3, status = (int)response.StatusCode });
                         }
                     }
                     //虛擬學校刪除
                     else
                     {
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"VirtualBase"));
-                        if (response.Status == 204)
-                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.Status},删除ID:{tempId}");
+                        if (response.StatusCode == HttpStatusCode.NoContent)
+                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.StatusCode},删除ID:{tempId}");
                         else
-                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "VirtualBase", type = 1, status = response.Status });
+                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "VirtualBase", type = 1, status = (int)response.StatusCode });
                     }
                 }
 
 
                 //string scTecSql = $"select value(c.id) from c where ARRAY_LENGTH(c.roles) > 0 and c.status = 'join'";
-                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
+                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
                 //{
                 //    scTchIds.Add(item);
                 //}
 
                 //string scStuSql = $"select value(c.id) from c";
-                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
+                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
                 //{
                 //    scStuIds.Add(item);
                 //}
@@ -1267,9 +1267,9 @@ namespace TEAMModelBI.Controllers.BISchool
             if (schoolInfo != null)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolInfo.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                         schoolInfo.serial = serial.ToObject<List<ProductSumInfos>>();
 
@@ -1344,9 +1344,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
             RecSchool recSchool = new();
             var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 recSchool = json.ToObject<RecSchool>();
             }
             else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
@@ -1457,7 +1457,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             //获取当前学期所有的课程记录
             List<LessAnalyse> records = new List<LessAnalyse>();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessAnalyse>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessAnalyse>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
             {
                 records.Add(item);
             }
@@ -1470,7 +1470,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             List<LessonCount> scount = new();
             List<LessonCount> tcount = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{year}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{year}") }))
             {
                 scount.Add(item);
             }
@@ -1479,7 +1479,7 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (var tId in teacIds)
             {
                 var sqlTxtt = $"select value(c) from c where c.id='{tId}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
                 {
                     tcount.Add(item);
                 }
@@ -1864,15 +1864,15 @@ namespace TEAMModelBI.Controllers.BISchool
             AnSchool school = new();  //学校基础基础信息
 
             var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 school = json.ToObject<AnSchool>();
             }
             else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
             List<LessAnalyse> lessAnalyses = new();
 
-            await foreach (var lessItem in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessAnalyse>(queryText: "select c.id,c.code,c.periodId,c.subjectId,c.grade from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school.id}") }))
+            await foreach (var lessItem in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessAnalyse>(queryText: "select c.id,c.code,c.periodId,c.subjectId,c.grade from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school.id}") }))
             {
                 lessAnalyses.Add(lessItem);
             }
@@ -1883,9 +1883,9 @@ namespace TEAMModelBI.Controllers.BISchool
             var subCnt = subs.Select(x => new { name = x.key, value = x.count });
 
             var responseProduct = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
-            if (responseProduct.Status == 200)
+            if (responseProduct.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(responseProduct.ContentStream);
+                using var json = await JsonDocument.ParseAsync(responseProduct.Content);
                 if (json.RootElement.TryGetProperty("serial", out JsonElement _serial) && !_serial.ValueKind.Equals(JsonValueKind.Null))
                 {
                     school.serial = _serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -1920,7 +1920,7 @@ namespace TEAMModelBI.Controllers.BISchool
             if (!string.IsNullOrEmpty($"{areaId}"))
                 sql.Append($" where c.areaId = '{areaId}'");
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIterator<ScBriefInfo>(queryText: sql.ToString(), requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIteratorSql<ScBriefInfo>(queryText: sql.ToString(), requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 scBriefs.Add(item);
             }
@@ -1986,9 +1986,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         allCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", serialAllSql, $"Product-{scProd.id}");
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             {
                                 List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -2015,7 +2015,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //    var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
                     //    if (response.Status == 200)
                     //    {
-                    //        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    //        using var json = await JsonDocument.ParseAsync(response.Content);
                     //        if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     //        {
                     //            scProd.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList(); 
@@ -2061,9 +2061,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
             List<School> schools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -2107,9 +2107,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 foreach (var school in schools)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
                     {
-                        var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
@@ -2302,7 +2302,7 @@ namespace TEAMModelBI.Controllers.BISchool
             List<string> scIds = new();
 
             string mScSql = $"SELECT value(REPLACE(c.code, 'Teacher-', '')) FROM c where array_contains(c.roles,'admin',true) and c.pk='Teacher' and c.id='{tmdId}'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: mScSql, requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: mScSql, requestOptions: new QueryRequestOptions() { }))
             {
                 scIds.Add(item);
             }
@@ -2350,7 +2350,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             List<ScSimple> scSimple = new();
 
-            await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ScSimple>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<ScSimple>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 scSimple.Add(itemSchool);
             }
@@ -2417,9 +2417,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 ////取得各產品目前可得數量
                 var response = await db.ReadItemStreamAsync(school_code.ToString(), new PartitionKey($"ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     productSum = json.ToObject<SchoolProductSum>();
                     prodinfo = productSum.prodinfo;
                     serviceSum = productSum.service;
@@ -2429,9 +2429,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 List<string> serialPermitList = getSerialPermitProdcodeList();
                 string serialPermitJsonStr = JsonConvert.SerializeObject(serialPermitList);
                 string serialQueryText = $"SELECT * FROM c WHERE c.dataType = 'serial' AND ARRAY_CONTAINS({serialPermitJsonStr}, c.prodCode)";
-                await foreach (var itemsr in db.GetItemQueryStreamIterator(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
+                await foreach (var itemsr in db.GetItemQueryStreamIteratorSql(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(itemsr.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(itemsr.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         deviceForCoreService uuidForCore;
@@ -2445,9 +2445,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //服務
                 List<SchoolProductSumDataService> service = new List<SchoolProductSumDataService>();
                 SchoolProductSum schoolProductSum;
-                await foreach (var items in db.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.id = '{school_code}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
+                await foreach (var items in db.GetItemQueryStreamIteratorSql(queryText: $"SELECT * FROM c WHERE c.id = '{school_code}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(items.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(items.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -2472,9 +2472,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 }
 
                 //硬體
-                await foreach (var itemhd in db.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
+                await foreach (var itemhd in db.GetItemQueryStreamIteratorSql(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(itemhd.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(itemhd.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -2488,9 +2488,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 ////取得教師分配空間
                 long teach = 0;
                 var querysp = $"SELECT SUM(c.size) as size FROM c";
-                await foreach (var item in db.GetItemQueryStreamIterator(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
+                await foreach (var item in db.GetItemQueryStreamIteratorSql(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
                 {
-                    var jsonts = await JsonDocument.ParseAsync(item.ContentStream);
+                    var jsonts = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in jsonts.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         teach = obj.GetProperty("size").GetInt64() * 1073741824; //G換算
@@ -2621,13 +2621,13 @@ namespace TEAMModelBI.Controllers.BISchool
                 var client = _azureCosmos.GetCosmosClient(name:"CoreServiceV2");
                 string sqlPurchase = $"SELECT * FROM c ";
                 List<PurchaseSeats> purchaseSeatsList = new List<PurchaseSeats>();
-                await foreach (PurchaseSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIterator<PurchaseSeats>(queryText: sqlPurchase, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchase") }))
+                await foreach (PurchaseSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSeats>(queryText: sqlPurchase, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchase") }))
                 {
                     purchaseSeatsList.Add(item);
                 }
                 Dictionary<string, List<PurchaseSchoolSeats>> purchaseSchoolSeatsDic = new Dictionary<string, List<PurchaseSchoolSeats>>();
                 string sqlSchool = $"SELECT * FROM c ";
-                await foreach (PurchaseSchoolSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIterator<PurchaseSchoolSeats>(queryText: sqlSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchaseSchool") }))
+                await foreach (PurchaseSchoolSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSchoolSeats>(queryText: sqlSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchaseSchool") }))
                 {
                     if(!purchaseSchoolSeatsDic.ContainsKey(item.purchaseId))
                     {
@@ -2684,7 +2684,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (!string.IsNullOrWhiteSpace(provinceId)) sql += $" AND c.provinceId = '{provinceId}'";
                 if (!string.IsNullOrWhiteSpace(cityId)) sql += $" AND c.cityId = '{cityId}'";
                 if (!string.IsNullOrWhiteSpace(distId)) sql += $" AND c.distId = '{distId}'";
-                await foreach (CsSchoolBase item in client.GetContainer("Core", "School").GetItemQueryIterator<CsSchoolBase>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                await foreach (CsSchoolBase item in client.GetContainer("Core", "School").GetItemQueryIteratorSql<CsSchoolBase>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
                 {
                     result.Add(item);
                 }

+ 1 - 1
TEAMModelBI/Controllers/BIStudent/StuActivityController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;

+ 5 - 5
TEAMModelBI/Controllers/BIStudent/StudentController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -48,9 +48,9 @@ namespace TEAMModelBI.Controllers.BIStudent
             //if ($"{site}".Equals(BIConst.Global))
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<object> objs = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{studentId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{studentId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -83,9 +83,9 @@ namespace TEAMModelBI.Controllers.BIStudent
                 //string sqlTxt = "SELECT select c.id,c.code,c.classIds FROM c  where c.pk='Activity' and c.classIds <> []";
                 string sqlTxt = "select c.id,c.code,c.classIds from c where c.school='cswznb' and c.classIds <> []";
                 List<CorrectStu> correctStus = new();
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         obj.TryGetProperty("id", out JsonElement tempTd);

+ 4 - 4
TEAMModelBI/Controllers/BITable/BIOpenApiController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -57,9 +57,9 @@ namespace TEAMModelBI.Controllers.BITable
             }
 
             List<ReadApi> openApis = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryStreamIterator(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Api")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryStreamIteratorSql(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Api")}))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt32() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -124,7 +124,7 @@ namespace TEAMModelBI.Controllers.BITable
                 else
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(openApi.id, new PartitionKey("Api"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
                         openApi.ttl = -1;
                         openApi.pk = "Api";

+ 9 - 10
TEAMModelBI/Controllers/BITable/DDStructController.cs

@@ -14,11 +14,10 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Service;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Models;
 using TEAMModelBI.Controllers.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-using Microsoft.Azure.Cosmos.Table;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Context.BI;
 
@@ -282,7 +281,7 @@ namespace TEAMModelBI.Controllers.BITable
                         //string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{itemUser.Userid}'";
                         //try
                         //{
-                        //    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        //    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         //    {
                         //        dDAndTmdInfo.tmdId = item.id;
                         //        dDAndTmdInfo.isexist = true;
@@ -292,7 +291,7 @@ namespace TEAMModelBI.Controllers.BITable
                         //            var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
                         //            if (schoolRoles.Status == 200)
                         //            {
-                        //                using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
+                        //                using var json = await JsonDocument.ParseAsync(schoolRoles.Content);
                         //                if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
                         //                {
                         //                    foreach (var obj in _roles.EnumerateArray())
@@ -371,7 +370,7 @@ namespace TEAMModelBI.Controllers.BITable
                                         string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{itemUser2.Userid}'";
                                         try
                                         {
-                                            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                                            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                                             {
                                                 dDAndTmdInfo2.tmdId = item.id;
                                                 dDAndTmdInfo2.isexist = true;
@@ -379,9 +378,9 @@ namespace TEAMModelBI.Controllers.BITable
                                                 if (!string.IsNullOrEmpty($"{item.defaultSchool}"))
                                                 {
                                                     var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
-                                                    if (schoolRoles.Status == 200)
+                                                    if (schoolRoles.StatusCode == System.Net.HttpStatusCode.OK)
                                                     {
-                                                        using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
+                                                        using var json = await JsonDocument.ParseAsync(schoolRoles.Content);
                                                         if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
                                                         {
                                                             foreach (var obj in _roles.EnumerateArray())
@@ -503,7 +502,7 @@ namespace TEAMModelBI.Controllers.BITable
                             string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{tempid}'";
                             try
                             {
-                                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                                 {
                                     dDUserInfoAndTMD.tmdId = item.id;
                                     dDUserInfoAndTMD.isexist = true;
@@ -511,9 +510,9 @@ namespace TEAMModelBI.Controllers.BITable
                                     if (!string.IsNullOrEmpty($"{item.defaultSchool}"))
                                     {
                                         var schoolRoles = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
-                                        if (schoolRoles.Status == 200)
+                                        if (schoolRoles.StatusCode == System.Net.HttpStatusCode.OK)
                                         {
-                                            using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
+                                            using var json = await JsonDocument.ParseAsync(schoolRoles.Content);
                                             if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
                                             {
                                                 foreach (var obj in _roles.EnumerateArray())

+ 2 - 2
TEAMModelBI/Controllers/BITable/IES5OAuthController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
@@ -122,7 +122,7 @@ namespace TEAMModelBI.Controllers.BITable
                     if (oAuthShow.Type.Equals("art")) 
                     {
                         var isExist = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{oAuthShow.Code}", new PartitionKey("ArtSetting"));
-                        if (isExist.Status != 200)
+                        if (isExist.StatusCode != System.Net.HttpStatusCode.OK)
                         {
                             artSetting = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<ArtSetting>("default", new PartitionKey("ArtSetting"));
                             artSetting.id = oAuthShow.Code;

+ 2 - 2
TEAMModelBI/Controllers/BITable/OperateLogController.cs

@@ -1,6 +1,5 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Generic;
@@ -17,6 +16,7 @@ using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
 
 using TEAMModelOS.SDK.Context.BI;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelBI.Controllers.BITable
 {
@@ -138,7 +138,7 @@ namespace TEAMModelBI.Controllers.BITable
                 //保存操作记录
                 await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "operatelog-del", operateStr?.ToString(), _dingDing, httpContext: HttpContext);
 
-                if (temp.Count > 0)
+                if (temp.Count() > 0)
                 {
                     return Ok(new { state = 200 });
                 }

+ 18 - 18
TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs

@@ -18,8 +18,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI;
 using System.Net;
 using TEAMModelOS.SDK.Extension;
 using System.Text;
-using Azure.Cosmos;
-using Microsoft.Azure.Cosmos.Table;
+using Microsoft.Azure.Cosmos;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Models;
@@ -30,6 +29,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelBI.Controllers.BITable
 {
@@ -184,7 +184,7 @@ namespace TEAMModelBI.Controllers.BITable
                 var users = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{divide}" } });
 
                 List<DingDingUserInfo> noExisits = new();
-                if (users.Count > 0)
+                if (users.Count() > 0)
                 {
                     //var temps = users.Union(tempddUserInfos).Except(users.Intersect(tempddUserInfos));
                     List<DingDingUserInfo> existsUserInfo = users.Where(u => !tempddUserInfos.Exists(e => u.userId.Equals(e.userId) && u.PartitionKey.Equals(e.PartitionKey))).ToList();
@@ -416,7 +416,7 @@ namespace TEAMModelBI.Controllers.BITable
                         {
                             string tempSql = $"select value(c) from c join a in c.sales where a.id='{itemR}'";
 
-                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
                             {
                                 var tempRel = itemRel.sales.Find(f => f.id.Equals(itemR));
                                 itemRel.sales.Remove(tempRel);
@@ -426,7 +426,7 @@ namespace TEAMModelBI.Controllers.BITable
                             }
 
                             //string sql = $"select value(c) from c where c.pk='Teacher' and c.id='{item.tmdId}'";
-                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { })) 
+                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { })) 
                             //{
                             //    if (scTch.roles.Contains("sales"))
                             //    {
@@ -453,7 +453,7 @@ namespace TEAMModelBI.Controllers.BITable
 
                             string tempSql = $"select value(c) from c join a in c.assists where a.id='{itemR}'";
 
-                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
                             {
                                 var tempRel = itemRel.sales.Find(f => f.id.Equals(itemR));
                                 itemRel.assists.Remove(tempRel);
@@ -463,7 +463,7 @@ namespace TEAMModelBI.Controllers.BITable
                             }
 
                             //string sql = $"select value(c) from c where c.pk='Teacher' and c.id='{item.tmdId}'";
-                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { }))
+                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { }))
                             //{
                             //    if (scTch.roles.Contains("assist"))
                             //    {
@@ -867,7 +867,7 @@ namespace TEAMModelBI.Controllers.BITable
                     var userInfos = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" } });
 
                     var adminInfos = userInfos.FindAll(x => x.roles.Contains("admin"));
-                    if (adminInfos.Count == 1)
+                    if (adminInfos.Count() == 1)
                     {
                         return Ok(new { state = 403, msg = "已经是最后一个管理员了" });
                     }
@@ -1035,11 +1035,11 @@ namespace TEAMModelBI.Controllers.BITable
                 var users = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{divide}" } });
 
                 List<DingDingUserInfo> noExisits = new();
-                if (users.Count > 0)
+                if (users.Count() > 0)
                 {
                     //var temps = users.Union(tempddUserInfos).Except(users.Intersect(tempddUserInfos));
                     List<DingDingUserInfo> existsUserInfo = users.Where(u => !tempddUserInfos.Exists(e => u.userId.Equals(e.userId) && u.PartitionKey.Equals(e.PartitionKey))).ToList();
-                    if (users.Count >= tempddUserInfos.Count)
+                    if (users.Count() >= tempddUserInfos.Count)
                     {
                         existsUserInfo.AddRange(tempddUserInfos.Where(e => !users.Exists(u => e.userId.Equals(u.userId) && e.PartitionKey.Equals(u.PartitionKey))).ToList());
                     }
@@ -1433,7 +1433,7 @@ namespace TEAMModelBI.Controllers.BITable
                 string reole = null;
 
                 var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partKey}" }, { "RowKey", $"{rowKey}" } });
-                if (tempUser.Count > 0)
+                if (tempUser.Count() > 0)
                 {
                     foreach (var item in tempUser)
                     {
@@ -1460,9 +1460,9 @@ namespace TEAMModelBI.Controllers.BITable
 
                     Teacher teacher = new();
                     var respone = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(coreUser.id, new PartitionKey("Base"));
-                    if (respone.Status == 200)
+                    if (respone.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(respone.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(respone.Content);
                         teacher = json.ToObject<Teacher>();
                     }
                     else
@@ -1478,7 +1478,7 @@ namespace TEAMModelBI.Controllers.BITable
                     }
 
                     List<Task<ItemResponse<BIRelation>>> scRole = new();
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: $"select value(c) from c join a in c.assists join s in c.sales  where c.code='BIRel' and  s.id='{oldTmdId}' or a.id='{oldTmdId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: $"select value(c) from c join a in c.assists join s in c.sales  where c.code='BIRel' and  s.id='{oldTmdId}' or a.id='{oldTmdId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
                     {
                         var tempAss = item.assists.Find(f => f.id.Equals($"{oldTmdId}"));
                         if (tempAss != null)
@@ -1513,13 +1513,13 @@ namespace TEAMModelBI.Controllers.BITable
                     }
 
                     //List<Task<ItemResponse<SchoolTeacher>>> schoolTeachers = new();
-                    //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>($"select value(c) from c where c.pk='Teacher' and c.id='{oldTmdId}'"))
+                    //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<SchoolTeacher>($"select value(c) from c where c.pk='Teacher' and c.id='{oldTmdId}'"))
                     //{
                     //    item.id = coreUser.id;
                     //    var resp = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{coreUser.id}", new PartitionKey($"{item.code}"));
                     //    if (resp.Status == 200)
                     //    {
-                    //        using var json = await JsonDocument.ParseAsync(resp.ContentStream);
+                    //        using var json = await JsonDocument.ParseAsync(resp.Content);
                     //        SchoolTeacher scTeacher = json.ToObject<SchoolTeacher>();
                     //        if (scTeacher.roles.Contains("sales"))
                     //            scTeacher.roles.Remove("sales");
@@ -1568,7 +1568,7 @@ namespace TEAMModelBI.Controllers.BITable
                     //    }
                     //}
 
-                    if (respone.Status == 200)
+                    if (respone.StatusCode == HttpStatusCode.OK)
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
                     else
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
@@ -1674,7 +1674,7 @@ namespace TEAMModelBI.Controllers.BITable
                     {
                         var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                         var users = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "userId", $"{itemUser.Userid}" }, { "unionId", $"{itemUser.Unionid}" } });
-                        if (users.Count > 0)
+                        if (users.Count() > 0)
                         {
                             foreach (var user in users)
                             {

+ 5 - 5
TEAMModelBI/Controllers/BITeacher/TeacherController.cs

@@ -1,7 +1,7 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
 using System.Threading.Tasks;
 using System.Collections.Generic;
@@ -58,9 +58,9 @@ namespace TEAMModelBI.Controllers.BITeacher
                 sqlTxt = $"select c.id,c.name,c.code,c.picture from c join a1 in c.schools where a1.schoolId='{schoolCode}'";
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -97,9 +97,9 @@ namespace TEAMModelBI.Controllers.BITeacher
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<object> objs = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{teacherId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{teacherId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray()) 

+ 13 - 12
TEAMModelBI/Controllers/BITest/Ies5TestController.cs

@@ -2,6 +2,7 @@
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Azure.Cosmos;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
 using StackExchange.Redis;
@@ -103,7 +104,7 @@ namespace TEAMModelBI.Controllers.BITest
 
             if ($"{actType}".Equals("Study"))
             {
-                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>($"{id}", new Azure.Cosmos.PartitionKey($"Study-{code}"));
+                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>($"{id}", new PartitionKey($"Study-{code}"));
                 if (study.groupLists.Count > 0)
                 {
                     var group = study.groupLists;
@@ -122,7 +123,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Vote"))
             {
-                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>($"{id}", new Azure.Cosmos.PartitionKey($"Vote-{code}"));
+                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>($"{id}", new PartitionKey($"Vote-{code}"));
                 classes = vote.classes;
                 stuLists = vote.stuLists;
                 tchLists = vote.tchLists;
@@ -130,7 +131,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Homework"))
             {
-                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Homework>($"{id}", new Azure.Cosmos.PartitionKey($"Homework-{code}"));
+                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Homework>($"{id}", new PartitionKey($"Homework-{code}"));
                 classes = work.classes;
                 stuLists = work.stuLists;
                 tchLists = work.tchLists;
@@ -138,7 +139,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Survey")) 
             {
-                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>($"{id}", new Azure.Cosmos.PartitionKey($"Survey-{code}"));
+                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>($"{id}", new PartitionKey($"Survey-{code}"));
                 classes = survey.classes;
                 stuLists = survey.stuLists;
                 tchLists = survey.tchLists;
@@ -146,7 +147,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("ExamLite")) 
             {
-                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamLite>($"{id}", new Azure.Cosmos.PartitionKey($"ExamLite-{code}"));
+                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamLite>($"{id}", new PartitionKey($"ExamLite-{code}"));
                 classes = examLite.classes;
                 stuLists = examLite.stuLists;
                 tchLists = examLite.tchLists;
@@ -154,7 +155,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Exam"))
             {
-                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>($"{id}", new Azure.Cosmos.PartitionKey($"Exam-{code}"));
+                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>($"{id}", new PartitionKey($"Exam-{code}"));
                 classes = examInfo.classes;
                 stuLists = examInfo.stuLists;
                 school = examInfo.school;
@@ -165,37 +166,37 @@ namespace TEAMModelBI.Controllers.BITest
             if ($"{actType}".Equals("Study"))
             {
                 study.staffIds = idsList;
-                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Study>(study, study.id, new Azure.Cosmos.PartitionKey($"Study-{code}"));
+                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Study>(study, study.id, new PartitionKey($"Study-{code}"));
                 showAct = study;
             }
             else if ($"{actType}".Equals("Vote"))
             {
                 vote.staffIds = idsList;
-                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Vote>(vote, vote.id, new Azure.Cosmos.PartitionKey($"Vote-{code}")); 
+                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Vote>(vote, vote.id, new PartitionKey($"Vote-{code}")); 
                 showAct = vote;
             }
             else if ($"{actType}".Equals("Homework"))
             {
                 work.staffIds = idsList;
-                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Homework>(work, work.id, new Azure.Cosmos.PartitionKey($"Homework-{code}"));
+                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Homework>(work, work.id, new PartitionKey($"Homework-{code}"));
                 showAct = work;
             }
             else if ($"{actType}".Equals("Survey"))
             {
                 survey.staffIds = idsList;
-                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Survey>(survey, survey.id, new Azure.Cosmos.PartitionKey($"Survey-{code}"));
+                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Survey>(survey, survey.id, new PartitionKey($"Survey-{code}"));
                 showAct = work;
             }
             else if ($"{actType}".Equals("ExamLite"))
             {
                 examLite.staffIds = idsList;
-                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamLite>(examLite, examLite.id, new Azure.Cosmos.PartitionKey($"ExamLite-{code}"));
+                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamLite>(examLite, examLite.id, new PartitionKey($"ExamLite-{code}"));
                 showAct = work;
             }
             else if ($"{actType}".Equals("Exam"))
             {
                 examInfo.staffIds = idsList;
-                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new Azure.Cosmos.PartitionKey($"Exam-{code}"));
+                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new PartitionKey($"Exam-{code}"));
                 showAct = work;
             }
 

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

@@ -1,11 +1,10 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using DingTalk.Api;
 using DingTalk.Api.Request;
 using DingTalk.Api.Response;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
 using System;
@@ -58,6 +57,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using Microsoft.OData.Edm;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelBI.Controllers.BITest
 {
@@ -104,7 +104,7 @@ namespace TEAMModelBI.Controllers.BITest
             List<string> abilityIds = new();  //册别的ID集合
 
             //查询册别信息
-            await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
+            await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
             {
                 abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
             }
@@ -116,7 +116,7 @@ namespace TEAMModelBI.Controllers.BITest
 
             List<string> abilityTaskIds = new();  //章节ID集合
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
             {
                 abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
             }
@@ -460,7 +460,7 @@ namespace TEAMModelBI.Controllers.BITest
                     stringBuilder.Append($" where c.id='{_schoolCode}'");
                 }
 
-                //await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 //{
                 //    SchoolAssist schoolAssist = new()
                 //    {
@@ -484,7 +484,7 @@ namespace TEAMModelBI.Controllers.BITest
                 //    var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemSchool.id, new PartitionKey("ProductSum"));
                 //    if (response.Status == 200)
                 //    {
-                //        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                //        using var json = await JsonDocument.ParseAsync(response.Content);
 
                 //        if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                 //        {
@@ -506,9 +506,9 @@ namespace TEAMModelBI.Controllers.BITest
                 //}
                 //return Ok(new { state = 200, schoolAssists });
 
-                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                    using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.Content);
                     foreach (var objSchool in jsonSchool.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         var schoolId = objSchool.GetProperty("id").GetString();
@@ -535,9 +535,9 @@ namespace TEAMModelBI.Controllers.BITest
                         catch { schoolAssist.scale = 0; }
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("ProductSum"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             {
                                 schoolAssist.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -585,9 +585,9 @@ namespace TEAMModelBI.Controllers.BITest
             foreach (var temp in schoolAssists)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     {
                         temp.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -665,10 +665,10 @@ namespace TEAMModelBI.Controllers.BITest
 
                 //string sqlText = $"select value(c.id) from c where c.pk='Item' and c.field={i}";
                 string sqlText = $"select value(COUNT(c.id)) from c where c.pk='Item' and c.field={i}";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
                 {
                     total += item;
-                    //using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    //using var json = await JsonDocument.ParseAsync(item.Content);
                     //if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                     //{
                     //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -680,10 +680,10 @@ namespace TEAMModelBI.Controllers.BITest
                     //}
                 }
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
                 {
                     total += item;
-                    //using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    //using var json = await JsonDocument.ParseAsync(item.Content);
                     //if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt64() > 0)
                     //{
                     //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -780,9 +780,9 @@ namespace TEAMModelBI.Controllers.BITest
             {
                 var start = 00022222330;
                 long tempCount = 0;
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c._ts,c.name,c.id FROM c WHERE c._ts>={start}L", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c._ts,c.name,c.id FROM c WHERE c._ts>={start}L", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt64() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1027,9 +1027,9 @@ namespace TEAMModelBI.Controllers.BITest
             List<School> schools = new List<School>();
             //string sqlTxt = $"SELECT * FROM c where c.code='Base' order by c.id offset {endPosition} limit {pageSize}";
             string sqlTxt = $"SELECT * FROM c order by c.id offset {pageSize} limit {endPosition}";
-            await foreach (var tempPage in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var tempPage in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(tempPage.ContentStream);
+                using var json = await JsonDocument.ParseAsync(tempPage.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1077,9 +1077,9 @@ namespace TEAMModelBI.Controllers.BITest
 
             List<School> schools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "select value(c) from c", continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "select value(c) from c", continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1089,7 +1089,7 @@ namespace TEAMModelBI.Controllers.BITest
 
                     if (iscontinuation)
                     {
-                        continuationToken = item.GetContinuationToken();
+                        continuationToken = item.ContinuationToken;
                         break;
                     }
                 }
@@ -1321,13 +1321,13 @@ namespace TEAMModelBI.Controllers.BITest
 
             var cosmosDefaulat = _azureCosmos.GetCosmosClient(); //默认数据库
             List<School> schools = new();
-            await foreach (var item in cosmosDefaulat.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosDefaulat.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 schools.Add(item);
             }
             var cosmosGlobal = _azureCosmos.GetCosmosClient(name: "Global"); //默认数据库
             List<School> schoolGlobals = new();
-            await foreach (var item in cosmosGlobal.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosGlobal.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 schoolGlobals.Add(item);
             }
@@ -1353,7 +1353,7 @@ namespace TEAMModelBI.Controllers.BITest
             //School school = new();
             //if (response.Status == 200)
             //{
-            //    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(response.Content);
             //    school = json.ToObject<School>();
             //}
 

+ 32 - 30
TEAMModelBI/Controllers/BITmid/TmidController.cs

@@ -1,7 +1,7 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.Azure.Cosmos.Table;
+
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
 using System;
@@ -17,6 +17,8 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Services;
 using static TEAMModelBI.Models.Extension.GeoRegion;
+using Microsoft.Azure.Documents.Client;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelBI.Controllers.BITmid
 {
@@ -132,9 +134,9 @@ namespace TEAMModelBI.Controllers.BITmid
                        .WithParameter("@key", tmids);
                 await foreach (var item in cosmosClientCsv2
                             .GetContainer("Core", "ID2")
-                            .GetItemQueryStreamIterator(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                            .GetItemQueryStreamIteratorQuery(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -169,9 +171,9 @@ namespace TEAMModelBI.Controllers.BITmid
                     .WithParameter("@key", tmids);
                 await foreach (var item in cosmosClientCsv2
                             .GetContainer("Core", "ID2")
-                            .GetItemQueryStreamIterator(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base-ex") }))
+                            .GetItemQueryStreamIteratorQuery(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base-ex") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -375,9 +377,9 @@ namespace TEAMModelBI.Controllers.BITmid
                           .WithParameter("@key", tmidDic.Keys.ToList());
                     await foreach (var item in cosmosClientIes5
                                 .GetContainer(Constant.TEAMModelOS, "Teacher")
-                                .GetItemQueryStreamIterator(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                                .GetItemQueryStreamIteratorQuery(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -405,9 +407,9 @@ namespace TEAMModelBI.Controllers.BITmid
                                         .WithParameter("@key", schoolIds);
                                     await foreach (var itemsc in cosmosClientIes5
                                         .GetContainer(Constant.TEAMModelOS, "School")
-                                        .GetItemQueryStreamIterator(querysc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                                        .GetItemQueryStreamIteratorQuery(querysc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                                     {
-                                        using var jsonsc = await JsonDocument.ParseAsync(itemsc.ContentStream);
+                                        using var jsonsc = await JsonDocument.ParseAsync(itemsc.Content);
                                         if (jsonsc.RootElement.TryGetProperty("_count", out JsonElement countsc) && countsc.GetUInt16() > 0)
                                         {
                                             foreach (var school in jsonsc.RootElement.GetProperty("Documents").EnumerateArray())
@@ -422,7 +424,7 @@ namespace TEAMModelBI.Controllers.BITmid
                                                 //老師在此學校的課程數 ※只取當前學年
                                                 int courseCnt = 0;
                                                 var queryCrs = $"SELECT VALUE COUNT(1) FROM ( SELECT DISTINCT VALUE(c.id) FROM c JOIN schedules IN c.schedules WHERE schedules.teacherId = '{id}' AND c.year = {studyYear} )";
-                                                await foreach (int itemCrs in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<int>(queryText: queryCrs, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseTask-{schoolCodeNow}") }))
+                                                await foreach (int itemCrs in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<int>(queryText: queryCrs, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseTask-{schoolCodeNow}") }))
                                                 {
                                                     courseCnt = itemCrs;
                                                 }
@@ -464,12 +466,12 @@ namespace TEAMModelBI.Controllers.BITmid
                                 tmidStics.ies5.itemCount = 0; //題目數
                                 tmidStics.ies5.paperCount = 0; //試卷數
                                 ///IES5個人題目數
-                                await foreach (int itemC in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<int>(queryText: $"SELECT VALUE COUNT(1) FROM c WHERE c.pid = null", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{id}") }))
+                                await foreach (int itemC in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<int>(queryText: $"SELECT VALUE COUNT(1) FROM c WHERE c.pid = null", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{id}") }))
                                 {
                                     tmidStics.ies5.itemCount = itemC;
                                 }
                                 ///IES5個人試卷數
-                                await foreach (int paperC in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<int>(queryText: $"SELECT VALUE COUNT(1) FROM c WHERE c.scope = 'private'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{id}") }))
+                                await foreach (int paperC in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<int>(queryText: $"SELECT VALUE COUNT(1) FROM c WHERE c.scope = 'private'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{id}") }))
                                 {
                                     tmidStics.ies5.paperCount = paperC;
                                 }
@@ -501,9 +503,9 @@ namespace TEAMModelBI.Controllers.BITmid
                                           .WithParameter("@key", tmidDic.Keys.ToList());
                     await foreach (var item in cosmosClientCsv2
                                 .GetContainer("Core", "ID2")
-                                .GetItemQueryStreamIterator(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("benefits") }))
+                                .GetItemQueryStreamIteratorQuery(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("benefits") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -528,9 +530,9 @@ namespace TEAMModelBI.Controllers.BITmid
                       .WithParameter("@key", tmidDic.Keys.ToList());
                     await foreach (var item in cosmosClientCsv2
                                 .GetContainer("Core", "ID2")
-                                .GetItemQueryStreamIterator(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("sokrates") }))
+                                .GetItemQueryStreamIteratorQuery(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("sokrates") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -778,9 +780,9 @@ namespace TEAMModelBI.Controllers.BITmid
             {
                 await foreach (var item in cosmosClientCsv2
                 .GetContainer("Core", "ID2")
-                            .GetItemQueryStreamIterator(query, continuationToken: continuationToken, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base"), MaxItemCount = pageSize }))
+                            .GetItemQueryStreamIteratorSql(query, continuationToken: continuationToken, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base"), MaxItemCount = pageSize }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -808,7 +810,7 @@ namespace TEAMModelBI.Controllers.BITmid
                             }
                         }
                     }
-                    continuationToken = item.GetContinuationToken();
+                    continuationToken = item.ContinuationToken;
                 }
             }
             while (!string.IsNullOrWhiteSpace(continuationToken));
@@ -821,9 +823,9 @@ namespace TEAMModelBI.Controllers.BITmid
                 .WithParameter("@key", tmids);
                 await foreach (var item in cosmosClientCsv2
                             .GetContainer("Core", "ID2")
-                            .GetItemQueryStreamIterator(querye, continuationToken: continuationToken, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base-ex"), MaxItemCount = pageSize }))
+                            .GetItemQueryStreamIteratorQuery(querye, continuationToken: continuationToken, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base-ex"), MaxItemCount = pageSize }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -844,7 +846,7 @@ namespace TEAMModelBI.Controllers.BITmid
                             }
                         }
                     }
-                    continuationToken = item.GetContinuationToken();
+                    continuationToken = item.ContinuationToken;
                 }
             }
             while (!string.IsNullOrWhiteSpace(continuationToken));
@@ -871,9 +873,9 @@ namespace TEAMModelBI.Controllers.BITmid
                 string querys = $"SELECT * FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(schIds)}, c.shortCode, true)";
                 await foreach (var item in cosmosClientCsv2CnRead
                             .GetContainer("Core", "School")
-                            .GetItemQueryStreamIterator(querys, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                            .GetItemQueryStreamIteratorSql(querys, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1027,7 +1029,7 @@ namespace TEAMModelBI.Controllers.BITmid
             }
             //IOT(學校)
             string queryiot = $"SELECT * FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(schIds)}, c.schoolId, true) AND c.toolType = 'HiTeach' AND c.dateUnit = 'month' AND c.dateTime >= {dateTimeFrom.ToUnixTimeSeconds()} AND c.dateTime <= {dateTimeTo.ToUnixTimeSeconds()}";
-            await foreach (ProdAnalysisCosmos item in cosmosClientIes5.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ProdAnalysisCosmos>(queryText: queryiot, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProdAnalysis") }))
+            await foreach (ProdAnalysisCosmos item in cosmosClientIes5.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<ProdAnalysisCosmos>(queryText: queryiot, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProdAnalysis") }))
             {
                 //各校IOT累加
                 var schRow = sch.Where(s => s.id.Equals(item.schoolId)).FirstOrDefault();
@@ -1079,9 +1081,9 @@ namespace TEAMModelBI.Controllers.BITmid
             string sql = $"SELECT c.id, c.prodCode, c.type, c.startDate, c.endDate, c.number, c.unit, c.aprule FROM c WHERE {whereSql}";
             var client = cosmosClientCsv2.GetContainer("Habb", "Auth");
             var result = new List<object>();
-            await foreach (var item in client.GetItemQueryStreamIterator(queryText: sql, requestOptions: qryOption))
+            await foreach (var item in client.GetItemQueryStreamIteratorSql(queryText: sql, requestOptions: qryOption))
             {
-                var json = await JsonDocument.ParseAsync(item.ContentStream);
+                var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1114,7 +1116,7 @@ namespace TEAMModelBI.Controllers.BITmid
             {
                 strQueryV += $" AND c.prodCode = '{prodCode}'";
             }
-            await foreach (OrderHisService orderService in cosmosClientCsv2.GetContainer("Habb", "Auth").GetItemQueryIterator<OrderHisService>(strQueryV, null, qryOption))
+            await foreach (OrderHisService orderService in cosmosClientCsv2.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<OrderHisService>(queryText:strQueryV, continuationToken: null, requestOptions: qryOption))
             {
                 Ies5OrderHisService ies5OrderVRow = new Ies5OrderHisService();
                 ies5OrderVRow.prodCode = orderService.prodCode;
@@ -1199,7 +1201,7 @@ namespace TEAMModelBI.Controllers.BITmid
             if (from > 0) strQuery += $" AND c.dateTime >= {from}";
             if (to > 0) strQuery += $" AND c.dateTime <= {to}";
 
-            await foreach (TmidAnalysisCosmos tmidAnalysis in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TmidAnalysisCosmos>(strQuery, null, qryOption))
+            await foreach (TmidAnalysisCosmos tmidAnalysis in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<TmidAnalysisCosmos>(queryText:strQuery, continuationToken:null, requestOptions:qryOption))
             {
                 //特殊修正
                 tmidAnalysis.lTypeNone = ((tmidAnalysis.lTypeNone - tmidAnalysis.lessonLeng0) < 0) ? 0 : tmidAnalysis.lTypeNone - tmidAnalysis.lessonLeng0; //無學習型態數值須扣除未上課

+ 18 - 18
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -66,7 +66,7 @@ namespace TEAMModelBI.Controllers.Census
                 if (!string.IsNullOrEmpty($"{areaId}"))
                 {
                     string areaSc = $"select value(c.id) from c where c.pk='School' and c.areaId='{areaId}'";
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: areaSc, requestOptions: new QueryRequestOptions() { }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: areaSc, requestOptions: new QueryRequestOptions() { }))
                     {
                         scIds.Add(item);
                     }
@@ -260,9 +260,9 @@ namespace TEAMModelBI.Controllers.Census
                 //string stSql = $"{oftenSql} join s in c.currency where c.TeacherTrain and {comSql} and s.submitTime = 0 or s.submitTime >= {setting.submitTime}";
                 //submitCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", ctSql);
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and {comSql}", requestOptions: new QueryRequestOptions() { })) 
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and {comSql}", requestOptions: new QueryRequestOptions() { })) 
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -319,7 +319,7 @@ namespace TEAMModelBI.Controllers.Census
             //    scSqlTxt.Append($" where c.areaId='{areaId}'");
             //}
 
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: scSqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecSchool>(queryText: scSqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             //{
             //    schools.Add(item);
             //}
@@ -340,7 +340,7 @@ namespace TEAMModelBI.Controllers.Census
             //{
             //    int count = 0;
             //    int appraise = 0;
-            //    await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
+            //    await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
             //    {
             //        if (info)
             //        {
@@ -367,7 +367,7 @@ namespace TEAMModelBI.Controllers.Census
             //    else basics += 1;
 
             //    string sqlTxtSchool = $"select value(c) from c where c.code='LessonRecord-{school}'";
-            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: sqlTxtSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
+            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxtSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
             //    {
             //        records.Add(item);
             //    }
@@ -433,7 +433,7 @@ namespace TEAMModelBI.Controllers.Census
             //foreach (var tecId in tecIds)
             //{
             //    string sqlTxt = $"select value(c) from c where c.id='{tecId}'";
-            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
+            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
             //    {
             //        records.Add(item);
             //    }
@@ -565,7 +565,7 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
             List<AreaInfo> areaInfos = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<AreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
                 areaInfos.Add(item);
             }
@@ -686,9 +686,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -750,9 +750,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
                 ActivityCount activityCount = new() { id = itemId, name = school.name != null ? school.name : itemId };
@@ -795,9 +795,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
                     ActivityCount activityCount = new() { id = schoolId, name = school.name != null ? school.name : schoolId };
@@ -846,7 +846,7 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<RecSchool> schools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.scale from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.scale from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 schools.Add(item);
             }
@@ -928,9 +928,9 @@ namespace TEAMModelBI.Controllers.Census
                 }
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIteratorSql(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     infos.Add(obj.ToObject<object>());

+ 2 - 2
TEAMModelBI/Controllers/Census/BlobLogController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -145,7 +145,7 @@ namespace TEAMModelBI.Controllers.Census
             {
                 foreach (var teacherId in teacherIds)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecBlobFile>(queryText: $"SELECT c.id,c.code,c.name,c.size,c.type FROM c where c.pk='Bloblog'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{teacherId}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<RecBlobFile>(queryText: $"SELECT c.id,c.code,c.name,c.size,c.type FROM c where c.pk='Bloblog'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{teacherId}") }))
                     {
                         blobFiles.Add(item);
                     }

+ 21 - 21
TEAMModelBI/Controllers/Census/ItemSticsController.cs

@@ -5,7 +5,7 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using System.Threading.Tasks;
 using System.Collections.Generic;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
 using TEAMModelBI.Tool;
 using System;
@@ -87,9 +87,9 @@ namespace TEAMModelBI.Controllers.Census
             List<object> items = new();
             if (scope.ToString().Equals("private"))
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -102,9 +102,9 @@ namespace TEAMModelBI.Controllers.Census
             }
             else if (scope.ToString().Equals("school"))
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -117,9 +117,9 @@ namespace TEAMModelBI.Controllers.Census
             }
             else
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -130,9 +130,9 @@ namespace TEAMModelBI.Controllers.Census
                     }
                 }
 
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -172,9 +172,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var rsponse = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scid, new PartitionKey("Base"));
-                    if (rsponse.Status == 200)
+                    if (rsponse.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(rsponse.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(rsponse.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -225,9 +225,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var rsponse = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (rsponse.Status == 200) 
+                    if (rsponse.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(rsponse.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(rsponse.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -294,9 +294,9 @@ namespace TEAMModelBI.Controllers.Census
                     School school = new();
 
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200) 
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -361,9 +361,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200) 
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -430,9 +430,9 @@ namespace TEAMModelBI.Controllers.Census
                     tableName = "Teacher";
                 }
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         objItems.Add(obj.ToObject<object>());
@@ -444,9 +444,9 @@ namespace TEAMModelBI.Controllers.Census
                 List<string> tableName = new() { "School", "Teacher" };
                 foreach (string key in tableName) 
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", key).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", key).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             objItems.Add(obj.ToObject<object>());

+ 35 - 35
TEAMModelBI/Controllers/Census/LessonSticsController.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using Microsoft.Extensions.Options;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models;
@@ -73,7 +73,7 @@ namespace TEAMModelBI.Controllers.Census
             else
                 scSql.Append($" where c.areaId = null or c.areaId = ''");
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AreaSchools>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AreaSchools>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 areaSchools.Add(item);
             }
@@ -132,7 +132,7 @@ namespace TEAMModelBI.Controllers.Census
 
             foreach (var sId in schools)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: sqlTxts, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{sId}-{year}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: sqlTxts, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{sId}-{year}") }))
                 {
                     scount.Add(item);
                 }
@@ -142,7 +142,7 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var tId in teacIds)
             {
                 var sqlTxtt = $"select value(c) from c where c.id='{tId}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
                 {
                     tcount.Add(item);
                 }
@@ -229,7 +229,7 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
             List<AllAreaInfo> areaInfos = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AllAreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<AllAreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
                 areaInfos.Add(item);
             }
@@ -289,9 +289,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -354,9 +354,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -405,16 +405,16 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
                     SchoolLen schoolLen = new() { id = schoolId, name = school != null ? school.name : schoolId };
 
                     List<List<double>> begin = new();
-                    await foreach (var lcount in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{years}") }))
+                    await foreach (var lcount in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{years}") }))
                     {
                         begin.Add(lcount.beginCount);
                     }
@@ -427,7 +427,7 @@ namespace TEAMModelBI.Controllers.Census
             else
             {
                 List<List<double>> begin = new();
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: "select value(c) from c where c.pk='LessonCount'", requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: "select value(c) from c where c.pk='LessonCount'", requestOptions: new QueryRequestOptions() { }))
                 {
                     begin.Add(item.beginCount);
                 }
@@ -459,9 +459,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scid, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
@@ -485,13 +485,13 @@ namespace TEAMModelBI.Controllers.Census
                 List<LessonCount> tcount = new();
                 DenseMatrix dense = null;
                 var queryClass = $"select value(c) from c ";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{syear}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{syear}") }))
                 {
                     scount.Add(item);
                 }
                 if (tyear > syear)
                 {
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{tyear}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{tyear}") }))
                     {
                         tcount.Add(item);
                     }
@@ -573,7 +573,7 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var school in schools)
             {
                 string sqlTxt = $"select value(c) from c where c.code='LessonRecord-{school}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
                 {
                     records.Add(item);
                 }
@@ -583,7 +583,7 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var tecId in tecIds)
             {
                 string sqlTxt = $"select value(c) from c where c.id='{tecId}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
                 {
                     records.Add(item);
                 }
@@ -630,9 +630,9 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<object> lessons = new();
             string sqlTxt = $"select * from c where c.id='{lessonId}'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { })) 
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { })) 
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     lessons.Add(obj.ToObject<object>());
@@ -760,9 +760,9 @@ namespace TEAMModelBI.Controllers.Census
             List<double> yHours = new(daHours);
 
             var openRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey("LessonYear"));
-            if (openRes.Status == 200)
+            if (openRes.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(openRes.ContentStream);
+                using var json = await JsonDocument.ParseAsync(openRes.Content);
                 LessonStats lessonYear = json.ToObject<LessonStats>();
                 if (type == 0)
                 {
@@ -794,9 +794,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{hourId}", new PartitionKey("LessonHour"));
-            if (lessRes.Status == 200)
+            if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(lessRes.ContentStream);
+                using var json = await JsonDocument.ParseAsync(lessRes.Content);
                 LessonStats lessonHour = json.ToObject<LessonStats>();
                 if (type == 0)
                 {
@@ -831,9 +831,9 @@ namespace TEAMModelBI.Controllers.Census
             if (!string.IsNullOrEmpty(schoolId))
             {
                 var openResSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey($"LessonYear-{schoolId}"));
-                if (openResSc.Status == 200)
+                if (openResSc.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var jsonSc = await JsonDocument.ParseAsync(openResSc.ContentStream);
+                    using var jsonSc = await JsonDocument.ParseAsync(openResSc.Content);
                     LessonStats lessonYearSc = jsonSc.ToObject<LessonStats>();
                     if (type == 0)
                         if (lessonYearSc.open.Count == 0)
@@ -863,9 +863,9 @@ namespace TEAMModelBI.Controllers.Census
                 }
 
                 var lessResSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{hourId}", new PartitionKey($"LessonHour-{schoolId}"));
-                if (lessResSc.Status == 200)
+                if (lessResSc.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var jsonSc = await JsonDocument.ParseAsync(lessResSc.ContentStream);
+                    using var jsonSc = await JsonDocument.ParseAsync(lessResSc.Content);
                     LessonStats lessonHourSc = jsonSc.ToObject<LessonStats>();
                     if (type == 0)
                         if (lessonHourSc.open.Count == 0)
@@ -915,12 +915,12 @@ namespace TEAMModelBI.Controllers.Census
 
             List<LessonRecord> allLesson = new();
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { }))
             {
                 allLesson.Add(item);
             }
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
             {
                 allLesson.Add(item);
             }
@@ -930,9 +930,9 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var itemY in lessYears)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemY.id, new PartitionKey($"{itemY.code}"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     LessonStats lessonYear = json.ToObject<LessonStats>();
                     lessonYear.open = itemY.open;
                     lessonYear.lesson = itemY.lesson;
@@ -946,9 +946,9 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var itemH in lessHours)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemH.id, new PartitionKey($"{itemH.code}"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     LessonStats lessonHour = json.ToObject<LessonStats>();
                     lessonHour.open = itemH.open;
                     lessonHour.lesson = itemH.lesson;

+ 18 - 18
TEAMModelBI/Controllers/Census/PaperController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Sas;
@@ -104,7 +104,7 @@ namespace TEAMModelBI.Controllers.Census
             List<Paper> papers = new();
             if (scope.ToString().Equals("school"))
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Paper>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<Paper>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 {
                     papers.Add(item);
                 }
@@ -150,11 +150,11 @@ namespace TEAMModelBI.Controllers.Census
                         paper.code = $"Paper-{itemSc.newSc}";
 
                         var resState = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(paper.id, new PartitionKey(paper.code));
-                        if (resState.Status == 200)
+                        if (resState.StatusCode == System.Net.HttpStatusCode.OK)
                             paper.id = Guid.NewGuid().ToString();
 
                         msg.Append($"将学校[{cItem.oldSc}]中的[{cItem.oldId}]试卷复制到新学校试卷新id:{paper.id}");
-                        await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{paper.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{itemSc.newSc}") }))
+                        await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{paper.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{itemSc.newSc}") }))
                         {
                             existPaper.Add(item);
                         }
@@ -291,9 +291,9 @@ namespace TEAMModelBI.Controllers.Census
                     };
                     School school = new();
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -363,9 +363,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                if (response.Status == 200) 
+                if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
@@ -418,9 +418,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200) 
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -469,9 +469,9 @@ namespace TEAMModelBI.Controllers.Census
                     School school = new();
 
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if(response.Status == 200) 
+                    if(response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -481,9 +481,9 @@ namespace TEAMModelBI.Controllers.Census
 
                     schoolPaper.totals += await CommonFind.GetSqlValueCount(cosmosClient, "School", sqlTxt, $"Paper-{schoolId}");
 
-                    //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{schoolId}")}))
+                    //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{schoolId}")}))
                     //{
-                    //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    //    using var json = await JsonDocument.ParseAsync(item.Content);
                     //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                     //    {
                     //        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -536,9 +536,9 @@ namespace TEAMModelBI.Controllers.Census
                     tableName = "Teacher";
                 }
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         paperInfos.Add(obj.ToObject<object>());
@@ -550,9 +550,9 @@ namespace TEAMModelBI.Controllers.Census
                 List<string> tableName = new(){ "School", "Teacher" };
                 foreach (var temp in tableName)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", temp).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", temp).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             paperInfos.Add(obj.ToObject<object>());

+ 26 - 26
TEAMModelBI/Controllers/Census/ProductStatisController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -58,9 +58,9 @@ namespace TEAMModelBI.Controllers.Census
             //if ($"{site}".Equals(BIConst.Global))
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<ProductStatis> productStatis = new List<ProductStatis>();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c",requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c",requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -195,9 +195,9 @@ namespace TEAMModelBI.Controllers.Census
 
             //取产品的数量
             var response = await clientContainer.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolCode.ToString(), new PartitionKey($"ProductSum"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 productSum = json.ToObject<SchoolProductSum>();
                 prodinfo = productSum.prodinfo;
                 serialRecord = productSum.serial;
@@ -206,9 +206,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             //软体
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "SELECT * FROM c WHERE c.dataType='serial'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "SELECT * FROM c WHERE c.dataType='serial'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -219,9 +219,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             //服务
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "SELECT * FROM c WHERE c.dataType='service'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "SELECT * FROM c WHERE c.dataType='service'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -232,9 +232,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             //硬体
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "SELECT * FROM c WHERE c.dataType='hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "SELECT * FROM c WHERE c.dataType='hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -246,7 +246,7 @@ namespace TEAMModelBI.Controllers.Census
 
             //学校教室
             List<Room> rooms = new();
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<Room>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{schoolCode}") }))
             {
                 rooms.Add(item);
             }
@@ -277,9 +277,9 @@ namespace TEAMModelBI.Controllers.Census
                 School school = new();
 
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scid, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
@@ -287,9 +287,9 @@ namespace TEAMModelBI.Controllers.Census
 
                 List<ProductStatis> productStatis = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scid}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scid}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         ////所有的产品信息
@@ -407,15 +407,15 @@ namespace TEAMModelBI.Controllers.Census
                     List<SchoolProductSumData> Services = new();
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             //软体产品
@@ -457,9 +457,9 @@ namespace TEAMModelBI.Controllers.Census
                 //软体产品
                 List<SchoolProductSumData> Services = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         //软体产品
@@ -526,15 +526,15 @@ namespace TEAMModelBI.Controllers.Census
                 List<SchoolProductSumData> Services = new();
                 School school = new();
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         //软体产品

+ 48 - 48
TEAMModelBI/Controllers/Census/SchoolController.cs

@@ -1,5 +1,5 @@
 using Azure.Core;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using Pipelines.Sockets.Unofficial.Arenas;
@@ -199,9 +199,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
                 tecCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where ARRAY_CONTAINS(c.roles,'teacher',true) and c.status = 'join'", $"Teacher-{itemId}");
@@ -324,7 +324,7 @@ namespace TEAMModelBI.Controllers.Census
 
             //获取所有的课程记录
             List<LessonRecord> records = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
             {
                 records.Add(item);
             }
@@ -334,9 +334,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey($"Base"));
                 School sc = new();
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     sc = json.ToObject<School>();
                 }
 
@@ -379,7 +379,7 @@ namespace TEAMModelBI.Controllers.Census
             List<string> scIds = new(); //学校id集合
 
             string scIdSql = "select value(c.id) from c where c.areaId=null or c.areaId=''";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
             {
                 scIds.Add(item);
             }
@@ -423,7 +423,7 @@ namespace TEAMModelBI.Controllers.Census
             List<string> scIds = new(); //学校id集合
 
             string scIdSql = "select value(c.id) from c where c.areaId=null or c.areaId=''";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
             {
                 scIds.Add(item);
             }
@@ -431,12 +431,12 @@ namespace TEAMModelBI.Controllers.Census
             string scsSql = BICommonWay.ManyScSql("c.school", scIds);
             string cntSql = $"select value(count(c.id)) from c where {scsSql}";
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(queryText: cntSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<int>(queryText: cntSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 tchCnt += item;
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<int>(queryText: cntSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIteratorSql<int>(queryText: cntSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 stuCnt += item;
             }
@@ -444,7 +444,7 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var scId in scIds)
             {
                 string tchIdSql = $"select value(c.id) from c where array_contains(c.roles,'assist',true) and c.pk='Teacher'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: tchIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: tchIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
                 {
                     tchIds.Add(item);
                 }
@@ -509,9 +509,9 @@ namespace TEAMModelBI.Controllers.Census
             ScStats scStats = new();
 
             var respSc = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{scId}", new PartitionKey($"Base"));
-            if (respSc.Status == 200)
+            if (respSc.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(respSc.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(respSc.Content);
                 school = fileJson.ToObject<School>();
             }
             else
@@ -522,11 +522,11 @@ namespace TEAMModelBI.Controllers.Census
             StatsInfo statsInfo = null;
             List<LastYearLessAndAct> lastYear = new();
             var scDataStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{DateTimeOffset.UtcNow.Year}-{scId}", new PartitionKey("Statistics"));
-            if (scDataStats.Status == 200)
+            if (scDataStats.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(scDataStats.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(scDataStats.Content);
                 statsInfo = fileJson.ToObject<StatsInfo>();
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<LastYearLessAndAct>(queryText: $"select c.activity,c.lesson from c where c.id='{DateTimeOffset.UtcNow.Year - 1}-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<LastYearLessAndAct>(queryText: $"select c.activity,c.lesson from c where c.id='{DateTimeOffset.UtcNow.Year - 1}-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
                 {
                     lastYear.Add(item);
                 }
@@ -635,9 +635,9 @@ namespace TEAMModelBI.Controllers.Census
             ScStats scStats = new();
 
             var respSc = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{scId}", new PartitionKey($"Base"));
-            if (respSc.Status == 200)
+            if (respSc.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(respSc.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(respSc.Content);
                 school = fileJson.ToObject<School>();
             }
             else
@@ -648,11 +648,11 @@ namespace TEAMModelBI.Controllers.Census
                 StatsInfo statsInfo = null;
                 List<LastYearLessAndAct> lastYear = new();
                 var scDataStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{DateTimeOffset.UtcNow.Year}-{scId}", new PartitionKey("Statistics"));
-                if (scDataStats.Status == 200)
+                if (scDataStats.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(scDataStats.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(scDataStats.Content);
                     statsInfo = fileJson.ToObject<StatsInfo>();
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<LastYearLessAndAct>(queryText: $"select c.activity,c.lesson from c where c.id='{DateTimeOffset.UtcNow.Year - 1}-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<LastYearLessAndAct>(queryText: $"select c.activity,c.lesson from c where c.id='{DateTimeOffset.UtcNow.Year - 1}-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
                     {
                         lastYear.Add(item);
                     }
@@ -805,7 +805,7 @@ namespace TEAMModelBI.Controllers.Census
             //    var respSc = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey($"Base-Area"));
             //    if (respSc.Status == 200)
             //    {
-            //        using var fileJson = await JsonDocument.ParseAsync(respSc.ContentStream);
+            //        using var fileJson = await JsonDocument.ParseAsync(respSc.Content);
             //        area = fileJson.ToObject<Area>();
             //    }
             //    else
@@ -832,7 +832,7 @@ namespace TEAMModelBI.Controllers.Census
 
             List<string> tempProduct = new();
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelStats>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelStats>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
             {
                 if (item.serial == null) item.serial = new List<string>();
                 if (item.service == null) item.service = new List<string>();
@@ -853,7 +853,7 @@ namespace TEAMModelBI.Controllers.Census
                 statsSql.Append($"  and {BICommonWay.ManyScSql("c.id", scIds, $"{dateTime.Year}-")}");
             }
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<StatsInfo>(queryText: statsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<StatsInfo>(queryText: statsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
             {
                 statsInfos.Add(item);
             }
@@ -865,7 +865,7 @@ namespace TEAMModelBI.Controllers.Census
             }
             List<LastYearLessAndAct> lastYear = new();
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<LastYearLessAndAct>(queryText: lastStsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<LastYearLessAndAct>(queryText: lastStsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
             {
                 lastYear.Add(item);
             }
@@ -979,11 +979,11 @@ namespace TEAMModelBI.Controllers.Census
             var (mthS, mthE) = TimeHelper.GetStartOrEnd(dateTime, "month");  //本月开始/结束时间
             //學區成員修正:若學校(Base)有學區ID而學校中間件無 ->補足
             List<string> schInBIRel = new List<string>();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: $"SELECT VALUE c.id FROM c WHERE c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: $"SELECT VALUE c.id FROM c WHERE c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
             {
                 schInBIRel.Add(item);
             }
-            await foreach (School school in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: $"SELECT * FROM c WHERE c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (School school in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: $"SELECT * FROM c WHERE c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 string schId = school.id.ToString();
                 if (!schInBIRel.Contains(schId))
@@ -992,7 +992,7 @@ namespace TEAMModelBI.Controllers.Census
                 }
             }
             //學校中間件資料取得
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BISchoolInfo>(queryText: $"select c.id,c.name,c.picture,c.areaId,c.areaName,c.size,c.scale,c.assists,c.sales,c.createDate,c.serial,c.service,c.hard from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BISchoolInfo>(queryText: $"select c.id,c.name,c.picture,c.areaId,c.areaName,c.size,c.scale,c.assists,c.sales,c.createDate,c.serial,c.service,c.hard from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
             {
                 schoolInfos.Add(item);
             }
@@ -1002,7 +1002,7 @@ namespace TEAMModelBI.Controllers.Census
             if (scIds.Count > 0)
             {
                 statsSql.Append($" and {BICommonWay.ManyScSql("c.id", scIds, $"{dateTime.Year}-")}");
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<StatsInfo>(queryText: statsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<StatsInfo>(queryText: statsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
                 {
                     statsInfos.Add(item);
                 }
@@ -1012,7 +1012,7 @@ namespace TEAMModelBI.Controllers.Census
             if (scIds.Count > 0)
             {
                 lastStsSql.Append($" and {BICommonWay.ManyScSql("c.id", scIds, $"{dateTime.Year - 1}-")}");
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<LastYearLessAndAct>(queryText: lastStsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<LastYearLessAndAct>(queryText: lastStsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
                 {
                 lastYear.Add(item);
                 }
@@ -1240,7 +1240,7 @@ namespace TEAMModelBI.Controllers.Census
 
             string sql = "select value(count(c.id)) from c ";
             List<EasyInfo> easyInfos = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<EasyInfo>(queryText: $"select c.id,c.code,c.name from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<EasyInfo>(queryText: $"select c.id,c.code,c.name from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
                 easyInfos.Add(item);
             }
@@ -1250,7 +1250,7 @@ namespace TEAMModelBI.Controllers.Census
             int scWeekCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", $"{sql} where c.createTime >= {weekS} and c.createTime <= {weekE}");
             int scMonthCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", $"{sql} where c.createTime >= {mthS} and c.createTime <= {mthE}");
             List<string> scId = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<StatsInfo>(queryText: $"select value(c) from c where c.year={dateTime.Year}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<StatsInfo>(queryText: $"select value(c) from c where c.year={dateTime.Year}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
             {
                 statsInfos.Add(item);
                 if (item.activity.year.Count > 366) 
@@ -1347,14 +1347,14 @@ namespace TEAMModelBI.Controllers.Census
             var (monthS, monthE) = TimeHelper.GetStartOrEnd(dateTime, "month");  //本月开始/结束时间
 
             var client = _azureCosmos.GetCosmosClient();
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: "select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: "select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{code}") }))
             {
                 records.Add(item);
             }
             double itemCount = 0;
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT count(1) as items FROM c where c.scope = 'school' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT count(1) as items FROM c where c.scope = 'school' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1368,9 +1368,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             double paperCount = 0;
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT count(1) as papers FROM c where c.scope = 'school' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT count(1) as papers FROM c where c.scope = 'school' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1414,16 +1414,16 @@ namespace TEAMModelBI.Controllers.Census
             ////IES5實體學校學區名稱
             List<string> AreaIdList = new List<string>();
             StringBuilder sqlBiArea = new($"SELECT DISTINCT VALUE c.areaId FROM c WHERE IS_DEFINED(c.areaId) AND NOT IS_NULL(c.areaId) AND c.areaId != ''");
-            await foreach (string item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: sqlBiArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            await foreach (string item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: sqlBiArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
             {
                 AreaIdList.Add(item);
             }
             Dictionary<string, string> areaDic = new Dictionary<string, string>();
             string AreaListStr = JsonSerializer.Serialize(AreaIdList);
             StringBuilder sqlArea = new($"SELECT c.id, c.name FROM c WHERE ARRAY_CONTAINS({AreaListStr}, c.id, true)");
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: sqlArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIteratorSql(queryText: sqlArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
-                var json = await JsonDocument.ParseAsync(item.ContentStream);
+                var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     string arId = obj.GetProperty("id").GetString();
@@ -1457,7 +1457,7 @@ namespace TEAMModelBI.Controllers.Census
             //取得學校BI統計中間件
             List<BIRelation> scInfos = new();
             List<string> schIds = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
             {
                 if (!string.IsNullOrWhiteSpace(item.areaId) && areaDic.ContainsKey(item.areaId))
                 {
@@ -1471,7 +1471,7 @@ namespace TEAMModelBI.Controllers.Census
             {
                 string schIdListStr = JsonSerializer.Serialize(schIds);
                 StringBuilder sqlPSum = new($"SELECT * FROM c WHERE ARRAY_CONTAINS({schIdListStr}, c.id, true)");
-                await foreach (SchoolProductSum item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolProductSum>(queryText: sqlPSum.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (SchoolProductSum item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<SchoolProductSum>(queryText: sqlPSum.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
                     List<string> serialProdList = item.serial.Select(s => s.prodCode).ToList();
                     List<string> serviceProdList = item.service.Select(s => s.prodCode).ToList();
@@ -1490,16 +1490,16 @@ namespace TEAMModelBI.Controllers.Census
             ////取得虛擬學校學區名稱
             List<string> vrAreaIdList = new List<string>();
             StringBuilder sqlVrArea = new($"SELECT DISTINCT VALUE c.areaId FROM c WHERE IS_DEFINED(c.areaId) AND NOT IS_NULL(c.areaId) AND c.areaId != ''");
-            await foreach (string item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: sqlVrArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+            await foreach (string item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: sqlVrArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
             {
                 vrAreaIdList.Add(item);
             }
             //Dictionary<string, string> areaDic = new Dictionary<string, string>();
             string vrAreaListStr = JsonSerializer.Serialize(vrAreaIdList);
             StringBuilder vrSqlArea = new($"SELECT c.id, c.name FROM c WHERE ARRAY_CONTAINS({vrAreaListStr}, c.id, true)");
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: vrSqlArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIteratorSql(queryText: vrSqlArea.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
-                var json = await JsonDocument.ParseAsync(item.ContentStream);
+                var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     string arId = obj.GetProperty("id").GetString();
@@ -1516,7 +1516,7 @@ namespace TEAMModelBI.Controllers.Census
             {
                 sqlV.Append($" where c.areaId ='{areaId}'");
             }
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: sqlV.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: sqlV.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
             {
                 if(!string.IsNullOrWhiteSpace(item.areaId) && areaDic.ContainsKey(item.areaId))
                 {
@@ -1546,9 +1546,9 @@ namespace TEAMModelBI.Controllers.Census
             List<object> infos = new List<object>();
 
             string sqlTxt = $"select value(c) from c where c.id='{id}'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     infos.Add(obj.ToObject<object>());

+ 3 - 3
TEAMModelBI/Controllers/LoginController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using DingTalk.Api;
 using DingTalk.Api.Request;
 using DingTalk.Api.Response;
@@ -559,7 +559,7 @@ namespace TEAMModelBI.Controllers
             else return Ok(new { state = RespondCode.ParamsError, msg = "手机号/和邮箱为空" });
 
             List<BizUsers> bizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText:loginSql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText:loginSql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(item);
             }
@@ -630,7 +630,7 @@ namespace TEAMModelBI.Controllers
             else return Ok(new { state = RespondCode.ParamsError, msg = "手机号/和邮箱为空" });
 
             List<BizUsers> tempBizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: loginSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: loginSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 tempBizUsers.Add(item);
             }

+ 8 - 8
TEAMModelBI/Controllers/RepairApi/InitialAreaController.cs

@@ -14,7 +14,7 @@ using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
 using Microsoft.AspNetCore.Hosting;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
@@ -94,7 +94,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             var table = tableClient.GetTableReference("IESLogin");
 
             //查询新的是否存在
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
             {
                 if (item.standard.Equals($"{standard}"))
                     return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
@@ -169,13 +169,13 @@ namespace TEAMModelBI.Controllers.RepairApi
             Area AreaS2 = null;
             List<Area> areas = new();
 
-            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
             {
                 areas.Add(itemArea);
                 AreaS2 = itemArea;
             }
 
-            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard3'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='standard3'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
             {
                 areas.Add(itemArea);
             }
@@ -183,7 +183,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             foreach (var area in areas)
             {
                 //查询要复制区域的能力标准点 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                 {
                     if (!string.IsNullOrEmpty(item.blob))
                     {
@@ -222,7 +222,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 try
                 {
                     //微能力点
-                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                     {
                         List<Tnode> tnodes = new();
                         foreach (Tnode tnode in atask.children)
@@ -285,7 +285,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             if (AreaS2 != null)
             {
                 //新政策文件
-                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                 {
                     if (standardFile != null)
                     {
@@ -296,7 +296,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 }
 
                 //新的区域设置
-                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                 {
                     if (areaSetting != null)
                     {

+ 2 - 2
TEAMModelBI/Controllers/RepairApi/NormalController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using DinkToPdf;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
@@ -61,7 +61,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             string sql = $"select value(c) from c where c.name = '{oldName}'";
 
             Area area = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
                 area = item;
             };

+ 15 - 15
TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs

@@ -16,7 +16,7 @@ using System.Text;
 using TEAMModelOS.SDK.Extension;
 using System;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Linq;
 using TEAMModelOS.SDK.Context.Constant;
 using Pipelines.Sockets.Unofficial.Arenas;
@@ -159,12 +159,12 @@ namespace TEAMModelBI.Controllers.RepairApi
             if (!string.IsNullOrEmpty($"{periodName}"))
                 scName = $"{periodName}";
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "select value(c) from c where c.code='Base' and c.period=[]", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: "select value(c) from c where c.code='Base' and c.period=[]", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 allSc.Add(item);
             }
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: noPeriodScSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: noPeriodScSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 allSc.Add(item);
             }
@@ -418,10 +418,10 @@ namespace TEAMModelBI.Controllers.RepairApi
                 {
                     BIRelation bIRelation = null;
                     var resRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("BIRel"));
-                    if (resRel.Status == 200)
+                    if (resRel.StatusCode == System.Net.HttpStatusCode.OK)
                     {
                         continue;
-                        //using var fileJson = await JsonDocument.ParseAsync(resRel.ContentStream);
+                        //using var fileJson = await JsonDocument.ParseAsync(resRel.Content);
                         //bIRelation = fileJson.ToObject<BIRelation>();
                     }
                     else
@@ -430,7 +430,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                         string areaName = null;
                         if (!string.IsNullOrEmpty(scBaseInfo.areaId))
                         {
-                            await foreach (var itemName in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.pk='Area' and c.id='{scBaseInfo.areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+                            await foreach (var itemName in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.pk='Area' and c.id='{scBaseInfo.areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
                             {
                                 areaName = itemName;
                             }
@@ -455,9 +455,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                         };
 
                         var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("ProductSum"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             {
                                 List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -527,9 +527,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                     id = sc;
                     StatsInfo statsInfo = new();
                     var scDataStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{year}-{sc}", new PartitionKey("Statistics"));
-                    if (scDataStats.Status == 200)
+                    if (scDataStats.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(scDataStats.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(scDataStats.Content);
                         statsInfo = fileJson.ToObject<StatsInfo>();
                     }
                     else
@@ -540,7 +540,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                     statsInfo = await SchoolStatsWay.GetSingleSc(cosmosClient, redisClinet, sc, year);
                     statsInfo.witRoom = ((int)await SchoolStatsWay.GetShoolWisdomRoomCount(_azureCosmos, _azureRedis, _configuration, _httpClient, _dingDing, statsInfo.schoolId));
 
-                    if (scDataStats.Status == 200)
+                    if (scDataStats.StatusCode == System.Net.HttpStatusCode.OK)
                         taskStss.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<StatsInfo>(statsInfo, $"{year}-{sc}", new PartitionKey("Statistics")));
                     else
                         taskStss.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync<StatsInfo>(statsInfo, new PartitionKey("Statistics")));
@@ -638,9 +638,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                 where += $"ARRAY_CONTAINS({schIdListStr}, c.id, true)";
             }
             qry = $"{qry}{where}";
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: qry, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: qry, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -662,9 +662,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                     whereBIRel += $"ARRAY_CONTAINS({schIdListStr}, c.id, true)";
                 }
                 qryBIRel = $"{qryBIRel}{whereBIRel}";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: qryBIRel, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"BIRel") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: qryBIRel, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"BIRel") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())

+ 5 - 5
TEAMModelBI/Controllers/RepairApi/TeacherREPController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Pipelines.Sockets.Unofficial.Arenas;
@@ -41,7 +41,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 School school = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>($"{item}", new PartitionKey("Base"));
 
                 List<Teacher> teachers = new();
-                await foreach (var tch in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId='dghznx' and c.code='Base'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var tch in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId='dghznx' and c.code='Base'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     teachers.Add(tch);
                 }
@@ -75,7 +75,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 tchSql.Append($" where c.id='{tmdId}'");
 
             List<Teacher> tchs = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 tchs.Add(item);
             }
@@ -90,9 +90,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                     foreach (var teacher in tch.schools)
                     {
                         var resSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{teacher.schoolId}", new PartitionKey("Base"));
-                        if (resSc.Status == 200)
+                        if (resSc.StatusCode == System.Net.HttpStatusCode.OK)
                         {
-                            using var areaBase = await JsonDocument.ParseAsync(resSc.ContentStream);
+                            using var areaBase = await JsonDocument.ParseAsync(resSc.Content);
                             School school = areaBase.ToObject<School>();
                             if (teacher.areaId != school.areaId)
                                 teacher.areaId = school.areaId;

+ 0 - 1
TEAMModelBI/Filter/RequestAuditFilter.cs

@@ -12,7 +12,6 @@ using Azure.Core;
 using TEAMModelOS.SDK.DI;
 using Microsoft.Extensions.Primitives;
 using System.Net.Http;
-using System.ServiceModel.Channels;
 using System.Net;
 using System.Net.Http.Json;
 using Microsoft.Extensions.Options;

+ 0 - 1
TEAMModelBI/Startup.cs

@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.SpaServices;
-using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;

+ 22 - 21
TEAMModelBI/Tool/CommonFind.cs

@@ -1,10 +1,11 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 
 namespace TEAMModelBI.Tool
@@ -24,9 +25,9 @@ namespace TEAMModelBI.Tool
             try
             {
                 string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, '{roles}', true) AND c.pk = 'Teacher' AND c.status = 'join' AND c.code = 'Teacher-{schoolId}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         SchoolTeacherRoles str = new()
@@ -57,9 +58,9 @@ namespace TEAMModelBI.Tool
         {
             List<string> schoolIds = new();
             //string schoolSql = $"SELECT DISTINCT REPLACE(c.code,'Teacher-','') AS schoolId,c.code,c.roles,c.id,c.name From c where ARRAY_CONTAINS(c.roles,'assist',true) AND c.status = 'join' AND c.id='{tmdId}'";
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: schoolSql, requestOptions: new QueryRequestOptions() { }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: schoolSql, requestOptions: new QueryRequestOptions() { }))
             //{
-            //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(item.Content);
             //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
             //    {
             //        schoolIds.Add(obj.GetProperty("schoolId").GetString());
@@ -71,7 +72,7 @@ namespace TEAMModelBI.Tool
                 schoolSql.Append($" and (array_contains(c.roles,'assist',true) or array_contains(c.roles,'sales',true))");
             else
                 schoolSql.Append($" and array_contains(c.roles,'{roles}',true)");
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: schoolSql.ToString(), requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: schoolSql.ToString(), requestOptions: new QueryRequestOptions() { }))
             {
                 schoolIds.Add(item);
             }
@@ -90,7 +91,7 @@ namespace TEAMModelBI.Tool
         public static async Task<List<string>> GetValueSingle(CosmosClient cosmosClient, string container, string sqlTxt, string code = null)
         {
             List<string> ids = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { })) 
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { })) 
             {
                 ids.Add(item);
             }
@@ -110,9 +111,9 @@ namespace TEAMModelBI.Tool
         public async Task<List<string>> GetStreamSingle(CosmosClient cosmosClient, string container, string sqlTxt, string single = "id", string code = null)
         {
             List<string> ids = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     ids.Add(obj.GetProperty(single).GetString());
@@ -132,14 +133,14 @@ namespace TEAMModelBI.Tool
         public static async Task<List<string>> FindScIds(CosmosClient cosmosClient, string sqlTxt, string code)
         {
             List<string> schoolIds = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 schoolIds.Add(item);
             }
 
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             //{
-            //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(item.Content);
             //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
             //    {
             //        schoolIds.Add(obj.GetProperty("id").GetString());
@@ -168,14 +169,14 @@ namespace TEAMModelBI.Tool
             foreach (var school in schools) 
             {
                 string sqlTxt = $"select value(c.id) from c where ARRAY_CONTAINS(c.roles,'{rolesName}',true) and c.status = 'join'";
-                await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
+                await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
                 {
                     teachers.Add(itemTeac);
                 }
                 //string sqlTxt = $"select c.id from c where ARRAY_CONTAINS(c.roles,'{rolesName}',true) and c.status = 'join'";
-                //await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() {PartitionKey =new PartitionKey($"Teacher-{school}") }))
+                //await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() {PartitionKey =new PartitionKey($"Teacher-{school}") }))
                 //{
-                //    using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                 //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 //    {
                 //        teachers.Add(obj.GetProperty("id").GetString());
@@ -198,7 +199,7 @@ namespace TEAMModelBI.Tool
             int totals = 0;
             try
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     totals = item;
                 }
@@ -221,7 +222,7 @@ namespace TEAMModelBI.Tool
             int totals = 0;
             foreach (var container in containers)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     totals += item;
                 }
@@ -241,7 +242,7 @@ namespace TEAMModelBI.Tool
         public static async Task<double> GetSqlValueDoubleCounnt(CosmosClient cosmosClient, string container, string SqlTxt, string code = null)
         {
             double totals = 0;
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 totals = item;
             }
@@ -262,7 +263,7 @@ namespace TEAMModelBI.Tool
             double totals = 0;
             foreach (var container in containers)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     totals += item;
                 }
@@ -285,7 +286,7 @@ namespace TEAMModelBI.Tool
             List<T> temps = new();
             foreach (var container in containers)
             {
-                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     temps.Add(items);
                 }
@@ -305,7 +306,7 @@ namespace TEAMModelBI.Tool
         public static async Task<List<T>> GetObject<T>(CosmosClient cosmosClient, string containers, string sqlTxt, string code = null)
         {
             List<T> temps = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIterator<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIteratorSql<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 temps.Add(items);
             }

+ 8 - 7
TEAMModelBI/Tool/CosmosBank/ActivityWay.cs

@@ -1,7 +1,8 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Collections.Generic;
 using System.Text.Json;
 using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelBI.Tool.CosmosBank
 {
@@ -28,9 +29,9 @@ namespace TEAMModelBI.Tool.CosmosBank
                     {
                         foreach (string sc in scIds)
                         {
-                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
+                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
                             {
-                                using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                                using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                                 {
                                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -46,9 +47,9 @@ namespace TEAMModelBI.Tool.CosmosBank
                     {
                         foreach (string sc in scIds)
                         {
-                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
+                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
                             {
-                                using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                                using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                                 {
                                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -81,7 +82,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                 foreach (string type in types)
                 {
                     string sqlTxt = $"select value(count(c.id)) from c where c.pk='{type}' {condSql}";
-                    await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
                         total += cnt;
                     }
@@ -110,7 +111,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                     foreach (string type in types)
                     {
                         string sqlTxt = $"select value(count(c.id)) from c where c.pk='{type}' {condSql}";
-                        await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                        await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                         {
                             total += cnt;
                         }

+ 5 - 4
TEAMModelBI/Tool/CosmosBank/JointlySingleQuery1.cs

@@ -1,6 +1,7 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelBI.Tool.CosmosBank
 {
@@ -25,7 +26,7 @@ namespace TEAMModelBI.Tool.CosmosBank
 
             foreach (string conId in containerId) 
             {
-                await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", conId).GetItemQueryIterator<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", conId).GetItemQueryIteratorSql<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     totals += itemInt;
                 }
@@ -51,7 +52,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                 sql = sqlTxt;
             }
 
-            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
                 totals += itemInt;
             }
@@ -71,7 +72,7 @@ namespace TEAMModelBI.Tool.CosmosBank
         {
             List<string> strList = new();
 
-            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", containerId).GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", containerId).GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
                 strList.Add(itemInt);
             }

+ 4 - 3
TEAMModelBI/Tool/CosmosBank/ProductWay.cs

@@ -1,8 +1,9 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Collections.Generic;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 
 namespace TEAMModelBI.Tool.CosmosBank
@@ -25,9 +26,9 @@ namespace TEAMModelBI.Tool.CosmosBank
             foreach (var sc in scIds) 
             {
                 string sqlTxt = $"select array_length(c.service) as totals from c where c.id='{sc.id}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())

+ 4 - 3
TEAMModelBI/Tool/CosmosBank/SchoolWay.cs

@@ -1,10 +1,11 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
@@ -25,7 +26,7 @@ namespace TEAMModelBI.Tool.CosmosBank
             List<BaseInfo> advSchools = new();
             foreach (var item in schoolIds)
             {
-                await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<BaseInfo>(queryText: $"select c.id,c.name,c.picture,c.areaId from c where c.id='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<BaseInfo>(queryText: $"select c.id,c.name,c.picture,c.areaId from c where c.id='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     advSchools.Add(info);
                 }
@@ -51,7 +52,7 @@ namespace TEAMModelBI.Tool.CosmosBank
             {
                 BIRelation bIRelation = new();
                 var resBiRel = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(item, new PartitionKey($"BIRel"));
-                if (resBiRel.Status == 200)
+                if (resBiRel.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     JsonDocument jsonD = JsonDocument.Parse(resBiRel.Content);
                     bIRelation = jsonD.RootElement.ToObject<BIRelation>();

+ 11 - 10
TEAMModelBI/Tool/CosmosBank/StatsWay.cs

@@ -1,9 +1,10 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
@@ -108,7 +109,7 @@ namespace TEAMModelBI.Tool.CosmosBank
 
             List<LessRelStats> lessRelStats = new();
             string sql = $"select c.id,c.code,c.startTime,c.clientInteractionCount from c where c.pk='LessonRecord' and c.startTime >= {lastYearS} and c.startTime <= {yearE}";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{id}") })) 
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{id}") })) 
             {
                 lessRelStats.Add(item);
             }
@@ -247,14 +248,14 @@ namespace TEAMModelBI.Tool.CosmosBank
                 {
                     case "Exam":
                         exam = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Exam-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{scId}")}))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{scId}")}))
                         {
                             examSts.Add(item);
                         }
                         break;
                     case "Survey":
                         survey = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Survey-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{scId}") }))
                         {
                             surveySts.Add(item);
                         }
@@ -262,14 +263,14 @@ namespace TEAMModelBI.Tool.CosmosBank
                         break;
                     case "Vote":
                         vote = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Vote-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{scId}") }))
                         {
                             voteSts.Add(item);
                         }
                         break;
                     case "Homework":
                         homework = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Homework-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{scId}") }))
                         {
                             homeworkSts.Add(item);
                         }
@@ -431,13 +432,13 @@ namespace TEAMModelBI.Tool.CosmosBank
             List<AreaStudy> trains = new();
 
             School school = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>($"{scId}", new PartitionKey("Base"));
-            //cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText:$"select value(c.areaId) from c where c.id='{scId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")});
+            //cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText:$"select value(c.areaId) from c where c.id='{scId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")});
 
             AreaSetting setting = null;
             var responSett = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{school.areaId}", new PartitionKey("AreaSetting"));
-            if (responSett.Status == 200)
+            if (responSett.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(responSett.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(responSett.Content);
                 setting = fileJson.ToObject<AreaSetting>();
             }
             if (setting == null)
@@ -453,7 +454,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                 };
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<AreaStudy>(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and c.school='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{scId}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<AreaStudy>(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and c.school='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{scId}") }))
             {
                 trains.Add(item);
             }

+ 19 - 19
TEAMModelOS.Function/CosmosDBTriggers/TriggerArt.cs

@@ -10,7 +10,7 @@ using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 
 using TEAMModelOS.Function;
@@ -61,7 +61,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     adcode = $"Activity-{tdata.creatorId}";
                     blobcntr = tdata.creatorId;
                 }
-                ArtEvaluation art = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ArtEvaluation>(tdata.id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                ArtEvaluation art = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ArtEvaluation>(tdata.id, new PartitionKey($"{tdata.code}"));
 
                 if (art != null)
                 {
@@ -255,9 +255,9 @@ namespace TEAMModelOS.CosmosDBTriggers
                                  {
                                      *//* List<(string id, string code, List<Tasks> settings)> artSchools = new();
                                       string ql = $"select c.id,c.school,c.settings,c.classes from c where  c.pk = 'Art' and c.pId = '{art.id}'";
-                                      await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: ql))
+                                      await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIteratorSql(queryText: ql))
                                       {
-                                          using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                                          using var json = await JsonDocument.ParseAsync(item.Content);
                                           if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                                           {
                                               var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
@@ -342,20 +342,20 @@ namespace TEAMModelOS.CosmosDBTriggers
                             //根据学校编码去获取区级ID
                             try {
                                 School scInfo = new();
-                                //School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
-                                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
-                                if (response.Status == 200)
+                                //School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new PartitionKey("Base"));
+                                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{art.school}", partitionKey: new PartitionKey("Base"));
+                                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                                 {
-                                    using var cJson = await JsonDocument.ParseAsync(response.ContentStream);
+                                    using var cJson = await JsonDocument.ParseAsync(response.Content);
                                     scInfo = cJson.ToObject<School>();
                                 }
                                 ArtSetting setting = new();
                                 try
                                 {
-                                    var artResponse = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{scInfo.areaId}", partitionKey: new Azure.Cosmos.PartitionKey("ArtSetting"));
-                                    if (response.Status == 200)
+                                    var artResponse = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{scInfo.areaId}", partitionKey: new PartitionKey("ArtSetting"));
+                                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                                     {
-                                        using var json = await JsonDocument.ParseAsync(artResponse.ContentStream);
+                                        using var json = await JsonDocument.ParseAsync(artResponse.Content);
                                         setting = json.ToObject<ArtSetting>();
                                     }
                                 }
@@ -375,9 +375,9 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     });
                                     List<string> results = new();
                                     results = ids.Select(x => x.id).ToList();
-                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId in ({string.Join(",", results.Select(x => $"'{x}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{art.school}") }))
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.examId in ({string.Join(",", results.Select(x => $"'{x}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{art.school}") }))
                                     {
-                                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                                        using var json = await JsonDocument.ParseAsync(item.Content);
                                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                                         {
                                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -388,7 +388,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     }
                                     //获取该艺术评测下面的评测活动
                                     List<ExamInfo> exams = new();
-                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ExamInfo>(queryText: $"select value(c) from c where c.pk = 'Exam' and c.id in ({string.Join(",", results.Select(o => $"'{o}'"))})"))
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIteratorSql<ExamInfo>(queryText: $"select value(c) from c where c.pk = 'Exam' and c.id in ({string.Join(",", results.Select(o => $"'{o}'"))})"))
                                     {
                                         exams.Add(item);
                                     }
@@ -400,7 +400,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     List<StudentArtResult> studentArtResults = new();
                                     string sql = $"SELECT value c FROM c   where  c.pk='ArtResult' ";
                                     await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student)
-                                        .GetItemQueryIterator<StudentArtResult>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{art.id}") }))
+                                        .GetItemQueryIteratorSql<StudentArtResult>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{art.id}") }))
                                     {
                                         studentArtResults.Add(item);
                                     }
@@ -798,7 +798,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -815,9 +815,9 @@ namespace TEAMModelOS.CosmosDBTriggers
                 string subjectId = string.Empty;
                 List<Knowledge> knowledges = new();
                 List<(string name, List<string> kno)> blocks = new();
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     School sc = json.ToObject<School>();
                     var subjects = sc.period.Where(p => p.id.Equals(pId)).Select(x => x.subjects);
                     foreach (var sj in subjects)
@@ -838,7 +838,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                         sql.Append($" where c.periodId = '{pId}'");
                     }
 
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
                         knowledges.Add(item);
                     }

+ 17 - 17
TEAMModelOS.Function/CosmosDBTriggers/TriggerCorrect.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using System.Text.Json;
 using TEAMModelOS.SDK.DI;
@@ -56,7 +56,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             var table = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
 
             try {
-                Correct correct = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Correct>(tdata.id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                Correct correct = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Correct>(tdata.id, new PartitionKey($"{tdata.code}"));
 
                 if (correct != null)
                 {
@@ -99,7 +99,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                             string eid = correct.id;
                             //评测的分区键
                             string ecode = correct.scode;
-                            ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(tdata.id, new Azure.Cosmos.PartitionKey($"{ecode}"));
+                            ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(tdata.id, new PartitionKey($"{ecode}"));
                             if (correct.subs.IsNotEmpty())
                             {
 
@@ -144,7 +144,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                                 createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                                                 source = info.source
                                             };
-                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new PartitionKey(task.code));
                                         }
                                     }
 
@@ -184,7 +184,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                                 type = 2,
                                                 createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                             };
-                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new PartitionKey(task.code));
                                         }
 
 
@@ -226,7 +226,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                                 type = 3,
                                                 createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                             };
-                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new PartitionKey(task.code));
                                         }
 
 
@@ -235,7 +235,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     string subjectId = sub.id;
                                     //生成临时作答数据存放到redis
                                     //var redisClient = _azureRedis.GetRedisClient(8);
-                                    //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(eid, new Azure.Cosmos.PartitionKey(ecode));
+                                    //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(eid, new PartitionKey(ecode));
                                     List<ExamClassResult> classResults = new List<ExamClassResult>();
                                     //获取原题配分
                                     int paperIndex = 0;
@@ -255,18 +255,18 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     if (info.scope.Equals("school"))
                                     {
 
-                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(
                                         queryText: $"select value(c) from c where c.examId = '{eid}' and c.subjectId = '{subjectId}'",
-                                        requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.school}") }))
+                                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
                                         {
                                             classResults.Add(item);
                                         }
                                     }
                                     else
                                     {
-                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(
                                             queryText: $"select value(c) from c where c.examId = '{eid}' and c.subjectId = '{subjectId}'",
-                                            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
+                                            requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
                                         {
                                             classResults.Add(item);
                                         }
@@ -345,7 +345,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                                     model = sub.model
 
                                                 };
-                                                tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<SDK.Models.Cosmos.Common.Scoring>(sc, new Azure.Cosmos.PartitionKey(sc.code)));
+                                                tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<SDK.Models.Cosmos.Common.Scoring>(sc, new PartitionKey(sc.code)));
                                             }
                                             //tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{eid}-{subjectId}", stuId, new { tmdId = tmds, ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "", score = examClass.studentScores[index] }.ToJsonString()));
                                         }
@@ -393,7 +393,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     foreach (var marker in sub.markers)
                                     {
                                         ids.Add(marker.id);
-                                        //await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code),new ItemRequestOptions().PostTriggers);
+                                        //await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new PartitionKey(task.code),new ItemRequestOptions().PostTriggers);
                                     }
                                 }
                                 //异常卷处理人员
@@ -424,9 +424,9 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 List<CorrectTask> corrects = new List<CorrectTask>();
                                 foreach (string id in ids)
                                 {
-                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<CorrectTask>(
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<CorrectTask>(
                                           queryText: $"select value(c) from c where c.cid = '{correct.id}'",
-                                          requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"CorrectTask-{id}") }))
+                                          requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CorrectTask-{id}") }))
                                     {
                                         corrects.Add(item);
                                     }
@@ -435,7 +435,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 foreach (CorrectTask task in corrects)
                                 {
                                     task.progress = "finish";
-                                    tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(task, task.id, new Azure.Cosmos.PartitionKey(task.code)));
+                                    tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(task, task.id, new PartitionKey(task.code)));
                                 }
                                 await Task.WhenAll(tasks);
                             }
@@ -445,7 +445,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception e)
             {

+ 31 - 31
TEAMModelOS.Function/CosmosDBTriggers/TriggerExam.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
@@ -67,14 +67,14 @@ namespace TEAMModelOS.CosmosDBTriggers
                     await BIStats.SetTypeAddStats(client, _dingDing, data.school, "Exam", -1, careDate: data.startTime);//BI统计增/减量
                     return;
                 }
-                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(data.id, new Azure.Cosmos.PartitionKey($"{data.code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(data.id, new PartitionKey($"{data.code}"));
                 if (info != null)
                 {
                     if (info.scope.Equals("teacher", StringComparison.OrdinalIgnoreCase) || info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
                     {
-                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
                         {
-                            using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(item.Content);
                             if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                             {
                                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -86,9 +86,9 @@ namespace TEAMModelOS.CosmosDBTriggers
                     }
                     else
                     {
-                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{data.school}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{data.school}") }))
                         {
-                            using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(item.Content);
                             if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                             {
                                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -106,7 +106,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     School sc = new();
                     if (!string.IsNullOrEmpty(info.school) && !info.school.Equals("SYSTEM_NO_SCHOOL"))
                     {
-                        sc = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
+                        sc = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new PartitionKey("Base"));
                     }
 
                     foreach (ExamSubject subject in info.subjects)
@@ -115,7 +115,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     }
                     //整合名单
                     List<string> classes = ExamService.getClasses(info.classes, info.stuLists);
-                    //ChangeRecord record = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ChangeRecord>(input.Id, new Azure.Cosmos.PartitionKey($"{info.progress}"));
+                    //ChangeRecord record = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ChangeRecord>(input.Id, new PartitionKey($"{info.progress}"));
                     switch (info.progress)
                     {
                         case "pending":
@@ -133,7 +133,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(data.startTime));
                                 records[0].sequenceNumber = start;
                                 await table.SaveOrUpdate<ChangeRecord>(records[0]);
-                                //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
+                                //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new PartitionKey($"{record.code}"));
                             }
                             else
                             {
@@ -147,7 +147,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     msgId = message.MessageId
                                 };
                                 await table.Save<ChangeRecord>(changeRecord);
-                                //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
+                                //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new PartitionKey($"{changeRecord.code}"));
                             }
                             break;
                         case "going":
@@ -230,11 +230,11 @@ namespace TEAMModelOS.CosmosDBTriggers
                                                 marks.Add(new List<Details>());
                                                 ansPoint.Add(-1);
                                             }
-                                            var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
-                                            if (sresponse.Status == 200)
+                                            var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new PartitionKey($"Class-{info.school}"));
+                                            if (sresponse.StatusCode == System.Net.HttpStatusCode.OK)
                                             {
 
-                                                using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
+                                                using var json = await JsonDocument.ParseAsync(sresponse.Content);
                                                 Class classroom = json.ToObject<Class>();
 
                                                 foreach (SDK.Models.Period period in sc.period)
@@ -267,9 +267,9 @@ namespace TEAMModelOS.CosmosDBTriggers
                                                 //result.info.name = classroom.name;
                                                 //result.gradeId = classroom.year.ToString();
                                                 //处理班级人数
-                                                /* await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{info.school}") }))
+                                                /* await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIteratorSql(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{info.school}") }))
                                                  {
-                                                     using var json_stu = await JsonDocument.ParseAsync(item.ContentStream);
+                                                     using var json_stu = await JsonDocument.ParseAsync(item.Content);
                                                      if (json_stu.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                                                      {
                                                          var accounts = json_stu.RootElement.GetProperty("Documents").EnumerateArray();
@@ -283,10 +283,10 @@ namespace TEAMModelOS.CosmosDBTriggers
                                             }
                                             /*if (info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
                                             {
-                                                var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"GroupList"));
+                                                var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(cla, new PartitionKey($"GroupList"));
                                                 if (stuResponse.Status == 200)
                                                 {
-                                                    using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
+                                                    using var json = await JsonDocument.ParseAsync(stuResponse.Content);
                                                     GroupList stuList = json.ToObject<GroupList>();
                                                     //result.info.id = stuList.id;
                                                     result.info.name = stuList.name;
@@ -304,10 +304,10 @@ namespace TEAMModelOS.CosmosDBTriggers
                                             }
                                             else
                                             {
-                                                var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"GroupList-{info.school}"));
+                                                var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new PartitionKey($"GroupList-{info.school}"));
                                                 if (stuResponse.Status == 200)
                                                 {
-                                                    using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
+                                                    using var json = await JsonDocument.ParseAsync(stuResponse.Content);
                                                     GroupList stuList = json.ToObject<GroupList>();
                                                     //result.info.id = stuList.id;
                                                     result.info.name = stuList.name;
@@ -406,7 +406,7 @@ namespace TEAMModelOS.CosmosDBTriggers
 
                                         records[0].sequenceNumber = end;
                                         await table.SaveOrUpdate<ChangeRecord>(records[0]);
-                                        //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
+                                        //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new PartitionKey($"{record.code}"));
                                     }
                                     else
                                     {
@@ -420,7 +420,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                             msgId = messageEnd.MessageId
                                         };
                                         await table.Save<ChangeRecord>(changeRecord);
-                                        //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
+                                        //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new PartitionKey($"{changeRecord.code}"));
                                     }
                                 } catch (Exception e) {
                                     await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-ChangeRecord{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
@@ -542,7 +542,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, info.school, info.classes, info.stuLists, null);
                                     info.staffIds = idList;
 
-                                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
+                                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
                                 }
                                 await SetLearnRecordContent(info, data, _azureStorage, _azureCosmos);
                             }
@@ -562,7 +562,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception e)
             {
@@ -618,7 +618,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 }
                                 List<StudentAnswers> studentAnswersList = new List<StudentAnswers>();
                                 List<string> stuListForSql = new List<string>();
-                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<StudentAnswers>(queryText: sbsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{rootName}") }))
+                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIteratorSql<StudentAnswers>(queryText: sbsql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{rootName}") }))
                                 {
                                     studentAnswersList.Add(item);
                                     stuListForSql = stuListForSql.Union(item.studentIds).ToList();
@@ -628,7 +628,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 if(!string.IsNullOrWhiteSpace(info.school))
                                 {
                                     StringBuilder stusql = new StringBuilder($"SELECT VALUE c.id FROM c WHERE c.pk = 'Base' AND ARRAY_CONTAINS({System.Text.Json.JsonSerializer.Serialize(stuListForSql)}, c.id)");
-                                    await foreach (string item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<string>(queryText: stusql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{info.school}") }))
+                                    await foreach (string item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIteratorSql<string>(queryText: stusql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{info.school}") }))
                                     {
                                         stuDic[info.school].Add(item);
                                     }
@@ -1003,8 +1003,8 @@ namespace TEAMModelOS.CosmosDBTriggers
             //计算单次考试简易统计信息
             Settlement settlement = new();
             List<ExamResult> examResults = new();
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(
-                               queryText: $"select value(c) from c where c.examId  = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(
+                               queryText: $"select value(c) from c where c.examId  = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{info.id}") }))
             {
                 examResults.Add(item);
             }
@@ -1483,7 +1483,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                             classResult.pc = pc;
                             classResult.krate = persent;
                         }
-                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}"));
                     }
                     foreach (string k in knowledgeName)
                     {
@@ -1629,7 +1629,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                         classResult.fpc = pc;
                         classResult.frate = persent;
                     }
-                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}"));
                 }
 
                 for (int i = 0; i < knowledgeName.Count; i++)
@@ -1890,7 +1890,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             if (info.qamode != 2) {
                 await examRecordCount(info, subject, _dingDing, no, result, examClassResults, _azureCosmos);
             }          
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}"));
+            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(result, new PartitionKey($"ExamResult-{info.id}"));
             List<ErrorItems> errorItems = new();
             string code = string.Empty;
             string pk = string.Empty;
@@ -1909,7 +1909,7 @@ namespace TEAMModelOS.CosmosDBTriggers
 
             if (result.studentIds.Any()) {
                 string sqlqueryText = $"select value(c) from c where c.activityId = '{info.id}'and c.subjectId = '{info.subjects[no].id}' and c.stuId in ({string.Join(",", result.studentIds.Select(x => $"'{x}'"))})";
-                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIteratorSql<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     errorItems.Add(item);
                 }

+ 1 - 1
TEAMModelOS.Function/CosmosDBTriggers/TriggerExamImport.cs

@@ -7,7 +7,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Net.Http;
 using TEAMModelOS.SDK.Models.Cosmos.School;
 using TEAMModelOS.SDK.Extension;

+ 7 - 6
TEAMModelOS.Function/CosmosDBTriggers/TriggerExamLite.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Azure.Documents;
 using Microsoft.Extensions.Configuration;
@@ -15,6 +15,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.Function;
+
 namespace TEAMModelOS.CosmosDBTriggers
 {
     public static class TriggerExamLite
@@ -26,7 +27,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             {
                 if ((tdata.status != null && tdata.status.Value == 404))
                 {
-                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new   Microsoft.Azure.Cosmos.PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                    // await IESActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     var table_cancel = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
@@ -60,7 +61,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     blobcntr = tdata.creatorId;
                 }
                // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修评测活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作", GroupNames.醍摩豆服務運維群組);
-                ExamLite lite = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamLite>(tdata.id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                ExamLite lite = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamLite>(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey($"{tdata.code}"));
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
                 if (lite != null)
                 {
@@ -119,7 +120,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 School school = null;
                                 if (!string.IsNullOrEmpty(lite.school))
                                 {
-                                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(lite.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(lite.school, new Microsoft.Azure.Cosmos.PartitionKey("Base"));
                                     list.school = school.id;
                                     list.standard = school.standard;
                                 }
@@ -198,7 +199,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, lite.school, lite.classes, lite.stuLists, lite.tchLists, gls);
                                 lite.staffIds = idList;
 
-                                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamLite>(lite, lite.id, new Azure.Cosmos.PartitionKey(lite.code));
+                                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamLite>(lite, lite.id, new Microsoft.Azure.Cosmos.PartitionKey(lite.code));
                             }
                                 
 
@@ -211,7 +212,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {

+ 8 - 8
TEAMModelOS.Function/CosmosDBTriggers/TriggerHomework.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Azure.Documents;
 using Microsoft.Extensions.Configuration;
@@ -27,7 +27,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             {
                 if ((tdata.status != null && tdata.status.Value == 404))
                 {
-                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     //await IESActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     var table_cancel = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
@@ -63,7 +63,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     blobcntr = tdata.creatorId;
                 }
                 //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}作业活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作", GroupNames.醍摩豆服務運維群組);
-                Homework work = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Homework>(tdata.id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                Homework work = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Homework>(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey($"{tdata.code}"));
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
                 if (work != null)
                 {
@@ -170,7 +170,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     List<FMember> idsList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, work.school, work.classes, work.stuLists, work.tchLists, gls);
                                     work.staffIds = idsList;
 
-                                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Homework>(work, work.id, new Azure.Cosmos.PartitionKey(work.code));
+                                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Homework>(work, work.id, new Microsoft.Azure.Cosmos.PartitionKey(work.code));
                                 }
                             } catch (Exception e) {
                                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修作业活动finish{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
@@ -188,7 +188,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -220,12 +220,12 @@ namespace TEAMModelOS.CosmosDBTriggers
             //List<StuActivity> tac = new();
             List<string> tIds = addStudentsCls.Select(x => x.id).ToList();
             /*
-                         await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuActivity>(queryText: $"select value(c) from c where c.id ='{work.id}' and c.type = 'Homework'"))
+                         await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIteratorSql<StuActivity>(queryText: $"select value(c) from c where c.id ='{work.id}' and c.type = 'Homework'"))
             {
                 tac.Add(item);
 
             }
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuActivity>(queryText: $"select value(c) from c where c.id ='{work.id}' and c.type = 'Homework'"))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<StuActivity>(queryText: $"select value(c) from c where c.id ='{work.id}' and c.type = 'Homework'"))
             {
                 tac.Add(item);
 
@@ -350,7 +350,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                 School school = null;
                 if (!string.IsNullOrEmpty(work.school))
                 {
-                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(work.school, new Azure.Cosmos.PartitionKey("Base"));
+                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(work.school, new Microsoft.Azure.Cosmos.PartitionKey("Base"));
                     list.school = school.id;
                     list.standard = school.standard;
                 }

+ 1 - 1
TEAMModelOS.Function/CosmosDBTriggers/TriggerQuotaImport.cs

@@ -8,7 +8,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.School;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Extension;

+ 9 - 9
TEAMModelOS.Function/CosmosDBTriggers/TriggerStudy.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
  
 using Microsoft.Azure.Documents;
@@ -28,7 +28,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             {
                 if ((tdata.status != null && tdata.status.Value == 404)  || tdata.publish == 1)
                 {
-                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     //await IESActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     var table_cancel = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
@@ -63,7 +63,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     blobcntr = tdata.creatorId;
                 }
               
-                Study study = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>(tdata.id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                Study study = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey($"{tdata.code}"));
                 
                 if (study != null)
                 {
@@ -125,16 +125,16 @@ namespace TEAMModelOS.CosmosDBTriggers
                                     School school = null;
                                     if (!string.IsNullOrEmpty(study.school))
                                     {
-                                        school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(study.school, new Azure.Cosmos.PartitionKey("Base"));
+                                        school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(study.school, new Microsoft.Azure.Cosmos.PartitionKey("Base"));
                                         list.school = school.id;
                                         list.standard = school.standard;
                                     }
                                     string queryScore = $" select c.id from c where c.id ='{study.id}' and c.pk = 'Activity' ";
                                     List<string> ids = new();
-                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryStreamIterator
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryStreamIteratorSql
                                         (queryText: queryScore))
                                     {
-                                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                                        using var json = await JsonDocument.ParseAsync(item.Content);
                                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                                         {
                                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -183,7 +183,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 if (study.teacIds != null && study.teacIds.Count == 0)
                                 {
                                     study.teacIds = list.tmdids;
-                                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(study, study.id, new PartitionKey($"{study.code}"));
+                                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(study, study.id, new Microsoft.Azure.Cosmos.PartitionKey($"{study.code}"));
                                 }
 
                                 if (changeRecords.Count > 0)
@@ -243,7 +243,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 {
                                     List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, study.school, study.classes, study.stuLists, study.tchLists, gls);
                                     study.staffIds = idList;
-                                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Study>(study, study.id, new Azure.Cosmos.PartitionKey(study.code));
+                                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Study>(study, study.id, new Microsoft.Azure.Cosmos.PartitionKey(study.code));
 
                                 }
 
@@ -263,7 +263,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {

+ 8 - 8
TEAMModelOS.Function/CosmosDBTriggers/TriggerSurvey.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Sas;
@@ -33,7 +33,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             {
                 if ((tdata.status != null && tdata.status.Value == 404) )
                 {
-                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     //await IESActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Record:{tdata.id}");
@@ -70,7 +70,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     adcode = $"Activity-{tdata.creatorId}";
                     blobcntr = tdata.creatorId;
                 }
-                Survey survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(tdata.id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                Survey survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey($"{tdata.code}"));
 
                 if (survey != null)
                 {
@@ -229,7 +229,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 School school = null;
                                 if (!string.IsNullOrEmpty(survey.school))
                                 {
-                                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(survey.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(survey.school, new Microsoft.Azure.Cosmos.PartitionKey("Base"));
                                     list.school = school.id;
                                     list.standard = school.standard;
                                 }
@@ -468,7 +468,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                             if (string.IsNullOrEmpty(survey.recordUrl))
                             {
                                 survey.recordUrl = $"/survey/{survey.id}/record.json";
-                                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Survey>(survey, survey.id, new Azure.Cosmos.PartitionKey(survey.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Survey>(survey, survey.id, new Microsoft.Azure.Cosmos.PartitionKey(survey.code));
                             }
                             else
                             {
@@ -482,11 +482,11 @@ namespace TEAMModelOS.CosmosDBTriggers
                             //data.progress = "finish";
                             //if (survey.scope .Equals("school"))
                             //{
-                            //    await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<ActivityData>(data, data.id, new Azure.Cosmos.PartitionKey(data.code));
+                            //    await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<ActivityData>(data, data.id, new PartitionKey(data.code));
                             //}
                             //else if (survey.scope .Equals("private"))
                             //{
-                            //    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<ActivityData>(data, data.id, new Azure.Cosmos.PartitionKey(data.code));
+                            //    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<ActivityData>(data, data.id, new PartitionKey(data.code));
                             //}
 
                             break;
@@ -496,7 +496,7 @@ namespace TEAMModelOS.CosmosDBTriggers
 
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {

+ 6 - 6
TEAMModelOS.Function/CosmosDBTriggers/TriggerVote.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Azure.Documents;
 using System;
@@ -32,7 +32,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             {
                 if ((tdata.status != null && tdata.status.Value == 404) )
                 {
-                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                    // await IESActivityService. DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Record:{tdata.id}");
@@ -70,7 +70,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                     blobcntr = tdata.creatorId;
                 }
                // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作", GroupNames.醍摩豆服務運維群組);
-                Vote vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(tdata.id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                Vote vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(tdata.id, new Microsoft.Azure.Cosmos.PartitionKey($"{tdata.code}"));
 
                 if (vote != null)
                 {
@@ -237,7 +237,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                                 School school = null;
                                 if (!string.IsNullOrEmpty(vote.school))
                                 {
-                                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(vote.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(vote.school, new Microsoft.Azure.Cosmos.PartitionKey("Base"));
                                     list.school = school.id;
                                     list.standard = school.standard;
                                 }
@@ -393,7 +393,7 @@ namespace TEAMModelOS.CosmosDBTriggers
                             if (string.IsNullOrEmpty(vote.recordUrl))
                             {
                                 vote.recordUrl = url;
-                                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Vote>(vote, vote.id, new Azure.Cosmos.PartitionKey(vote.code));
+                                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Vote>(vote, vote.id, new Microsoft.Azure.Cosmos.PartitionKey(vote.code));
                             }
                             else
                             {
@@ -409,7 +409,7 @@ namespace TEAMModelOS.CosmosDBTriggers
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {

+ 1 - 1
TEAMModelOS.Function/IESCosmosDBTrigger.cs

@@ -7,7 +7,7 @@ using Microsoft.Extensions.Logging;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK;
 using System.Xml.Linq;
-using Microsoft.Azure.Cosmos.Linq;
+
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.CosmosDBTriggers;
 namespace TEAMModelOS.Function

+ 9 - 9
TEAMModelOS.Function/IESHttpTrigger.cs

@@ -14,7 +14,7 @@ using System.Reflection;
 using StackExchange.Redis;
 using static TEAMModelOS.SDK.Services.BlobService;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Extension;
 using System.Dynamic;
 using Azure.Storage.Blobs.Models;
@@ -134,7 +134,7 @@ namespace TEAMModelOS.Function
                         string sql = $"select   value c from c    where c.code='Teacher-{name}' and c.status='join'  and  array_contains(c.roles,'admin') ";
                         List<SchoolTeacher> adminTeachers = new List<SchoolTeacher>();
                         await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
-                            .GetItemQueryIterator<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{name}") }))
+                            .GetItemQueryIteratorSql<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{name}") }))
                         {
                             adminTeachers.Add(item);
                         }
@@ -143,7 +143,7 @@ namespace TEAMModelOS.Function
 
                             string sqlAdmin = $"select c.id,c.lang  as code ,c.name from c where c.id in ({string.Join(",", adminTeachers.Select(z => $"'{z.id}'"))}) ";
                             await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
-                                .GetItemQueryIterator<IdNameCode>(queryText: sqlAdmin, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
+                                .GetItemQueryIteratorSql<IdNameCode>(queryText: sqlAdmin, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
                             {
                                 ids.Add(item);
                             }
@@ -234,7 +234,7 @@ namespace TEAMModelOS.Function
                 string schoolSQL = $"select value c from c where c.areaId='{_areaId}'";
                 List<School> schools = new List<School>();
                 await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
-                               .GetItemQueryIterator<School>(queryText: schoolSQL, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
+                               .GetItemQueryIteratorSql<School>(queryText: schoolSQL, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
                 {
                     schools.Add(item);
                 }
@@ -329,7 +329,7 @@ namespace TEAMModelOS.Function
                                 string sql = $"select value(c) from c where c.periodId = '{period.id}'";
                                 string pk = $"Knowledge-{school.id}-{subject.id}";
                                 await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").
-                                    GetItemQueryIterator<Knowledge>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(pk) }))
+                                    GetItemQueryIteratorSql<Knowledge>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(pk) }))
                                 {
                                     old = item;
                                     break;
@@ -443,7 +443,7 @@ namespace TEAMModelOS.Function
                         List<Student> students = new List<Student>();
                         string sql = $"select value c from c where  (c.graduate = 0 or  IS_DEFINED(c.graduate) = false)  and  c.classId in ({string.Join(",", ids)})";
                         await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student)
-                            .GetItemQueryIterator<Student>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
+                            .GetItemQueryIteratorSql<Student>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
                         {
                             item.graduate = 1;
                             students.Add(item);
@@ -470,7 +470,7 @@ namespace TEAMModelOS.Function
                         List<Student> students = new List<Student>();
                         string sql = $"select value c from c where  c.graduate =1   and  c.classId in ({string.Join(",", ids)})";
                         await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student)
-                            .GetItemQueryIterator<Student>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
+                            .GetItemQueryIteratorSql<Student>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
                         {
                             item.graduate = 0;
                             students.Add(item);
@@ -516,7 +516,7 @@ namespace TEAMModelOS.Function
                 {
                     List<LessonRecord> lessonRecords = new List<LessonRecord>();
                     string sql = $"select value(c) from c    where array_contains(c.category,'{on._old}') ";
-                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>
+                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>
                         (queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{_school}") }))
                     {
                         lessonRecords.Add(item);
@@ -571,7 +571,7 @@ namespace TEAMModelOS.Function
                 {
                     List<ItemInfo> items = new List<ItemInfo>();
                     string sql = $"select value(c) from c    where array_contains(c.knowledge,'{on._old}') ";
-                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>
+                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<ItemInfo>
                         (queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{_school}") }))
                     {
                         items.Add(item);

+ 36 - 36
TEAMModelOS.Function/IESServiceBusTrigger.cs

@@ -13,7 +13,7 @@ using Microsoft.Extensions.Options;
 using static Microsoft.Azure.Amqp.Serialization.SerializableType;
 using System.Text.Json;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
@@ -97,7 +97,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,ExamBus()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{json.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,ExamBus()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{json.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -137,7 +137,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,VoteBus()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,VoteBus()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -178,7 +178,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Correct()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Correct()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -219,7 +219,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,SurveyBus()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,SurveyBus()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -260,7 +260,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Homework()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Homework()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -302,7 +302,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Study()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Study()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -344,7 +344,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Art()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Art()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -384,7 +384,7 @@ namespace TEAMModelOS.Function
             }
             catch (CosmosException e)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,ExamLite()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,ExamLite()-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.StatusCode}\n{jsonMsg.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             catch (Exception ex)
             {
@@ -454,7 +454,7 @@ namespace TEAMModelOS.Function
                     {
                         List<Study> studies = new List<Study>();
                         await foreach (var item in client.GetContainer("TEAMModelOS", "Common")
-                           .GetItemQueryIterator<Study>(queryText: $"select value(c) from c    where c.owner<>'area'  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{school.school}") }))
+                           .GetItemQueryIteratorSql<Study>(queryText: $"select value(c) from c    where c.owner<>'area'  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{school.school}") }))
                         {
                             studies.Add(item);
                         }
@@ -462,7 +462,7 @@ namespace TEAMModelOS.Function
                         {
                             string trainSql = $"select value(c) from c where c.id in ({string.Join(",", school.teachers.Select(x => $"'{x}'"))}) ";
                             await foreach (var item in client.GetContainer("TEAMModelOS", Constant.Teacher)
-                          .GetItemQueryIterator<TeacherTrain>(queryText: trainSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{school.school}") }))
+                          .GetItemQueryIteratorSql<TeacherTrain>(queryText: trainSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{school.school}") }))
                             {
                                 trains.Add(item);
                             }
@@ -641,7 +641,7 @@ namespace TEAMModelOS.Function
                         ItemCond itemCond = null;
                         List<ItemInfo> items = new List<ItemInfo>();
                         var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where   c.periodId='{itemCondDto.filed}' and c.pid= null  ";
-                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.key}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.key}") }))
                         {
                             items.Add(item);
                         }
@@ -669,7 +669,7 @@ namespace TEAMModelOS.Function
                         ItemCond itemCond = null;
                         List<ItemInfo> items = new List<ItemInfo>();
                         var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where c.pid= null  ";
-                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.filed}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.filed}") }))
                         {
                             items.Add(item);
                         }
@@ -729,9 +729,9 @@ namespace TEAMModelOS.Function
                 ////序號
                 List<SchoolProductSumData> serialsProductSumOrg = new List<SchoolProductSumData>();
                 strQuery = $"SELECT * FROM c WHERE c.dataType = 'serial'";
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: strQuery, requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Product-{schoolId}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: strQuery, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolId}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -762,9 +762,9 @@ namespace TEAMModelOS.Function
                 //////取得學校產品 授權週期:授權中 條件: startDate <= now <= endDate
                 long timestampToday = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
                 string strQueryM = $"SELECT * FROM c WHERE c.dataType = 'servicePeriod' AND c.startDate <= {timestampToday} AND {timestampToday} <= c.endDate AND c.ttl < 0";
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: strQueryM, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolId}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: strQueryM, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolId}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -830,9 +830,9 @@ namespace TEAMModelOS.Function
                 ////硬體
                 List<SchoolProductSumDataHard> hardsProductSumOrg = new List<SchoolProductSumDataHard>();
                 strQuery = $"SELECT * FROM c WHERE c.dataType = 'hard'";
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: strQuery, requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Product-{schoolId}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: strQuery, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolId}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -981,10 +981,10 @@ namespace TEAMModelOS.Function
 
                     LessonRecord oldlessonRecord = null;
                     LessonRecord lessonRecord = null;
-                    Azure.Response response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync(lessonId, new PartitionKey(code));
-                    if (response.Status == 200)
+                    ResponseMessage response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync(lessonId, new PartitionKey(code));
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        var doc = JsonDocument.Parse(response.ContentStream);
+                        var doc = JsonDocument.Parse(response.Content);
                         lessonRecord = doc.RootElement.ToObject<LessonRecord>();
                         oldlessonRecord = doc.RootElement.ToObject<LessonRecord>();
                     }
@@ -1365,17 +1365,17 @@ namespace TEAMModelOS.Function
                                         try
                                         {
                                             var cresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(lessonRecord.courseId, new PartitionKey($"CourseBase-{lessonRecord.school}"));
-                                            if (cresponse.Status == 200)
+                                            if (cresponse.StatusCode == System.Net.HttpStatusCode.OK)
                                             {
-                                                using var cJson = await JsonDocument.ParseAsync(cresponse.ContentStream);
+                                                using var cJson = await JsonDocument.ParseAsync(cresponse.Content);
                                                 course = cJson.ToObject<CourseBase>();
                                             }
                                             else
                                             {
                                                 var sresponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(lessonRecord.courseId, new PartitionKey($"CourseBase"));
-                                                if (sresponse.Status == 200)
+                                                if (sresponse.StatusCode == System.Net.HttpStatusCode.OK)
                                                 {
-                                                    using var cJson = await JsonDocument.ParseAsync(sresponse.ContentStream);
+                                                    using var cJson = await JsonDocument.ParseAsync(sresponse.Content);
                                                     course = cJson.ToObject<CourseBase>();
                                                 }
                                                 else
@@ -1441,8 +1441,8 @@ namespace TEAMModelOS.Function
                                             }
                                             var space = await BlobService.GetSurplusSpace(school, scope, $"{Environment.GetEnvironmentVariable("Option:Location")}", _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
                                             SchoolSetting setting = null;
-                                            Azure.Response schoolSetting = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemStreamAsync(school, new PartitionKey("SchoolSetting"));
-                                            if (schoolSetting.Status == 200)
+                                            ResponseMessage schoolSetting = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemStreamAsync(school, new PartitionKey("SchoolSetting"));
+                                            if (schoolSetting.StatusCode == System.Net.HttpStatusCode.OK)
                                             {
                                                 setting = JsonDocument.Parse(schoolSetting.Content).RootElement.Deserialize<SchoolSetting>();
                                                 if (setting.lessonSetting != null)
@@ -1666,7 +1666,7 @@ namespace TEAMModelOS.Function
                                                 HashSet<string> ids = new HashSet<string>();
                                                 //未定义的 以及过期时间小于等于0 的 课例
                                                 string private_count_sql = $"select value(c.id) from  c where  ( c.expire<=0 or IS_DEFINED(c.expire) = false  ) and c.tmdid='{tmdid}'  ";
-                                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<string>(
+                                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIteratorSql<string>(
                                                     queryText: private_count_sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey(code) }))
                                                 {
 
@@ -1676,7 +1676,7 @@ namespace TEAMModelOS.Function
                                                 // 220601  收藏不限條數,但空間不足時,僅保留最後一次上傳的課例   ()
                                                 //包含收藏的本人的个人课例
                                                 //string favorite_count_sql = $"select value(c.id) from  c where c.type='LessonRecord' and c.owner='{tmdid}'   and c.scope='private' ";
-                                                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<string>(
+                                                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIteratorSql<string>(
                                                 //    queryText: favorite_count_sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Favorite-{tmdid}") }))
                                                 //{
                                                 //    ids.Add(item);
@@ -1697,7 +1697,7 @@ namespace TEAMModelOS.Function
                                                     //220712 讨论,将desc去掉,获取最旧的那一笔数据。删除最旧的
                                                     string sql = $"SELECT top 1 value(c)  FROM c  where  ( c.expire<=0 or IS_DEFINED(c.expire) = false  ) and  c.tmdid='{tmdid}' " +
                                                         $"and  c.favorite<=0  and c.id<>'{lessonRecord.id}' and c.status<>404  order by c.startTime   ";
-                                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<LessonRecord>(
+                                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIteratorSql<LessonRecord>(
                                                         queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"{code}") }))
                                                     {
                                                         lessonRecordExpire = item; break;
@@ -1881,11 +1881,11 @@ namespace TEAMModelOS.Function
                     {
                         return;
                     }
-                    Azure.Response response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync(lessonId, new PartitionKey(code));
-                    if (response.Status == 200)
+                    ResponseMessage response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync(lessonId, new PartitionKey(code));
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
                         LessonRecord lessonRecord;
-                        var doc = JsonDocument.Parse(response.ContentStream);
+                        var doc = JsonDocument.Parse(response.Content);
                         lessonRecord = doc.RootElement.ToObject<LessonRecord>();
                         lessonRecord.status = 404;
                         await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync(lessonRecord, lessonRecord.id, new PartitionKey(lessonRecord.code));
@@ -1944,11 +1944,11 @@ namespace TEAMModelOS.Function
                     var db = _azureCosmos.GetCosmosClient();
                     foreach (var stu in stus.EnumerateArray())
                     {
-                        await foreach (Response item in db.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator(
+                        await foreach (var item in db.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIteratorSql(
                         queryText: $"SELECT TOP 1 * FROM c WHERE c.stuid = '{stu.GetString()}' and c.school='{school}'  ",
                         requestOptions: new() { PartitionKey = new($"Imei") }))
                         {
-                            using var root = await JsonDocument.ParseAsync(item.ContentStream);
+                            using var root = await JsonDocument.ParseAsync(item.Content);
                             if (root.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                             {
                                 var doc = root.RootElement.GetProperty("Documents").EnumerateArray().First();

+ 3 - 3
TEAMModelOS.Function/IESTimerTrigger.cs

@@ -56,19 +56,19 @@ namespace TEAMModelOS.Function
             try
             {
                 await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.location},定时任务{DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss")}", GroupNames.成都开发測試群組);
-                string local = Environment.GetEnvironmentVariable("Option:Location");
+                string? local = Environment.GetEnvironmentVariable("Option:Location");
                 // if (local.Contains("Test")||local.Contains("Dep"))
                 {
 
                     int am = 9;
-                    int pm = 9;
+                    int pm = 20;
                     //int am = DateTimeOffset.Now.Hour;
                     //int pm = DateTimeOffset.Now.Hour;
                     var url = Environment.GetEnvironmentVariable("HaBookAuth:CoreAPI");
                     var clientID = Environment.GetEnvironmentVariable("HaBookAuth:CoreService:clientID");
                     var clientSecret = Environment.GetEnvironmentVariable("HaBookAuth:CoreService:clientSecret");
                     string location = "";
-                    if (local.Contains("China"))
+                    if (local!.Contains("China"))
                     {
                         location = "China";
                     }

+ 1 - 1
TEAMModelOS.Function/TEAMModelOS.Function.csproj

@@ -41,7 +41,7 @@
     <FrameworkReference Include="Microsoft.AspNetCore.App" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
     <!--<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.0.0-preview2" />-->
-	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.3.0" />
+	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.9.0" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
     <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.20.0" />

+ 6 - 6
TEAMModelOS.SDK/Context/Attributes/Filter/ApiTokenAttribute.cs

@@ -247,8 +247,8 @@ namespace TEAMModelOS.Filter
                                             {
                                                 //访问次数记录 开始
                                                 //long udate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                                                //var respon = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(id, new Azure.Cosmos.PartitionKey("BizVisit")).Result;
-                                                //if (respon.Status == 200)
+                                                //var respon = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(id, new PartitionKey("BizVisit")).Result;
+                                                //if (respon.StatusCode == System.Net.HttpStatusCode.OK)
                                                 //{
                                                 //    BizVisitCnt bizVisit = JsonDocument.Parse(respon.Content).Deserialize<BizVisitCnt>();
                                                 //    bizVisit.visit += 1;
@@ -260,17 +260,17 @@ namespace TEAMModelOS.Filter
                                                 //    //}
                                                 //    //else
                                                 //    bizVisit.apis.Add(new APIInfo() { name = $"{path}", upDate = udate });//记录加一下
-                                                //       _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizVisitCnt>(bizVisit, id, new Azure.Cosmos.PartitionKey("BizVisit"));
+                                                //       _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizVisitCnt>(bizVisit, id, new PartitionKey("BizVisit"));
                                                 //}
                                                 //else
                                                 //{
                                                 //    BizVisitCnt bizVisit = new() { id = id, visit = 1, apis = new List<APIInfo>() { new APIInfo() { name = $"{path}", upDate = udate } } };
-                                                //  _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizVisitCnt>(bizVisit, new Azure.Cosmos.PartitionKey("BizVisit"));
+                                                //  _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizVisitCnt>(bizVisit, new PartitionKey("BizVisit"));
                                                 //}
                                                 //访问次数记录 结束
 
-                                                var response = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(id, new Azure.Cosmos.PartitionKey("BizConfig")).Result;
-                                                if (response.Status == 200)
+                                                var response = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(id, new Microsoft.Azure.Cosmos.PartitionKey("BizConfig")).Result;
+                                                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                                                 {
                                                     BizConfig bizConfig = JsonDocument.Parse(response.Content).Deserialize<BizConfig>();
                                                     //智学研可以直接访问所有学校的授权。

+ 217 - 86
TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosExtensions.cs

@@ -9,7 +9,6 @@ using Azure;
 using TEAMModelOS.SDK.DI;
 using System.IO;
 using System.Diagnostics;
-using Azure.Cosmos;
 using System.Text.Json;
 using System.Net;
 using System.Linq.Expressions;
@@ -17,6 +16,7 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
+using Microsoft.Azure.Cosmos;
 
 
 namespace TEAMModelOS.SDK.DI
@@ -37,7 +37,7 @@ namespace TEAMModelOS.SDK.DI
             }
         }
 
-        public static string GetContinuationToken(this Response response)
+        public static string? GetContinuationToken(this Response response)
         {
             try
             {
@@ -50,6 +50,122 @@ namespace TEAMModelOS.SDK.DI
             }
         }
 
+        public static async Task<T?> GetOne<T>(this Container container, QueryDefinition queryDefinition, string? partitionkey = null)
+        {
+            List<T?> list = new List<T?>();
+            //if (string.IsNullOrWhiteSpace(partitionkey))
+            //{
+            //    return default;
+            //}
+            FeedIterator<T> iterator = container.GetItemQueryIterator<T>(queryDefinition: queryDefinition,
+                requestOptions: new QueryRequestOptions { MaxItemCount = 2, PartitionKey =!string.IsNullOrWhiteSpace(partitionkey) ? new PartitionKey(partitionkey) : null });
+            while (iterator.HasMoreResults)
+            {
+                FeedResponse<T> currentResultSet = await iterator.ReadNextAsync();
+                list.AddRange(currentResultSet);
+            }
+            if (list.Count > 1)
+            {
+                throw new Exception("当前查询条件返回的结果不唯一");
+            }
+            else if (list.Count <= 0)
+            {
+                return default;
+            }
+            else
+            {
+                return list.First();
+            }
+        }
+
+        public static async Task<T?> GetOne<T>(this Container container, string sql, string? partitionkey = null)
+        {
+            List<T?> list = new List<T?>();
+            //if (string.IsNullOrWhiteSpace(partitionkey))
+            //{
+            //    return default;
+            //}
+            FeedIterator<T> iterator = container.GetItemQueryIterator<T>(queryText: sql,
+                 requestOptions: new QueryRequestOptions { MaxItemCount = 2, PartitionKey =!string.IsNullOrWhiteSpace(partitionkey) ? new PartitionKey(partitionkey) : null });
+            while (iterator.HasMoreResults)
+            {
+                FeedResponse<T> currentResultSet = await iterator.ReadNextAsync();
+                list.AddRange(currentResultSet);
+            }
+            if (list.Count > 1)
+            {
+                throw new Exception("当前查询条件返回的结果不唯一");
+            }
+            else if (list.Count <=0)
+            {
+                return default;
+            }
+            else
+            {
+                return list.First();
+            }
+        }
+
+        public static async Task<CosmosDBResult<T>> GetList<T>(this Container container, QueryDefinition queryDefinition, string? partitionkey = null, string? continuationToken = null, int? pageSize = null)
+        {
+            List<T> list = new List<T>();
+            double RU = 0;
+
+            FeedIterator<T> iterator = container.GetItemQueryIterator<T>(queryDefinition: queryDefinition, continuationToken: continuationToken, requestOptions: new QueryRequestOptions { MaxItemCount=pageSize, PartitionKey =!string.IsNullOrWhiteSpace(partitionkey) ? new PartitionKey(partitionkey) : null });
+            while (iterator.HasMoreResults)
+            {
+                FeedResponse<T> currentResultSet = await iterator.ReadNextAsync();
+                list.AddRange(currentResultSet);
+                RU += currentResultSet.RequestCharge;
+                //此处需要优化 ,检查相关的 关键字 用正则
+                if (queryDefinition.QueryText.Contains(" distinct ", StringComparison.OrdinalIgnoreCase)
+                    || (queryDefinition.QueryText.Contains("order ", StringComparison.OrdinalIgnoreCase)
+                    && !queryDefinition.QueryText.Contains(".order ", StringComparison.OrdinalIgnoreCase)))
+                {
+                    continuationToken = null;
+                }
+                else
+                {
+                    continuationToken = currentResultSet.ContinuationToken;
+                }
+                if (pageSize.HasValue && pageSize.Value >= 0 && list.Count >= pageSize)
+                {
+                    break;
+                }
+            }
+            return (new CosmosDBResult<T> { list = list, ru = RU, continuationToken = continuationToken });
+        }
+
+        public static async Task<CosmosDBResult<T>> GetList<T>(this Container container, string sql, string? partitionkey = null, string? continuationToken = null, int? pageSize = null)
+        {
+            List<T> list = new List<T>();
+            double RU = 0;
+
+            FeedIterator<T> iterator = container.GetItemQueryIterator<T>(queryText: sql, continuationToken: continuationToken, requestOptions: new QueryRequestOptions { MaxItemCount=pageSize, PartitionKey =!string.IsNullOrWhiteSpace(partitionkey) ? new PartitionKey(partitionkey) : null });
+            while (iterator.HasMoreResults)
+            {
+                FeedResponse<T> currentResultSet = await iterator.ReadNextAsync();
+                list.AddRange(currentResultSet);
+                RU += currentResultSet.RequestCharge;
+                //此处需要优化 ,检查相关的 关键字 用正则
+                if (sql.Contains(" distinct ", StringComparison.OrdinalIgnoreCase)
+                    || (sql.Contains("order ", StringComparison.OrdinalIgnoreCase)
+                    && !sql.Contains(".order ", StringComparison.OrdinalIgnoreCase)))
+                {
+                    continuationToken = null;
+                }
+                else
+                {
+                    continuationToken = currentResultSet.ContinuationToken;
+                }
+                if (pageSize.HasValue && pageSize.Value >=0 && list.Count>=pageSize)
+                {
+                    break;
+                }
+            }
+            //记录日志,RU开销大于400(开发测试),1000(正式)
+            return (new CosmosDBResult<T> { list = list, ru = RU, continuationToken = continuationToken });
+        }
         /// <summary>
         /// 取得当前容器指定分区键的Count数,支持SQL Where条件,不支持排序
         /// </summary>
@@ -57,14 +173,16 @@ namespace TEAMModelOS.SDK.DI
         /// <param name="partitionkey"></param>
         /// <param name="queryWhere"></param>
         /// <returns></returns>
-        public static async Task<int> GetCount(this CosmosContainer container, string partitionkey, string queryWhere = "WHERE 1=1")
+        public static async Task<int> GetCount(this Container container, string? partitionkey = null, string queryWhere = "WHERE 1=1")
         {
             int totalCount = 0;
-            await foreach (var item in container.GetItemQueryStreamIterator(
+            var items = container.GetItemQueryStreamIterator(
                 queryText: $"SELECT VALUE COUNT(1) From c {queryWhere}",
-                requestOptions: new QueryRequestOptions() { PartitionKey =!string.IsNullOrWhiteSpace(partitionkey) ? new PartitionKey(partitionkey) : null , MaxItemCount = -1 }))
+                requestOptions: new QueryRequestOptions() { PartitionKey =!string.IsNullOrWhiteSpace(partitionkey) ? new PartitionKey(partitionkey) : null, MaxItemCount = -1 });
+            while (items.HasMoreResults)
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var response = await items.ReadNextAsync();
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -76,123 +194,136 @@ namespace TEAMModelOS.SDK.DI
             return totalCount;
         }
 
-        public static async Task<List<Response>> DeleteItemsStreamAsync(this CosmosContainer container, List<string> ids, string partitionkey )
+        public static async Task<ResponseMessage[]> DeleteItemsStreamAsync(this Container container, List<string> ids, string partitionkey)
         {
-            List<Response> responses = new List<Response>();
-
-            foreach (var id in ids)
+            List<Task<ResponseMessage>> responses = new List<Task<ResponseMessage>>();
+            if (ids!= null  && ids.Count > 0)
             {
-                try
+                foreach (var id in ids)
                 {
-                    responses.Add(await container.DeleteItemStreamAsync(id, new PartitionKey(partitionkey)));
+                    try
+                    {
+                        responses.Add(container.DeleteItemStreamAsync(id, new PartitionKey(partitionkey)));
+                    }
+                    catch
+                    {
+                        continue;
+                    }
                 }
-                catch 
+            }
+            var response = await Task.WhenAll(responses);
+            return response;
+        }
+
+        public static async Task<ItemResponse<T>[]> DeleteItemsAsync<T>(this Container container, List<string> ids, string partitionkey)
+        {
+            List<Task<ItemResponse<T>>> responses = new List<Task<ItemResponse<T>>>(); ;
+            if (ids!= null  && ids.Count > 0)
+            {
+                foreach (var id in ids)
                 {
-                    continue;
+                    try
+                    {
+                        responses.Add(container.DeleteItemAsync<T>(id, new PartitionKey(partitionkey)));
+                    }
+                    catch
+                    {
+                        continue;
+                    }
                 }
             }
-            return responses;
+            var response = await Task.WhenAll(responses);
+            return response;
         }
 
-        public static async Task<List<ItemResponse<T>>> DeleteItemsAsync<T>(this CosmosContainer container, List<string> ids, string partitionkey)
+        public static async IAsyncEnumerable<ResponseMessage> GetItemQueryStreamIteratorSql(this  Container container, string queryText = null, QueryRequestOptions requestOptions = null, string continuationToken = null)
         {
-            List<ItemResponse<T>> responses = new List<ItemResponse<T>>();
-
-            foreach (var id in ids)
+            var items = container.GetItemQueryStreamIterator(
+            queryText: queryText, continuationToken: continuationToken,
+                requestOptions: requestOptions);
+            while (items.HasMoreResults)
             {
-                try
+                ResponseMessage response = await items.ReadNextAsync();
+                if (response.IsSuccessStatusCode)
                 {
-                    responses.Add(await container.DeleteItemAsync<T>(id, new PartitionKey(partitionkey)));
+                    yield return response;
                 }
-                catch
+                else
                 {
-                    continue;
+                    break;
                 }
             }
-            return responses;
         }
-        public static async Task<CosmosDBResult<T>> GetList<T>(this CosmosContainer container, QueryDefinition  queryDefinition, string partitionkey= null, string continuationToken = null, int? pageSize = null)
+        public static async IAsyncEnumerable<ResponseMessage> GetItemQueryStreamIteratorQuery(this Container container, QueryDefinition queryDefinition,QueryRequestOptions requestOptions = null, string continuationToken = null)
         {
-            List<T> list = new List<T>();
-            double RU = 0;
-            await foreach (var item in container.GetItemQueryStreamIterator(queryDefinition: queryDefinition, continuationToken: continuationToken,
-                requestOptions: new QueryRequestOptions { MaxItemCount = pageSize, PartitionKey =!string.IsNullOrWhiteSpace(partitionkey) ? new PartitionKey(partitionkey) : null }))
+            var items = container.GetItemQueryStreamIterator(
+            queryDefinition: queryDefinition, continuationToken: continuationToken,
+            requestOptions: requestOptions);
+            while (items.HasMoreResults)
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                {
-                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                    {
-                        list.Add(obj.ToObject<T>());
-                    }
-                }
-                if (queryDefinition.QueryText.Contains(" distinct ", StringComparison.OrdinalIgnoreCase) ||
-                    (queryDefinition.QueryText.Contains("order ", StringComparison.OrdinalIgnoreCase) &&
-                    !queryDefinition.QueryText.Contains(".order ", StringComparison.OrdinalIgnoreCase)))
+                ResponseMessage response = await items.ReadNextAsync();
+                if (response.IsSuccessStatusCode)
                 {
-                    continuationToken = null;
+                    yield return response;
                 }
                 else
-                {
-                    continuationToken = item.GetContinuationToken();
-                }
-                RU  +=item.RU();
-                if (pageSize.HasValue && pageSize.Value >= 0 && list.Count >= pageSize)
                 {
                     break;
                 }
+
             }
-            //记录日志,RU开销大于400(开发测试),1000(正式)
-            return (new CosmosDBResult<T> { list = list, ru = RU, continuationToken = continuationToken }); ;
         }
 
-        public static async Task<CosmosDBResult<T>> GetList<T>(this CosmosContainer container, string sql, string partitionkey= null, string continuationToken = null, int? pageSize = null)
+        public static async IAsyncEnumerable<T> GetItemQueryIteratorQuery<T>(this Container container, QueryDefinition queryDefinition, QueryRequestOptions requestOptions = null, string continuationToken = null)
         {
-            List<T> list = new List<T>();
-            double RU = 0;
-            try
+            var items = container.GetItemQueryIterator<T>(
+            queryDefinition: queryDefinition, continuationToken: continuationToken,
+            requestOptions: requestOptions);
+            while (items.HasMoreResults)
             {
-
-                await foreach (var item in container.GetItemQueryStreamIterator(queryText: sql, continuationToken: continuationToken,
-                 requestOptions: new QueryRequestOptions { MaxItemCount = pageSize, PartitionKey =!string.IsNullOrWhiteSpace(partitionkey)?new PartitionKey(partitionkey) : null}))
+                FeedResponse<T> response = await items.ReadNextAsync();
+                if (response.Any())
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                        {
-                            list.Add(obj.ToObject<T>());
-                        }
-                    }
-                    if (sql.Contains(" distinct ", StringComparison.OrdinalIgnoreCase)
-                        || (sql.Contains("order ", StringComparison.OrdinalIgnoreCase)
-                        && !sql.Contains(".order ", StringComparison.OrdinalIgnoreCase)))
-                    {
-                        continuationToken = null;
-                    }
-                    else
+                    foreach (var rs in response)
                     {
-                        continuationToken = item.GetContinuationToken();
-                    }
-                    RU += item.RU();
-                    if (pageSize.HasValue && pageSize.Value >= 0 && list.Count >= pageSize)
-                    {
-                        break;
+                        yield return rs;
                     }
                 }
+                else
+                {
+                    yield break;
+                }
             }
-            catch (Exception ex)
-            {
-                Console.WriteLine(ex.ToString());
-            }
-            //记录日志,RU开销大于400(开发测试),1000(正式)
-            return (new CosmosDBResult<T> { list = list, ru = RU, continuationToken = continuationToken }); ;
         }
-        public class CosmosDBResult<T>
+        public static async IAsyncEnumerable<T> GetItemQueryIteratorSql<T>(this     Container container, string queryText, QueryRequestOptions requestOptions = null, string continuationToken = null)
         {
-            public List<T>? list { get; set; }
-            public string? continuationToken { get; set; }
-            public double ru { get; set; }
+            var items = container.GetItemQueryIterator<T>(
+            queryText: queryText, continuationToken: continuationToken,
+            requestOptions: requestOptions);
+
+            while (items.HasMoreResults)
+            {
+                FeedResponse<T> response = await items.ReadNextAsync();
+                if (response.Any())
+                {
+                    foreach (var rs in response)
+                    {
+                        yield return rs;
+                    }
+                }
+                else
+                {
+                    yield break;
+                }
+            }
         }
     }
+
+    public class CosmosDBResult<T>
+    {
+        public List<T>? list { get; set; } = new List<T>();
+        public string? continuationToken { get; set; }
+        //RU数据库查询开销
+        public double ru { get; set; }
+    }
 }

+ 63 - 15
TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosFactory.cs

@@ -1,30 +1,33 @@
-using Azure.Cosmos;
-using Microsoft.Extensions.DependencyInjection;
+using Azure.Core.Serialization;
+using Microsoft.Azure.Cosmos;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.IO;
+using System.Threading.Tasks;
 namespace TEAMModelOS.SDK.DI
 {
     public class AzureCosmosFactory
     {
         private readonly IServiceProvider _services;
         private readonly IOptionsMonitor<AzureCosmosFactoryOptions> _optionsMonitor;
-        
+        private readonly ILogger _logger;
         //private Option _option;
-        private ConcurrentDictionary<string, CosmosClient> CosmosClients { get; } = new ConcurrentDictionary<string, CosmosClient>();        
+        private ConcurrentDictionary<string, CosmosClient> CosmosClients { get; } = new ConcurrentDictionary<string, CosmosClient>();
 
         //   private CosmosDatabase database { get; set; }
 
-        public AzureCosmosFactory(IServiceProvider services, IOptionsMonitor<AzureCosmosFactoryOptions> optionsMonitor)
+        public AzureCosmosFactory(IServiceProvider services, IOptionsMonitor<AzureCosmosFactoryOptions> optionsMonitor, ILogger<AzureCosmosFactory> logger)
         {
             if (services == null) throw new ArgumentNullException(nameof(services));
             if (optionsMonitor == null) throw new ArgumentNullException(nameof(optionsMonitor));
-           _optionsMonitor = optionsMonitor;
+
             _services = services;
+            _optionsMonitor = optionsMonitor;
+            _logger = logger;
         }
 
         /// <summary>
@@ -33,20 +36,65 @@ namespace TEAMModelOS.SDK.DI
         /// <param name="name"></param>
         /// <param name="region">可以使用Regions.{區域}設置,指定此屬性後,SDK會首選該區域來執行操作。此外,SDK會自動選擇後備的地理複製區域以實現高可用性。如果未指定此屬性,則SDK會將寫區域用作所有操作的首選區域</param>
         /// <returns></returns>
-        public CosmosClient GetCosmosClient(string region = null, string name = "Default")
+        public CosmosClient GetCosmosClient(string? region = null, string name = "Default")
         {
             try
             {
-                //CosmosClientOptions 的 SerializerOptions = new CosmosSerializationOptions() { PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase }
+                //CosmosClientOptions 的 SerializerOptions = new CosmosSerializationOptions() { PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase } 
                 //需等待官方修正
-                var cm = CosmosClients.GetOrAdd(name, x => new CosmosClient(_optionsMonitor.Get(name).CosmosConnectionString, new CosmosClientOptions() { ApplicationRegion = region }));
-                return cm; ;
+
+                JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions()
+                {
+                  //  DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
+                };
+                var cm = CosmosClients.GetOrAdd(name, x => new CosmosClient(_optionsMonitor.Get(name).CosmosConnectionString, new CosmosClientOptions()
+                {
+                    Serializer= new CosmosSystemTextJsonSerializer(jsonSerializerOptions),
+                    ApplicationRegion = region
+                }));
+                return cm;
             }
             catch (Exception e)
             {
-               throw new Exception($"GetCosmosClient error:{e.Message}{e.StackTrace}");
+                _logger?.LogWarning(e, e.Message);
+                throw;
             }
-        }        
+        }
+    }
+    /// <summary>
+    /// Uses <see cref="Azure.Core.Serialization.JsonObjectSerializer"/> which leverages System.Text.Json providing a simple API to interact with on the Azure SDKs.
+    /// </summary>
+    // <SystemTextJsonSerializer>
+    public class CosmosSystemTextJsonSerializer : CosmosSerializer
+    {
+        private readonly JsonSerializerOptions _serializerOptions;
+
+        public CosmosSystemTextJsonSerializer(JsonSerializerOptions jsonSerializerOptions)
+        {
+            this._serializerOptions = jsonSerializerOptions;
+        }
 
+        public override T FromStream<T>(Stream stream)
+        {
+            using (stream)
+            {
+                if (typeof(Stream).IsAssignableFrom(typeof(T)))
+                {
+                    return (T)(object)stream;
+                }
+                return JsonSerializer.Deserialize<T>(stream, _serializerOptions);
+            }
+        }
+
+        public   override Stream ToStream<T>(T input)
+        {
+            var outputStream = new MemoryStream();
+             JsonSerializer.Serialize<T>(outputStream, input, _serializerOptions);
+
+            // A BREAKPOINT HERE AND A LOOK INSIDE 'outputStream' shows that ALL the fields have been serialized EXCEPT 'Id' or 'id.
+            outputStream.Position = 0;
+            return outputStream;
+        }
     }
+    // </SystemTextJsonSerializer>
 }

+ 1 - 1
TEAMModelOS.SDK/DI/AzureCosmos/Inner/AzureCosmosQuery.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Text;

+ 0 - 1
TEAMModelOS.SDK/DI/AzureRedis/AzureRedisExtensions.cs

@@ -1,5 +1,4 @@
 using Microsoft.Azure.Cosmos.Table;
-using Microsoft.Azure.Cosmos.Table.Queryable;
 using System;
 using System.Collections;
 using System.Collections.Generic;

+ 5 - 4
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageBlobExtensions.cs

@@ -16,9 +16,10 @@ using System.Text.Encodings.Web;
 using TEAMModelOS.SDK.Models.Table;
 using Microsoft.AspNetCore.Http;
 using TEAMModelOS.Models;
-using Microsoft.Azure.Cosmos.Table;
+using Microsoft.Azure.Cosmos;
 
 using static TEAMModelOS.SDK.CoreAPIHttpService;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelOS.SDK.DI
 {
@@ -160,7 +161,7 @@ namespace TEAMModelOS.SDK.DI
                 BlobContainerClient bcc = client.GetBlobContainerClient(blobContainerName.ToLower());
                 BlobBatchClient bbc = client.GetBlobBatchClient();
                 List<Uri> blobs = new List<Uri>();
-                List<Task<Azure.Response<bool>>> list = new List<Task<Response<bool>>>();
+                List<Task<Azure.Response<bool>>> list = new List<Task<Azure.Response<bool>>>();
                 foreach (var prefix in prefixs) {
                     string px = prefix;
                     if (prefix.StartsWith("/")) {
@@ -223,7 +224,7 @@ namespace TEAMModelOS.SDK.DI
                 {
                     if (blobs.Count > 0) {
                         try {
-                            Azure.Response[] ass = await bbc.DeleteBlobsAsync(blobs); 
+                            ResponseMessage[] ass = await bbc.DeleteBlobsAsync(blobs); 
                         }
                         catch (AggregateException ex)
                         {
@@ -248,7 +249,7 @@ namespace TEAMModelOS.SDK.DI
                     for (int i = 0; i < pages; i++)
                     {
                         List<Uri> lists = blobs.Skip((i) * 256).Take(256).ToList();
-                        try { Azure.Response[] ass = await bbc.DeleteBlobsAsync(lists); }
+                        try { ResponseMessage[] ass = await bbc.DeleteBlobsAsync(lists); }
                         catch (AggregateException ex)
                         {
                             //删除多个时会,如果其中一个文件不存在 或者其中一个删除失败会引发该异常

+ 2 - 1
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageTableExtensions.cs

@@ -1,5 +1,6 @@
+
+using TEAMModelOS.SDK.Models.Table;
 using Microsoft.Azure.Cosmos.Table;
-using Microsoft.Azure.Cosmos.Table.Queryable;
 using System;
 using System.Collections;
 using System.Collections.Generic;

+ 4 - 4
TEAMModelOS.SDK/DI/Mail/MailFactory.cs

@@ -88,9 +88,9 @@ namespace TEAMModelOS.SDK.DI.Mail
                     }
                     try
                     {
-                        TMDOrder order = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<TMDOrder>(userToken, new Azure.Cosmos.PartitionKey("TMDOrder"));
+                        TMDOrder order = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<TMDOrder>(userToken, new Microsoft.Azure.Cosmos.PartitionKey("TMDOrder"));
                         order.invoiceNotify=result;
-                        await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReplaceItemAsync<TMDOrder>(order, userToken, new Azure.Cosmos.PartitionKey("TMDOrder"));
+                        await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReplaceItemAsync<TMDOrder>(order, userToken, new Microsoft.Azure.Cosmos.PartitionKey("TMDOrder"));
                     }
                     catch(Exception ex)
                     {
@@ -136,9 +136,9 @@ namespace TEAMModelOS.SDK.DI.Mail
                     }
                     //try
                     //{
-                    //    TMDOrder order = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<TMDOrder>(userToken, new Azure.Cosmos.PartitionKey("TMDOrder"));
+                    //    TMDOrder order = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<TMDOrder>(userToken, new PartitionKey("TMDOrder"));
                     //    order.invoiceNotify=result;
-                    //    await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReplaceItemAsync<TMDOrder>(order, userToken, new Azure.Cosmos.PartitionKey("TMDOrder"));
+                    //    await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReplaceItemAsync<TMDOrder>(order, userToken, new PartitionKey("TMDOrder"));
                     //}
                     //catch (Exception ex)
                     //{

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/School/Class.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;

+ 6 - 1
TEAMModelOS.SDK/Models/Cosmos/School/ScoreCalc.cs

@@ -370,6 +370,7 @@ namespace TEAMModelOS.SDK.Models.Cosmos.School
         public ExamItem()
         {            
             point = new List<double>();
+            subjects = new List<ItemId>();
         }
         /// <summary>
         /// 評量id
@@ -395,7 +396,11 @@ namespace TEAMModelOS.SDK.Models.Cosmos.School
         /// 每題的滿分分數
         /// </summary>
         public List<double> point { get; set; }
-        
+        /// <summary>
+        /// 科目Id
+        /// </summary>
+        public List<ItemId> subjects { get; set; }
+
 
     }
     /// <summary>

+ 6 - 6
TEAMModelOS.SDK/Models/Service/ArtService.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using System;
@@ -92,7 +92,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 query = $" select value c from c where c.school  = '{_schoolId}' and c.studentId in ({string.Join(",", studentIds.Select(z => $"'{z}'"))})";
             }
             List<StudentArtResult> artResults = new List<StudentArtResult>();
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<StudentArtResult>
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIteratorSql<StudentArtResult>
               (queryText: query, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{_artId}") }))
             {
                 artResults.Add(item);
@@ -152,7 +152,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 List<Block> blocks = new List<Block>();
                 string code = $"Knowledge-{_schoolId}-{schSub.id}";
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
-                    .GetItemQueryIterator<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    .GetItemQueryIteratorSql<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     item.blocks.ForEach(x =>
                     {
@@ -174,14 +174,14 @@ namespace TEAMModelOS.SDK.Models.Service
             if (allExamIds.Any())
             {
                 var queryExam = $"select  value c  from c where c.id  in  ({string.Join(",", allExamIds.Select(x => $"'{x.acId}'"))}) ";
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: queryExam, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{_schoolId}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamInfo>(queryText: queryExam, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{_schoolId}") }))
                 {
                     exams.Add(item);
                 }
                 foreach (var allexamId in allExamIds)
                 {
                     var queryResult = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes,c.sRate,c.average,c.standard,c.lostStus,c.record,c.phc,c.plc,c.examId from c where c.examId = '{allexamId.acId}' and c.subjectId = '{allexamId.subject}' ";
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: queryResult, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{allexamId.acId}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: queryResult, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{allexamId.acId}") }))
                     {
                         examResults.Add(item);
                     }
@@ -476,7 +476,7 @@ namespace TEAMModelOS.SDK.Models.Service
         /* List<ExamResult> examResults = new();
          ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(examId.ToString(), new PartitionKey($"Exam-{code}"));
          var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes,c.sRate,c.average,c.standard,c.lostStus,c.record,c.phc,c.plc from c where c.examId = '{examId}' and c.subjectId = '{subjectId}' ";
-         await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{examId}") }))
+         await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{examId}") }))
                  {
                      examResults.Add(item);
                  }*/

+ 9 - 9
TEAMModelOS.SDK/Models/Service/BI/BILeesonService.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using StackExchange.Redis;
 using System;
 using System.Collections.Generic;
@@ -73,9 +73,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     List<double> lessHours = new(daHour);
 
                     var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{dateDay}", new PartitionKey("LessonHour"));
-                    if (lessRes.Status == 200)
+                    if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(lessRes.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(lessRes.Content);
                         LessonStats lessonStats = json.ToObject<LessonStats>();
                         lessonStats.code = "LessonHour";
                         lessonStats.pk = "LessonHour";
@@ -114,9 +114,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     List<double> lessYear = new(daYear);
 
                     var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey("LessonYear"));
-                    if (lessRes.Status == 200)
+                    if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(lessRes.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(lessRes.Content);
                         LessonStats lessonYear = json.ToObject<LessonStats>();
                         lessonYear.code = "LessonYear";
                         lessonYear.pk = "LessonYear";
@@ -166,9 +166,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                         List<double> lessHours = new(daHour);
 
                         var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{dateDay}", new PartitionKey($"LessonHour-{schoolId}"));
-                        if (lessRes.Status == 200)
+                        if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(lessRes.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(lessRes.Content);
                             LessonStats lessonStats = json.ToObject<LessonStats>();
                             lessonStats.code = $"LessonHour-{schoolId}";
                             lessonStats.pk = "LessonHour";
@@ -206,9 +206,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                         List<double> lessYear = new(daYear);
 
                         var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey($"LessonYear-{schoolId}"));
-                        if (lessRes.Status == 200)
+                        if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(lessRes.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(lessRes.Content);
                             LessonStats lessonYear = json.ToObject<LessonStats>();
                             lessonYear.code = $"LessonYear-{schoolId}";
                             lessonYear.pk = "LessonYear";

+ 13 - 13
TEAMModelOS.SDK/Models/Service/BI/BIProdAnalysis.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Newtonsoft.Json;
 using StackExchange.Redis;
 using System;
@@ -125,9 +125,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 //取得TMID進階資料,以弱強歸戶學校補足學校ID
                 QueryDefinition querye = new QueryDefinition(@"SELECT c.id, c.schoolCode, c.schoolCodeW FROM c WHERE (ARRAY_CONTAINS(@key, c.id) AND ( (IS_DEFINED(c.schoolCode) AND IS_STRING(c.schoolCode)) OR (IS_DEFINED(c.schoolCodeW) AND IS_STRING(c.schoolCodeW)) ))").WithParameter("@key", tmids);
                 await foreach (var item in _azureCosmosClientCsv2.GetContainer("Core", "ID2")
-                .GetItemQueryStreamIterator(querye, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base-ex")}))
+                .GetItemQueryStreamIteratorQuery(querye, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base-ex")}))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -487,9 +487,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 Dictionary<string, Dictionary<string, ProdAnalysisCosmos>> ProdAnalysisListYear = new Dictionary<string, Dictionary<string, ProdAnalysisCosmos>>();
                 Dictionary<string, ProdAnalysisCosmos> cosmosAllSchSumYearDic = new Dictionary<string, ProdAnalysisCosmos>();
                 var query = $"SELECT * FROM c WHERE c.year = {y} AND c.dateUnit = 'month' AND c.schoolId != 'allschool'";
-                await foreach (var itemcr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProdAnalysis") }))
+                await foreach (var itemcr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProdAnalysis") }))
                 {
-                    var json = await JsonDocument.ParseAsync(itemcr.ContentStream);
+                    var json = await JsonDocument.ParseAsync(itemcr.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -587,9 +587,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     //取得IES5 school Base
                     string schIdListStr = JsonConvert.SerializeObject(crtVirtualSchoolId);
                     string schBaseQueryText = $"SELECT c.id FROM c where ARRAY_CONTAINS({schIdListStr}, c.id, true)";
-                    await foreach (var itemsr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: schBaseQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                    await foreach (var itemsr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: schBaseQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemsr.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemsr.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -605,9 +605,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     //取得IES5 school VirtualBase
                     schIdListStr = JsonConvert.SerializeObject(crtVirtualSchoolId);
                     schBaseQueryText = $"SELECT c.id FROM c where ARRAY_CONTAINS({schIdListStr}, c.id, true)";
-                    await foreach (var itemsr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: schBaseQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"VirtualBase") }))
+                    await foreach (var itemsr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: schBaseQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"VirtualBase") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemsr.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemsr.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -627,9 +627,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                         List<School> crtVSchoolList = new List<School>();
                         string csv2SchIdListStr = JsonConvert.SerializeObject(crtVirtualSchoolId);
                         string schCsv2QueryText = $"SELECT c.shortCode, c.name, c.countryName, c.provinceName, c.cityName, c.distName, c.address FROM c where ARRAY_CONTAINS({csv2SchIdListStr}, c.shortCode, true)";
-                        await foreach (var item in _azureCosmosClientCsv2CnRead.GetContainer("Core", "School").GetItemQueryStreamIterator(queryText: schCsv2QueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                        await foreach (var item in _azureCosmosClientCsv2CnRead.GetContainer("Core", "School").GetItemQueryStreamIteratorSql(queryText: schCsv2QueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
                         {
-                            using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(item.Content);
                             if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                             {
                                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -982,9 +982,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 Dictionary<string, Dictionary<string, TmidAnalysisCosmos>> TmidAnalysisListYear = new Dictionary<string, Dictionary<string, TmidAnalysisCosmos>>();
                 Dictionary<string, TmidAnalysisCosmos> cosmosAllTmidSumYearDic = new Dictionary<string, TmidAnalysisCosmos>();
                 var query = $"SELECT * FROM c WHERE c.year = {y} AND c.dateUnit = 'month' AND c.tmid != 'alltmid'";
-                await foreach (var itemcr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("TmidAnalysis") }))
+                await foreach (var itemcr in _azureCosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorSql(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("TmidAnalysis") }))
                 {
-                    var json = await JsonDocument.ParseAsync(itemcr.ContentStream);
+                    var json = await JsonDocument.ParseAsync(itemcr.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())

+ 1 - 1
TEAMModelOS.SDK/Models/Service/BI/BISchoolService.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 24 - 23
TEAMModelOS.SDK/Models/Service/BI/BIStats.cs

@@ -1,7 +1,7 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs;
 using MathNet.Numerics.LinearAlgebra.Double;
-using Microsoft.Azure.Cosmos.Table;
+using TEAMModelOS.SDK.Models.Table;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -13,6 +13,7 @@ using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelOS.SDK.Models.Service.BI
 {
@@ -67,9 +68,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 StatsInfo statsInfo = null;
 
                 var resStsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dateOff.Year}-{scId}", new PartitionKey("Statistics"));
-                if (resStsInfo.Status == 200)
+                if (resStsInfo.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(resStsInfo.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(resStsInfo.Content);
                     statsInfo = fileJson.ToObject<StatsInfo>();
                     if (string.IsNullOrEmpty(statsInfo.schoolId))
                     {
@@ -79,9 +80,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 else
                 {
                     var resLastStsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dateOff.Year - 1}-{scId}", new PartitionKey("Statistics"));
-                    if (resLastStsInfo.Status == 200)
+                    if (resLastStsInfo.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(resLastStsInfo.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(resLastStsInfo.Content);
                         statsInfo = fileJson.ToObject<StatsInfo>();
                         statsInfo.id = $"{dateOff.Year}-{scId}";
                         statsInfo.year = dateOff.Year;
@@ -148,9 +149,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
 
                         StatsInfo lastStats = null;
                         var resLastStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dateOff.Year - 1}-{scId}", new PartitionKey("Statistics"));
-                        if (resLastStats.Status == 200)
+                        if (resLastStats.StatusCode == System.Net.HttpStatusCode.OK)
                         {
-                            using var fileJson = await JsonDocument.ParseAsync(resLastStats.ContentStream);
+                            using var fileJson = await JsonDocument.ParseAsync(resLastStats.Content);
                             lastStats = fileJson.ToObject<StatsInfo>();
                             lastLesson = DenseMatrix.OfColumns(new List<List<double>>() { lastStats.lesson.year });
                             lastInter = DenseMatrix.OfColumns(new List<List<double>>() { lastStats.lesson.yearInters });
@@ -186,9 +187,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                         statsInfo.lesson.week = ((int)lessList.SubMatrix(weekDayS.DayOfYear - 1, (dateOff.DayOfYear - weekDayS.DayOfYear + 1), 0, lessList.ColumnCount).ColumnSums().Sum());
 
                         //var resLast = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{lTermDayS.Year}-{scId}", new PartitionKey("Statistics"));
-                        //if (resLast.Status == 200)
+                        //if (resLast.StatusCode == System.Net.HttpStatusCode.OK)
                         //{
-                        //    using var fileJson = await JsonDocument.ParseAsync(resLast.ContentStream);
+                        //    using var fileJson = await JsonDocument.ParseAsync(resLast.Content);
                         //    lastStats = fileJson.ToObject<StatsInfo>();
                         //}
 
@@ -329,9 +330,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                             DenseMatrix lastAct = null;
                             StatsInfo lastStats = null;
                             var resLastStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dateOff.Year - 1}-{scId}", new PartitionKey("Statistics"));
-                            if (resLastStats.Status == 200)
+                            if (resLastStats.StatusCode == System.Net.HttpStatusCode.OK)
                             {
-                                using var fileJson = await JsonDocument.ParseAsync(resLastStats.ContentStream);
+                                using var fileJson = await JsonDocument.ParseAsync(resLastStats.Content);
                                 lastStats = fileJson.ToObject<StatsInfo>();
                                 lastAct = DenseMatrix.OfColumns(new List<List<double>>() { lastStats.activity.year });
                             }
@@ -431,7 +432,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                         }
                     }
                 }
-                if (resStsInfo.Status == 200)
+                if (resStsInfo.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     statsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<StatsInfo>(statsInfo, statsInfo.id, new PartitionKey("Statistics"));
                 }
@@ -459,9 +460,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 DateTimeOffset dateOff = DateTimeOffset.UtcNow;
                 StatsInfo statsInfo = new();
                 var resStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dateOff.Year}-{school.id}", new PartitionKey("Statistics"));
-                if (resStats.Status == 200)
+                if (resStats.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(resStats.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(resStats.Content);
                     statsInfo = fileJson.ToObject<StatsInfo>();
                 }
                 else
@@ -489,7 +490,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 statsInfo.areaId = school.areaId;
                 statsInfo.upTime = dateOff.ToUnixTimeMilliseconds();
 
-                if (resStats.Status == 200)
+                if (resStats.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<StatsInfo>(statsInfo, statsInfo.id, new PartitionKey("Statistics"));
                 }
@@ -520,9 +521,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 string type = "";
                 BIRelation bIRelation = new();
                 var resBiRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school.id, new PartitionKey("BIRel"));
-                if (resBiRel.Status == 200)
+                if (resBiRel.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(resBiRel.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(resBiRel.Content);
                     bIRelation = fileJson.ToObject<BIRelation>();
                 }
                 else
@@ -549,7 +550,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 bIRelation.areaName = aName;
                 bIRelation.edition = school.edition;
 
-                if (resBiRel.Status == 200)
+                if (resBiRel.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<BIRelation>(bIRelation, bIRelation.id, new PartitionKey("BIRel"));
                     type = "update";
@@ -606,7 +607,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 StringBuilder statsSql = new($"select value(c) from c where c.year={dateOff.Year}");
                 List<string> scIds = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: $"select value(c.id) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.id) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
                 {
                     scIds.Add(item);
                 }
@@ -616,7 +617,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     statsSql.Append($" and {BICommonWay.ManyScSql("c.id", scIds, $"{dateOff.Year}-")}");
                 }
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<StatsInfo>(queryText: statsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<StatsInfo>(queryText: statsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
                 {
                     tempStatsInfos.Add(item);
                 }
@@ -634,9 +635,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                             DenseMatrix lastInter = null;
                             DenseMatrix lastAct = null;
                             var lastSts = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dateOff.Year - 1}-{item.schoolId}", new PartitionKey("Statistics"));
-                            if (lastSts.Status == 200)
+                            if (lastSts.StatusCode == System.Net.HttpStatusCode.OK)
                             {
-                                using var fileJson = await JsonDocument.ParseAsync(lastSts.ContentStream);
+                                using var fileJson = await JsonDocument.ParseAsync(lastSts.Content);
                                 lastStatsInfo = fileJson.ToObject<StatsInfo>();
                                 item.schoolId = lastStatsInfo.schoolId;
                                 item.year = dateOff.Year;

+ 6 - 6
TEAMModelOS.SDK/Models/Service/BI/BIStatsNotice.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.Extensions.Configuration;
 using System;
 using System.Collections.Generic;
@@ -42,9 +42,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 string dt = dateOff.ToString("yyyyMMdd");
                 StatsNotice statsNotice = new();
                 var resStsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dt}-{id}", new PartitionKey("StatsNotice"));
-                if (resStsInfo.Status == 200)
+                if (resStsInfo.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(resStsInfo.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(resStsInfo.Content);
                     statsNotice = fileJson.ToObject<StatsNotice>();
                 }
                 else
@@ -73,7 +73,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 statsNotice.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 
                 statsNotice.ttl = 86400;
-                if (resStsInfo.Status == 200)
+                if (resStsInfo.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     statsNotice = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<StatsNotice>(statsNotice, statsNotice.id, new PartitionKey("StatsNotice"));
                 }
@@ -122,7 +122,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 }
                 List<StatsNotice> statsNotices = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<StatsNotice>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StatsNotice") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<StatsNotice>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StatsNotice") }))
                 {
                     statsNotices.Add(item);
                 }
@@ -132,7 +132,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     List<string> tacherIds = new();
                     if (item.type == "school")
                     {
-                        await foreach (var tchId in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: "SELECT c.id FROM c WHERE ARRAY_CONTAINS(c.roles, 'admin', true) AND c.pk = 'Teacher' AND c.status = 'join'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{item.rangeId}") }))
+                        await foreach (var tchId in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: "SELECT c.id FROM c WHERE ARRAY_CONTAINS(c.roles, 'admin', true) AND c.pk = 'Teacher' AND c.status = 'join'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{item.rangeId}") }))
                         {
                             tacherIds.Add(tchId);
                         }

+ 23 - 22
TEAMModelOS.SDK/Models/Service/BI/CosmosQueryHelper.cs

@@ -1,10 +1,11 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelOS.SDK.Models.Service.BI
 {
@@ -23,9 +24,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             try
             {
                 string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, '{roles}', true) AND c.pk = 'Teacher' AND c.status = 'join' AND c.code = 'Teacher-{schoolId}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         SchoolTeacherRoles str = new()
@@ -55,9 +56,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         {
             List<string> schoolIds = new();
             //string schoolSql = $"SELECT DISTINCT REPLACE(c.code,'Teacher-','') AS schoolId,c.code,c.roles,c.id,c.name From c where ARRAY_CONTAINS(c.roles,'assist',true) AND c.status = 'join' AND c.id='{tmdId}'";
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: schoolSql, requestOptions: new QueryRequestOptions() { }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: schoolSql, requestOptions: new QueryRequestOptions() { }))
             //{
-            //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(item.Content);
             //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
             //    {
             //        schoolIds.Add(obj.GetProperty("schoolId").GetString());
@@ -69,7 +70,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 schoolSql.Append($" and (array_contains(c.roles,'assist',true) or array_contains(c.roles,'sales',true))");
             else
                 schoolSql.Append($" and array_contains(c.roles,'{roles}',true)");
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: schoolSql.ToString(), requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: schoolSql.ToString(), requestOptions: new QueryRequestOptions() { }))
             {
                 schoolIds.Add(item);
             }
@@ -88,7 +89,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         public static async Task<List<string>> GetValueSingle(CosmosClient cosmosClient, string container, string sqlTxt, string code = null)
         {
             List<string> ids = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
             {
                 ids.Add(item);
             }
@@ -108,9 +109,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         public async Task<List<string>> GetStreamSingle(CosmosClient cosmosClient, string container, string sqlTxt, string single = "id", string code = null)
         {
             List<string> ids = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     ids.Add(obj.GetProperty(single).GetString());
@@ -130,14 +131,14 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         public static async Task<List<string>> FindScIds(CosmosClient cosmosClient, string sqlTxt, string code)
         {
             List<string> schoolIds = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 schoolIds.Add(item);
             }
 
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             //{
-            //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(item.Content);
             //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
             //    {
             //        schoolIds.Add(obj.GetProperty("id").GetString());
@@ -166,14 +167,14 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             foreach (var school in schools)
             {
                 string sqlTxt = $"select value(c.id) from c where ARRAY_CONTAINS(c.roles,'{rolesName}',true) and c.status = 'join'";
-                await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
+                await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
                 {
                     teachers.Add(itemTeac);
                 }
                 //string sqlTxt = $"select c.id from c where ARRAY_CONTAINS(c.roles,'{rolesName}',true) and c.status = 'join'";
-                //await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() {PartitionKey =new PartitionKey($"Teacher-{school}") }))
+                //await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() {PartitionKey =new PartitionKey($"Teacher-{school}") }))
                 //{
-                //    using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                 //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 //    {
                 //        teachers.Add(obj.GetProperty("id").GetString());
@@ -196,7 +197,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             int totals = 0;
             try
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     totals = item;
                 }
@@ -219,7 +220,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             int totals = 0;
             foreach (var container in containers)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     totals += item;
                 }
@@ -239,7 +240,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         public static async Task<double> GetSqlValueDoubleCounnt(CosmosClient cosmosClient, string container, string SqlTxt, string code = null)
         {
             double totals = 0;
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 totals = item;
             }
@@ -260,7 +261,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             double totals = 0;
             foreach (var container in containers)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     totals += item;
                 }
@@ -283,7 +284,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             List<T> temps = new();
             foreach (var container in containers)
             {
-                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     temps.Add(items);
                 }
@@ -303,7 +304,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         public static async Task<List<T>> GetObject<T>(CosmosClient cosmosClient, string containers, string sqlTxt, string code = null)
         {
             List<T> temps = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIterator<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIteratorSql<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 temps.Add(items);
             }
@@ -322,7 +323,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         {
             string str = null;
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 str = item;
             }

+ 5 - 5
TEAMModelOS.SDK/Models/Service/BI/JointlySingleQuery.cs

@@ -1,8 +1,8 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
-
+using TEAMModelOS.SDK.DI;
 namespace TEAMModelOS.SDK.Models.Service.BI
 {
     public class JointlySingleQuery
@@ -28,7 +28,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
 
                 foreach (string conId in containerId)
                 {
-                    await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", conId).GetItemQueryIterator<int>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", conId).GetItemQueryIteratorSql<int>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
                         totals += itemInt;
                     }
@@ -60,7 +60,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                     sql = sqlTxt;
                 }
 
-                await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     totals += itemInt;
                 }
@@ -84,7 +84,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         {
             List<string> strList = new();
 
-            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", containerId).GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", containerId).GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
                 strList.Add(itemInt);
             }

+ 9 - 9
TEAMModelOS.SDK/Models/Service/BI/LessonStatisWay.cs

@@ -1,11 +1,11 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
-
+using TEAMModelOS.SDK.DI;
 namespace TEAMModelOS.SDK.Models.Service.BI
 {
     public class LessonStatisWay
@@ -25,9 +25,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             {
                 foreach (string sc in scIds)
                 {
-                    await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{sc}") }))
+                    await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{sc}") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -43,9 +43,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 foreach (string sc in scIds)
                 {
                     string sqlTecTxt = $"select count(c.id) from c where c.id='{sc}'";
-                    await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
+                    await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -71,14 +71,14 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             int totals = 0;
             string LessonSqlTxt = "select value(count(c.id)) from c";
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(queryText: LessonSqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<int>(queryText: LessonSqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
             {
                 totals += item;
             }
 
             List<string> tecIdS = new();
             string managerSql = $"SELECT value(c.id) FROM c WHERE ARRAY_CONTAINS(c.roles, 'teacher', true) AND  c.pk = 'Teacher' AND c.status = 'join'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: managerSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: managerSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
             {
                 tecIdS.Add(item);
             }
@@ -86,7 +86,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             foreach (var itemId in tecIdS)
             {
                 string tecLessSQL = $"select value(count(c.id)) from c where c.tmdid='{itemId}'";
-                await foreach (var itemCount in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(queryText: tecLessSQL, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
+                await foreach (var itemCount in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<int>(queryText: tecLessSQL, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
                 {
                     totals += itemCount;
                 }

+ 4 - 4
TEAMModelOS.SDK/Models/Service/BI/ProductUseRecordService.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Linq;
 using System.Text.Json;
@@ -26,9 +26,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 ProductUseRecord productUseRecord = new();
                 var resUseRecord = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{dateOff.Year}", new PartitionKey("ProductUseRecord"));
 
-                if (resUseRecord.Status == 200)
+                if (resUseRecord.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(resUseRecord.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(resUseRecord.Content);
                     productUseRecord = fileJson.ToObject<ProductUseRecord>();
                 }
                 else
@@ -90,7 +90,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                         break;
                 }
 
-                if (resUseRecord.Status == 200)
+                if (resUseRecord.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     productUseRecord = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ProductUseRecord>(productUseRecord, productUseRecord.id, new PartitionKey("ProductUseRecord"));
                 }

+ 6 - 6
TEAMModelOS.SDK/Models/Service/BIStatsWay/ActivityStatsWay.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -6,7 +6,7 @@ using System.Text;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Service.BI;
-
+using TEAMModelOS.SDK.DI;
 namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
 {
     public static class ActivityStatsWay
@@ -69,14 +69,14 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 {
                     case "Exam":
                         exam = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Exam-{scId}", currSql);
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{scId}") }))
                         {
                             examSts.Add(item);
                         }
                         break;
                     case "Survey":
                         survey = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Survey-{scId}", currSql);
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{scId}") }))
                         {
                             surveySts.Add(item);
                         }
@@ -84,14 +84,14 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                         break;
                     case "Vote":
                         vote = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Vote-{scId}", currSql);
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{scId}") }))
                         {
                             voteSts.Add(item);
                         }
                         break;
                     case "Homework":
                         homework = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Homework-{scId}", currSql);
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{scId}") }))
                         {
                             homeworkSts.Add(item);
                         }

+ 3 - 3
TEAMModelOS.SDK/Models/Service/BIStatsWay/LessonRecordStatsWay.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -6,7 +6,7 @@ using System.Text;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Service.BI;
-
+using TEAMModelOS.SDK.DI;
 namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
 {
     public static class LessonRecordStatsWay
@@ -46,7 +46,7 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
 
             List<LessRelStats> lessRelStats = new();
             string sql = $"select c.id,c.code,c.startTime,c.clientInteractionCount from c where c.pk='LessonRecord' and c.startTime >= {yearS} and c.startTime <= {yearE}";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{id}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{id}") }))
             {
                 lessRelStats.Add(item);
             }

+ 3 - 3
TEAMModelOS.SDK/Models/Service/BIStatsWay/SchoolStatsWay.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using MathNet.Numerics.LinearAlgebra.Double;
 using Newtonsoft.Json;
 using StackExchange.Redis;
@@ -218,9 +218,9 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 List<string> serialPermitList = StaticValue.GetSerialPermitProdcodeList();
                 string serialPermitJsonStr = JsonConvert.SerializeObject(serialPermitList);
                 string serialQueryText = $"SELECT * FROM c WHERE c.dataType = 'serial' AND ARRAY_CONTAINS({serialPermitJsonStr}, c.prodCode)";
-                await foreach (var itemsr in db.GetItemQueryStreamIterator(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{code}") }))
+                await foreach (var itemsr in db.GetItemQueryStreamIteratorSql(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(itemsr.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(itemsr.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         deviceForCoreService uuidForCore;

+ 6 - 6
TEAMModelOS.SDK/Models/Service/BIStatsWay/StudyStatsWay.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -7,7 +7,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-
+using TEAMModelOS.SDK.DI;
 namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
 {
 
@@ -25,13 +25,13 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             List<AreaStudy> trains = new();
 
             School school = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>($"{scId}", new PartitionKey("Base"));
-            //cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText:$"select value(c.areaId) from c where c.id='{scId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")});
+            //cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText:$"select value(c.areaId) from c where c.id='{scId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")});
 
             AreaSetting setting = null;
             var responSett = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{school.areaId}", new PartitionKey("AreaSetting"));
-            if (responSett.Status == 200)
+            if (responSett.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(responSett.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(responSett.Content);
                 setting = fileJson.ToObject<AreaSetting>();
 
             }
@@ -48,7 +48,7 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 };
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<AreaStudy>(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and c.school='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{scId}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<AreaStudy>(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and c.school='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{scId}") }))
             {
                 trains.Add(item);
             }

+ 3 - 3
TEAMModelOS.SDK/Models/Service/BIStatsWay/UserStatsWay.cs

@@ -1,10 +1,10 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Service.BI;
-
+using TEAMModelOS.SDK.DI;
 namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
 {
     public class UserStatsWay
@@ -35,7 +35,7 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
 
             List<ArtRelStats> artRelStats = new();
             string sql = $"select c.id,c.code,c.createTime from c where  c.startTime >= {yearS} and c.startTime <= {yearE}";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<ArtRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<ArtRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
                 artRelStats.Add(item);
             }

+ 9 - 9
TEAMModelOS.SDK/Models/Service/Common/ActivityService.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Sas;
 using System;
 using System.Collections.Generic;
@@ -23,8 +23,8 @@ namespace TEAMModelOS.SDK
             List<ExpertDto> expertTasks = new List<ExpertDto>();
             ActivityExpert activityExpert = null;
 
-            Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync($"{_activityId}", new PartitionKey("ActivityExpert"));
-            if (response.Status == 200)
+            ResponseMessage response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync($"{_activityId}", new PartitionKey("ActivityExpert"));
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
                 bool change = false;
                 activityExpert = JsonDocument.Parse(response.Content).RootElement.Deserialize<ActivityExpert>();
@@ -140,8 +140,8 @@ namespace TEAMModelOS.SDK
                 }
 
                 Contest contest = null;
-                Azure.Response contestResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId, new PartitionKey("Contest"));
-                if (contestResponse.Status==200)
+                ResponseMessage contestResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId, new PartitionKey("Contest"));
+                if (contestResponse.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     contest = JsonDocument.Parse(contestResponse.Content).RootElement.ToObject<Contest>();
                 }
@@ -181,8 +181,8 @@ namespace TEAMModelOS.SDK
 
         public static async Task<List<ActivityScoreLevel>> ActivityScores (AzureCosmosFactory _azureCosmos,JsonElement _activityId,string teacherId= null) {
             List<ActivityScoreLevel> scoreLevels = new List<ActivityScoreLevel>();
-            Azure.Response responseContest = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("Contest"));
-            if (responseContest.Status == 200)
+            ResponseMessage responseContest = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("Contest"));
+            if (responseContest.StatusCode == System.Net.HttpStatusCode.OK)
             {
 
                 long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
@@ -1068,7 +1068,7 @@ namespace TEAMModelOS.SDK
             //代码顺序不能动
             var checkReult = CheckReviewRule(reviewRule, contest);
             if (checkReult.invalidCode==200) {
-                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(reviewRule, new Azure.Cosmos.PartitionKey(reviewRule.code));
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(reviewRule, new PartitionKey(reviewRule.code));
                 if (reviewRuleTree.upsertAsTemplate==1)
                 {
                     reviewRule.code="ReviewRule-template";
@@ -1077,7 +1077,7 @@ namespace TEAMModelOS.SDK
                     reviewRule.scoreRule = reviewRuleTree.scoreRule;
                     reviewRule.distribute = reviewRuleTree.distribute;
                     reviewRule.scoreDetail = reviewRuleTree.scoreDetail;
-                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(reviewRule, new Azure.Cosmos.PartitionKey(reviewRule.code));
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(reviewRule, new PartitionKey(reviewRule.code));
                 }
             }
             return (reviewRule,checkReult.invalidCode,checkReult.msg);

+ 10 - 10
TEAMModelOS.SDK/Models/Service/Common/ActivityStudentService.cs

@@ -4,7 +4,7 @@ using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Extension;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common.Inner;
@@ -53,7 +53,7 @@ namespace TEAMModelOS.SDK.Services
                 //1.再次检查投票
                 var client = _azureCosmos.GetCosmosClient();
                 ///TODO 检查是否在投票范围内,包括在tmdids 及班级  但是需要处理认证金钥中的班级问题
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Vote>(queryText: $"select c.id,c.code ,c.school,c.creatorId,c.scope , c.progress,c.times,c.voteNum,c.startTime,c.endTime from c where c.id = '{id}'",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<Vote>(queryText: $"select c.id,c.code ,c.school,c.creatorId,c.scope , c.progress,c.times,c.voteNum,c.startTime,c.endTime from c where c.id = '{id}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     vote = item;
@@ -188,7 +188,7 @@ namespace TEAMModelOS.SDK.Services
                     }
                     catch (CosmosException ex)
                     {
-                        if (ex.Status == 404)
+                        if (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
                         {
                             try
                             {
@@ -512,10 +512,10 @@ namespace TEAMModelOS.SDK.Services
             }
             string querySchool = $" SELECT  value c   FROM c   {joinSqlSubjects}  where c.pk='Activity' and c.qamode <> 2 {stimesql}  {etimesql}  {typesql}  {andSqlSubjects} {source} {owner} {name} order by c.createTime desc";
             //查询数据归属学校的
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, containerId).GetItemQueryStreamIterator(querySchool, continuationToken: token,
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, containerId).GetItemQueryStreamIteratorSql(querySchool, continuationToken: token,
                 requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey(PartitionKey) }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -526,7 +526,7 @@ namespace TEAMModelOS.SDK.Services
                 //如果需要分页则跳出
                 if (iscontinuation)
                 {
-                    token = item.GetContinuationToken();
+                    token = item.ContinuationToken;
                     break;
                 }
             }
@@ -559,7 +559,7 @@ namespace TEAMModelOS.SDK.Services
                 var client = _azureCosmos.GetCosmosClient();
                 Survey survey = null;
                 ///TODO 检查是否在问卷范围内,包括在tmdids 及班级  但是需要处理认证金钥中的班级问题
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Survey>(queryText: $"select c.id,c.owner,c.scope, c.code ,c.creatorId,c.answers ,c.school , c.progress,c.times,c.startTime,c.endTime from c where c.id = '{id}'",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<Survey>(queryText: $"select c.id,c.owner,c.scope, c.code ,c.creatorId,c.answers ,c.school , c.progress,c.times,c.startTime,c.endTime from c where c.id = '{id}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     survey = item;
@@ -826,7 +826,7 @@ namespace TEAMModelOS.SDK.Services
                     }
                     catch (CosmosException ex)
                     {
-                        if (ex.Status == 404)
+                        if (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
                         {
                             try
                             {
@@ -836,7 +836,7 @@ namespace TEAMModelOS.SDK.Services
                             }
                             catch (CosmosException cex)
                             {
-                                if (cex.Status == 404)
+                                if (cex.StatusCode == System.Net.HttpStatusCode.NotFound)
                                 {
                                     try
                                     {
@@ -850,7 +850,7 @@ namespace TEAMModelOS.SDK.Services
                                     }
                                     catch (CosmosException cosex)
                                     {
-                                        if (cosex.Status == 404)
+                                        if (cosex.StatusCode == System.Net.HttpStatusCode.NotFound)
                                         {
                                             taskStatus = -1;
                                         }

+ 5 - 5
TEAMModelOS.SDK/Models/Service/Common/BlobService.cs

@@ -1,5 +1,5 @@
 using Azure;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using StackExchange.Redis;
@@ -72,10 +72,10 @@ namespace TEAMModelOS.SDK.Services
                         total = school.size;
                         teach = school.tsize;
                         //用tsize代替
-                        //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
+                        //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ",
                         //    requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{name}") }))
                         //{
-                        //    var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        //    var json = await JsonDocument.ParseAsync(item.Content);
                         //    foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
                         //    {
                         //        if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
@@ -224,7 +224,7 @@ namespace TEAMModelOS.SDK.Services
                     queryslt.Append($"JOIN A1 IN c.periodId WHERE A1 IN ('{periodId}') ");
                     if(!string.IsNullOrWhiteSpace(type)) queryslt.Append($"AND c.type='{type}'");
                     queryslt.Append("GROUP BY c.type");
-                   await foreach (var item in clientc.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BlobCount>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{containerName}") }))
+                   await foreach (var item in clientc.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BlobCount>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{containerName}") }))
                     {
                         bloblogcnt.Add(item);
                     }
@@ -233,7 +233,7 @@ namespace TEAMModelOS.SDK.Services
                 {
                     if (!string.IsNullOrWhiteSpace(type)) queryslt.Append($"AND c.type='{type}'");
                     queryslt.Append("GROUP BY c.type");
-                    await foreach (var item in clientc.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<BlobCount>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{containerName}") }))
+                    await foreach (var item in clientc.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<BlobCount>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{containerName}") }))
                     {
                         bloblogcnt.Add(item);
                     }

+ 4 - 4
TEAMModelOS.SDK/Models/Service/Common/SheetService.cs

@@ -1,5 +1,5 @@
 using Azure;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
@@ -17,8 +17,8 @@ namespace TEAMModelOS.SDK.Services
             string id = $"{Utils.CreatSaltString(7, _num09)}";
             for (int i = 0; i < 10; i++)
             {
-                Response response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync($"{id}", new PartitionKey(sheetCode)); 
-                if (response.Status == 404)
+                var  response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync($"{id}", new PartitionKey(sheetCode)); 
+                if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                 {
                     break;
                 }
@@ -46,7 +46,7 @@ namespace TEAMModelOS.SDK.Services
             {
                 List<SheetConfig> sheets = new List<SheetConfig>();
                 bool hasCurrFrom = false;
-                await foreach (var item  in  client.GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<SheetConfig>(
+                await foreach (var item  in  client.GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIteratorSql<SheetConfig>(
                     queryText: $"select value(c) from  c where c.no='{no}'",
                     requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey(sheetCode) })) 
                 {

+ 3 - 3
TEAMModelOS.SDK/Models/Service/Common/SyllabusService.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -24,8 +24,8 @@ namespace TEAMModelOS.SDK.Services
         public async static Task<(List<List<IdCode>> idCodes, List<SyllabusTreeNode> tree)> ImportSyllabus(List<List<string>> nodes,string volumeId,string scope ,string code,string creatorId ,string creatorName,string grant_type, AzureCosmosFactory azureCosmos, bool ignoreCharacter = true) { 
             HashSet<Syllabus> syllabuses= new HashSet<Syllabus>();
             string tbname = scope.Equals("school", StringComparison.OrdinalIgnoreCase) ? Constant.School : Constant.Teacher;
-            await foreach (var item in azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
-                        requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{code}") })) {
+            await foreach (var item in azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIteratorSql<Syllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
+                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{code}") })) {
                 syllabuses.Add(item);
             }
             Volume volume = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<Volume>($"{volumeId}", new PartitionKey($"Volume-{code}"));

+ 11 - 11
TEAMModelOS.SDK/Models/Service/Common/TeacherService.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Sas;
 using System;
@@ -77,9 +77,9 @@ namespace TEAMModelOS.Services
                         if (statusNow.Equals("join"))
                         {
                             var sctch = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{sc.schoolId}"));
-                            if (sctch.Status == 200 && sctch != null && sctch.ContentStream != null)
+                            if (sctch.StatusCode == System.Net.HttpStatusCode.OK && sctch != null && sctch.Content != null)
                             {
-                                var jsonDoc = await JsonDocument.ParseAsync(sctch.ContentStream);
+                                var jsonDoc = await JsonDocument.ParseAsync(sctch.Content);
                                 SchoolTeacher schoolTeacher = jsonDoc.RootElement.ToObject<SchoolTeacher>();
                                 if (schoolTeacher.name == null || schoolTeacher.picture == null || !schoolTeacher.name.Equals($"{name}") || !schoolTeacher.picture.Equals($"{picture}"))
                                 {
@@ -140,7 +140,7 @@ namespace TEAMModelOS.Services
             }
             catch (CosmosException ex)
             {
-                if (ex.Status == 404 && teacher == null)
+                if (ex.StatusCode == System.Net.HttpStatusCode.NotFound && teacher == null)
                 {
                     //如果沒有,則初始化Teacher基本資料到Cosmos
                     teacher = new Teacher
@@ -249,11 +249,11 @@ namespace TEAMModelOS.Services
                 if (areaIds.Count > 0)
                 {
                     string queryText = $"select value(c) from c where c.id in ({string.Join(",", areaIds.Select(x => $"'{x}'"))})";
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
                     {
                         areasDbs.Add(item);
                     }
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                     {
                         areaSettings.Add(item);
                     }
@@ -348,9 +348,9 @@ namespace TEAMModelOS.Services
                                 schoolExtobj.area = area;
                             }
                             var sctch = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{sc.schoolId}"));
-                            if (sctch.Status == 200 && sctch != null && sctch.ContentStream != null)
+                            if (sctch.StatusCode == System.Net.HttpStatusCode.OK && sctch != null && sctch.Content != null)
                             {
-                                var jsonDoc = await JsonDocument.ParseAsync(sctch.ContentStream);
+                                var jsonDoc = await JsonDocument.ParseAsync(sctch.Content);
                                 SchoolTeacher schoolTeacher = jsonDoc.RootElement.ToObject<SchoolTeacher>();
                                 sc.roles=schoolTeacher.roles;
                                 if (schoolTeacher.name == null || schoolTeacher.picture == null || !schoolTeacher.name.Equals($"{name}") || !schoolTeacher.picture.Equals($"{picture}"))
@@ -429,7 +429,7 @@ namespace TEAMModelOS.Services
             }
             catch (CosmosException ex)
             {
-                if (ex.Status == 404 && teacher == null)
+                if (ex.StatusCode == System.Net.HttpStatusCode.NotFound && teacher == null)
                 {
                     //如果沒有,則初始化Teacher基本資料到Cosmos
                     teacher = new Teacher
@@ -460,9 +460,9 @@ namespace TEAMModelOS.Services
             }
             //私人課程
             List<object> courses = new List<object>();
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c WHERE c.creatorId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseBase") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c WHERE c.creatorId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseBase") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())

+ 3 - 3
TEAMModelOS.SDK/Models/Service/Common/WebHookService.cs

@@ -7,7 +7,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BINormal;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Extension;
 using System.Net.Http.Json;
 
@@ -70,7 +70,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 {
                     string sql = $"select distinct value c from c join s in c.schools where s.id='{_school}' and c.webhook<>null and c.webhook<>'' ";
                     await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal)
-                        .GetItemQueryIterator<BizConfig>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("BizConfig") }))
+                        .GetItemQueryIteratorSql<BizConfig>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("BizConfig") }))
                     {
                         bizConfigs.Add(item);
                     }
@@ -82,7 +82,7 @@ namespace TEAMModelOS.SDK.Models.Service
                         BizConfig bizConfig = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReadItemAsync<BizConfig>($"{_bizid}", new PartitionKey("BizConfig"));
                         bizConfigs.Add(bizConfig);
                     }
-                    catch (CosmosException ex) when (ex.Status == 404)
+                    catch (CosmosException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
                     {
                         return (bizConfigs, null);
                     }

+ 0 - 0
TEAMModelOS.SDK/Models/Service/ErrorItemsService.cs


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff