瀏覽代碼

Merge branch 'develop5.0-tmduser' into develop5.0-tmd

CrazyIter_Bin 3 年之前
父節點
當前提交
0d031427ab
共有 62 個文件被更改,包括 910 次插入867 次删除
  1. 8 7
      TEAMModelFunction/ActivityHttpTrigger.cs
  2. 29 28
      TEAMModelFunction/CourseServiceBus.cs
  3. 8 8
      TEAMModelFunction/MonitorServicesBus.cs
  4. 9 8
      TEAMModelFunction/TriggerCorrect.cs
  5. 21 20
      TEAMModelFunction/TriggerExam.cs
  6. 5 4
      TEAMModelFunction/TriggerSurvey.cs
  7. 3 2
      TEAMModelFunction/TriggerVote.cs
  8. 3 2
      TEAMModelOS.SDK/Context/Constant/ConstField.cs
  9. 1 1
      TEAMModelOS.SDK/Context/Constant/ContentTypeDict.cs
  10. 1 1
      TEAMModelOS.SDK/Context/Constant/FileType.cs
  11. 2 2
      TEAMModelOS.SDK/Context/Constant/FileTypeMap.cs
  12. 2 2
      TEAMModelOS.SDK/Context/Constant/GetFileType.cs
  13. 1 1
      TEAMModelOS.SDK/Context/Constant/ResponseCode.cs
  14. 1 0
      TEAMModelOS.SDK/DI/AzureCosmos/Inner/SQLHelper.cs
  15. 1 1
      TEAMModelOS.SDK/DI/AzureStorage/AzureStorageBlobExtensions.cs
  16. 1 0
      TEAMModelOS.SDK/DI/AzureStorage/AzureStorageTableExtensions.cs
  17. 0 28
      TEAMModelOS.SDK/Helper/Common/CollectionHelper/CollectionHelper.cs
  18. 2 1
      TEAMModelOS.SDK/Models/Cosmos/Student/TmdUser.cs
  19. 8 7
      TEAMModelOS.SDK/Models/Service/FixDataService.cs
  20. 15 14
      TEAMModelOS.SDK/Models/Service/StuListService.cs
  21. 52 0
      TEAMModelOS.SDK/Models/Service/TmdUserService.cs
  22. 20 19
      TEAMModelOS.SDK/Models/Service/TriggerStuActivity.cs
  23. 1 0
      TEAMModelOS.SDK/TEAMModelOS.SDK.csproj
  24. 53 54
      TEAMModelOS/Controllers/Analysis/AchievementController.cs
  25. 13 13
      TEAMModelOS/Controllers/Analysis/AnalysisController.cs
  26. 11 11
      TEAMModelOS/Controllers/Client/HiScanController.cs
  27. 36 35
      TEAMModelOS/Controllers/Client/HiTeachController.cs
  28. 17 16
      TEAMModelOS/Controllers/Common/CommonController.cs
  29. 92 92
      TEAMModelOS/Controllers/Common/ExamController.cs
  30. 1 2
      TEAMModelOS/Controllers/Common/HomeworkController.cs
  31. 14 14
      TEAMModelOS/Controllers/Common/LearnController.cs
  32. 9 10
      TEAMModelOS/Controllers/Common/SurveyController.cs
  33. 8 9
      TEAMModelOS/Controllers/Common/VoteController.cs
  34. 13 13
      TEAMModelOS/Controllers/Core/BlobController.cs
  35. 0 2
      TEAMModelOS/Controllers/Core/ImportController.cs
  36. 8 8
      TEAMModelOS/Controllers/Core/OpenApiController.cs
  37. 30 29
      TEAMModelOS/Controllers/Item/ItemController.cs
  38. 4 4
      TEAMModelOS/Controllers/Knowledge/KnowledgesController.cs
  39. 13 13
      TEAMModelOS/Controllers/Paper/PaperController.cs
  40. 10 10
      TEAMModelOS/Controllers/Paper/SheetConfigController.cs
  41. 31 30
      TEAMModelOS/Controllers/School/ClassController.cs
  42. 6 7
      TEAMModelOS/Controllers/School/CorrectController.cs
  43. 78 78
      TEAMModelOS/Controllers/School/CourseController.cs
  44. 7 7
      TEAMModelOS/Controllers/School/RoomController.cs
  45. 17 17
      TEAMModelOS/Controllers/School/SchoolController.cs
  46. 23 22
      TEAMModelOS/Controllers/School/SchoolTeacherController.cs
  47. 4 4
      TEAMModelOS/Controllers/School/StudentCommonController.cs
  48. 33 33
      TEAMModelOS/Controllers/School/StudentController.cs
  49. 5 4
      TEAMModelOS/Controllers/School/TmdUserController.cs
  50. 6 6
      TEAMModelOS/Controllers/Syllabus/FavoriteController.cs
  51. 24 24
      TEAMModelOS/Controllers/Syllabus/ShareController.cs
  52. 23 22
      TEAMModelOS/Controllers/Syllabus/SyllabusController.cs
  53. 20 19
      TEAMModelOS/Controllers/Syllabus/VolumeController.cs
  54. 12 11
      TEAMModelOS/Controllers/Teacher/CommentController.cs
  55. 28 28
      TEAMModelOS/Controllers/Teacher/InitController.cs
  56. 16 14
      TEAMModelOS/Controllers/XTest/DataMigrationController.cs
  57. 20 20
      TEAMModelOS/Controllers/XTest/FixDataController.cs
  58. 11 11
      TEAMModelOS/Controllers/XTest/TestController.cs
  59. 1 0
      TEAMModelOS/Services/Analysis/AchievementService.cs
  60. 17 17
      TEAMModelOS/Services/Common/ActivityStudentService.cs
  61. 1 1
      TEAMModelOS/Services/Common/SheetService.cs
  62. 1 1
      TEAMModelOS/TEAMModelOS.csproj

+ 8 - 7
TEAMModelFunction/ActivityHttpTrigger.cs

@@ -18,6 +18,7 @@ using TEAMModelOS.SDK.Models.Cosmos.Common;
 using System.Linq;
 using TEAMModelOS.Services.Common;
 using TEAMModelOS.SDK.Models.Service;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -52,12 +53,12 @@ namespace TEAMModelFunction
             List<Course> courses = new List<Course>();
             var client = _azureCosmos.GetCosmosClient();
             var query = $"select  *  from c ";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(queryText: query,
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: query,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Course-{originCode}") }))
             {
                 courses.Add(item);
             }
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Course>(queryText: query,
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: query,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Course-{originCode}") }))
             {
                 courses.Add(item);
@@ -86,7 +87,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stuCourse, new PartitionKey(stuCourse.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stuCourse, new PartitionKey(stuCourse.code));
                             }
                             foreach (var addTmd in tmdids)
                             {
@@ -102,7 +103,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(tmdCourse, new PartitionKey(tmdCourse.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(tmdCourse, new PartitionKey(tmdCourse.code));
                             }
                         }
                     }
@@ -127,7 +128,7 @@ namespace TEAMModelFunction
             var query = $"select  *  from c ";
             foreach (string data in datas) {
                 List<ExamInfo> exams = new List<ExamInfo>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                     queryText: query,  requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{data}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -232,7 +233,7 @@ namespace TEAMModelFunction
             foreach (string data in datas)
             {
                 List<Vote> votes = new List<Vote>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                     queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{data}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -333,7 +334,7 @@ namespace TEAMModelFunction
             foreach (string data in datas)
             {
                 List<Survey> surveys = new List<Survey>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                     queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{data}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);

+ 29 - 28
TEAMModelFunction/CourseServiceBus.cs

@@ -10,6 +10,7 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -48,11 +49,11 @@ namespace TEAMModelFunction
                     foreach (var stu in addStudentsCls) {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
                             if (!stuCourse.Value.classId.Contains(cls)) {
                                 stuCourse.Value.classId.Add(cls);
                             }
-                            await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
                         }
                         catch (CosmosException ex)
                         {
@@ -71,7 +72,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(course, new PartitionKey(course.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
                             }
                         }
                     }
@@ -79,12 +80,12 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             if (!stuCourse.Value.classId.Contains(cls))
                             {
                                 stuCourse.Value.classId.Add(cls);
                             }
-                            await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                         }
                         catch (CosmosException ex)
                         {
@@ -103,7 +104,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
                             }
                         }
                     }
@@ -116,11 +117,11 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
                             if (!stuCourse.Value.stulist.Contains(list))
                             {
                                 stuCourse.Value.stulist.Add(list);
-                                await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
                             }
                         }
                         catch (CosmosException ex)
@@ -140,7 +141,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(course, new PartitionKey(course.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
                             }
                         }
                     }
@@ -148,11 +149,11 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             if (!stuCourse.Value.stulist.Contains(list))
                             {
                                 stuCourse.Value.stulist.Add(list);
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
                             
                         }
@@ -173,7 +174,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
                             }
                         }
                     }
@@ -185,7 +186,7 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
                            
                             if (stuCourse.Value.classId.Contains(delCls))
                             {
@@ -195,10 +196,10 @@ namespace TEAMModelFunction
                             if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
                             {
                                 //当两个列表都不存在时则直接删除
-                                await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuCourse>( courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>( courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
                             }
                             else {
-                                await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
                             }
                            
                         }
@@ -211,7 +212,7 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
 
                             if (stuCourse.Value.classId.Contains(delCls))
                             {
@@ -221,11 +222,11 @@ namespace TEAMModelFunction
                             if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
                             {
                                 //当两个列表都不存在时则直接删除
-                                await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
                             else
                             {
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
 
                         }
@@ -242,7 +243,7 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
 
                             if (stuCourse.Value.stulist.Contains(delList))
                             {
@@ -252,11 +253,11 @@ namespace TEAMModelFunction
                             if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
                             {
                                 //当两个列表都不存在时则直接删除
-                                await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
                             }
                             else
                             {
-                                await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
                             }
 
                         }
@@ -269,7 +270,7 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
 
                             if (stuCourse.Value.stulist.Contains(delList))
                             {
@@ -279,11 +280,11 @@ namespace TEAMModelFunction
                             if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
                             {
                                 //当两个列表都不存在时则直接删除
-                                await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
                             else
                             {
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
 
                         }
@@ -311,7 +312,7 @@ namespace TEAMModelFunction
                 //        creatorId = courseChange.creatorId,
                 //        pk = "StuCourse"
                 //    };
-                //    await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(course, new PartitionKey(course.code));
+                //    await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(course, new PartitionKey(course.code));
                 //}
                 //foreach (var addTmd in addTmdids)
                 //{
@@ -326,15 +327,15 @@ namespace TEAMModelFunction
                 //        creatorId = courseChange.creatorId,
                 //        pk = "StuCourse"
                 //    };
-                //    await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(course, new PartitionKey(course.code));
+                //    await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(course, new PartitionKey(course.code));
                 //}
                 //foreach (var delStu in delStudents)
                 //{
-                //    await client.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{courseChange.school}-{delStu.id}"));
+                //    await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{courseChange.school}-{delStu.id}"));
                 //}
                 //foreach (var delTmd in delTmdids)
                 //{
-                //    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{delTmd}"));
+                //    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{delTmd}"));
                 //}
             }
             catch (Exception ex)

+ 8 - 8
TEAMModelFunction/MonitorServicesBus.cs

@@ -45,9 +45,9 @@ namespace TEAMModelFunction
                 json.RootElement.TryGetProperty("code", out JsonElement code);
                 //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
                 var client = _azureCosmos.GetCosmosClient();
-                ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
+                ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
                 exam.progress = progress.ToString();
-                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{code}"));
             }
             catch (Exception ex)
             {
@@ -65,9 +65,9 @@ namespace TEAMModelFunction
                 jsonMsg.RootElement.TryGetProperty("progress", out JsonElement progress);
                 jsonMsg.RootElement.TryGetProperty("code", out JsonElement code);
                 var client = _azureCosmos.GetCosmosClient();
-                Vote vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(id.ToString(), new PartitionKey($"{code}"));
+                Vote vote = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Vote>(id.ToString(), new PartitionKey($"{code}"));
                 vote.progress = progress.ToString();
-                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(vote, id.ToString(), new PartitionKey($"{code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(vote, id.ToString(), new PartitionKey($"{code}"));
             }
             catch (Exception ex)
             {
@@ -85,9 +85,9 @@ namespace TEAMModelFunction
                 jsonMsg.RootElement.TryGetProperty("progress", out JsonElement progress);
                 jsonMsg.RootElement.TryGetProperty("code", out JsonElement code);
                 var client = _azureCosmos.GetCosmosClient();
-                Correct correct = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Correct>(id.ToString(), new PartitionKey($"{code}"));
+                Correct correct = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Correct>(id.ToString(), new PartitionKey($"{code}"));
                 correct.progress = progress.ToString();
-                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(correct, id.ToString(), new PartitionKey($"{code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(correct, id.ToString(), new PartitionKey($"{code}"));
             }
             catch (Exception ex)
             {
@@ -106,9 +106,9 @@ namespace TEAMModelFunction
                 jsonMsg.RootElement.TryGetProperty("code", out JsonElement code);
                 //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
                 var client = _azureCosmos.GetCosmosClient();
-                Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(id.ToString(), new PartitionKey($"{code}"));
+                Survey survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(id.ToString(), new PartitionKey($"{code}"));
                 survey.progress = progress.ToString();
-                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(survey, id.ToString(), new PartitionKey($"{code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(survey, id.ToString(), new PartitionKey($"{code}"));
             }
             catch (Exception ex)
             {

+ 9 - 8
TEAMModelFunction/TriggerCorrect.cs

@@ -12,6 +12,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Table;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -37,7 +38,7 @@ namespace TEAMModelFunction
                 return;
             }
             await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}阅卷配置【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在执行", GroupNames.成都开发測試群組);
-            Correct correct = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Correct>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+            Correct correct = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Correct>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
             List<ChangeRecord> correctRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", correct.progress } });
             if (correct != null)
             {
@@ -109,7 +110,7 @@ namespace TEAMModelFunction
                                             type = 1,
                                             createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                         };
-                                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
                                     }
                                 }
 
@@ -148,7 +149,7 @@ namespace TEAMModelFunction
                                             type = 2,
                                             createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                         };
-                                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
                                     }
 
 
@@ -189,7 +190,7 @@ namespace TEAMModelFunction
                                             type = 3,
                                             createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                         };
-                                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
                                     }
 
 
@@ -203,7 +204,7 @@ namespace TEAMModelFunction
                                 string subjectId = sub.id;
                                 //生成临时作答数据存放到redis
                                 var redisClient = _azureRedis.GetRedisClient(8);
-                                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(eid, new Azure.Cosmos.PartitionKey(ecode));
+                                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(eid, new Azure.Cosmos.PartitionKey(ecode));
                                 List<ExamClassResult> classResults = new List<ExamClassResult>();
                                 //获取原题配分
                                 int paperIndex = 0;
@@ -223,7 +224,7 @@ namespace TEAMModelFunction
                                 if (info.scope.Equals("school"))
                                 {
 
-                                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<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}") }))
                                     {
@@ -232,7 +233,7 @@ namespace TEAMModelFunction
                                 }
                                 else
                                 {
-                                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<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}") }))
                                     {
@@ -289,7 +290,7 @@ namespace TEAMModelFunction
                                                 model = sub.model
 
                                             };
-                                            tasks.Add(client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Scoring>(sc, new Azure.Cosmos.PartitionKey(sc.code)));
+                                            tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Scoring>(sc, new Azure.Cosmos.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()));
                                     }

+ 21 - 20
TEAMModelFunction/TriggerExam.cs

@@ -14,6 +14,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Service;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -22,14 +23,14 @@ namespace TEAMModelFunction
         public static async void Trigger(AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
             CosmosClient client, Document input, string code, long stime, long etime, string school)
         {
-            ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(input.Id, new Azure.Cosmos.PartitionKey($"{code}"));
+            ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(input.Id, new Azure.Cosmos.PartitionKey($"{code}"));
             List<ExamClassResult> examClassResults = new List<ExamClassResult>();
             List<ExamSubject> examSubjects = new List<ExamSubject>();
             try
             {
                 if (info.scope.Equals("teacher", StringComparison.OrdinalIgnoreCase) || info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
                 {
-                    await foreach (var item in client.GetContainer("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").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -43,7 +44,7 @@ namespace TEAMModelFunction
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{school}") }))
+                    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-{school}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -64,7 +65,7 @@ namespace TEAMModelFunction
                 {
                     sub.Add(subject.id);
                 }
-                //ChangeRecord record = await client.GetContainer("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 Azure.Cosmos.PartitionKey($"{info.progress}"));
                 switch (info.progress)
                 {
                     case "pending":
@@ -76,7 +77,7 @@ namespace TEAMModelFunction
                             long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
                             records[0].sequenceNumber = start;
                             await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
-                            //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
+                            //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
                         }
                         else
                         {
@@ -89,7 +90,7 @@ namespace TEAMModelFunction
                                 msgId = message.MessageId
                             };
                             await _azureStorage.Save<ChangeRecord>(changeRecord);
-                            //await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
+                            //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
                         }
                         break;
                     case "going":
@@ -214,13 +215,13 @@ namespace TEAMModelFunction
                                             marks.Add(new List<Details>());
                                             ansPoint.Add(-1);
                                         }
-                                        var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
+                                        var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
                                         if (sresponse.Status == 200)
                                         {
 
                                             using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
                                             Class classroom = json.ToObject<Class>();
-                                            School sc = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
+                                            School sc = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
                                             foreach (Period period in sc.period)
                                             {
                                                 if (period.id.Equals(classroom.periodId))
@@ -243,7 +244,7 @@ namespace TEAMModelFunction
                                             result.info.name = classroom.name;
                                             //result.gradeId = classroom.year.ToString();
                                             //处理班级人数
-                                            await foreach (var item in client.GetContainer("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").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{info.school}") }))
                                             {
                                                 using var json_stu = await JsonDocument.ParseAsync(item.ContentStream);
                                                 if (json_stu.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -259,7 +260,7 @@ namespace TEAMModelFunction
                                         }
                                         if (info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
                                         {
-                                            var stuResponse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList"));
+                                            var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList"));
                                             if (stuResponse.Status == 200)
                                             {
                                                 using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
@@ -287,7 +288,7 @@ namespace TEAMModelFunction
                                         }
                                         else
                                         {
-                                            var stuResponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList-{info.school}"));
+                                            var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList-{info.school}"));
                                             if (stuResponse.Status == 200)
                                             {
                                                 using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
@@ -317,7 +318,7 @@ namespace TEAMModelFunction
                                         //result.progress = info.progress;
                                         result.school = info.school;
                                         m++;
-                                        await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
+                                        await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
                                     }
                                 }
                                 // 发送信息通知
@@ -329,7 +330,7 @@ namespace TEAMModelFunction
                                     await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
                                     records[0].sequenceNumber = end;
                                     await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
-                                    //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
+                                    //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
                                 }
                                 else
                                 {
@@ -342,7 +343,7 @@ namespace TEAMModelFunction
                                         msgId = messageEnd.MessageId
                                     };
                                     await _azureStorage.Save<ChangeRecord>(changeRecord);
-                                    //await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
+                                    //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
                                 }
                             }
                             else
@@ -376,7 +377,7 @@ namespace TEAMModelFunction
 
                             //计算单次考试简易统计信息
                             List<ExamResult> examResults = new List<ExamResult>();
-                            await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(
+                            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}") }))
                             {
                                 examResults.Add(item);
@@ -415,7 +416,7 @@ namespace TEAMModelFunction
                                 classResult.standard = Math.Round(scount > 0 ? Math.Pow(sPowSum / scount, 0.5) : 0, 2);
                                 classResult.average = scount > 0 ? Math.Round(subScore / scount, 2) : 0;
                                 classResult.progress = true;
-                                tasks.Add(client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}")));
+                                tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}")));
                             }
                             await Task.WhenAll(tasks);
                             //记录某次考试所有学生得分总分
@@ -477,7 +478,7 @@ namespace TEAMModelFunction
                             {
                                 info.sRate = NewsRate;
                                 info.average = NewsRateScore;
-                                await client.GetContainer("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 Azure.Cosmos.PartitionKey(info.code));
                             }
                         }
                         catch (Exception e)
@@ -666,7 +667,7 @@ namespace TEAMModelFunction
                             classResult.pc = pc;
                             classResult.krate = persent;
                         }
-                        //await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
+                        //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
                     }
                 }
 
@@ -766,7 +767,7 @@ namespace TEAMModelFunction
                         classResult.fpc = pc;
                         classResult.frate = persent;
                     }
-                    //await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
+                    //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
                 }
             }
             catch (Exception ex)
@@ -941,7 +942,7 @@ namespace TEAMModelFunction
             result.name = info.name;
             result.time = info.startTime;
 
-            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").UpsertItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}"));
+            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}"));
 
         }       
     }

+ 5 - 4
TEAMModelFunction/TriggerSurvey.cs

@@ -18,6 +18,7 @@ using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.Common.Inner;
 using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
 using TEAMModelOS.SDK.Models.Service;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -44,7 +45,7 @@ namespace TEAMModelFunction
                     adcode = $"Activity-{tdata.creatorId}";
                     blobcntr = tdata.creatorId;
                 }
-                Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                Survey survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
                 List<ChangeRecord> changeRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", survey.progress } });
                 if (survey != null)
                 {
@@ -274,7 +275,7 @@ namespace TEAMModelFunction
                             if (string.IsNullOrEmpty(survey.recordUrl))
                             {
                                 survey.recordUrl = $"/survey/{survey.id}/record.json";
-                                await client.GetContainer("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 Azure.Cosmos.PartitionKey(survey.code));
                             }
                             else
                             {
@@ -287,11 +288,11 @@ namespace TEAMModelFunction
                             //data.progress = "finish";
                             //if (survey.scope .Equals("school"))
                             //{
-                            //    await client.GetContainer("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 Azure.Cosmos.PartitionKey(data.code));
                             //}
                             //else if (survey.scope .Equals("private"))
                             //{
-                            //    await client.GetContainer("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 Azure.Cosmos.PartitionKey(data.code));
                             //}
 
                             break;

+ 3 - 2
TEAMModelFunction/TriggerVote.cs

@@ -15,6 +15,7 @@ using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.Common.Inner;
 using TEAMModelOS.SDK.Models.Service;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -43,7 +44,7 @@ namespace TEAMModelFunction
                     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>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+                Vote vote = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Vote>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
                 List<ChangeRecord> voteRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", vote.progress } });
                 if (vote != null)
                 {
@@ -225,7 +226,7 @@ namespace TEAMModelFunction
                             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(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Vote>(vote, vote.id, new Azure.Cosmos.PartitionKey(vote.code));
                             }
                             else
                             {

+ 3 - 2
TEAMModelOS.SDK/Context/Constant/ConstField.cs

@@ -2,11 +2,12 @@ using System;
 using System.Collections.Generic;
 using System.Text;
 
-namespace TEAMModelOS.SDK
+namespace TEAMModelOS.SDK.DI
 {
-    public class ConstField
+    public class Constant
     {
         public static readonly List<string> BlobPrefix = new List<string> { "exam", "vote", "survey", "item", "paper", "syllabus", "records", "doc", "image", "res", "video", "audio", "other", "thum", "train", "temp", "jyzx" };
         public static readonly List<string> ContentPrefix = new List<string> { "doc", "image", "res", "video", "audio", "other"};
+        public static string TEAMModelOS = "TEAMModelOS";
     }
 }

+ 1 - 1
TEAMModelOS.SDK/Context/Constant/ContentTypeDict.cs

@@ -2,7 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Text;
 
-namespace TEAMModelOS.SDK.Context.Constant
+namespace TEAMModelOS.SDK
 {
     public static class ContentTypeDict
     {

+ 1 - 1
TEAMModelOS.SDK/Context/Constant/FileType.cs

@@ -1,4 +1,4 @@
-namespace TEAMModelOS.SDK.Context.Constant.Common
+namespace TEAMModelOS.SDK
 {
 	public class FileType
 	{

+ 2 - 2
TEAMModelOS.SDK/Context/Constant/FileTypeMap.cs

@@ -1,7 +1,7 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
 
 
-namespace TEAMModelOS.SDK.Context.Constant.Common
+namespace TEAMModelOS.SDK
 {
 	public class FileTypeMap
 	{

+ 2 - 2
TEAMModelOS.SDK/Context/Constant/GetFileType.cs

@@ -1,8 +1,8 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Text;
 
-namespace TEAMModelOS.SDK.Context.Constant.Common
+namespace TEAMModelOS.SDK
 {
 	public class GetFileType
 	{

+ 1 - 1
TEAMModelOS.SDK/Context/Constant/ResponseCode.cs

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

+ 1 - 0
TEAMModelOS.SDK/DI/AzureCosmos/Inner/SQLHelper.cs

@@ -1,3 +1,4 @@
+using HTEXLib.COMM.Helpers;
 using Newtonsoft.Json.Linq;
 using System;
 using System.Collections;

+ 1 - 1
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageBlobExtensions.cs

@@ -4,7 +4,6 @@ using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Models;
 using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
 using TEAMModelOS.SDK.Module.AzureBlob.Container;
-using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using System;
 using System.IO;
@@ -16,6 +15,7 @@ using Azure.Core;
 using Azure;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Extension;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.SDK.DI
 {

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

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
 using System.Linq;
 using TEAMModelOS.SDK;
 using System.Reflection;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.SDK.DI
 {

+ 0 - 28
TEAMModelOS.SDK/Helper/Common/CollectionHelper/CollectionHelper.cs

@@ -1,28 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-using System.Text;
-
-namespace TEAMModelOS.SDK
-{
-    public static class CollectionHelper
-    {
-        /// <summary>
-        /// 判断集合是否不为空
-        /// </summary>
-        /// <param name="collection"></param>
-        /// <returns></returns>
-        public static bool IsNotEmpty(this ICollection collection)
-        {
-            if (collection != null && collection.Count > 0)
-            {
-                return true;
-            }
-            else
-            {
-                return false;
-            }
-        }
-    }
-}

+ 2 - 1
TEAMModelOS.SDK/Models/Cosmos/Student/TmdUser.cs

@@ -1,8 +1,9 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using TEAMModelOS.SDK.Models;
 
-namespace TEAMModelOS.SDK.Models
+namespace TEAMModelOS.SDK
 {
     public class TmdUser : CosmosEntity
     {

+ 8 - 7
TEAMModelOS.SDK/Models/Service/FixDataService.cs

@@ -10,6 +10,7 @@ using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.SDK.Models.Service
 {
@@ -29,7 +30,7 @@ namespace TEAMModelOS.SDK.Models.Service
             var dict = data.GetProperty("dict").ToObject<Dictionary<string, object>>();
             string queryText = $"SELECT VALUE c FROM c WHERE c.id IN ({string.Join(",", ids.Select(o => $"'{o}'"))})";
             List<Student> students = new List<Student>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Student")
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student")
                             .GetItemQueryIterator<Student>(
                                 queryText: queryText,
                                 requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{code}") })) {
@@ -52,7 +53,7 @@ namespace TEAMModelOS.SDK.Models.Service
                         default:
                             break;
                     }
-                  await  client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<Student>(item, item.id, new PartitionKey(item.code));
+                  await  client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<Student>(item, item.id, new PartitionKey(item.code));
                     students.Add(item);
                 }
             }
@@ -78,7 +79,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 }
             }
             List<School> schools = new List<School>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") })) {
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") })) {
                 schools.Add(item);
             }
             foreach (var school in schools) {
@@ -94,11 +95,11 @@ namespace TEAMModelOS.SDK.Models.Service
                 tb = "School";
             }
             List<string> ids = new List<string>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", tb).GetItemQueryIterator<Bloblog>(queryDefinition: new QueryDefinition("select c.id from c "), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, tb).GetItemQueryIterator<Bloblog>(queryDefinition: new QueryDefinition("select c.id from c "), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
             {
                 ids.Add(item.id);
             }
-            await client.GetContainer("TEAMModelOS", tb).DeleteItemsStreamAsync(ids, $"Bloblog-{name}");
+            await client.GetContainer(Constant.TEAMModelOS, tb).DeleteItemsStreamAsync(ids, $"Bloblog-{name}");
             long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
             foreach (var prefix in prefixs)
             {
@@ -122,7 +123,7 @@ namespace TEAMModelOS.SDK.Models.Service
                                 url += ".HTEX";
                             }
                             Bloblog bloblog = new Bloblog { id = Guid.NewGuid().ToString(), code = $"Bloblog-{name}", pk = "Bloblog", time = now, url = url, size = urlsSize != null && urlsSize.HasValue ? urlsSize.Value : 0, type = prefix };
-                            await client.GetContainer("TEAMModelOS", tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code));
+                            await client.GetContainer(Constant.TEAMModelOS, tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code));
                         }
                     }
                 }
@@ -135,7 +136,7 @@ namespace TEAMModelOS.SDK.Models.Service
                         {
                             var urlsSize = await ContainerClient.GetBlobsSize(item);
                             Bloblog bloblog = new Bloblog { id = Guid.NewGuid().ToString(), code = $"Bloblog-{name}", pk = "Bloblog", time = now, url = item, size = urlsSize != null && urlsSize.HasValue ? urlsSize.Value : 0, type = prefix };
-                            await client.GetContainer("TEAMModelOS", tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code));
+                            await client.GetContainer(Constant.TEAMModelOS, tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code));
                         }
                     }
                 }

+ 15 - 14
TEAMModelOS.SDK/Models/Service/StuListService.cs

@@ -11,6 +11,7 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Service;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -26,14 +27,14 @@ namespace TEAMModelFunction
                     //$"and A1 in('{stuListChange.listid}') ";
                 List<MQActivity> datas = new List<MQActivity>();
                 if (stuListChange.scope.Equals("school", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(stuListChange.school)) {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<MQActivity>(queryText: query,
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<MQActivity>(queryText: query,
                        requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{type}-{stuListChange.school}") }))
                     {
                         datas.Add(item);
                     }
                     ///还要处理该学校每个老师发布的班级的
                     List<SchoolTeacher> teachers = new List<SchoolTeacher>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolTeacher>(queryText: $"SELECT c.id, c.name FROM c",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>(queryText: $"SELECT c.id, c.name FROM c",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{stuListChange.school}") }))
                     {
                         teachers.Add(item);
@@ -43,7 +44,7 @@ namespace TEAMModelFunction
                             $" where c.school='{stuListChange.school}'   and   c.pk='{type}'" +
                             $" and (( array_contains(c.classes,'{stuListChange.listid}')) or ( array_contains(c.teachclasses,'{stuListChange.listid}')))";
                       //  $" and A1 in('{stuListChange.listid}') ";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<MQActivity>(queryText: queryTech,
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<MQActivity>(queryText: queryTech,
                             requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{type}-{techer.id}") }))
                         {
                             datas.Add(item);
@@ -52,7 +53,7 @@ namespace TEAMModelFunction
                 }
                 if (stuListChange.scope.Equals("private", StringComparison.OrdinalIgnoreCase)&&!string.IsNullOrEmpty(stuListChange.creatorId))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<MQActivity>(queryText: query,
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<MQActivity>(queryText: query,
                         requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{type}-{stuListChange.creatorId}") }))
                     {
                         datas.Add(item);
@@ -91,7 +92,7 @@ namespace TEAMModelFunction
                             classIds = classes
                         };
                         await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixActivity\n名单发生变更 新建活动中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }//tmd新加入的
                     foreach (string tmdid in stuListChange.tmdjoin)
                     {
@@ -116,14 +117,14 @@ namespace TEAMModelFunction
                             classIds = classes
                         }; 
                         await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixActivity\n名单发生变更 新建活动中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }
                     foreach (Students students in stuListChange.stuleave)
                     {
                         try
                         {
 
-                            await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{students.code.Replace("Base-", "")}-{students.id}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{students.code.Replace("Base-", "")}-{students.id}"));
                         }
                         catch (CosmosException ex)
                         {
@@ -135,7 +136,7 @@ namespace TEAMModelFunction
                         try
                         {
 
-                            await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{tmdid}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{tmdid}"));
                         }
                         catch(CosmosException ex )
                         {
@@ -156,7 +157,7 @@ namespace TEAMModelFunction
             List<Course> courses = new List<Course>();
             if (stuListChange.scope.Equals("school") && !string.IsNullOrEmpty(stuListChange.school))
             {
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(queryText: query,
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: query,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Course-{stuListChange.school}") }))
                 {
                     courses.Add(item);
@@ -164,7 +165,7 @@ namespace TEAMModelFunction
             }
             if (stuListChange.scope.Equals("private") && !string.IsNullOrEmpty(stuListChange.creatorId))
             {
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Course>(queryText: query,
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: query,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Course-{stuListChange.creatorId}") }))
                 {
                     courses.Add(item);
@@ -191,7 +192,7 @@ namespace TEAMModelFunction
                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                     };
                     await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                    await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                 }
                 //tmd新加入的
                 foreach (string tmdid in stuListChange.tmdjoin)
@@ -210,16 +211,16 @@ namespace TEAMModelFunction
                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                     };
                     await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                    await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                 }
                 //移除名单的。 在点击相关的课程,再去二次校验是否存在,不存在则再去删除。
                 foreach (var delStu in stuListChange.stuleave)
                 {
-                    await client.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync(course.id, new PartitionKey($"Course-{delStu.code.Replace("Base-", "")}-{delStu.id}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemStreamAsync(course.id, new PartitionKey($"StuCourse-{delStu.code.Replace("Base-", "")}-{delStu.id}"));
                 }
                 foreach (var delTmd in stuListChange.tmdhleave)
                 {
-                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(course.id, new PartitionKey($"Course-{delTmd}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemStreamAsync(course.id, new PartitionKey($"StuCourse-{delTmd}"));
                 }
             }
         }

+ 52 - 0
TEAMModelOS.SDK/Models/Service/TmdUserService.cs

@@ -0,0 +1,52 @@
+using Azure.Cosmos;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Models;
+
+namespace TEAMModelOS.SDK
+{
+    public class TmdUserService
+    {
+        public async Task<TmdUser> JoinSchool(CosmosClient client, string tmdid,string picture,string name , string schoolId, string schoolName) {
+            TmdUser tmdUser = null;
+            try {
+                tmdUser= await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<TmdUser>(tmdid, partitionKey: new PartitionKey("Base"));
+                tmdUser.picture = string.IsNullOrEmpty(picture) ? picture:tmdUser.picture;
+                tmdUser.name = string.IsNullOrEmpty(name) ? name : tmdUser.name;
+                var school= tmdUser.schools.Find(x => x.schoolId.Equals(schoolId));
+                if (school == null)
+                {
+
+                    tmdUser.schools.Add(new TmdUser.School { schoolId = schoolId, name = schoolName, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<TmdUser>(tmdUser, tmdid, partitionKey: new PartitionKey("Base"));
+                }
+                else {
+                    school.name = schoolName;
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<TmdUser>(tmdUser, tmdid, partitionKey: new PartitionKey("Base"));
+                }
+            } catch (CosmosException ex) {
+                if (ex.Status == 404) {
+                    tmdUser = new TmdUser()
+                    {
+                        id = tmdid,
+                        code = "Base",
+                        schools = new List<TmdUser.School>() { 
+                            new TmdUser.School { 
+                                schoolId = schoolId, status = "join", name = schoolName, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
+                            } 
+                        },
+                        defaultSchool=schoolId,
+                        picture=picture,
+                        name=name,
+                        ttl=-1
+                    };
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(tmdUser, partitionKey: new PartitionKey(tmdUser.code));
+                }
+            }
+            return tmdUser;
+        }
+    }
+}

+ 20 - 19
TEAMModelOS.SDK/Models/Service/TriggerStuActivity.cs

@@ -13,6 +13,7 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Service;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -23,7 +24,7 @@ namespace TEAMModelFunction
             MQActivity activity = null;
             try
             {
-                var aactivity = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id, new Azure.Cosmos.PartitionKey(code));
+                var aactivity = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id, new Azure.Cosmos.PartitionKey(code));
                 using var da = await JsonDocument.ParseAsync(aactivity.ContentStream);
                 activity = da.ToObject<MQActivity>();
             }
@@ -58,7 +59,7 @@ namespace TEAMModelFunction
                             taskStatus = -1,
                             classIds = classes
                         };
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }
                 }
                 if (students.IsNotEmpty())
@@ -85,7 +86,7 @@ namespace TEAMModelFunction
                             taskStatus = -1,
                             classIds = classes
                         };
-                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }
                 }
             }
@@ -97,14 +98,14 @@ namespace TEAMModelFunction
                 {
                     foreach (var x in stuActivities)
                     {
-                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(x, new PartitionKey(x.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(x, new PartitionKey(x.code));
                     }
                 }
                 if (tmdActivities.IsNotEmpty())
                 {
                     foreach (var x in tmdActivities)
                     {
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(x, new PartitionKey(x.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(x, new PartitionKey(x.code));
                     }
                 }
             } catch (Exception ex) {
@@ -130,13 +131,13 @@ namespace TEAMModelFunction
                     string sql = string.Join(" , ", sqlList);
                     if (!string.IsNullOrEmpty(school))
                     {
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name ,c.periodId,c.year from c where c.id in ({sql})",
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name ,c.periodId,c.year from c where c.id in ({sql})",
                            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
                         {
 
                             classInfos.Add(item);
                         }
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name from c where c.id in ({sql})",
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name from c where c.id in ({sql})",
                           requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
                         {
                             //item.from = "SchStuList";
@@ -144,7 +145,7 @@ namespace TEAMModelFunction
                         }
                     }
                     List<StuList> tchLists = new List<StuList>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name from c where c.id in ({sql})",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name from c where c.id in ({sql})",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
                     {
                        // item.from = "TchStuList";
@@ -179,19 +180,19 @@ namespace TEAMModelFunction
                 List<Student> students = new List<Student>();
                 if (!string.IsNullOrEmpty(school))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
                     {
                         schList.Add(item);
                     }
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
                     {
                         students.Add(item);
                     }
                 }
                 List<StuList> tchLists = new List<StuList>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
                 {
                     tchLists.Add(item);
@@ -229,7 +230,7 @@ namespace TEAMModelFunction
                     tmdids.ForEach(x => { inids.Add($"'{x}'"); });
                     var insql = string.Join(",", inids);
                     var queryslt = $"SELECT  value(c) FROM c where c.id in ({insql})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                     {
                         infos.Add(item);
                     }
@@ -244,7 +245,7 @@ namespace TEAMModelFunction
                         PartitionKey partitionKey = new PartitionKey($"Base-{gp.key.Replace("Base-", "")}");
                         var insqlstu = string.Join(",", inidstus);
                         var querystu = $"SELECT  c.id,c.code,c.name,c.picture,c.classId,c.year,c.schoolId FROM c where c.id in ({insqlstu})";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey= partitionKey }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey= partitionKey }))
                         {
                             stuInfos.Add(item);
                         }
@@ -346,19 +347,19 @@ namespace TEAMModelFunction
                 List<StuList> schList = new List<StuList>();
                 List<Student> students = new List<Student>();
                 if (!string.IsNullOrEmpty(school)) {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
                     {
                         schList.Add(item);
                     }
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
                     {
                         students.Add(item);
                     }
                 }
                 List<StuList> tchLists = new List<StuList>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
                 {
                     tchLists.Add(item);
@@ -393,7 +394,7 @@ namespace TEAMModelFunction
                     tmdids.ForEach(x => { inids.Add($"'{x}'"); });
                     var insql = string.Join(",", inids);
                     var queryslt = $"SELECT  value(c) FROM c where c.id in ({insql})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                     {
                         infos.Add(item);
                     }
@@ -403,7 +404,7 @@ namespace TEAMModelFunction
                     List<string> inidstus = new List<string>();
                     foreach (Students stu in studentss) {
                         var querystu = $"SELECT  c.id,c.code,c.name,c.picture,c.classId,c.year,c.schoolId FROM c where c.id = '{stu.id}'";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{stu.code}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{stu.code}") }))
                         {
                             stuInfos.Add(item);
                         }
@@ -411,7 +412,7 @@ namespace TEAMModelFunction
                     /*studentss.Select(x => x.id).ToList().ForEach(x => { inidstus.Add($"'{x}'"); });
                     var insqlstu = string.Join(",", inidstus);
                     var querystu = $"SELECT  c.id,c.code,c.name,c.picture,c.classId,c.year,c.schoolId FROM c where c.id in ({insqlstu})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
                     {
                         stuInfos.Add(item);
                     }*/

+ 1 - 0
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -11,6 +11,7 @@
 
 
   <ItemGroup>
+    <PackageReference Include="HTEXLib" Version="5.2108.31" />
     <PackageReference Include="AspectCore.Extensions.Reflection" Version="2.2.0" />
     <PackageReference Include="Azure.Cosmos" Version="4.0.0-preview3" />
     <PackageReference Include="Azure.Identity" Version="1.4.0" />

+ 53 - 54
TEAMModelOS/Controllers/Analysis/AchievementController.cs

@@ -20,7 +20,6 @@ using Azure.Cosmos;
 using TEAMModelOS.Models.Dto;
 using System.Text;
 using Microsoft.AspNetCore.Http;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using HTEXLib.Translator;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 
@@ -1818,11 +1817,11 @@ namespace TEAMModelOS.Controllers.Analysis
         //    {
         //        var client = _azureCosmos.GetCosmosClient();
         //        //获取本次评测所有科目结算结果
-        //        ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
-        //        School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
+        //        ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
         //        List<ExamResult> examResults = new List<ExamResult>();
         //        var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
         //        {
         //            /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
         //            if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1837,7 +1836,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //        //获取本次评测所有班级作答结果
         //        List<ExamClassResult> examClassResults = new List<ExamClassResult>();
         //        var queryClass = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info from c where c.examId =  '{id}' and c.progress = true ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
         //        {
         //            examClassResults.Add(item);
         //            /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1882,7 +1881,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //            List<double> totalClass = new List<double>();
         //            ClassAnalysis classAnalysis = new ClassAnalysis();
         //            classAnalysis.classId = s;
-        //            var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(s, new PartitionKey($"Class-{code}"));
+        //            var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(s, new PartitionKey($"Class-{code}"));
         //            if (sresponse.Status == 200)
         //            {
         //                using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
@@ -1892,7 +1891,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //                int count = 0;
         //                //处理班级学生名单
         //                List<Student> students = new List<Student>();
-        //                await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<Student>(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{code}") }))
+        //                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{code}") }))
         //                {
         //                    students.Add(item);
         //                }
@@ -2543,11 +2542,11 @@ namespace TEAMModelOS.Controllers.Analysis
         //    {
         //        var client = _azureCosmos.GetCosmosClient();
         //        //获取本次评测所有科目结算结果
-        //        ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
-        //        School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
+        //        ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
         //        List<ExamResult> examResults = new List<ExamResult>();
         //        var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
         //        {
         //            /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
         //            if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -2562,7 +2561,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //        //获取本次评测所有班级作答结果
         //        List<ExamClassResult> examClassResults = new List<ExamClassResult>();
         //        var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
         //        {
         //            examClassResults.Add(item);
         //            /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -2630,7 +2629,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //                        classResult.sum[k] = classResult.studentScores[k].Sum();
         //                        k++;
         //                    }
-        //                    //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+        //                    //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
         //                    if (!classResult.progress)
         //                    {
         //                        bool flag = true;
@@ -2652,13 +2651,13 @@ namespace TEAMModelOS.Controllers.Analysis
 
         //                        }
         //                    }
-        //                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+        //                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
         //                }
 
         //            }
         //            m++;
         //        }
-        //        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
         //        return Ok(new { examClassResults });
         //    }
         //    catch (Exception e)
@@ -2678,18 +2677,18 @@ namespace TEAMModelOS.Controllers.Analysis
         //    {
         //        var client = _azureCosmos.GetCosmosClient();
         //        //获取本次评测所有科目结算结果
-        //        ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
-        //        School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
+        //        ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
         //        List<ExamResult> examResults = new List<ExamResult>();
         //        var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
         //        {
         //            examResults.Add(item);
         //        }
         //        //获取本次评测所有班级作答结果
         //        List<ExamClassResult> examClassResults = new List<ExamClassResult>();
         //        var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
         //        {
         //            examClassResults.Add(item);
         //        }
@@ -2741,12 +2740,12 @@ namespace TEAMModelOS.Controllers.Analysis
         //                    {
         //                        info.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
         //                    }
-        //                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+        //                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
         //                }
         //            }
         //            m++;
         //        }
-        //        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
         //        return Ok(new { examClassResults });
         //    }
         //    catch (Exception e)
@@ -2843,7 +2842,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //            });
         //            info.papers.Add(simple);
         //        });
-        //        await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(info, new PartitionKey("Exam-hbcn"));
+        //        await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(info, new PartitionKey("Exam-hbcn"));
         //        return Ok(new { info });
         //    }
         //    catch (Exception e)
@@ -2866,7 +2865,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //        //获取本次评测所有班级作答结果
         //        List<ExamClassResult> examClassResults = new List<ExamClassResult>();
         //        var queryClass = $"select value(c) from c where c.examId =  '{id}'";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ExamClassResult-hbcn") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ExamClassResult-hbcn") }))
         //        {
         //            examClassResults.Add(item);
 
@@ -2977,7 +2976,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //        foreach (ExamClassResult result in examClassResults)
         //        {
         //            result.progress = true;
-        //            await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
+        //            await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
         //        }
         //        return Ok(new { examClassResults });
         //    }
@@ -3366,11 +3365,11 @@ namespace TEAMModelOS.Controllers.Analysis
         //    {
         //        var client = _azureCosmos.GetCosmosClient();
         //        获取本次评测所有科目结算结果
-        //        ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
-        //        School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
+        //        ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
         //        List<ExamResult> examResults = new List<ExamResult>();
         //        var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
         //        {
         //            /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
         //            if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -3385,7 +3384,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //        获取本次评测所有班级作答结果
         //                List<ExamClassResult> examClassResults = new List<ExamClassResult>();
         //        var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
         //        {
         //            examClassResults.Add(item);
         //            /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -3453,7 +3452,7 @@ namespace TEAMModelOS.Controllers.Analysis
         //                        classResult.sum[k] = classResult.studentScores[k].Sum();
         //                        k++;
         //                    }
-        //                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+        //                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
         //                    if (!classResult.progress)
         //                    {
         //                        bool flag = true;
@@ -3475,13 +3474,13 @@ namespace TEAMModelOS.Controllers.Analysis
 
         //                        }
         //                    }
-        //                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+        //                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
         //                }
 
         //            }
         //            m++;
         //        }
-        //        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
         //        return Ok(new { examClassResults });
         //    }
         //    catch (Exception e)
@@ -3501,18 +3500,18 @@ namespace TEAMModelOS.Controllers.Analysis
         //    {
         //        var client = _azureCosmos.GetCosmosClient();
         //        获取本次评测所有科目结算结果
-        //        ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
-        //        School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
+        //        ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
         //        List<ExamResult> examResults = new List<ExamResult>();
         //        var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
         //        {
         //            examResults.Add(item);
         //        }
         //        获取本次评测所有班级作答结果
         //                List<ExamClassResult> examClassResults = new List<ExamClassResult>();
         //        var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId =  '{id}' ";
-        //        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+        //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
         //        {
         //            examClassResults.Add(item);
         //        }
@@ -3564,12 +3563,12 @@ namespace TEAMModelOS.Controllers.Analysis
         //                    {
         //                        info.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
         //                    }
-        //                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+        //                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
         //                }
         //            }
         //            m++;
         //        }
-        //        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
+        //        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
         //        return Ok(new { examClassResults });
         //    }
         //    catch (Exception e)
@@ -3612,7 +3611,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 info.type = examDtos.type;
                 info.scope = "school";
                 info.examType = examDtos.examType;
-                await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(info, new PartitionKey($"Exam-{code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(info, new PartitionKey($"Exam-{code}"));
                 return Ok(new { info });
             }
             catch (Exception e)
@@ -3644,7 +3643,7 @@ namespace TEAMModelOS.Controllers.Analysis
             try
             {
                 var client = _azureCosmos.GetCosmosClient();
-                var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(fileDto.examId, new PartitionKey($"Exam-{fileDto.code}"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(fileDto.examId, new PartitionKey($"Exam-{fileDto.code}"));
                 ExamInfo examInfo;
                 if (response.Status == 200)
                 {
@@ -3793,7 +3792,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 simple.multipleRule = fileDto.multipleRule;
 
                 examInfo.papers.Add(simple);
-                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examInfo, examInfo.id, new PartitionKey($"{examInfo.code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(examInfo, examInfo.id, new PartitionKey($"{examInfo.code}"));
                 await Task.WhenAll(tasks);
 
                 return Ok(new { code = 200 });
@@ -3821,12 +3820,12 @@ namespace TEAMModelOS.Controllers.Analysis
                 //获取本次评测所有班级作答结果
                 List<ExamClassResult> examClassResults = new List<ExamClassResult>();
                 var queryClass = $"select value(c) from c where c.examId =  '{id}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
                 {
                     examClassResults.Add(item);
 
                 }
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 if (info == null)
                 {
                     return Ok(new { code = 404, msg = "请先录入评测数据" });
@@ -4002,7 +4001,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 foreach (ExamClassResult result in examClassResults)
                 {
                     result.progress = true;
-                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
                 }
                 return Ok(new { examClassResults });
             }
@@ -4023,7 +4022,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 var client = _azureCosmos.GetCosmosClient();
                 List<object> info = new List<object>();
                 var query = $"select c.period,c.id,c.campuses from c where c.id = '{code}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -4054,7 +4053,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 var client = _azureCosmos.GetCosmosClient();
                 List<object> classInfo = new List<object>();
                 var query = $"select c.id,c.name from c where c.periodId = '{periodId}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -4084,9 +4083,9 @@ namespace TEAMModelOS.Controllers.Analysis
             {
                 var client = _azureCosmos.GetCosmosClient();
                 List<Class> classInfo = new List<Class>();
-                School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey("Base"));
+                School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey("Base"));
                 var query = $"select value(c) from c where c.periodId = '{periodId}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Class>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Class>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
                 {
                     classInfo.Add(item);
                 }
@@ -4195,7 +4194,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 var client = _azureCosmos.GetCosmosClient();
                 ExamInfo info = exam.ToObject<ExamInfo>();
                 info.progress = "going";
-                await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(info, new PartitionKey($"Exam-{code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(info, new PartitionKey($"Exam-{code}"));
                 return Ok(new { info });
             }
             catch (Exception e)
@@ -4221,13 +4220,13 @@ namespace TEAMModelOS.Controllers.Analysis
                 //获取本次评测所有班级作答结果
                 List<ExamClassResult> examClassResults = new();
                 var queryClass = $"select value(c) from c where c.examId =  '{id}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
                 {
                     examClassResults.Add(item);
                 }
                 try
                 {
-                    ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                    ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 }
                 catch (Exception)
                 {
@@ -4251,7 +4250,7 @@ namespace TEAMModelOS.Controllers.Analysis
                                     ex.ans = examClass.ans;
                                 }
                             }
-                            tasks.Add(client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(ex, ex.id, new PartitionKey($"{ex.code}")));
+                            tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(ex, ex.id, new PartitionKey($"{ex.code}")));
                         }
                     }
                 }                
@@ -4279,13 +4278,13 @@ namespace TEAMModelOS.Controllers.Analysis
                 List<StuList> stuTeacher = new List<StuList>();
                 var query = $"select value(c) from c where c.pk = 'StuList'";
 
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: query))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: query))
                 {
                     stuSchool.Add(item);
                 }
 
 
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: query))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: query))
                 {
                     stuTeacher.Add(item);
                 }
@@ -4296,7 +4295,7 @@ namespace TEAMModelOS.Controllers.Analysis
                         string channelnum = $"{_option.LocationNum}{Utils.CreatSaltString(6, "0123456789")}";
                         stu.no = channelnum;
                     }
-                    await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(stu, stu.id);
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(stu, stu.id);
 
                 }
                 foreach (StuList stu in stuTeacher)
@@ -4306,7 +4305,7 @@ namespace TEAMModelOS.Controllers.Analysis
                         string channelnum = $"{_option.LocationNum}{Utils.CreatSaltString(6, "0123456789")}";
                         stu.no = channelnum;
                     }
-                    await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(stu, stu.id);
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(stu, stu.id);
                 }
 
                 return Ok(new { code = 200 });

+ 13 - 13
TEAMModelOS/Controllers/Analysis/AnalysisController.cs

@@ -138,17 +138,17 @@ namespace TEAMModelOS.Controllers.Analysis
             {
                 var client = _azureCosmos.GetCosmosClient();
                 //获取本次评测所有科目结算结果
-                info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
-                School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
+                info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
                 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 =  '{id}' ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
                 {
                     examResults.Add(item);
                 }
                 //获取本次评测所有班级作答结果
                 List<ExamClassResult> examClassResults = new List<ExamClassResult>();
                 var queryClass = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.standard,c.krate,c.phc,c.plc,c.pc,c.frate,c.fphc,c.fplc,c.fpc from c where c.examId =  '{id}' and c.progress = true ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
                 {
                     examClassResults.Add(item);
 
@@ -303,7 +303,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 foreach (string classId in info.classes)
                 {
                     Class classroom = null;
-                    var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classId, new PartitionKey($"Class-{code}"));
+                    var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(classId, new PartitionKey($"Class-{code}"));
                     if (sresponse.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
@@ -352,7 +352,7 @@ namespace TEAMModelOS.Controllers.Analysis
 
                     });
                     List<Student> stus = new List<Student>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<Student>(queryText: $"select c.id,c.name,c.no from c where c.classId = '{classId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select c.id,c.name,c.no from c where c.classId = '{classId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{code}") }))
                     {
                         stus.Add(item);
                     }
@@ -1394,10 +1394,10 @@ namespace TEAMModelOS.Controllers.Analysis
                 List<Dictionary<string, object>> averageMap = new List<Dictionary<string, object>>();
                 List<Dictionary<string, object>> averageTotal = new List<Dictionary<string, object>>();
                 var client = _azureCosmos.GetCosmosClient();
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 List<ExamResult> examResults = new List<ExamResult>();
                 var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId =  '{id}' ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
                 {
                     examResults.Add(item);
                 }
@@ -1465,18 +1465,18 @@ namespace TEAMModelOS.Controllers.Analysis
                 List<List<double>> classAllAverage = new();
                 School school = new();
                 var client = _azureCosmos.GetCosmosClient();
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
 
-                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(code.ToString(), new PartitionKey($"Base"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(code.ToString(), new PartitionKey($"Base"));
                 if (response.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
                     school = json.ToObject<School>();
                 }
-                //School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
+                //School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
                 List<ExamResult> examResults = new List<ExamResult>();
                 var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId =  '{id}' ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
                 {
                     examResults.Add(item);
                 }
@@ -1629,7 +1629,7 @@ namespace TEAMModelOS.Controllers.Analysis
 
         public async Task<string> getGId(int cyear,string periodId,string code) {
             var client = _azureCosmos.GetCosmosClient();
-            School sc = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code, new Azure.Cosmos.PartitionKey("Base"));
+            School sc = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(code, new Azure.Cosmos.PartitionKey("Base"));
             string gradeId = "";
             foreach (Period period in sc.period)
             {

+ 11 - 11
TEAMModelOS/Controllers/Client/HiScanController.cs

@@ -11,7 +11,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
@@ -33,6 +32,7 @@ using Lib.AspNetCore.ServerSentEvents;
 using TEAMModelFunction;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using static TEAMModelFunction.TriggerStuActivity;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers.Core
 {
@@ -80,7 +80,7 @@ namespace TEAMModelOS.Controllers.Core
             List<dynamic> schools = new List<dynamic>();
             if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
             var client = _azureCosmos.GetCosmosClient();
-            var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{id}", new PartitionKey("Base"));
+            var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{id}", new PartitionKey("Base"));
             if (response.Status == 200)
             {
                 var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -95,7 +95,7 @@ namespace TEAMModelOS.Controllers.Core
                         if (statusNow .Equals("join"))
                         {
                             //dynamic schoolExtobj = new ExpandoObject();
-                            var schoolJson = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{obj.GetProperty("schoolId")}", new PartitionKey("Base"));
+                            var schoolJson = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{obj.GetProperty("schoolId")}", new PartitionKey("Base"));
                             var school = await JsonDocument.ParseAsync(schoolJson.ContentStream);
                             var schoolId = obj.GetProperty("schoolId");
                             var schoolName = obj.GetProperty("name");
@@ -103,7 +103,7 @@ namespace TEAMModelOS.Controllers.Core
                             //检查学校购买的模组是否包含阅卷模组
                             int count = 0;
                             string sql = $" SELECT value(count(product))  FROM c join product in c.service.product      where c.id ='{schoolId}'  and  c.pk='Product'  and product.prodCode='YMPCVCIM' ";
-                            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
+                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
                             {
                                 count = item;
                             }
@@ -150,18 +150,18 @@ namespace TEAMModelOS.Controllers.Core
                 var client = _azureCosmos.GetCosmosClient();
                 School school = null;
                 try {
-                    school= await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
+                    school= await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
                 } catch (CosmosException ex) {
                     if (ex.Status == 404) {
                         school = null;
                     }
                 }
-                var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{id}", new PartitionKey("Base"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{id}", new PartitionKey("Base"));
                 if (school != null) {
                     //检查学校购买的模组是否包含阅卷模组
                     int count = 0;
                     string sql = $" SELECT value(count(product))  FROM c join product in c.service.product      where c.id ='{_schoolId}'  and  c.pk='Product'  and product.prodCode='YMPCVCIM' ";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<int>(sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
                     {
                         count = item;
                     }
@@ -196,7 +196,7 @@ namespace TEAMModelOS.Controllers.Core
                     {
                         try
                         {
-                            SheetConfig con = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<SheetConfig>(config.id, new PartitionKey(config.code));
+                            SheetConfig con = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SheetConfig>(config.id, new PartitionKey(config.code));
                             configsN.Add(con);
                         }
                         catch (CosmosException ex) { }
@@ -204,7 +204,7 @@ namespace TEAMModelOS.Controllers.Core
                     else {
                         try
                         {
-                            SheetConfig con = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SheetConfig>(config.id, new PartitionKey(config.code));
+                            SheetConfig con = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SheetConfig>(config.id, new PartitionKey(config.code));
                             configsN.Add(con);
                         }
                         catch (CosmosException ex) { }
@@ -287,8 +287,8 @@ namespace TEAMModelOS.Controllers.Core
             if (!string.IsNullOrEmpty(school)) {
                 sql.Append($"  and c.school='{school}' ");
             }
-            //await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Correct>(queryText: "SELECT  * FROM c where c.source='2' and c.progress='going' order by c.createTime  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Correct-{code}") }))
-            await foreach (var exam in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamInfo>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
+            //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Correct>(queryText: "SELECT  * FROM c where c.source='2' and c.progress='going' order by c.createTime  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Correct-{code}") }))
+            await foreach (var exam in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
             {
                 List<ClassListInfo> classes = new List<ClassListInfo>();
                 if (exam.classes.IsNotEmpty()) {

文件差異過大導致無法顯示
+ 36 - 35
TEAMModelOS/Controllers/Client/HiTeachController.cs


+ 17 - 16
TEAMModelOS/Controllers/Common/CommonController.cs

@@ -14,6 +14,7 @@ using System.Threading.Tasks;
 using TEAMModelFunction;
 using TEAMModelOS.Filter;
 using TEAMModelOS.Models;
+using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
@@ -63,7 +64,7 @@ namespace TEAMModelOS.Controllers.Common
                     string queryList = $"select  count(1) as countschool  from c where c.pk='{key}' ";
                     if (code.ValueKind.Equals(JsonValueKind.String)) {
                         var queryschool = $"select  count(1) as countschool  from c where c.pk='{key}' ";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                            queryText: queryschool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{key}-{code}") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -86,7 +87,7 @@ namespace TEAMModelOS.Controllers.Common
 
                     if (tmdid.ValueKind.Equals(JsonValueKind.String)) {
                         var queryprivate = $"select  count(1) as countprivate  from c where c.pk='{key}' ";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                            queryText: queryprivate, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{key}-{tmdid}") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -151,13 +152,13 @@ namespace TEAMModelOS.Controllers.Common
                 if (!element.TryGetProperty("id", out JsonElement id)) return BadRequest();
                 if (!element.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var data = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync($"{id}", new Azure.Cosmos.PartitionKey($"{code}"));
+                var data = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{id}", new Azure.Cosmos.PartitionKey($"{code}"));
                 using var json = await JsonDocument.ParseAsync(data.ContentStream);
                 long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 Dictionary<string, object> dy = System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, object>>(json.RootElement.ToString());
                 dy["endTime"] = now;
                 dy["progress"] = "finish"; 
-                await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Dictionary<string, object>>(dy, dy["id"].ToString(), new Azure.Cosmos.PartitionKey(dy["code"].ToString()));
+                await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Dictionary<string, object>>(dy, dy["id"].ToString(), new Azure.Cosmos.PartitionKey(dy["code"].ToString()));
                 var httpClient = _clientFactory.CreateClient();
                 var content = new { id = $"{id}", code = $"{code}" };
                 await TriggerStuActivity.RefreshStuActivity(client, _dingDing, $"{id}", $"{code}");
@@ -184,7 +185,7 @@ namespace TEAMModelOS.Controllers.Common
                 var client = _azureCosmos.GetCosmosClient();
                 List<ExamInfo> examInfo = new();
                 List<Task<ItemResponse<ExamInfo>>> tasks = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamInfo>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
                 {
                     examInfo.Add(item);
                 }
@@ -193,7 +194,7 @@ namespace TEAMModelOS.Controllers.Common
                     if (info.size == 0)
                     {
                         info.size = await _azureStorage.GetBlobContainerClient(info.school).GetBlobsSize($"exam/{info.id}");
-                        tasks.Add(client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"{info.code}")));
+                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"{info.code}")));
                     }
                 }
                 await Task.WhenAll(tasks);
@@ -219,7 +220,7 @@ namespace TEAMModelOS.Controllers.Common
                 var client = _azureCosmos.GetCosmosClient();
                 List<Vote> votes = new();
                 List<Task<ItemResponse<Vote>>> tasks = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Vote>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Vote>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{code}") }))
                 {
                     votes.Add(item);
                 }
@@ -228,7 +229,7 @@ namespace TEAMModelOS.Controllers.Common
                     if (vote.size == 0)
                     {
                         vote.size = await _azureStorage.GetBlobContainerClient(vote.school).GetBlobsSize($"vote/{vote.id}");
-                        tasks.Add(client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(vote, vote.id, new PartitionKey($"{vote.code}")));
+                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(vote, vote.id, new PartitionKey($"{vote.code}")));
                     }
                 }
                 await Task.WhenAll(tasks);
@@ -254,7 +255,7 @@ namespace TEAMModelOS.Controllers.Common
                 var client = _azureCosmos.GetCosmosClient();
                 List<Survey> surveys = new();
                 List<Task<ItemResponse<Survey>>> tasks = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Survey>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Survey>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{code}") }))
                 {
                     surveys.Add(item);
                 }
@@ -263,7 +264,7 @@ namespace TEAMModelOS.Controllers.Common
                     if (survey.size == 0)
                     {
                         survey.size = await _azureStorage.GetBlobContainerClient(survey.school).GetBlobsSize($"vote/{survey.id}");
-                        tasks.Add(client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(survey, survey.id, new PartitionKey($"{survey.code}")));
+                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(survey, survey.id, new PartitionKey($"{survey.code}")));
                     }
                 }
                 await Task.WhenAll(tasks);
@@ -290,7 +291,7 @@ namespace TEAMModelOS.Controllers.Common
                 var client = _azureCosmos.GetCosmosClient();
                 List<ItemInfo> items = new();
                 List<Task<ItemResponse<ItemInfo>>> tasks = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ItemInfo>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
                     items.Add(item);
                 }
@@ -299,7 +300,7 @@ namespace TEAMModelOS.Controllers.Common
                     if (info.size == 0)
                     {
                         info.size = await _azureStorage.GetBlobContainerClient(code.ToString()).GetBlobsSize($"item/{info.id}");
-                        tasks.Add(client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(info, info.id, new PartitionKey($"{info.code}")));
+                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(info, info.id, new PartitionKey($"{info.code}")));
                     }
                 }
                 await Task.WhenAll(tasks);
@@ -325,7 +326,7 @@ namespace TEAMModelOS.Controllers.Common
                 var client = _azureCosmos.GetCosmosClient();
                 List<Paper> papers = new();
                 List<Task<ItemResponse<Paper>>> tasks = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Paper>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Paper>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 {
                     papers.Add(item);
                 }
@@ -334,7 +335,7 @@ namespace TEAMModelOS.Controllers.Common
                     if (paper.size == 0)
                     {
                         paper.size = await _azureStorage.GetBlobContainerClient(code.ToString()).GetBlobsSize($"paper/{paper.name}");
-                        tasks.Add(client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}")));
+                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}")));
                     }
                 }
                 await Task.WhenAll(tasks);
@@ -364,11 +365,11 @@ namespace TEAMModelOS.Controllers.Common
                 {
                     if (role.GetString().Equals("teacher") || role.GetString().Equals("admin"))
                     {
-                        await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
                     }
                     else if (role.GetString().Equals("student"))
                     {
-                        await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuActivity>($"{id}", new PartitionKey($"{code}"));
                     }
                     else
                     {

+ 92 - 92
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -14,7 +14,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
@@ -27,6 +26,7 @@ using Microsoft.Extensions.Configuration;
 using TEAMModelOS.Filter;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.SDK.Models.Cosmos;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -87,7 +87,7 @@ namespace TEAMModelOS.Controllers
                 //查询所有学生名单
                 List<string> sids = new List<string>();
                 //List<Student> students = new List<Student>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -107,7 +107,7 @@ namespace TEAMModelOS.Controllers
                     List<string> ids = new List<string>();
                     //处理班级人数(公共部分的校本名单)
                     //List<Student> students = new List<Student>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -125,7 +125,7 @@ namespace TEAMModelOS.Controllers
 
                         //处理发布对象为自选名单(个人)
                         List<StuList> stuLists = new List<StuList>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                         {
                             stuLists.Add(item);
                         }
@@ -170,7 +170,7 @@ namespace TEAMModelOS.Controllers
                                         ids.Add(tid);
                                     }
                                 }
-                                await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
                             }
 
                         }
@@ -180,7 +180,7 @@ namespace TEAMModelOS.Controllers
                         //request.size = await _azureStorage.GetBlobContainerClient(request.school).GetBlobsSize($"exam/{request.id}");
                         //发布对象为自选名单(校本)
                         List<StuList> stuLists = new List<StuList>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{request.school}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{request.school}") }))
                         {
                             stuLists.Add(item);
                         }
@@ -203,7 +203,7 @@ namespace TEAMModelOS.Controllers
                                         stuList.students.RemoveAt(j);
                                     }
                                 }
-                                await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
                             }
 
                         }
@@ -244,11 +244,11 @@ namespace TEAMModelOS.Controllers
                         n++;
                         simple.sheet = null;
                     }
-                    exam = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    exam = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
                 {
-                    ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(request.id, new PartitionKey($"{request.code}"));
+                    ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(request.id, new PartitionKey($"{request.code}"));
                     if (info.progress.Equals("going"))
                     {
                         return Ok(new { v = "活动正在进行中" });
@@ -276,7 +276,7 @@ namespace TEAMModelOS.Controllers
                         simple.blob = "/exam/" + request.id + "/paper/" + request.subjects[n].id;
                         n++;
                     }
-                    exam = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
+                    exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
                 }
                 return Ok(new { exam });
             }
@@ -309,7 +309,7 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 //string school_code = code.ToString().Substring(typeof(ExamClassResult).Name.Length + 1);
-                var response = await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
                 //删除blob 相关资料
                 await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, code.ToString(), new List<string> { $"exam/{id}" });
                 //通知评测删除信息
@@ -318,7 +318,7 @@ namespace TEAMModelOS.Controllers
                 var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
                 await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
                 //删除阅卷配置
-                var cresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Correct-{code}"));
+                var cresponse = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Correct-{code}"));
                 if (cresponse.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -351,16 +351,16 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                     }
-                    await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.GetString(), new PartitionKey($"Correct-{code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(id.GetString(), new PartitionKey($"Correct-{code}"));
                 }
 
                 List<ExamClassResult> examClassResults = new List<ExamClassResult>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select c.id from c where c.examId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select c.id from c where c.examId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
                 {
                     examClassResults.Add(item);
                 }
                 List<string> resultIds = new List<string>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select c.id from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select c.id from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -375,12 +375,12 @@ namespace TEAMModelOS.Controllers
                 }
                 foreach (ExamClassResult classResult in examClassResults)
                 {
-                    await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(classResult.id, new PartitionKey($"ExamClassResult-{code}"));
                 }
-                await client.GetContainer("TEAMModelOS", "Common").DeleteItemsStreamAsync(resultIds, $"ExamResult-{id}");
+                await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemsStreamAsync(resultIds, $"ExamResult-{id}");
                 /*foreach (ExamResult result in results)
                 {
-                    await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(result.id, new PartitionKey($"ExamResult-{id}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(result.id, new PartitionKey($"ExamResult-{id}"));
                 }*/
                 //await _azureCosmos.DeleteAll(examClassResults);
                 return Ok(new { id });
@@ -417,7 +417,7 @@ namespace TEAMModelOS.Controllers
                 else
                 {
                     long ct = 0;
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: "SELECT  top 1  c.createTime FROM c order by c.createTime  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: "SELECT  top 1  c.createTime FROM c order by c.createTime  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
                     {
 
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -481,7 +481,7 @@ namespace TEAMModelOS.Controllers
                 }
 
                 List<ExamInfo> examInfo = new List<ExamInfo>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
                 {
 
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -503,7 +503,7 @@ namespace TEAMModelOS.Controllers
                 //List<string> examIds = new List<string>();
                 /* List<ExamResult> examResults = new List<ExamResult>();
                  foreach (ExamInfo info in examInfos) {                    
-                     await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(
+                     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 PartitionKey($"ExamResult-{info.id}") }))
                      {
                          examResults.Add(item);
@@ -578,7 +578,7 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 List<ExamInfo> examInfo = new List<ExamInfo>();
                 //var query = $"select value(c) from c ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -629,7 +629,7 @@ namespace TEAMModelOS.Controllers
                 ids = classId.ToObject<List<string>>();
                 var client = _azureCosmos.GetCosmosClient();
                 List<ExamClassResult> examClassResults = new List<ExamClassResult>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
                 {
@@ -645,7 +645,7 @@ namespace TEAMModelOS.Controllers
 
                 ExamClassResult classResult = new ExamClassResult();
                 List<PaperSimple> standerAnswers = new List<PaperSimple>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                     queryText: $"select A0.point,A0.answers from c join A0 in c.papers where c.id = '{id}'and A0.id = '{paperId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
@@ -863,7 +863,7 @@ namespace TEAMModelOS.Controllers
                     }
                     if (flag)
                     {
-                        ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{scode}"));
+                        ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{scode}"));
                         result.progress = true;
                         /*//标记单科单班总得分
                         double score = 0;
@@ -887,10 +887,10 @@ namespace TEAMModelOS.Controllers
                                 s.classCount += 1;
                             }
                         });
-                        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{scode}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{scode}"));
                     }
                     result.sum[newIndex] = result.studentScores[newIndex].Sum();
-                    classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
+                    classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
                 }
                 await Task.WhenAll(tasks);
 
@@ -927,7 +927,7 @@ namespace TEAMModelOS.Controllers
                 List<ExamClassResult> examClassResults = new List<ExamClassResult>();
                 if (request.TryGetProperty("classId", out JsonElement classId))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                        queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
                     {
@@ -936,7 +936,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                            queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and array_contains(c.studentIds,'{studentId}')",
                            requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
                     {
@@ -945,8 +945,8 @@ namespace TEAMModelOS.Controllers
                 }
 
                 ExamClassResult classResult = new ExamClassResult();
-                //ExamInfo classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
-                //ExamClassResult classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
+                //ExamInfo classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
+                //ExamClassResult classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
                 /*foreach (double index in ans) {
                     classResult.studentScores.in
                 }*/
@@ -973,7 +973,7 @@ namespace TEAMModelOS.Controllers
                         }
                         if (flag)
                         {
-                            ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                            ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                             result.progress = true;
                             exam.subjects.ForEach(s =>
                             {
@@ -982,17 +982,17 @@ namespace TEAMModelOS.Controllers
                                     s.classCount += 1;
                                 }
                             });
-                            await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
                         }
                     }
                     else
                     {
-                        ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                        ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                         exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
                     }
                     result.sum[index] = result.studentScores[index].Sum();
-                    classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
+                    classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
                 }
 
                 return Ok(new { classResult });
@@ -1044,9 +1044,9 @@ namespace TEAMModelOS.Controllers
                 // 如果只有学生id则返回学生参加过的考试 只返回相关摘要信息
                 var client = _azureCosmos.GetCosmosClient();
                 //string code = school_code.ToString().Substring(5);
-                //ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{school_code}"));
+                //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{school_code}"));
                 List<object> examClassResults = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select c.id, c.code,c.info,c.studentIds,c.studentAnswers,c.studentScores,c.mark from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select c.id, c.code,c.info,c.studentIds,c.studentAnswers,c.studentScores,c.mark from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school_code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1061,7 +1061,7 @@ namespace TEAMModelOS.Controllers
                 /*if (StringHelper.getKeyCount(requert) == 1 && requert.TryGetProperty("code", out JsonElement code))
                 {
                     List<object> props = new List<object>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c where c.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c where c.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1082,7 +1082,7 @@ namespace TEAMModelOS.Controllers
                         //List<ExamRecord> examRecords = await _azureCosmos.FindByDict<ExamRecord>(request, props);
                         //return builder.Data(examRecords).Extend(new Dictionary<string, object> { { "props", props } }).build();
                         List<object> props = new List<object>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
                             if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1130,7 +1130,7 @@ namespace TEAMModelOS.Controllers
                 //List<string> ids = new List<string>();
                 //处理班级人数(公共部分的校本名单)
                 //List<Student> students = new List<Student>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.classId id from c where c.id = '{studentId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.classId id from c where c.id = '{studentId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1145,12 +1145,12 @@ namespace TEAMModelOS.Controllers
                 }
                 //获取自定义名单信息
                 List<StuList> stuLists = new List<StuList>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}'",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                 {
                     stuLists.Add(item);
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}'",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{school}") }))
                 {
                     stuLists.Add(item);
@@ -1164,7 +1164,7 @@ namespace TEAMModelOS.Controllers
 
                 }
                 var queryClassId = $"select c.classes id from c where c.id ='{id}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryClassId, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryClassId, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1188,7 +1188,7 @@ namespace TEAMModelOS.Controllers
                         infoIds.Add(ids);
                     }
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1201,7 +1201,7 @@ namespace TEAMModelOS.Controllers
                 }
                 var querySubject = $"select A0.id,A0.name from c join A0 in c.subjects where c.id ='{id}'";
                 //List<object> props = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: querySubject, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: querySubject, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1214,7 +1214,7 @@ namespace TEAMModelOS.Controllers
                 }
                 var queryAnswers = $"select c.id,c.code,c.studentIds,c.subjectId,c.studentAnswers,c.studentScores,c.sum,c.mark from c where c.examId ='{id}' and array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult' ";
                 List<ExamClassResult> answers = new List<ExamClassResult>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryAnswers,
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryAnswers,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1282,7 +1282,7 @@ namespace TEAMModelOS.Controllers
                 List<string> resultIds = new List<string>();
                 var client = _azureCosmos.GetCosmosClient();
                 //查询校本班级ID
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
                     queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}' and c.pk = 'Class' "))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1297,7 +1297,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
                 //查询私人班级ID
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
                    queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}' and c.pk = 'Class' "))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1334,7 +1334,7 @@ namespace TEAMModelOS.Controllers
 
                 var query = $"select c.id,c.code,c.name,c.startTime,c.endTime,c.type,c.progress,c.school,c.scope from c where ({ss}) and c.progress != 'pending' ";
                 List<object> props = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1347,7 +1347,7 @@ namespace TEAMModelOS.Controllers
                 }
                 var queryClass = $"select c.examId,c.subjectId,c.studentIds,c.studentAnswers,c.studentScores from c where array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult'";
                 List<ExamClassResult> Classes = new List<ExamClassResult>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryClass))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryClass))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1395,7 +1395,7 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 var query = $"select c.examId,c.subjectId,c.studentScores from c where array_contains(c.studentIds,'{id}') ";
                 List<object> props = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1431,14 +1431,14 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 info.progress = "finish";
                 info.endTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 List<ExamClassResult> classResults = new();
                 if (info.scope.Equals("school"))
                 {
 
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                     queryText: $"select value(c) from c where c.examId = '{id}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
                     {
@@ -1447,7 +1447,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                         queryText: $"select value(c) from c where c.examId = '{id}'",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
                     {
@@ -1457,9 +1457,9 @@ namespace TEAMModelOS.Controllers
                 foreach (ExamClassResult examClass in classResults)
                 {
                     examClass.progress = true;
-                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examClass, examClass.id, new PartitionKey($"{examClass.code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(examClass, examClass.id, new PartitionKey($"{examClass.code}"));
                 }
-                info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
+                info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
                 return Ok(info);
             }
             catch (Exception ex)
@@ -1485,7 +1485,7 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 int index = 0;
                 foreach (ExamSubject subject in info.subjects) {
                     if (!subject.id.Equals(subjectId.ToString()))
@@ -1502,7 +1502,7 @@ namespace TEAMModelOS.Controllers
                 if (info.scope.Equals("school"))
                 {
 
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
                     {
@@ -1511,7 +1511,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                         queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
                     {
@@ -1545,7 +1545,7 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
-                //info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
+                //info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
                 return Ok(new { score = itemScore , stuAns, paper = info.papers });
             }
             catch (Exception ex)
@@ -1572,10 +1572,10 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 //var redisClient = _azureRedis.GetRedisClient(8);
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 List<ExamClassResult> classResults = new();
                 List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
                                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and array_contains(c.tIds,'{tId}') ",
                                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
                 {
@@ -1649,15 +1649,15 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
                 //if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
                 if (response.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
                     ExamInfo info = json.ToObject<ExamInfo>();
-                    //ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                    //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                     List<ExamClassResult> classResults = new();
                     List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
                                         queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
                     {
@@ -1722,10 +1722,10 @@ namespace TEAMModelOS.Controllers
                 {
                     return Ok(new { msg = "还在进行中", code = 202 });
                 }
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 List<ExamClassResult> classResults = new();
                 List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
                                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
                 {
@@ -1789,7 +1789,7 @@ namespace TEAMModelOS.Controllers
                 List<SDK.Models.Cosmos.Common.Scoring> recs = new();
                 List<SDK.Models.Cosmos.Common.Scoring> all = new();
                 List<SDK.Models.Cosmos.Common.Scoring> attr = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
                                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' ",
                                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
                 {
@@ -1838,7 +1838,7 @@ namespace TEAMModelOS.Controllers
                 {
 
                     List<SDK.Models.Cosmos.Common.Scoring> value = new();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
                                         queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{stuId}' ",
                                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
                     {
@@ -1855,7 +1855,7 @@ namespace TEAMModelOS.Controllers
                             else
                             {
                                 scoring.tIds.Add(tId.ToString());
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
                             }
                         }
                     }
@@ -1935,7 +1935,7 @@ namespace TEAMModelOS.Controllers
                         {
                             item.tIds.Add(tId.ToString());
                         }
-                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
                         //序列化单个学生作答记录、得分情况、批注情况
                         /*var cs = JsonSerializer.Serialize(item);
                         var json = JsonDocument.Parse(cs);
@@ -1987,11 +1987,11 @@ namespace TEAMModelOS.Controllers
                 }
 
                 //var json = JsonDocument.Parse(record);
-                /*ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-hbcn"));
+                /*ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-hbcn"));
                 if (info.scope.Equals("school"))
                 {
 
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
                     {
@@ -2000,7 +2000,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                         queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
                     {
@@ -2019,7 +2019,7 @@ namespace TEAMModelOS.Controllers
                 }
                 await Task.WhenAll(tasks);
                 return Ok();*/
-                //info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));                
+                //info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));                
             }
             catch (Exception ex)
             {
@@ -2053,7 +2053,7 @@ namespace TEAMModelOS.Controllers
                 //var redisClient = _azureRedis.GetRedisClient(8);
                 List<ExamClassResult> classResults = new();
                 List<SDK.Models.Cosmos.Common.Scoring> attr = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
                                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{sId}' and array_contains(c.tIds,'{tId}') ",
                                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
                 {
@@ -2193,7 +2193,7 @@ namespace TEAMModelOS.Controllers
                             }
                         }
 
-                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
 
                     }
                 }
@@ -2205,7 +2205,7 @@ namespace TEAMModelOS.Controllers
                 if (attr.Count == count.GetInt32())
                 {
 
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
                     {
@@ -2229,7 +2229,7 @@ namespace TEAMModelOS.Controllers
                                 if (!item.flag)
                                 {
                                     //scoring.type = 3;
-                                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
+                                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
                                     return Ok(new { msg = "试题分数差异过大" });
                                 }
                                 double sc = item.scores.Select(x => x.sc).ToList().Aggregate((i, j) => (i + j) / item.scores.Count);
@@ -2271,7 +2271,7 @@ namespace TEAMModelOS.Controllers
                             }
 
                         }
-                        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
                     }
 
                 }
@@ -2300,7 +2300,7 @@ namespace TEAMModelOS.Controllers
             if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
             var client = _azureCosmos.GetCosmosClient();
             List<SDK.Models.Cosmos.Common.Scoring> attr = new();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
                                 queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{sId}' and c.type = '{type}' and array_contains(c.tIds,'{tId}') ",
                                 requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
             {
@@ -2321,7 +2321,7 @@ namespace TEAMModelOS.Controllers
             if (!requert.TryGetProperty("index", out JsonElement index)) return BadRequest();
             if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
             var client = _azureCosmos.GetCosmosClient();
-            SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
+            SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
             if (null != scoring)
             {
                 if (string.IsNullOrEmpty(scoring.qs[index.GetInt32()].tId))
@@ -2342,7 +2342,7 @@ namespace TEAMModelOS.Controllers
             {
                 return Ok(new { code = 404 });
             }
-            var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
+            var sc = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
             return Ok(new { sc });
         }
 
@@ -2358,7 +2358,7 @@ namespace TEAMModelOS.Controllers
             if (!requert.TryGetProperty("index", out JsonElement index)) return BadRequest();
             //if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
             var client = _azureCosmos.GetCosmosClient();
-            SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
+            SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
             if (null != scoring)
             {
                 if (string.IsNullOrEmpty(scoring.qs[index.GetInt32()].improve))
@@ -2379,7 +2379,7 @@ namespace TEAMModelOS.Controllers
             {
                 return Ok(new { code = 404 });
             }
-            var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
+            var sc = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
             return Ok(new { sc });
         }
 
@@ -2395,11 +2395,11 @@ namespace TEAMModelOS.Controllers
             var client = _azureCosmos.GetCosmosClient();
             List<double> scs = score.ToObject<List<double>>();
             List<ExamClassResult> classResults = new();
-            SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
+            SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
             if (null != scoring)
             {
                 scoring.scores = scs;
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{scoring.subjectId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
                 {
@@ -2414,14 +2414,14 @@ namespace TEAMModelOS.Controllers
                         //exam.mark[index] = scoring.marks;
                     }
 
-                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
                 }
             }
             else
             {
                 return Ok(new { code = 404 });
             }
-            var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
+            var sc = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
             return Ok(new { sc });
         }
 
@@ -2437,7 +2437,7 @@ namespace TEAMModelOS.Controllers
         private async Task deleteAsync(CosmosClient client, string id, string tId)
         {
             List<string> correctIds = new List<string>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.cid = '{id}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CorrectTask-{tId}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.cid = '{id}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CorrectTask-{tId}") }))
             {
                 using var jsonTask = await JsonDocument.ParseAsync(item.ContentStream);
                 if (jsonTask.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -2452,7 +2452,7 @@ namespace TEAMModelOS.Controllers
             }
             if (correctIds.Count > 0)
             {
-                await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(correctIds, $"CorrectTask-{tId}");
+                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemsStreamAsync(correctIds, $"CorrectTask-{tId}");
             }
         }
     }

+ 1 - 2
TEAMModelOS/Controllers/Common/HomeworkController.cs

@@ -11,7 +11,6 @@ using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK.Models;
 
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK;
@@ -291,7 +290,7 @@ namespace TEAMModelOS.Controllers.Learn
 
     //        List<object> records = new List<object>();
     //        var query = $"select c.id,c.classroom,c.submit, c.submitTime,c.score,c.content,c.stuCmt,c.tchCmt from c where id = {id}";
-    //        await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{id}") }))
+    //        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{id}") }))
     //        {
     //            using var json = await JsonDocument.ParseAsync(item.ContentStream);
 

+ 14 - 14
TEAMModelOS/Controllers/Common/LearnController.cs

@@ -42,7 +42,7 @@ namespace TEAMModelOS.Controllers.Learn
 //            var id = jwt.Payload.Sub;*//*
 
 //            var client = _azureCosmos.GetCosmosClient();
-//            var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id.ToString(), new PartitionKey($"LearnTask-{id}"));
+//            var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(id.ToString(), new PartitionKey($"LearnTask-{id}"));
 //            if (response.Status == 200)
 //            {
 //                using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -85,7 +85,7 @@ namespace TEAMModelOS.Controllers.Learn
 //                writer.Flush();
 //                //Debug
 //                //string teacher = Encoding.UTF8.GetString(stream.ToArray());
-//                response = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemStreamAsync(stream, new PartitionKey($"LearnTask-{id}"));
+//                response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemStreamAsync(stream, new PartitionKey($"LearnTask-{id}"));
 //            }*/
 //            var client = _azureCosmos.GetCosmosClient();
 //            LearnTask learnTask;            
@@ -95,12 +95,12 @@ namespace TEAMModelOS.Controllers.Learn
 //                request.id = _snowflakeId.NextId() + "";
 //                request.code = typeof(LearnTask).Name + "-" + request.code;
 //                request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-//                learnTask = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+//                learnTask = await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
 //                //await _azureCosmos.Save(request);
 //            }
 //            else
 //            {
-//                learnTask = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
+//                learnTask = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
 //                //await _azureCosmos.Update(request);
 //            }
 
@@ -140,7 +140,7 @@ namespace TEAMModelOS.Controllers.Learn
 
 //            List<object> tasks = new List<object>();
 //            var query = $"select c.id,c.endTime,c.status, c.type,c.createTime,c.stage,c.passScore from c";
-//            await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnTask-{id}") }))
+//            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnTask-{id}") }))
 //            {
 //                using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -196,13 +196,13 @@ namespace TEAMModelOS.Controllers.Learn
 //                request.id = _snowflakeId.NextId() + "";               
 //                request.code = typeof(LearnUnit).Name + "-" + request.code;
 //                request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-//                learnUnit = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+//                learnUnit = await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
 //                //await _azureCosmos.Save(request);
 //            }
 //            else
 //            {
 //                request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-//                learnUnit = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
+//                learnUnit = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
 //                //await _azureCosmos.Update(request);
 //            }
 
@@ -214,7 +214,7 @@ namespace TEAMModelOS.Controllers.Learn
 //            var id = jwt.Payload.Sub;
 
 //            var client = _azureCosmos.GetCosmosClient();
-//            var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id, new PartitionKey($"LearnUnit-{id}"));
+//            var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(id, new PartitionKey($"LearnUnit-{id}"));
 //            if (response.Status == 200)
 //            {
 //                using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -245,7 +245,7 @@ namespace TEAMModelOS.Controllers.Learn
 //                writer.Flush();
 //                //Debug
 //                //string teacher = Encoding.UTF8.GetString(stream.ToArray());
-//                response = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemStreamAsync(stream, new PartitionKey($"LearnUnit-{id}"));
+//                response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemStreamAsync(stream, new PartitionKey($"LearnUnit-{id}"));
 //            }
 
 //            return Ok();*/
@@ -285,7 +285,7 @@ namespace TEAMModelOS.Controllers.Learn
 
 //            List<object> units = new List<object>();
 //            var query = $"select c.id,c.resource,c.item, c.name,c.createTime from c";
-//            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnUnit-{code}") }))
+//            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnUnit-{code}") }))
 //            {
 //                using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -341,11 +341,11 @@ namespace TEAMModelOS.Controllers.Learn
 //                request.id = _snowflakeId.NextId() + "";
 //                request.code = typeof(LearnProcess).Name + "-" + request.code;
 //                request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-//                learnProcess = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(request, new PartitionKey($"LearnProcess-{request.code}"));
+//                learnProcess = await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(request, new PartitionKey($"LearnProcess-{request.code}"));
 //               // await _azureCosmos.Save<LearnProcess>(request);
 //            }
 //            else {
-//                learnProcess = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(request, request.id,new PartitionKey($"{request.code}"));
+//                learnProcess = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(request, request.id,new PartitionKey($"{request.code}"));
 //                //await _azureCosmos.Update<LearnProcess>(request);
 //            }
            
@@ -372,7 +372,7 @@ namespace TEAMModelOS.Controllers.Learn
 
 //            List<object> process = new List<object>();
 //            var query = $"select c.id,c.name,c.subjectCode, c.periodCode,c.Introduce from c where id = {id}";
-//            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnProcess-{id}") }))
+//            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnProcess-{id}") }))
 //            {
 //                using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -457,7 +457,7 @@ namespace TEAMModelOS.Controllers.Learn
 
 //            List<object> records = new List<object>();
 //            var query = $"select c.id,c.steps from c where id = {id}";
-//            await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnRecord-{id}") }))
+//            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LearnRecord-{id}") }))
 //            {
 //                using var json = await JsonDocument.ParseAsync(item.ContentStream);
 

+ 9 - 10
TEAMModelOS/Controllers/Common/SurveyController.cs

@@ -10,7 +10,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
@@ -118,12 +117,12 @@ namespace TEAMModelOS.Controllers
                     request.recordUrl = $"/survey/{request.id}/record.json";
                     var cods = new { records = new List<string>(), userids = new List<string>(), question = new List<QuestionRecord>() };
                     await _azureStorage.UploadFileByContainer(blobcntr, cods.ToJsonString(), "survey", $"{request.id}/record.json");
-                    request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
                 {
                     string blobcntr = null;
-                    var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
                     var messageBlob = new ServiceBusMessage();
                     if (request.scope.Equals("school"))
                     {
@@ -158,7 +157,7 @@ namespace TEAMModelOS.Controllers
                         }
                         request.progress = info.progress;
                         request.recordUrl = $"/survey/{request.id}/record.json";
-                        request = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
                     }
                     else {
                         if (request.startTime > now)
@@ -172,7 +171,7 @@ namespace TEAMModelOS.Controllers
                         request.recordUrl = $"/survey/{request.id}/record.json";
                         var cods = new { records = new List<string>(), userids = new List<string>(), question = new List<QuestionRecord>() };
                         await _azureStorage.UploadFileByContainer(blobcntr, cods.ToJsonString(), "survey", $"{request.id}/record.json");
-                        request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     }
                 }
                 return Ok(new { survey = request});
@@ -260,7 +259,7 @@ namespace TEAMModelOS.Controllers
                 if (string.IsNullOrEmpty(school)) {
                     query = $"{query} and c.scope='private' ";
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Survey>(queryText: query,
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Survey>(queryText: query,
                     requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Survey-{code}") })) {
                     if (!string.IsNullOrEmpty(school))
                     {
@@ -281,7 +280,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
                 //var query = $"select c.id,c.name,c.code,c.startTime,c.endTime,c.progress,c.classes from c where  c.createTime >= {stimestamp} and c.createTime <= {etimestamp}  {progresssql } ";
-                //await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query,
+                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query,
                 //    requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Survey-{code}") }))
                 //{
                 //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -329,7 +328,7 @@ namespace TEAMModelOS.Controllers
             {
                 var client = _azureCosmos.GetCosmosClient();
                
-                survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(id.GetString(), new PartitionKey($"{code}"));
+                survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(id.GetString(), new PartitionKey($"{code}"));
                 if (survey != null)
                 {
 
@@ -365,7 +364,7 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
 
-                Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(id.GetString(), new PartitionKey($"{code}"));
+                Survey survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(id.GetString(), new PartitionKey($"{code}"));
                 bool flag = false;
                 //必须是本人或者这个学校的管理者才能删除
                 if (survey.creatorId == userid)
@@ -384,7 +383,7 @@ namespace TEAMModelOS.Controllers
                     //使用ttl删除,并处理相关事务逻辑
                     survey.ttl = 1;
                     survey.status = 404;
-                    survey = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(survey,survey.id, new PartitionKey($"{survey.code}"));
+                    survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(survey,survey.id, new PartitionKey($"{survey.code}"));
                     _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Record:{survey.id}");
                     _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Submit:{survey.id}");
                     //删除blob 相关资料

+ 8 - 9
TEAMModelOS/Controllers/Common/VoteController.cs

@@ -11,7 +11,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
@@ -115,11 +114,11 @@ namespace TEAMModelOS.Controllers.Learn
                     string url = $"/vote/{request.id}/record.json";
                     request.recordUrl = url;
                     await _azureStorage.UploadFileByContainer(blobcntr, new { options = new List<string>(), records = new List<VoteRecord>() }.ToJsonString(), "vote", $"{request.id}/record.json");
-                    request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
                     var messageBlob = new ServiceBusMessage();
                     string blobcntr = null;
                     if (request.scope.Equals("school"))
@@ -156,7 +155,7 @@ namespace TEAMModelOS.Controllers.Learn
                         request.progress = info.progress;
                         string url = $"/vote/{request.id}/record.json";
                         request.recordUrl = url;
-                        request = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
                     }
                     else
                     {
@@ -171,7 +170,7 @@ namespace TEAMModelOS.Controllers.Learn
                         string url = $"/vote/{request.id}/record.json";
                         request.recordUrl = url;
                         await _azureStorage.UploadFileByContainer(blobcntr, new { options = new List<string>(), records = new List<VoteRecord>() }.ToJsonString(), "vote", $"{request.id}/record.json");
-                        request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     }
                 }
                 return Ok(new { vote = request });
@@ -260,7 +259,7 @@ namespace TEAMModelOS.Controllers.Learn
                 {
                     query = $"{query} and c.scope='private' ";
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Vote>(queryText: query,
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Vote>(queryText: query,
                     requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Vote-{code}") }))
                 {
                     if (!string.IsNullOrEmpty(school))
@@ -312,7 +311,7 @@ namespace TEAMModelOS.Controllers.Learn
             {
                 var client = _azureCosmos.GetCosmosClient();
               
-                  vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(id.GetString(), new PartitionKey($"{code}"));
+                  vote = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Vote>(id.GetString(), new PartitionKey($"{code}"));
                 if (vote != null)
                 {
                     
@@ -348,7 +347,7 @@ namespace TEAMModelOS.Controllers.Learn
                 if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 
-                Vote vote =await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(id.GetString(), new PartitionKey($"{code}") );
+                Vote vote =await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Vote>(id.GetString(), new PartitionKey($"{code}") );
                 bool flag = false;
                 //必须是本人或者这个学校的管理者才能删除
                 if (vote.creatorId == userid)
@@ -365,7 +364,7 @@ namespace TEAMModelOS.Controllers.Learn
                     //使用ttl删除,并处理相关事务逻辑
                     vote.ttl = 1;
                     vote.status = 404;
-                    vote = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(vote,vote.id,  new PartitionKey($"{vote.code}"));
+                    vote = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(vote,vote.id,  new PartitionKey($"{vote.code}"));
                     await _dingDing.SendBotMsg($"{_option.Location}-投票活动【{vote.name}-{vote.id}-ttl={vote.ttl}】正在操作", GroupNames.成都开发測試群組);
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Record:{vote.id}");
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Count:{vote.id}");

+ 13 - 13
TEAMModelOS/Controllers/Core/BlobController.cs

@@ -21,7 +21,6 @@ using Azure.Messaging.ServiceBus;
 using static TEAMModelOS.SDK.DI.AzureStorageBlobExtensions;
 using System.Linq;
 using Microsoft.AspNetCore.Http;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using HTEXLib.COMM.Helpers;
 using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
@@ -31,6 +30,7 @@ using Azure;
 using System.IO;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Sas;
+using ContentTypeDict = TEAMModelOS.SDK.ContentTypeDict;
 
 namespace TEAMModelOS.Controllers.Core
 {
@@ -181,7 +181,7 @@ namespace TEAMModelOS.Controllers.Core
                 request.TryGetProperty("containerName", out JsonElement containerName);
                 if (_scope.ValueKind.Equals(JsonValueKind.String) && _scope.GetString().Equals("school")) {
                     var client = _azureCosmos.GetCosmosClient();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{containerName}") })) {
                         var json = await JsonDocument.ParseAsync(item.ContentStream);
                         foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -288,7 +288,7 @@ namespace TEAMModelOS.Controllers.Core
                 {
                     var queryslt = new StringBuilder($"SELECT  value(c) FROM c join A1 in  c.periodId  WHERE c.type='{type}' and  A1 in ('{periodId}') ");
 
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Bloblog>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Bloblog>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
                     {
                         bloblogs.Add(item);
                     }
@@ -296,7 +296,7 @@ namespace TEAMModelOS.Controllers.Core
                 else if (scope.GetString().Equals("private"))
                 {
                     var queryslt = new StringBuilder($"SELECT  value(c) FROM c   WHERE c.type='{type}'  ");
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Bloblog>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Bloblog>(queryText: queryslt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
                     {
                         bloblogs.Add(item);
                     }
@@ -326,7 +326,7 @@ namespace TEAMModelOS.Controllers.Core
             string tbname= $"{_scope}".Equals("school",StringComparison.OrdinalIgnoreCase) ? "School": "Teacher";
             try
             {
-                Bloblog bloblog = await client.GetContainer("TEAMModelOS", tbname).ReadItemAsync<Bloblog>($"{_id}", new PartitionKey($"Bloblog-{_cntr}"));
+                Bloblog bloblog = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<Bloblog>($"{_id}", new PartitionKey($"Bloblog-{_cntr}"));
                 string oldUrl = bloblog.url;
                 if (oldUrl.Equals($"{_newName}")) {
                     return Ok();
@@ -376,7 +376,7 @@ namespace TEAMModelOS.Controllers.Core
 
                 };
                 await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, $"{_cntr}", new List<string> { px });
-                await client.GetContainer("TEAMModelOS", tbname).ReplaceItemAsync<Bloblog>(bloblog, $"{_id}", new PartitionKey($"Bloblog-{_cntr}"));
+                await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<Bloblog>(bloblog, $"{_id}", new PartitionKey($"Bloblog-{_cntr}"));
                 string u = "";
                 string[] uls = System.Web.HttpUtility.UrlDecode(px, Encoding.UTF8).Split("/");
                 if (uls != null)
@@ -459,28 +459,28 @@ namespace TEAMModelOS.Controllers.Core
                         var queryslt = $"SELECT  value(c) FROM c WHERE c.url='{url}'";
                         if (scope.GetString().Equals("school"))
                         {
-                            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Bloblog>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
+                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Bloblog>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
                             {
                                 item.time = now;
                                 item.size = size != null && size.HasValue ? size.Value : 0;
                                 item.periodId = periodId.ValueKind.Equals(JsonValueKind.Array) ? periodId.ToObject<List<string>>() : new List<string> { "" };
                                 item.subjectId = subjectId.ValueKind.Equals(JsonValueKind.Array) ? subjectId.ToObject<List<string>>() : new List<string> { "" };
                                 item.gradeId = gradeId.ValueKind.Equals(JsonValueKind.Array) ? gradeId.ToObject<List<string>>() : new List<string> { "" };
-                                await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Bloblog>(item, item.id, new Azure.Cosmos.PartitionKey(item.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Bloblog>(item, item.id, new Azure.Cosmos.PartitionKey(item.code));
                                 bloblog.Add(item);
                                 exsit = true;
                             }
                         }
                         else if (scope.GetString().Equals("private"))
                         {
-                            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Bloblog>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
+                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Bloblog>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
                             {
                                 item.time = now;
                                 item.size = size != null && size.HasValue ? size.Value : 0;
                                 item.periodId = periodId.ValueKind.Equals(JsonValueKind.Array) ? periodId.ToObject<List<string>>() : new List<string> { "" };
                                 item.subjectId = subjectId.ValueKind.Equals(JsonValueKind.Array) ? subjectId.ToObject<List<string>>() : new List<string> { "" };
                                 item.gradeId = gradeId.ValueKind.Equals(JsonValueKind.Array) ? gradeId.ToObject<List<string>>() : new List<string> { "" };
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Bloblog>(item, item.id, new Azure.Cosmos.PartitionKey(item.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Bloblog>(item, item.id, new Azure.Cosmos.PartitionKey(item.code));
                                 bloblog.Add(item);
                                 exsit = true;
                             }
@@ -507,11 +507,11 @@ namespace TEAMModelOS.Controllers.Core
                         };
                         if (scope.GetString().Equals("school"))
                         {
-                            await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(blob, new Azure.Cosmos.PartitionKey(blob.code));
+                            await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(blob, new Azure.Cosmos.PartitionKey(blob.code));
                         }
                         else if (scope.GetString().Equals("private"))
                         {
-                            await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(blob, new Azure.Cosmos.PartitionKey(blob.code));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(blob, new Azure.Cosmos.PartitionKey(blob.code));
                         }
                         bloblog.Add(blob);
                     }
@@ -636,7 +636,7 @@ namespace TEAMModelOS.Controllers.Core
                     {
                         containerId = "Teacher";
                     }
-                    await client.GetContainer("TEAMModelOS", containerId).DeleteItemsAsync<Bloblog>(ids, $"Bloblog-{blobContainerName}");
+                    await client.GetContainer(Constant.TEAMModelOS, containerId).DeleteItemsAsync<Bloblog>(ids, $"Bloblog-{blobContainerName}");
                 }
                 catch (CosmosException   ex )
                 {

+ 0 - 2
TEAMModelOS/Controllers/Core/ImportController.cs

@@ -19,8 +19,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Context.Constant;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Module.AzureBlob.Configuration;

+ 8 - 8
TEAMModelOS/Controllers/Core/OpenApiController.cs

@@ -50,7 +50,7 @@ namespace TEAMModelOS.Controllers.Core
                 if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
                 var client = _azureCosmos.GetCosmosClient();
                 List<OpenApp> apps = new List<OpenApp>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<OpenApp>(queryText: $"select value(c) from c ",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<OpenApp>(queryText: $"select value(c) from c ",
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"OpenApp-{code}") }))
                 {
                     apps.Add(item);
@@ -134,21 +134,21 @@ namespace TEAMModelOS.Controllers.Core
                 if (string.IsNullOrEmpty(request.id))
                 {
                     request.id = Guid.NewGuid().ToString();
-                    request = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    request = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
                     if (response.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
                         var info = json.ToObject<OpenApp>();
                         request.token = info.token;
-                        request = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
                     }
                     else
                     {
-                        request = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     }
                 }
                 return Ok(new { app = request });
@@ -177,7 +177,7 @@ namespace TEAMModelOS.Controllers.Core
                 if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
                 //
                 if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id.GetString(), new PartitionKey($"OpenApp-{code}")) ;
+                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id.GetString(), new PartitionKey($"OpenApp-{code}")) ;
                 if (response.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -186,7 +186,7 @@ namespace TEAMModelOS.Controllers.Core
                     //域名  应用的id, jwtkey  学校编码
                     var auth_token = JwtAuthExtension.CreateApiToken(_option.HostName, info.id, _option.JwtSecretKey,info.name, info.auths, info.school);
                     info.token = auth_token;
-                    info = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(info, info.id, new PartitionKey($"{info.code}"));
+                    info = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(info, info.id, new PartitionKey($"{info.code}"));
                     return Ok(new { auth_token });
                 }
                 else
@@ -221,7 +221,7 @@ namespace TEAMModelOS.Controllers.Core
                 if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
                 //
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                var room = await client.GetContainer("TEAMModelOS", "School").DeleteItemAsync<Room>(id.GetString(), new PartitionKey($"OpenApp-{code}"));
+                var room = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Room>(id.GetString(), new PartitionKey($"OpenApp-{code}"));
                 return Ok();
             }
             catch (Exception ex)

+ 30 - 29
TEAMModelOS/Controllers/Item/ItemController.cs

@@ -20,6 +20,7 @@ using Microsoft.Extensions.Options;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using TEAMModelOS.Services.Common;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -63,13 +64,13 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("schoolCode", out JsonElement schoolCode)) return BadRequest();
                 if (periodId.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrEmpty(periodId.GetString()))
                 {
-                    ItemCond itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>($"{periodId}", new PartitionKey($"ItemCond-{schoolCode}"));
+                    ItemCond itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>($"{periodId}", new PartitionKey($"ItemCond-{schoolCode}"));
                     return Ok(new { itemConds = new List<ItemCond>() { itemCond } });
                 }
                 else {
                     List<ItemCond> items = new List<ItemCond>();
                     var queryslt = $"SELECT  value(c) FROM c ";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ItemCond>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ItemCond-{schoolCode}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemCond>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ItemCond-{schoolCode}") }))
                     {
                         items.Add(item);
                     }
@@ -111,9 +112,9 @@ namespace TEAMModelOS.Controllers
                     if (!itemInfo.code.Contains("Item"))
                     {
                         itemInfo.code = "Item-" + itemInfo.code;
-                        // itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
+                        // itemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
                     }
-                    var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemInfo.id, new PartitionKey($"{itemInfo.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemInfo.id, new PartitionKey($"{itemInfo.code}"));
                     if (response.Status == 200)
                     {
                         return Ok();
@@ -122,22 +123,22 @@ namespace TEAMModelOS.Controllers
                     {
                         if (itemInfo.scope.Equals("private"))
                         {
-                            itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
+                            itemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
                         }
                         else
                         {
                             // itemInfo.periodId
-                            itemInfo = await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
+                            itemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
                             ItemCond itemCond = null;
                             try {
 
-                                itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
+                                itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
                             } catch (Exception  ex) {
                                 itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
 
                             };
                             ItemService.CountItemCond(itemInfo, null, itemCond);
-                            await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
+                            await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
                         }
                     }
                 }
@@ -150,7 +151,7 @@ namespace TEAMModelOS.Controllers
                         {
                             itemInfo.code = "Item-" + itemInfo.code;
                         }
-                        itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
+                        itemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
 
                     }
                     else
@@ -159,14 +160,14 @@ namespace TEAMModelOS.Controllers
                         {
                             itemInfo.code = "Item-" + itemInfo.code;
                         }
-                        ItemInfo olditemInfo = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemInfo>( itemInfo.id, new PartitionKey($"{itemInfo.code}"));
-                        itemInfo = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
+                        ItemInfo olditemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemInfo>( itemInfo.id, new PartitionKey($"{itemInfo.code}"));
+                        itemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
                         //更新题目数量
                         ItemCond itemCond = null;
                         try
                         {
 
-                            itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
+                            itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
                         }
                         catch (Exception ex)
                         {
@@ -174,7 +175,7 @@ namespace TEAMModelOS.Controllers
 
                         };
                         ItemService.CountItemCond(itemInfo, olditemInfo, itemCond);
-                        await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
 
                     }
                 }
@@ -236,7 +237,7 @@ namespace TEAMModelOS.Controllers
                 //List<object> items = new List<object>();
                 if (scope.ToString().Equals("private"))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -251,7 +252,7 @@ namespace TEAMModelOS.Controllers
                 }
                 if (scope.ToString().Equals("school"))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -299,14 +300,14 @@ namespace TEAMModelOS.Controllers
                 await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
                 if (scope.ToString().Equals("school"))
                 {
-                    ItemInfo itemInfo = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemInfo>(id.ToString(), new PartitionKey($"{code}"));
-                    var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
+                    ItemInfo itemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemInfo>(id.ToString(), new PartitionKey($"{code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
                     //更新题目数量
                     ItemCond itemCond = null;
                     try
                     {
 
-                        itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
+                        itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
                     }
                     catch (Exception ex)
                     {
@@ -314,12 +315,12 @@ namespace TEAMModelOS.Controllers
 
                     };
                     ItemService.CountItemCond(null, itemInfo, itemCond);
-                    await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
                     return Ok(new { code = response.Status });
                 }
                 else
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
                     return Ok(new { code = response.Status });
                 }
               
@@ -411,7 +412,7 @@ namespace TEAMModelOS.Controllers
                 List<object> items = new List<object>();
                 if (scope.ToString().Equals("private"))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -426,7 +427,7 @@ namespace TEAMModelOS.Controllers
                 }
                 if (scope.ToString().Equals("school"))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -478,7 +479,7 @@ namespace TEAMModelOS.Controllers
             }
             List<object> items = new List<object>();
             var query = $"select c.id, c.question,c.useCount,c.level,c.field,c.knowledge,c.type,c.option,c.createTime from c where c.id in ({info[0..^1]})";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{school_code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{school_code}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -565,7 +566,7 @@ namespace TEAMModelOS.Controllers
                                     AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
                                     if (request[i].scope.Equals("school"))
                                     {
-                                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
                                         {
                                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -580,7 +581,7 @@ namespace TEAMModelOS.Controllers
                                     }
                                     else
                                     {
-                                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
                                         {
                                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -626,7 +627,7 @@ namespace TEAMModelOS.Controllers
                                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
                                 if (request[i].scope.Equals("school"))
                                 {
-                                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
                                     {
                                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -641,7 +642,7 @@ namespace TEAMModelOS.Controllers
                                 }
                                 else
                                 {
-                                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{request[i].code}") }))
                                     {
                                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -725,7 +726,7 @@ namespace TEAMModelOS.Controllers
                         {
                             if (item.scope .Equals("school"))
                             {
-                                var iteme = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemInfo>(item.id, new PartitionKey(item.code));
+                                var iteme = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemInfo>(item.id, new PartitionKey(item.code));
                                 if (iteme != null)
                                 {
                                     restItem.Add(iteme.Value);
@@ -734,7 +735,7 @@ namespace TEAMModelOS.Controllers
                             }
                             else if (item.scope .Equals("private"))
                             {
-                                var iteme = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ItemInfo>(item.id, new PartitionKey(item.code));
+                                var iteme = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<ItemInfo>(item.id, new PartitionKey(item.code));
                                 if (iteme != null)
                                 {
                                     restItem.Add(iteme.Value);

+ 4 - 4
TEAMModelOS/Controllers/Knowledge/KnowledgesController.cs

@@ -82,7 +82,7 @@ namespace TEAMModelOS.Controllers
             knowledge.code = $"Knowledge-{knowledge.owner}-{knowledge.subjectId}";
             StringBuilder sql = new StringBuilder($"select value(c) from c where c.periodId = '{knowledge.periodId}'");
             TEAMModelOS.SDK.Models.Cosmos.Knowledge old = null;
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<TEAMModelOS.SDK.Models.Cosmos.Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{ knowledge.code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<TEAMModelOS.SDK.Models.Cosmos.Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{ knowledge.code}") }))
             {
                 old = item;
                 break;
@@ -90,11 +90,11 @@ namespace TEAMModelOS.Controllers
             if (old != null)
             {
                 knowledge.id = old.id;
-                knowledge = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(knowledge, old.id, new PartitionKey($"{knowledge.code}"));
+                knowledge = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(knowledge, old.id, new PartitionKey($"{knowledge.code}"));
             }
             else {
                 knowledge.id = Guid.NewGuid().ToString();
-                knowledge = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(knowledge, new PartitionKey($"{knowledge.code}"));
+                knowledge = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(knowledge, new PartitionKey($"{knowledge.code}"));
             }
             var count= new { pcount = knowledge.points!=null ? knowledge.points.Count:0,bcount= knowledge.blocks!=null? knowledge.blocks.Count:0 };
             //处理知识点,知识块计数问题
@@ -188,7 +188,7 @@ namespace TEAMModelOS.Controllers
                 sql.Append($" where c.periodId = '{periodId}'");
             }
             List<TEAMModelOS.SDK.Models.Cosmos.Knowledge> knowledges = new List<SDK.Models.Cosmos.Knowledge>() ;
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<TEAMModelOS.SDK.Models.Cosmos.Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<TEAMModelOS.SDK.Models.Cosmos.Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
                 knowledges.Add(item);
             }

+ 13 - 13
TEAMModelOS/Controllers/Paper/PaperController.cs

@@ -68,10 +68,10 @@ namespace TEAMModelOS.Controllers
             await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
             if (scope.ToString().Equals("school"))
             {
-                paper = await client.GetContainer("TEAMModelOS", "School").DeleteItemAsync<Paper>(id.ToString(), new PartitionKey($"{code}"));
+                paper = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Paper>(id.ToString(), new PartitionKey($"{code}"));
             }
             else {
-                paper = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Paper>(id.ToString(), new PartitionKey($"{code}"));
+                paper = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Paper>(id.ToString(), new PartitionKey($"{code}"));
             }
 
             //IdPk items = await _azureCosmos.DeleteAsync<Paper>(request.id, request.pk);
@@ -97,7 +97,7 @@ namespace TEAMModelOS.Controllers
             var client = _azureCosmos.GetCosmosClient();
             List<object> papers = new List<object>();
             var query = $"select c.id,c.subjectCode,c.code,c.periodCode,c.name,c.itemCount,c.level,c.pointItem,c.pointScore,c.score,c.gradeCode,c.createTime,c.sheet from c where c.id = {id}";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{school_code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{school_code}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -159,7 +159,7 @@ namespace TEAMModelOS.Controllers
             {
                 sql.Append("select c.id,c.code,c.name,c.blob,c.periodId,c.gradeIds,c.subjectId,c.subjectName,c.score,c.useCount,c.scope,c.scoring,c.createTime,c.sheet from c");
                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -176,7 +176,7 @@ namespace TEAMModelOS.Controllers
             {
                 sql.Append("select c.id,c.code,c.name,c.blob,c.subjectName,c.score,c.useCount,c.scope,c.scoring ,c.createTime ,c.sheet from c");
                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -225,11 +225,11 @@ namespace TEAMModelOS.Controllers
             {               
                 if (paper.scope.Equals("private"))
                 {
-                    paper = await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
+                    paper = await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
                 }
                 else
                 {
-                    paper = await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
+                    paper = await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
                 }
                 
             }
@@ -237,11 +237,11 @@ namespace TEAMModelOS.Controllers
             {
                 if (paper.scope.Equals("private"))
                 {
-                    paper = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
+                    paper = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
                 }
                 else
                 {
-                    paper = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
+                    paper = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
                 }
             }
             return Ok(new { paper });
@@ -267,15 +267,15 @@ namespace TEAMModelOS.Controllers
                 if ($"{scope}".Equals("school"))
                 {
 
-                    Paper paper = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Paper>($"{id}", new PartitionKey($"Paper-{code}"));
+                    Paper paper = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Paper>($"{id}", new PartitionKey($"Paper-{code}"));
                     paper.sheet = $"{sheet}";
-                    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
                 }
                 else
                 {
-                    Paper paper = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Paper>($"{id}", new PartitionKey($"Paper-{code}"));
+                    Paper paper = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Paper>($"{id}", new PartitionKey($"Paper-{code}"));
                     paper.sheet = $"{sheet}";
-                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(paper, paper.id, new PartitionKey($"{paper.code}"));
                 }
                 return Ok(new { status = 200 });
             } catch (CosmosException ex)

+ 10 - 10
TEAMModelOS/Controllers/Paper/SheetConfigController.cs

@@ -59,12 +59,12 @@ namespace TEAMModelOS.Controllers.Common
                 if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
                 if ($"{scope}" .Equals("school"))
                 {
-                    SheetConfig config = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<SheetConfig>($"{id}", new PartitionKey($"SheetConfig-{code}"));
+                    SheetConfig config = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SheetConfig>($"{id}", new PartitionKey($"SheetConfig-{code}"));
                     return Ok(new { config = config, status = 200 });
                 }
                 else
                 {
-                    SheetConfig config = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SheetConfig>($"{id}", new PartitionKey($"SheetConfig-{code}"));
+                    SheetConfig config = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SheetConfig>($"{id}", new PartitionKey($"SheetConfig-{code}"));
                     return Ok(new { config = config,status=200 });
                 }
             }
@@ -215,13 +215,13 @@ namespace TEAMModelOS.Controllers.Common
                     }
                     try
                     {
-                        ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>($"{_examId}", new PartitionKey($"{code}"));
+                        ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>($"{_examId}", new PartitionKey($"{code}"));
                         var ps = exam.papers.Where(p => p.id == $"{_paperId}").FirstOrDefault();
                         if (ps != null)
                         {
                             if (!string.IsNullOrEmpty(ps.sheet))
                             {
-                                await client.GetContainer("TEAMModelOS", tbname).DeleteItemStreamAsync($"{ps.sheet}", new PartitionKey(sheet.code));
+                                await client.GetContainer(Constant.TEAMModelOS, tbname).DeleteItemStreamAsync($"{ps.sheet}", new PartitionKey(sheet.code));
                             }
                             sheet.id = await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
                             exam.papers.ForEach(x =>
@@ -231,7 +231,7 @@ namespace TEAMModelOS.Controllers.Common
                                     x.sheet = sheet.id;
                                 }
                             });
-                            exam = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(exam, $"{_examId}", new PartitionKey($"{code}"));
+                            exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(exam, $"{_examId}", new PartitionKey($"{code}"));
                         }
                         else
                         {
@@ -250,12 +250,12 @@ namespace TEAMModelOS.Controllers.Common
                     string code = sheet.scope.Equals("school", StringComparison.OrdinalIgnoreCase) ? $"Paper-{sheet.school}": $"Paper-{sheet.creatorId}";
                     try
                     {
-                        Paper paper = await client.GetContainer("TEAMModelOS", tbname).ReadItemAsync<Paper>($"{_paperId}", new PartitionKey($"{code}"));
+                        Paper paper = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<Paper>($"{_paperId}", new PartitionKey($"{code}"));
                         if (string.IsNullOrEmpty(paper.sheet))
                         {
                             sheet.id =await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
                             paper.sheet = sheet.id;
-                            paper = await client.GetContainer("TEAMModelOS", tbname).ReplaceItemAsync<Paper>(paper, $"{_paperId}", new PartitionKey($"{code}"));
+                            paper = await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<Paper>(paper, $"{_paperId}", new PartitionKey($"{code}"));
                         }
                         else
                         {
@@ -283,7 +283,7 @@ namespace TEAMModelOS.Controllers.Common
                     sheet.id = await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
 
                 }
-                sheet = await client.GetContainer("TEAMModelOS", tbname).UpsertItemAsync(sheet, new PartitionKey($"{sheet.code}"));
+                sheet = await client.GetContainer(Constant.TEAMModelOS, tbname).UpsertItemAsync(sheet, new PartitionKey($"{sheet.code}"));
                 return Ok(new { config = sheet, status=200 });
             }
             catch (CosmosException ex)
@@ -316,11 +316,11 @@ namespace TEAMModelOS.Controllers.Common
                 List<string> idslist = ids.ToObject<List<string>>();
                 if ($"{scope}" .Equals("school"))
                 {
-                    await client.GetContainer("TEAMModelOS", "School").DeleteItemsStreamAsync(idslist, $"SheetConfig-{code}");
+                    await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsStreamAsync(idslist, $"SheetConfig-{code}");
                 }
                 else
                 {
-                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(idslist, $"SheetConfig-{code}");
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemsStreamAsync(idslist, $"SheetConfig-{code}");
                 }
                 return Ok(new { status = 404 });
             }

+ 31 - 30
TEAMModelOS/Controllers/School/ClassController.cs

@@ -1,4 +1,5 @@
 using Azure.Cosmos;
+using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -51,7 +52,7 @@ namespace TEAMModelOS.Controllers
                 if (string.IsNullOrEmpty(classroom.id))
                 {
                     List<string> resultIds = new List<string>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.periodId = '{classroom.periodId}' and c.no = '{classroom.no}' and c.year = '{classroom.year}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(classroom.code) }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.periodId = '{classroom.periodId}' and c.no = '{classroom.no}' and c.year = '{classroom.year}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(classroom.code) }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -69,10 +70,10 @@ namespace TEAMModelOS.Controllers
                         return Ok(new { error = ResponseCode.DATA_EXIST, V = "班级编码已经存在!" });
                     }
                     classroom.id = Guid.NewGuid().ToString();
-                    classroom = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(classroom, new PartitionKey(classroom.code));
+                    classroom = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(classroom, new PartitionKey(classroom.code));
                 }
                 else {
-                    var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classroom.id, new PartitionKey(classroom.code));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(classroom.id, new PartitionKey(classroom.code));
                     if (response.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -80,7 +81,7 @@ namespace TEAMModelOS.Controllers
                         if (!@class.no.Equals(classroom.no))
                         {
                             List<string> resultIds = new List<string>();
-                            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.year = '{classroom.year}' and c.no = '{classroom.no}' and c.periodId = '{classroom.periodId}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(classroom.code) }))
+                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.year = '{classroom.year}' and c.no = '{classroom.no}' and c.periodId = '{classroom.periodId}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(classroom.code) }))
                             {
                                 using var document = await JsonDocument.ParseAsync(item.ContentStream);
                                 if (document.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -98,11 +99,11 @@ namespace TEAMModelOS.Controllers
                                 return Ok(new { error = ResponseCode.DATA_EXIST, V = "班级编码已经存在!" });
                             }
                         }
-                        classroom = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom, classroom.id, new PartitionKey(classroom.code));
+                        classroom = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(classroom, classroom.id, new PartitionKey(classroom.code));
                     }
                     else
                     {
-                        classroom = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(classroom, new PartitionKey(classroom.code));
+                        classroom = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(classroom, new PartitionKey(classroom.code));
                     }
                 }
                 return Ok(new { classroom });
@@ -129,14 +130,14 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 foreach (Student stu in students)
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "Student").ReadItemStreamAsync(stu.id, new PartitionKey($"{stu.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemStreamAsync(stu.id, new PartitionKey($"{stu.code}"));
                     if (response.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
                         Student stuInfo = json.ToObject<Student>();
                         stuInfo.groupId = stu.groupId;
                         stuInfo.groupName = stu.groupName;
-                        await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(stuInfo, stuInfo.id, new PartitionKey($"{stuInfo.code}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(stuInfo, stuInfo.id, new PartitionKey($"{stuInfo.code}"));
                     }
                 }
                 /*Class classroom = new Class();
@@ -144,13 +145,13 @@ namespace TEAMModelOS.Controllers
                 //if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 classroom = room.ToObject<Class>();
                
-                var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classroom.id, new PartitionKey($"{classroom.code}"));
+                var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(classroom.id, new PartitionKey($"{classroom.code}"));
                 if (sresponse.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
                     Class classroom1 = json.ToObject<Class>();
                     //classroom1.students = classroom.students;
-                    var response = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom.code}"));
                 }*/
                 return Ok(new { students });
             }
@@ -187,7 +188,7 @@ namespace TEAMModelOS.Controllers
                     dict.Remove("school_code");
                 }
                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -259,7 +260,7 @@ namespace TEAMModelOS.Controllers
                 //List<object> scList = new List<object>();
                 List<object> suList = new List<object>();
                 List<(string id, string name, string pic, string code, string classId ,string groupId, string groupName, string no)> listStudent = new List<(string id, string name, string pic, string code, string classId, string groupId, string groupName, string no)>();
-                //var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(ids[i].GetString(), new PartitionKey($"Class-{schoolId}"));
+                //var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(ids[i].GetString(), new PartitionKey($"Class-{schoolId}"));
                 string className = "";
                 /*                if (response.Status == 200)
                                 {
@@ -268,7 +269,7 @@ namespace TEAMModelOS.Controllers
                                     className = @class.name;
                                 }*/
                 List<(string id, string name)> listClassList = new List<(string id,string name)>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
                                     queryText: $"select c.id,c.name from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -283,7 +284,7 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
                     queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.classId in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -327,7 +328,7 @@ namespace TEAMModelOS.Controllers
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
                     List<StuList> stuLists = new List<StuList>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
                     {
                         stuLists.Add(item);
                     }
@@ -347,7 +348,7 @@ namespace TEAMModelOS.Controllers
 
                         }
                         //根据学生ID  CODE获取学生基本信息
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
                        queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.id in ({string.Join(",", stuInfo.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -390,7 +391,7 @@ namespace TEAMModelOS.Controllers
                 {
                     //处理发布对象为自选名单(个人)
                     List<StuList> stuLists1 = new List<StuList>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                     {
                         stuLists1.Add(item);
                     }
@@ -401,7 +402,7 @@ namespace TEAMModelOS.Controllers
                             foreach (Students students in stuList.students)
                             {
                                 //根据学生ID  CODE获取学生基本信息
-                                await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(
+                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
                                queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.id = '{students.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{students.code}") }))
                                 {
                                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -482,11 +483,11 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
 /*                if (scope.ToString().Equals("school"))
                 {*/
-                    classroom = await client.GetContainer("TEAMModelOS", "School").DeleteItemAsync<Class>(id.ToString(), new PartitionKey($"Class-{school_code}"));
+                    classroom = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Class>(id.ToString(), new PartitionKey($"Class-{school_code}"));
                     //List<TeacherCourse> classes = new List<TeacherCourse>();
 
-                    //await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"CourseManagement-{school_code}"));
-                    //await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.classes where A0.id = '{id}'"))
+                    //await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"CourseManagement-{school_code}"));
+                    //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.classes where A0.id = '{id}'"))
                     //{
                     //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -510,18 +511,18 @@ namespace TEAMModelOS.Controllers
                     //    }
                     //    if (flag)
                     //    {
-                    //        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(classes[i], classes[i].id, new PartitionKey($"{classes[i].code}"));
+                    //        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(classes[i], classes[i].id, new PartitionKey($"{classes[i].code}"));
                     //    }
                     //}
                     List<Student> students = new List<Student>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<Student>(queryText: $"select *  from c where c.classId='{id}' ", requestOptions:new QueryRequestOptions { PartitionKey= new PartitionKey ($"Base-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select *  from c where c.classId='{id}' ", requestOptions:new QueryRequestOptions { PartitionKey= new PartitionKey ($"Base-{code}") }))
                     {
                         item.classId = "";
                         students.Add(item);
                     }
                     List<Task<ItemResponse<Student>>> tasks = new List<Task<ItemResponse<Student>>>();
                     foreach (var stu in students) {
-                        tasks.Add(client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(stu, stu.id, new PartitionKey(($"Base-{code}"))));
+                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(stu, stu.id, new PartitionKey(($"Base-{code}"))));
                     }
                     await Task.WhenAll(tasks);
                 //}
@@ -552,7 +553,7 @@ namespace TEAMModelOS.Controllers
             /*List<VoteRecord> sc = await _azureCosmos.FindByDict<VoteRecord>(request);
             await _azureCosmos.DeleteAll<VoteRecord>(sc);
             return Ok();*/
-            //await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync("", new PartitionKey($"Class-{code}"));
+            //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync("", new PartitionKey($"Class-{code}"));
         }
 
         [ProducesDefaultResponseType]
@@ -585,7 +586,7 @@ namespace TEAMModelOS.Controllers
 
                 // [取得DB資料]
                 var client = _azureCosmos.GetCosmosClient();
-                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school_code, new PartitionKey("Product"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school_code, new PartitionKey("Product"));
                 var error = 0;
 
                 if (response.Status == 200)
@@ -616,7 +617,7 @@ namespace TEAMModelOS.Controllers
                             {
                                 updDeviceBound.classId = null;
                             }
-                            if (error == 0) await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolProduct>(schoolProductItem, school_code, new PartitionKey("Product"));
+                            if (error == 0) await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolProduct>(schoolProductItem, school_code, new PartitionKey("Product"));
                         }
 
                     }
@@ -648,7 +649,7 @@ namespace TEAMModelOS.Controllers
 
                 // [取得DB資料]
                 var client = _azureCosmos.GetCosmosClient();
-                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school_code, new PartitionKey("Product"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school_code, new PartitionKey("Product"));
 
                 if (response.Status == 200)
                 {
@@ -670,7 +671,7 @@ namespace TEAMModelOS.Controllers
 
                     }
 
-                    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolProduct>(schoolProductItem, school_code, new PartitionKey("Product"));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolProduct>(schoolProductItem, school_code, new PartitionKey("Product"));
                 }
 
                 return Ok(new { error = 0 });
@@ -698,7 +699,7 @@ namespace TEAMModelOS.Controllers
                     info += ids[i].ToJsonString() + ",";
                 }
                 List<object> ClassName = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
                     queryText: $"select c.id,c.name from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);

+ 6 - 7
TEAMModelOS/Controllers/School/CorrectController.cs

@@ -11,7 +11,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
@@ -72,7 +71,7 @@ namespace TEAMModelOS.Controllers
                 
                 //活动分区
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<CorrectTask>(queryText: $"select value(c) from c ",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<CorrectTask>(queryText: $"select value(c) from c ",
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"CorrectTask-{code}") }))
                 {
                     tasks.Add(item);
@@ -149,11 +148,11 @@ namespace TEAMModelOS.Controllers
                     {
                         request.progress = "going";
                     }
-                    request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
                     if (response.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -171,7 +170,7 @@ namespace TEAMModelOS.Controllers
                             request.progress = "going";
                         }
                         request.progress = info.progress;
-                        request = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
                     }
                     else
                     {
@@ -183,7 +182,7 @@ namespace TEAMModelOS.Controllers
                         {
                             request.progress = "going";
                         }
-                        request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     }
                 }
                 return Ok(new { vote = request });
@@ -215,7 +214,7 @@ namespace TEAMModelOS.Controllers
                 //活动分区
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                Correct correct = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Correct>(id.GetString(), new PartitionKey($"Correct-{code}"));
+                Correct correct = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Correct>(id.GetString(), new PartitionKey($"Correct-{code}"));
                 return Ok(new { correct });
             }
             catch (CosmosException ex){

+ 78 - 78
TEAMModelOS/Controllers/School/CourseController.cs

@@ -26,6 +26,7 @@ using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using TEAMModelOS.Filter;
 using Azure.Storage.Blobs.Models;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -87,7 +88,7 @@ namespace TEAMModelOS.Controllers
                 {
                     if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                     {
-                        var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
+                        var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
                         if (response.Status == 200)
                         {
                             return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
@@ -97,12 +98,12 @@ namespace TEAMModelOS.Controllers
                             CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = course.school, creatorId = course.creatorId };
                             courseChange.addClass = course.schedule.Select(x => x.classId).ToList();
                             courseChange.addList = course.schedule.Select(x => x.stulist).ToList();
-                            course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
+                            course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
                         }
                     }
                     else
                     {
-                        var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
+                        var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
                         if (response.Status == 200)
                         {
                             return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
@@ -116,7 +117,7 @@ namespace TEAMModelOS.Controllers
                             messageBlob.ApplicationProperties.Add("name", "Course");
                             var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
                             await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
-                            course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
+                            course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
                         }
                     }
                 }
@@ -125,7 +126,7 @@ namespace TEAMModelOS.Controllers
                     if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                     {
 
-                        Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
+                        Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
                         CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = code };
                         var oldCls = odlCourse.schedule.Select(x => x.classId).ToList();
                         var oldLst = odlCourse.schedule.Select(x => x.stulist).ToList();
@@ -167,7 +168,7 @@ namespace TEAMModelOS.Controllers
                         courseChange.addList = addLst;
                         courseChange.delClass = delCls;
                         courseChange.delList = delLst;
-                        course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
+                        course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
                         var messageBlob = new ServiceBusMessage(courseChange.ToJsonString()); ;
                         messageBlob.ApplicationProperties.Add("name", "Course");
                         var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
@@ -175,7 +176,7 @@ namespace TEAMModelOS.Controllers
                     }
                     else
                     {
-                        Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
+                        Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
                         CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, creatorId = code };
                         var oldCls = odlCourse.schedule.Select(x => x.classId).ToList();
                         var oldLst = odlCourse.schedule.Select(x => x.stulist).ToList();
@@ -217,7 +218,7 @@ namespace TEAMModelOS.Controllers
                         courseChange.addList = addLst;
                         courseChange.delClass = delCls;
                         courseChange.delList = delLst;
-                        course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
+                        course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
                         var messageBlob = new ServiceBusMessage(courseChange.ToJsonString()); ;
                         messageBlob.ApplicationProperties.Add("name", "Course");
                         var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
@@ -249,7 +250,7 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 var query = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule join A1 in A0.time where A0.teacherId = '{tId}'and A1.id = '{timeId}' and A1.week = '{week}' ";
                 List<Schedule> teachers = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
                 {
                     using var jsonCheck = await JsonDocument.ParseAsync(item.ContentStream);
                     if (jsonCheck.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -268,7 +269,7 @@ namespace TEAMModelOS.Controllers
                 {
                     var queryClass = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule join A1 in A0.time where A1.id = '{timeId}' and A1.week = '{week}' and (A0.classId = '{cId}' or A0.stulist = '{cId}')";
                     List<Schedule> courses = new();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
                     {
                         using var jsonCheck = await JsonDocument.ParseAsync(item.ContentStream);
                         if (jsonCheck.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -325,7 +326,7 @@ namespace TEAMModelOS.Controllers
 
                 if (!string.IsNullOrEmpty(school) && !string.IsNullOrEmpty($"{_studentId}"))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryNo,
                           requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
                     {
                         using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
@@ -355,14 +356,14 @@ namespace TEAMModelOS.Controllers
                     jwt.Payload.TryGetValue("picture", out object picture);
                     try
                     {
-                        Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
+                        TmdUser tmduser = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<TmdUser>(id, new PartitionKey("Base"));
                     }
                     catch (CosmosException ex)
                     {
                         if (ex.Status == 404)
                         {
                             //如果沒有,則初始化Teacher基本資料到Cosmos
-                            Teacher teacher = new Teacher
+                            TmdUser tmduser = new TmdUser
                             {
                                 id = id,
                                 pk = "Base",
@@ -370,16 +371,15 @@ namespace TEAMModelOS.Controllers
                                 name = name?.ToString(),
                                 picture = picture?.ToString(),
                                 //创建账号并第一次登录IES5则默认赠送1G
-                                size = 1,
                                 defaultSchool = null,
-                                schools = new List<Teacher.School>(),
+                                schools = new List<TmdUser.School>(),
                             };
                             var container = _azureStorage.GetBlobContainerClient(id);
                             await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
-                            teacher = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
+                            tmduser = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync<TmdUser>(tmduser, new PartitionKey("Base"));
                         }
                     }
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
                        requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
                     {
                         using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
@@ -438,7 +438,7 @@ namespace TEAMModelOS.Controllers
                 json.TryGetProperty("tmdId", out JsonElement _tmdId);
                 if (!string.IsNullOrEmpty(school))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryNo,
                           requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
                     {
                         using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
@@ -459,7 +459,7 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
                 {
                     using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
@@ -570,7 +570,7 @@ namespace TEAMModelOS.Controllers
                     {
                         var queryNo = $"SELECT  c.no  FROM c where  c.no ='{stuList.no}'";
                         List<string> noStus = new();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryNo,
                                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{stuList.code}") }))
                         {
                             using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
@@ -584,7 +584,7 @@ namespace TEAMModelOS.Controllers
                                 }
                             }
                         }
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
                                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey("StuList") }))
                         {
                             using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
@@ -632,7 +632,7 @@ namespace TEAMModelOS.Controllers
                     };
                     var query = $"SELECT distinct value(c)  FROM c where  c.id='{stuList.id}'";
                     List<StuList> odlStus = new List<StuList>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: query,
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: query,
                             requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{stuList.school}") }))
                     {
                         odlStus.Add(item);
@@ -694,7 +694,7 @@ namespace TEAMModelOS.Controllers
                             await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
                         }
                     }
-                    stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").UpsertItemAsync(stuList, new PartitionKey($"StuList-{stuList.school}"));
+                    stuList = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(stuList, new PartitionKey($"StuList-{stuList.school}"));
                 }
                 else
                 {
@@ -714,7 +714,7 @@ namespace TEAMModelOS.Controllers
 
                     var query = $"SELECT distinct value(c)  FROM c    where  c.id='{stuList.id}'";
                     List<StuList> odlStus = new List<StuList>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: query,
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: query,
                             requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
                     {
                         odlStus.Add(item);
@@ -781,7 +781,7 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                     stuList.code = "StuList";
-                    stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stuList, new PartitionKey($"StuList"));
+                    stuList = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(stuList, new PartitionKey($"StuList"));
                 }
                 return stuList;
             }
@@ -809,7 +809,7 @@ namespace TEAMModelOS.Controllers
                 var query = $"select c.id,c.name,c.students,c.tmids,c.periodId from c";
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -826,7 +826,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -872,7 +872,7 @@ namespace TEAMModelOS.Controllers
                 var query = $"select c.id,c.name,c.students,c.tmids,c.no,c.code,c.scope,c.school,c.creatorId from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -889,7 +889,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -931,7 +931,7 @@ namespace TEAMModelOS.Controllers
                 {
                     /*List<string> classIds = new List<string>();
                     var query = $"select c.id from c join A0 in c.schedule where A0.teacherId = '{id}'";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -949,12 +949,12 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                     }*/
-                    await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuList-{code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuList-{code}"));
                 }
                 else
                 {
-                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuLis"));
-                    /*await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuLis"));
+                    /*await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1018,7 +1018,7 @@ namespace TEAMModelOS.Controllers
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
 
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
                     {
                         //continuationToken = item.GetContinuationToken();
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1035,7 +1035,7 @@ namespace TEAMModelOS.Controllers
                 else
                 {
 
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
                     {
                         //continuationToken = item.GetContinuationToken();
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1051,7 +1051,7 @@ namespace TEAMModelOS.Controllers
                     if (requert.TryGetProperty("schoolId", out JsonElement schoolId))
                     {
                         var querySchool = $"select distinct c.code,c.id,c.no,c.name,c.period,c.subject,c.scope from c join A0 in c.schedule where A0.teacherId = '{code}'";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
                         {
                             //continuationToken = item.GetContinuationToken();
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1106,7 +1106,7 @@ namespace TEAMModelOS.Controllers
                 List<(string id, string name,string scope,List<(string id, string name, string type)> stuName)> ps = new();
                 var query = $"select c.id,c.name,c.scope from c";
 
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1124,12 +1124,12 @@ namespace TEAMModelOS.Controllers
                     List<(string id, string name,string type)> sName = new();
                     List<Schedule> schedules = new List<Schedule>();
                     var querySc = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule where c.id = '{s}'";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
                     {
                         schedules.Add(item);
                     }
                     var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1147,7 +1147,7 @@ namespace TEAMModelOS.Controllers
                 if (requert.TryGetProperty("schoolId", out JsonElement schoolId))
                 {
                     var querySchool = $"select distinct c.code,c.id,c.no,c.name,c.scope from c join A0 in c.schedule where A0.teacherId = '{code}'";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1164,13 +1164,13 @@ namespace TEAMModelOS.Controllers
                     {
                         List<Schedule> schedules = new List<Schedule>();
                         var querySc = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule where c.id = '{s}' and A0.teacherId = '{code}'";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
                         {
                             schedules.Add(item);
                         }
                         List<(string id, string name,string type)> sName = new();
                         var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId.GetString()}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId.GetString()}") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
                             if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1184,7 +1184,7 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                         var queryClass = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.classId}'"))})";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId.GetString()}") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId.GetString()}") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
                             if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1245,7 +1245,7 @@ namespace TEAMModelOS.Controllers
                 //List<(string id, string code, string name)> listCourse = new List<(string id, string code, string name)>();
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
                     {
                         courseList.Add(item);
                     }
@@ -1253,7 +1253,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
                     {
                         courseList.Add(item);
                     }
@@ -1277,7 +1277,7 @@ namespace TEAMModelOS.Controllers
                         scheduleExtobj.teacherId = schedule.teacherId;
                         if (!string.IsNullOrEmpty(schedule.teacherId))
                         {
-                            var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(schedule.teacherId, new PartitionKey("Base"));
+                            var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(schedule.teacherId, new PartitionKey("Base"));
                             if (response.Status == 200)
                             {
                                 using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -1329,7 +1329,7 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 if (scope.ToString().Equals("school"))
                 {
-                    Course course = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
+                    Course course = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
                     CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = course.school, creatorId = course.creatorId };
                     courseChange.delClass = course.schedule.Select(x => x.classId).ToList();
                     courseChange.delList = course.schedule.Select(x => x.stulist).ToList();
@@ -1337,11 +1337,11 @@ namespace TEAMModelOS.Controllers
                     messageBlob.ApplicationProperties.Add("name", "Course");
                     var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
                     await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
-                    await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
                 }
                 else
                 {
-                    Course course = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
+                    Course course = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
                     CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = course.school, creatorId = course.creatorId };
                     courseChange.delClass = course.schedule.Select(x => x.classId).ToList();
                     courseChange.delList = course.schedule.Select(x => x.stulist).ToList();
@@ -1349,7 +1349,7 @@ namespace TEAMModelOS.Controllers
                     messageBlob.ApplicationProperties.Add("name", "Course");
                     var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
                     await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
-                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
                 }
                 return Ok(new { id });
             }
@@ -1381,11 +1381,11 @@ namespace TEAMModelOS.Controllers
 
                 if (request.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
-                    List<Response> res = await client.GetContainer("TEAMModelOS", "School").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
+                    List<Response> res = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
                 }
                 else
                 {
-                    List<Response> res = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
+                    List<Response> res = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
                 }
 
                 return Ok(new { ids = request.ids });
@@ -1417,14 +1417,14 @@ namespace TEAMModelOS.Controllers
         //        /*                if (requert.scope.Equals) { 
 
         //                        }*/
-        //        var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(requert.id, new PartitionKey($"CourseManagement-{code}"));
+        //        var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(requert.id, new PartitionKey($"CourseManagement-{code}"));
         //        if (response.Status == 200)
         //        {
-        //            course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(requert, requert.id, new PartitionKey($"CourseManagement-{code}"));
+        //            course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(requert, requert.id, new PartitionKey($"CourseManagement-{code}"));
         //        }
         //        else
         //        {
-        //            course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(requert, new PartitionKey($"CourseManagement-{code}"));
+        //            course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(requert, new PartitionKey($"CourseManagement-{code}"));
         //        }
         //        return Ok(new { course });
         //    }
@@ -1464,7 +1464,7 @@ namespace TEAMModelOS.Controllers
         //        dict.Remove("code");
         //    }
         //    AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
-        //    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
+        //    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
         //    {
         //        using var json = await JsonDocument.ParseAsync(item.ContentStream);
         //        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1487,7 +1487,7 @@ namespace TEAMModelOS.Controllers
         //    var client = _azureCosmos.GetCosmosClient();
         //    List<object> courses = new List<object>();
         //    var query = $"select c.code,c.id,c.name,A0.course.id courseId,A0.course.name courseName ,A0.course.notice notice ,A1,c.scope,c.teacher from c  join A0  in c.courses join A1  in A0.teachers where A1.id = '{id}' ";
-        //    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
+        //    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
         //    {
         //        using var json = await JsonDocument.ParseAsync(item.ContentStream);
         //        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1516,7 +1516,7 @@ namespace TEAMModelOS.Controllers
             if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
             {
                 var query = $"select distinct value(c) from c join A0 in c.schedule where A0.room = '{id}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
                 {
                     courseList.Add(item);
                 }
@@ -1524,7 +1524,7 @@ namespace TEAMModelOS.Controllers
             else
             {
                 var query = $"select distinct value(c) from c join A0 in c.schedule where A0.room = '{id}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
                 {
                     courseList.Add(item);
                 }
@@ -1540,7 +1540,7 @@ namespace TEAMModelOS.Controllers
             List<(string id, string name)> teachers = new List<(string id, string name)>();
             if (teacherIds.Count > 0)
             {
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
                                     queryText: $"select c.id,c.name from c where c.id in ({ string.Join(",", teacherIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1610,7 +1610,7 @@ namespace TEAMModelOS.Controllers
         //    dict.Add("courses[*].teachers[*].id", teachers.id);
         //    //dict.Add("id", classroom.id);
         //    AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
-        //    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
+        //    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
         //    {
         //        using var json = await JsonDocument.ParseAsync(item.ContentStream);
         //        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1628,7 +1628,7 @@ namespace TEAMModelOS.Controllers
         //            if (courseManagements[i].courses[j].course.id.Equals(courseId.ToString()))
         //            {
         //                courseManagements[i].courses[j].course.notice = notice.ToString();
-        //                await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(courseManagements[i], courseManagements[i].id, new PartitionKey($"{courseManagements[i].code}"));
+        //                await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(courseManagements[i], courseManagements[i].id, new PartitionKey($"{courseManagements[i].code}"));
         //                break;
         //            }
         //        }
@@ -1656,14 +1656,14 @@ namespace TEAMModelOS.Controllers
                 course.code = typeof(Course).Name + "-" + course.code;
                 if (option.ToString().Equals("insert"))
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
                     if (response.Status == 200)
                     {
                         return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
                     }
                     else
                     {
-                        course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
+                        course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
 
                     }
                 }
@@ -1683,12 +1683,12 @@ namespace TEAMModelOS.Controllers
                                 //cla.scope = classSimple.scope;
                                 cla.teacher.id = classSimple.teacher.id;
                                 cla.teacher.name = classSimple.teacher.name;
-                                await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(cla, new PartitionKey($"Class-{code}"));
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(cla, new PartitionKey($"Class-{code}"));
                             }
                             else
                             {
 
-                                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
+                                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
                                 if (response.Status == 200)
                                 {
                                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -1708,12 +1708,12 @@ namespace TEAMModelOS.Controllers
                                     }*/
                                     newCla.teacher.id = classSimple.teacher.id;
                                     newCla.teacher.name = classSimple.teacher.name;
-                                    await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
+                                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
                                     classSimple.code = code;
                                 }
                                 else
                                 {
-                                    Class cla = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Class>(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
+                                    Class cla = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Class>(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
                                     Class newCla = new Class();
                                     newCla.id = cla.id;
                                     newCla.code = cla.pk + "-" + code;
@@ -1723,12 +1723,12 @@ namespace TEAMModelOS.Controllers
                                     //newCla.students = cla.students;
                                     newCla.teacher.id = classSimple.teacher.id;
                                     newCla.teacher.name = classSimple.teacher.name;
-                                    await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
+                                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
                                 }
                             }
                         }
                     }
-                    course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
+                    course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
                 }
                 return Ok(new { course });
             }
@@ -1748,7 +1748,7 @@ namespace TEAMModelOS.Controllers
             var client = _azureCosmos.GetCosmosClient();
             List<object> courses = new List<object>();
             var query = $"select c.code,c.id,c.name,c.subjectId,c.periodId,c.scope,c.notice,c.classes from c ";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1781,7 +1781,7 @@ namespace TEAMModelOS.Controllers
             List<string> classIds = new List<string>();
             List<(string id, string scope)> listClassInfo = new List<(string id, string scope)>();
             var query = $"select distinct c.scope,A0.stulist id from c join A0 in c.schedule where A0.teacherId = '{id}'";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1800,7 +1800,7 @@ namespace TEAMModelOS.Controllers
                 }
             }
             var querySchool = $"select distinct c.scope,A0.classId id from c join A0 in c.schedule where A0.teacherId = '{id}'";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1820,7 +1820,7 @@ namespace TEAMModelOS.Controllers
             }
             //List<object> coursesBySchool = new List<object>();
             //var queryBySchool = $"select distinct c.id,c.name,c.scope from c  join A0  in c.courses join A1  in A0.teachers where A1.id = '{id}' ";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1838,7 +1838,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
             }
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1860,7 +1860,7 @@ namespace TEAMModelOS.Controllers
             if (classIds.Count > 0)
             {
                 //List<(string id, string name)> listClassList = new List<(string id, string name)>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
                                     queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1876,7 +1876,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
 
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
                                     queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1892,7 +1892,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
 
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
                                     queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);

+ 7 - 7
TEAMModelOS/Controllers/School/RoomController.cs

@@ -50,19 +50,19 @@ namespace TEAMModelOS.Controllers
                 if (string.IsNullOrEmpty(request.id))
                 {
                     request.id = Guid.NewGuid().ToString();
-                    request = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    request = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else {
-                    var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
                     if (response.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
                         var info = json.ToObject<Room>();
-                        request = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
                     }
                     else
                     {
-                        request = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     }
                 }
                 return Ok(new { room= request });
@@ -88,7 +88,7 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
                 var client = _azureCosmos.GetCosmosClient();
                 List<Room> rooms = new List<Room>() ;
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ",
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Room-{code}") })) {
                     rooms.Add(item);
                 }
@@ -116,7 +116,7 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
                 //
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                Room room = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Room>(id.GetString(), new PartitionKey($"Room-{code}"));
+                Room room = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Room>(id.GetString(), new PartitionKey($"Room-{code}"));
                 if (room != null)
                 {
 
@@ -149,7 +149,7 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
                 //
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                var room= await client.GetContainer("TEAMModelOS", "School").DeleteItemAsync<Room>(id.GetString(), new PartitionKey($"Room-{code}"));
+                var room= await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Room>(id.GetString(), new PartitionKey($"Room-{code}"));
                 return Ok();
             }
             catch (Exception ex)

+ 17 - 17
TEAMModelOS/Controllers/School/SchoolController.cs

@@ -63,7 +63,7 @@ namespace TEAMModelOS.Controllers
             {
                 TEAMModelOS.SDK.Models.School schoolInfo = new TEAMModelOS.SDK.Models.School();
                 var client = _azureCosmos.GetCosmosClient();
-                var schoolContainer = client.GetContainer("TEAMModelOS", "School");
+                var schoolContainer = client.GetContainer(Constant.TEAMModelOS, "School");
                 var response = await schoolContainer.ReadItemStreamAsync(requert.id, new PartitionKey($"Base"));
                 if (response.Status == 200)
                 {
@@ -126,7 +126,7 @@ namespace TEAMModelOS.Controllers
             var client = _azureCosmos.GetCosmosClient();
             List<TEAMModelOS.SDK.Models.School> schools = new List<TEAMModelOS.SDK.Models.School>();
             var query = $"select c.id,c.pk,c.code, c.name,c.region,c.province,c.city,c.timeZone,c.picture,c.size,c.period,c.campuses from c where c.id ='{school_code}'";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -162,7 +162,7 @@ namespace TEAMModelOS.Controllers
         {
             var client = _azureCosmos.GetCosmosClient();
             List<object> schools = new List<object>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.code, c.name, c.region, c.province, c.city, c.address, c.picture FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.code, c.name, c.region, c.province, c.city, c.address, c.picture FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -188,7 +188,7 @@ namespace TEAMModelOS.Controllers
             if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
 
             var client = _azureCosmos.GetCosmosClient();
-            var schoolContainer = client.GetContainer("TEAMModelOS", "School");
+            var schoolContainer = client.GetContainer(Constant.TEAMModelOS, "School");
             //取得學校學制、年級、教室
             List<object> classes = new List<object>();
             await foreach (var item in schoolContainer.GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.name, c.gradeId FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
@@ -244,7 +244,7 @@ namespace TEAMModelOS.Controllers
         public async Task<IActionResult> GetSchoolProductInfo(JsonElement request)
         {
             if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
-            var clientContainer = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School");
+            var clientContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School");
 
             List<deviceBoundRich> serialDeviceUpdList = new List<deviceBoundRich>(); //要更新DB的序號內容
             List<SerialInfoBaseWithdeviceBoundExt> serial = new List<SerialInfoBaseWithdeviceBoundExt>(); //最後要輸出的序號結果
@@ -680,7 +680,7 @@ namespace TEAMModelOS.Controllers
         {
             if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
 
-            var clientContainer = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School");
+            var clientContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School");
             var response = await clientContainer.ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Product"));
             int total = 0; //可分配總數
             int staNum = 0; //固定分配數
@@ -841,7 +841,7 @@ namespace TEAMModelOS.Controllers
                  */
                 int status = 0;
                 string err = "";
-                var clientContainer = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School");
+                var clientContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School");
                 var response = await clientContainer.ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Product"));
                 if (response.Status == 200)
                 {
@@ -929,7 +929,7 @@ namespace TEAMModelOS.Controllers
             var redisClient = _azureRedis.GetRedisClient(redisAclassoneDbNum);
             string keys = school_code.GetString() + ":" + "AclassOne" + ":" + "dynamic";
             string keyd = school_code.GetString() + ":" + "AclassOne" + ":" + "dynamicIds";
-            var clientContainer = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School");
+            var clientContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School");
             var response = await clientContainer.ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Product"));
             if (response.Status == 200)
             {
@@ -1060,7 +1060,7 @@ namespace TEAMModelOS.Controllers
                 }
                 long  avaliable = this.baseSpaceSize; // (G) 目前學校申請空間總數
                 long teacherSpace = 0; // 教師可設定的空間量(G)
-                School school = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(school_code, new PartitionKey("Base"));
+                School school = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school_code, new PartitionKey("Base"));
                 if (school.size <= 0) {
                     school.size = baseSpaceSize;
                 }
@@ -1103,7 +1103,7 @@ namespace TEAMModelOS.Controllers
 
                         queryText = $"select * from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
 
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
                         {
                             using var jsoncm = await JsonDocument.ParseAsync(item.ContentStream);
                             if (jsoncm.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0 && count.GetInt16() == list.GetArrayLength())
@@ -1122,7 +1122,7 @@ namespace TEAMModelOS.Controllers
                                     teacher.size = Convert.ToInt32(obj.GetProperty("size").ToString());
 
                                     // 修改DB裡Teacher的size
-                                    var response = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(teacher.id, new PartitionKey("Base"));
+                                    var response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(teacher.id, new PartitionKey("Base"));
                                     if (response.Status == 200)
                                     {
                                         var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -1133,8 +1133,8 @@ namespace TEAMModelOS.Controllers
                                         //最後一起修改
                                         //huanghb 2021,7.21修改 ,不用再统计到Teacher-Base中 ,Teacher-Base只记录教师自己的空间大小,并包含其他学校赠与的空间,其他学校的赠与空间放在School 表的Teacher-hbcn(SchoolTeacher)中SchoolTeacher
                                         //,并在教师登陆的时候 一并计算个人空间和总空间大小。其中总空间大小包含(个人空间+多个学校累加的空间大小,并且如果退出或者被移除Teacher-Base 的"schools": [],为空,则已经实现自动回收)
-                                        // await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacherHimself, teacherHimself.id, new PartitionKey("Base"));
-                                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(teacher, obj.GetProperty("id").ToString(), new PartitionKey($"Teacher-{school_code}"));
+                                        // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacherHimself, teacherHimself.id, new PartitionKey("Base"));
+                                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(teacher, obj.GetProperty("id").ToString(), new PartitionKey($"Teacher-{school_code}"));
                                     }
                                     else
                                     {
@@ -1165,7 +1165,7 @@ namespace TEAMModelOS.Controllers
                         queryText = "select * from c ";
                         string record = "0";
 
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
                         {
                             using var jsoncm = await JsonDocument.ParseAsync(item.ContentStream);
                             if (jsoncm.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1186,7 +1186,7 @@ namespace TEAMModelOS.Controllers
 
 
                                     // 修改DB裡Teacher的size
-                                    var response = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(teacher.id, new PartitionKey("Base"));
+                                    var response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(teacher.id, new PartitionKey("Base"));
                                     if (response.Status == 200)
                                     {
                                        // var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -1200,8 +1200,8 @@ namespace TEAMModelOS.Controllers
 
                                         //huanghb 2021,7.21修改 ,不用再统计到Teacher-Base中 ,Teacher-Base只记录教师自己的空间大小,并包含其他学校赠与的空间,其他学校的赠与空间放在School 表的Teacher-hbcn(SchoolTeacher)中SchoolTeacher
                                         //,并在教师登陆的时候 一并计算个人空间和总空间大小。其中总空间大小包含(个人空间+多个学校累加的空间大小,并且如果退出或者被移除Teacher-Base 的"schools": [],为空,则已经实现自动回收)
-                                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(teacher, teacher.id, new PartitionKey($"Teacher-{school_code}"));
-                                        //await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacherHimself, teacherHimself.id, new PartitionKey("Base"));
+                                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(teacher, teacher.id, new PartitionKey($"Teacher-{school_code}"));
+                                        //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacherHimself, teacherHimself.id, new PartitionKey("Base"));
                                     }
                                     else
                                     {

+ 23 - 22
TEAMModelOS/Controllers/School/SchoolTeacherController.cs

@@ -22,6 +22,7 @@ using System.Net;
 using Microsoft.Extensions.Configuration;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.Filter;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -61,7 +62,7 @@ namespace TEAMModelOS.Controllers
             //string status_str = (request.TryGetProperty("join_status", out JsonElement status_json)) ? status_json.ToString() : "join";
             //資料取得
             List<ScTeacher> teachers = new List<ScTeacher>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ScTeacher>(queryText: $"SELECT c.id, c.name,   c.picture ,c.status, c.job, c.createTime, ARRAY_LENGTH(c.permissions) as permissionCount,c.permissions , c.size FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ScTeacher>(queryText: $"SELECT c.id, c.name,   c.picture ,c.status, c.job, c.createTime, ARRAY_LENGTH(c.permissions) as permissionCount,c.permissions , c.size FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
             {
                 if ($"{item.createTime}".Length > 10) {
                     item.createTime = item.createTime / 1000;
@@ -98,7 +99,7 @@ namespace TEAMModelOS.Controllers
             if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
             //老師權限資料取得
             object permissions = null;
-            var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
+            var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
             if (response.Status == 200)
             {
                 using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -168,7 +169,7 @@ namespace TEAMModelOS.Controllers
                 //更新權限
                 foreach (var id in ids.EnumerateArray())
                 {
-                    SchoolTeacher st = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<SchoolTeacher>(id.GetString(), new PartitionKey($"Teacher-{school_code}"));
+                    SchoolTeacher st = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>(id.GetString(), new PartitionKey($"Teacher-{school_code}"));
                     if(mode.GetString().Equals("multi"))
                     {
                         foreach (var pm in pmRmvList)
@@ -191,7 +192,7 @@ namespace TEAMModelOS.Controllers
                         st.job = (!string.IsNullOrEmpty(job.GetString())) ? job.GetString() : null;
                     }
 
-                    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(st, id.GetString(), new PartitionKey($"Teacher-{school_code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(st, id.GetString(), new PartitionKey($"Teacher-{school_code}"));
                 }
                 return Ok(new {});
             }
@@ -218,7 +219,7 @@ namespace TEAMModelOS.Controllers
             if (!request.TryGetProperty("user_list", out JsonElement user_list)) return BadRequest();
             if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
             //取得學校資訊
-            var schresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
+            var schresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
             string schname = string.Empty;
             if (schresponse.Status == 200)
             {
@@ -240,7 +241,7 @@ namespace TEAMModelOS.Controllers
                     obj.TryGetProperty("picture", out JsonElement picture);
                     ids.Add(new TmdInfo { id=$"{id}",name=$"{name}" });
                     //老師個人資料
-                    var tresponse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id.ToString(), new PartitionKey("Base"));
+                    var tresponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(id.ToString(), new PartitionKey("Base"));
                     if(tresponse.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(tresponse.ContentStream);
@@ -257,7 +258,7 @@ namespace TEAMModelOS.Controllers
                         {
                             teacher.size = 2;
                         }
-                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, id.ToString(), new PartitionKey("Base"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id.ToString(), new PartitionKey("Base"));
                     }
                     else
                     {
@@ -282,18 +283,18 @@ namespace TEAMModelOS.Controllers
                         writer.WriteEndArray();
                         writer.WriteEndObject();
                         writer.Flush();
-                        await client.GetContainer("TEAMModelOS", "Teacher").CreateItemStreamAsync(stream, new PartitionKey("Base"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemStreamAsync(stream, new PartitionKey("Base"));
                     }
                     //學校老師資料
-                    var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
-                    //SchoolTeacher schteacher = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<SchoolTeacher>(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
+                    var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
+                    //SchoolTeacher schteacher = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
                     if (sresponse.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
                         SchoolTeacher schteacher = json.ToObject<SchoolTeacher>();
                         schteacher.status = grant_type.ToString();
                         schteacher.createTime =   DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                        await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(schteacher, id.ToString(), new PartitionKey($"Teacher-{school_code}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(schteacher, id.ToString(), new PartitionKey($"Teacher-{school_code}"));
                     }
                     else
                     {
@@ -325,7 +326,7 @@ namespace TEAMModelOS.Controllers
                         writer.WriteNumber("createTime", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
                         writer.WriteEndObject();
                         writer.Flush();
-                        await client.GetContainer("TEAMModelOS", "School").CreateItemStreamAsync(stream, new PartitionKey($"Teacher-{school_code}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemStreamAsync(stream, new PartitionKey($"Teacher-{school_code}"));
                     }
                 }
                 string bizcode = grant_type.GetString();
@@ -375,7 +376,7 @@ namespace TEAMModelOS.Controllers
 
                 var client = _azureCosmos.GetCosmosClient();
                 //取得學校資訊
-                var schresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
+                var schresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
                 string schname = string.Empty;
                 if (schresponse.Status == 200)
                 {
@@ -389,7 +390,7 @@ namespace TEAMModelOS.Controllers
                 }
 
                 //在老師表找出老師,處理該學校狀態 (老師基本資料應該要存在)
-                Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id.ToString(), new PartitionKey("Base"));
+                Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>(id.ToString(), new PartitionKey("Base"));
                 if (teacher.schools == null)
                     teacher.schools = new List<Teacher.School>();
                 var school = teacher.schools?.FirstOrDefault(x => x.schoolId.Equals(school_code.GetString(), StringComparison.OrdinalIgnoreCase));
@@ -404,9 +405,9 @@ namespace TEAMModelOS.Controllers
                 if (teacher.schools.Count > 0 && teacher.size<=1) {
                     teacher.size = 2;
                 }
-                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, id.ToString(), new PartitionKey("Base"));
+                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id.ToString(), new PartitionKey("Base"));
                 //在學校表處理該學校教師帳號的狀態
-                var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id.GetString(), new PartitionKey($"Teacher-{school_code}"));
+                var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id.GetString(), new PartitionKey($"Teacher-{school_code}"));
                 if (sresponse.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
@@ -429,7 +430,7 @@ namespace TEAMModelOS.Controllers
                             steacher.permissions = dft;
                         }
                     }
-                    var response = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(steacher, id.GetString(), new PartitionKey($"Teacher-{school_code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(steacher, id.GetString(), new PartitionKey($"Teacher-{school_code}"));
                 }
                 else
                 {
@@ -447,7 +448,7 @@ namespace TEAMModelOS.Controllers
                         size = 0,
                         status = grant_type.GetString()
                     };
-                    var response = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(st, new PartitionKey($"Teacher-{school_code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(st, new PartitionKey($"Teacher-{school_code}"));
                 }
                 string bizcode = grant_type.GetString();
                 if (grant_type.GetString() .Equals("join"))
@@ -495,13 +496,13 @@ namespace TEAMModelOS.Controllers
 
                 var client = _azureCosmos.GetCosmosClient();
                 //在老師表找出老師,刪除該學校 (老師基本資料應該要存在)
-                Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id.ToString(), new PartitionKey("Base"));
+                Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>(id.ToString(), new PartitionKey("Base"));
                 var school = teacher.schools.RemoveAll(x => x.schoolId.Equals(school_code.GetString(), StringComparison.OrdinalIgnoreCase));
-                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, id.ToString(), new PartitionKey("Base"));
+                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id.ToString(), new PartitionKey("Base"));
                 //移除學校表中的老師document
-                var sresponse = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.GetString(), new PartitionKey($"Teacher-{school_code}"));
+                var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.GetString(), new PartitionKey($"Teacher-{school_code}"));
                 //取得學校資訊
-                var schresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
+                var schresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
                 string schname = string.Empty;
                 if (schresponse.Status == 200)
                 {

+ 4 - 4
TEAMModelOS/Controllers/School/StudentCommonController.cs

@@ -110,7 +110,7 @@ namespace TEAMModelOS.Controllers
             }
             else
             {
-                containerId = "Teacher";
+                containerId = "Student";
                 PartitionKey = $"StuCourse-{id}";
             }
 
@@ -118,7 +118,7 @@ namespace TEAMModelOS.Controllers
 
             List<StuCourse> stus = new List<StuCourse>();
             List<CourseDto> sc = new List<CourseDto>();
-            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", containerId).GetItemQueryIterator<StuCourse>(queryText: $"select value(c) from c ",
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, containerId).GetItemQueryIterator<StuCourse>(queryText: $"select value(c) from c ",
               requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey(PartitionKey) }))
             {
                 stus.Add(item);
@@ -128,7 +128,7 @@ namespace TEAMModelOS.Controllers
                 {
                     Course course;
                     try {
-                        course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Course>(cos.id, new Azure.Cosmos.PartitionKey(cos.scode));
+                        course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Course>(cos.id, new Azure.Cosmos.PartitionKey(cos.scode));
                     } catch (CosmosException ex) { course = null; }
                     sc.Add( new CourseDto { course=course,stuCourse=cos}  );
                 }
@@ -136,7 +136,7 @@ namespace TEAMModelOS.Controllers
                     Course course ;
                     try
                     {
-                        course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS","Teacher").ReadItemAsync<Course>(cos.id, new Azure.Cosmos.PartitionKey(cos.scode));
+                        course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS,"Teacher").ReadItemAsync<Course>(cos.id, new Azure.Cosmos.PartitionKey(cos.scode));
                     }
                     catch (CosmosException ex) { course = null; }
                     sc.Add(new CourseDto { course = course, stuCourse = cos });

+ 33 - 33
TEAMModelOS/Controllers/School/StudentController.cs

@@ -342,7 +342,7 @@ namespace TEAMModelOS.Controllers
                 List<object> retStuds = new List<object>();
 
 
-                CosmosContainer cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student");
+                CosmosContainer cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
 
                 //並行處理
                 foreach (var stud in sortedImpData.studs)
@@ -444,7 +444,7 @@ namespace TEAMModelOS.Controllers
                             bool isUpPwDone = false;
                             Student student = await _azureCosmos
                                   .GetCosmosClient()
-                                  .GetContainer("TEAMModelOS", "Student")
+                                  .GetContainer(Constant.TEAMModelOS, "Student")
                                   .ReadItemAsync<Student>(stud.Key, new PartitionKey($"Base-{schoolId}"));
                             if (!string.IsNullOrWhiteSpace(stud.Value.name))
                             {
@@ -564,7 +564,7 @@ namespace TEAMModelOS.Controllers
                 writer.Flush();
                 var response = await _azureCosmos
                                 .GetCosmosClient()
-                                .GetContainer("TEAMModelOS", "Student")
+                                .GetContainer(Constant.TEAMModelOS, "Student")
                                 .CreateItemStreamAsync(stream, new PartitionKey($"Base-{schoolId}"));
                 if (response.Status == (int)HttpStatusCode.Created || response.Status == (int)HttpStatusCode.OK) return true;
                 if (response.Status == (int)HttpStatusCode.Conflict) return false;
@@ -633,7 +633,7 @@ namespace TEAMModelOS.Controllers
                 writer.WriteEndObject();
                 writer.Flush();
 
-                var ret = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemStreamAsync(memoryStream, new PartitionKey($"Class-{schoolId}"));
+                var ret = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemStreamAsync(memoryStream, new PartitionKey($"Class-{schoolId}"));
                 if (ret.Status != (int)HttpStatusCode.Created)
                 {
                     await _dingDing.SendBotMsg($"IES5,{_option.Location},StudentController/createClassInfo()\nStatus:{ret.Status}\nSchoolId:{schoolId},ClassId:{classId}", GroupNames.醍摩豆服務運維群組);
@@ -703,7 +703,7 @@ namespace TEAMModelOS.Controllers
                 //回傳用ContinuationToken
                 string continuationToken = string.Empty;
                 //進行學生資料的查詢
-                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student")
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
                    .GetItemQueryStreamIterator(
                        queryText: queryText,
                        continuationToken: token,
@@ -729,7 +729,7 @@ namespace TEAMModelOS.Controllers
                 List<object> ret = new List<object>();
                 //查教室資訊,使用上面的學生id並透過子查詢查詢。
                 queryText = $"SELECT c.id, c.name, c.gradeId, c.students FROM c JOIN (SELECT VALUE t FROM t IN c.students WHERE t.id IN ({string.Join(",", listStudent.Select(o => $"'{o.id}'"))}))";
-                await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School")
+                await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
                    .GetItemQueryStreamIterator(
                    queryText: queryText,
                    //continuationToken: token,
@@ -813,10 +813,10 @@ namespace TEAMModelOS.Controllers
 
                 //回傳用ContinuationToken
                 string continuationToken = string.Empty;
-                var container = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student");
+                var container = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
 
                 //進行學生資料的查詢 TEAMModelOS-Student
-                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student")
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
                    .GetItemQueryStreamIterator(
                        queryText: queryText,
                        requestOptions: new QueryRequestOptions()
@@ -966,7 +966,7 @@ namespace TEAMModelOS.Controllers
                 //if (!string.IsNullOrWhiteSpace(classId)) queryText += $" AND c.id = '{classId}'";
                 Dictionary<string, JsonElement> listStudent = new Dictionary<string, JsonElement>();
 
-                await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School")
+                await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
                     .GetItemQueryStreamIterator(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1005,7 +1005,7 @@ namespace TEAMModelOS.Controllers
                 var exceptions = new List<Exception>();
                 List<StuList> scStuLists = new List<StuList>();
                 List<StuList> teStuLists = new List<StuList>();
-                var container = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student");
+                var container = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
                 while (students.MoveNext())
                 {
                     string id = string.Empty;
@@ -1015,11 +1015,11 @@ namespace TEAMModelOS.Controllers
                         id = student.GetProperty("id").GetString();
                         var ret = await container.DeleteItemStreamAsync(id, new PartitionKey($"Base-{schoolId}"));
                         if (ret.Status == (int)HttpStatusCode.NoContent) sucIds.Add(id);
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 c.students where A0.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 c.students where A0.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
                         {
                             scStuLists.Add(item);
                         }
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 c.students where A0.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 c.students where A0.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                         {
                             teStuLists.Add(item);
                         }
@@ -1033,7 +1033,7 @@ namespace TEAMModelOS.Controllers
                                         break;
                                     }
                                 }
-                                await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
                             }
                         }
                         if (teStuLists.Count > 0) {
@@ -1047,7 +1047,7 @@ namespace TEAMModelOS.Controllers
                                         break;
                                     }
                                 }
-                                await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
                             }
                         }
                     }
@@ -1102,7 +1102,7 @@ namespace TEAMModelOS.Controllers
             if (impStuds.Count == 0) return (null, null, null);
 
             string queryText = $"SELECT VALUE c FROM c WHERE c.id IN ({string.Join(",", impStuds.Select(o => $"'{o}'"))})";
-            await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student")
+            await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
                             .GetItemQueryStreamIterator(
                                 queryText: queryText,
                                 requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
@@ -1151,7 +1151,7 @@ namespace TEAMModelOS.Controllers
                         writer.Flush();
                         var ret = await _azureCosmos
                                   .GetCosmosClient()
-                                  .GetContainer("TEAMModelOS", "Student")
+                                  .GetContainer(Constant.TEAMModelOS, "Student")
                                   .ReplaceItemStreamAsync(stream, id, new PartitionKey($"Base-{schoolId}"));
 
                         if (ret.Status == (int)HttpStatusCode.OK)
@@ -1189,7 +1189,7 @@ namespace TEAMModelOS.Controllers
 
                     Dictionary<string, JsonElement> dicClassInfo = new Dictionary<string, JsonElement>();
 
-                    await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School")
+                    await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
                         .GetItemQueryStreamIterator(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1235,7 +1235,7 @@ namespace TEAMModelOS.Controllers
                     foreach (var key in classNos.Keys)
                     {
                         string queryText = $"SELECT * FROM c WHERE c.code = 'Class-{schoolId}' AND c.no='{classNos[key].no}' and c.year={classNos[key].year} and c.periodId='{classNos[key].periodId}' ";
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School")
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
                        .GetItemQueryIterator<Class>(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
                         {
                             dicClassInfo[item.id] = item;
@@ -1378,7 +1378,7 @@ namespace TEAMModelOS.Controllers
                 var classInfo = await getClassInfoUseId(schoolId, classStuds.Keys.ToList());
 
                 //準備查詢db資料
-                CosmosContainer cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student");
+                CosmosContainer cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
 
                 //查要移除教室或是沒加入教室的學生
 
@@ -1641,7 +1641,7 @@ namespace TEAMModelOS.Controllers
             var exceptions = new List<Exception>();
             try
             {
-                var container = _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student");
+                var container = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
 
                 Parallel.ForEach(userStudents, async item =>
                 {
@@ -1689,7 +1689,7 @@ namespace TEAMModelOS.Controllers
 
             string queryText = $"SELECT c.id, c.no FROM c WHERE c.classId = '{classId}' AND c.code = 'Base-{schoolId}'";
             if (nos != null) queryText += $"AND c.no IN ({string.Join(",", nos.Select(o => $"'{o}'"))})";
-            await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student")
+            await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
                 .GetItemQueryStreamIterator(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1722,7 +1722,7 @@ namespace TEAMModelOS.Controllers
 
                 var response = await _azureCosmos
                     .GetCosmosClient()
-                    .GetContainer("TEAMModelOS", "School")
+                    .GetContainer(Constant.TEAMModelOS, "School")
                     .ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
 
                 if (response.Status != (int)HttpStatusCode.OK) return null;
@@ -1796,9 +1796,9 @@ namespace TEAMModelOS.Controllers
             try
             {
                 var client = _azureCosmos.GetCosmosClient();
-                var schoolClient = client.GetContainer("TEAMModelOS", "School");
-                var teacherClient = client.GetContainer("TEAMModelOS", "Teacher");
-                var studentClient = client.GetContainer("TEAMModelOS", "Student");
+                var schoolClient = client.GetContainer(Constant.TEAMModelOS, "School");
+                var teacherClient = client.GetContainer(Constant.TEAMModelOS, "Teacher");
+                var studentClient = client.GetContainer(Constant.TEAMModelOS, "Student");
                 //參數取得
                 if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
                 if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
@@ -1990,7 +1990,7 @@ namespace TEAMModelOS.Controllers
                         foreach (Students stu in stuList)
                         {
                             var query = $"select c.id,c.name,c.picture,c.classId,c.code,c.groupId,c.groupName,c.no from c where c.id = '{stu.id}'";
-                            await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{stu.code}") }))
+                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{stu.code}") }))
                             {
                                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -2013,7 +2013,7 @@ namespace TEAMModelOS.Controllers
                         tmdids.ForEach(x => { inids.Add($"'{x}'"); });
                         var insql = string.Join(",", inids);
                         var queryslt = $"SELECT c.id,c.name,c.picture FROM c where c.id in ({insql})";
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                         {
                             tmdinfos.Add(item);
                         }
@@ -2040,8 +2040,8 @@ namespace TEAMModelOS.Controllers
             try
             {
                 var client = _azureCosmos.GetCosmosClient();
-                var schoolClient = client.GetContainer("TEAMModelOS", "School");
-                var studentClient = client.GetContainer("TEAMModelOS", "Student");
+                var schoolClient = client.GetContainer(Constant.TEAMModelOS, "School");
+                var studentClient = client.GetContainer(Constant.TEAMModelOS, "Student");
                 //參數取得
                 if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
                 if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
@@ -2128,7 +2128,7 @@ namespace TEAMModelOS.Controllers
                 }
                 if (string.IsNullOrEmpty(school)) {
                     if (userType.Equals("tmdid")) {
-                        Teacher teacher = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
+                        Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
                         if (teacher.schools.IsNotEmpty()) {
                            var tech= teacher.schools.Find(x => x.status.Equals("join"));
                             if (tech == null)
@@ -2144,7 +2144,7 @@ namespace TEAMModelOS.Controllers
                 if (!string.IsNullOrEmpty(school))
                 {
                     object school_base = null;
-                    var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school, new PartitionKey("Base"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school, new PartitionKey("Base"));
                     if (response.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -2153,7 +2153,7 @@ namespace TEAMModelOS.Controllers
 
                     //取得班级
                     List<object> school_classes = new List<object>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.scope, ARRAY_LENGTH(c.students) AS studCount FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.scope, ARRAY_LENGTH(c.students) AS studCount FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school}") }))
                     {
                         var jsonc = await JsonDocument.ParseAsync(item.ContentStream);
                         foreach (var classeinfo in jsonc.RootElement.GetProperty("Documents").EnumerateArray())
@@ -2163,7 +2163,7 @@ namespace TEAMModelOS.Controllers
                     }
                     //取得教室
                     List<Room> school_rooms = new List<Room>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ",
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Room-{school}") }))
                     {
                         school_rooms.Add(item);

+ 5 - 4
TEAMModelOS/Controllers/School/TmdUserController.cs

@@ -22,6 +22,7 @@ using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Service;
 using Microsoft.Extensions.Configuration;
 using System.Net.Http;
+using TEAMModelOS.SDK;
 
 namespace TEAMModelOS.Controllers
 {
@@ -79,7 +80,7 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 try
                 {
-                    TmdUser tmdUser = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<TmdUser>(id, new PartitionKey("Base"));
+                    TmdUser tmdUser = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<TmdUser>(id, new PartitionKey("Base"));
                     tmdUser.name = $"{name}";
                     tmdUser.picture = $"{picture}";
                     if (tmdUser.schools.IsNotEmpty())
@@ -88,7 +89,7 @@ namespace TEAMModelOS.Controllers
                         {
                              
                             dynamic schoolExtobj = new ExpandoObject();
-                            var schoolJson = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{sc.schoolId}", new PartitionKey("Base"));
+                            var schoolJson = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{sc.schoolId}", new PartitionKey("Base"));
                             var school = await JsonDocument.ParseAsync(schoolJson.ContentStream);
                             schoolExtobj.schoolId = sc.schoolId;
                             schoolExtobj.name = school.RootElement.GetProperty("name");
@@ -99,7 +100,7 @@ namespace TEAMModelOS.Controllers
                         }
                         tmdUser.defaultSchool = string.IsNullOrEmpty(tmdUser.defaultSchool) ? tmdUser.schools[0].schoolId : tmdUser.defaultSchool;
                     }
-                    await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<TmdUser>(tmdUser, id, new PartitionKey("Base"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<TmdUser>(tmdUser, id, new PartitionKey("Base"));
                     //預設學校ID
                     defaultschool = tmdUser.defaultSchool;
                 }
@@ -120,7 +121,7 @@ namespace TEAMModelOS.Controllers
                         };
                         var container = _azureStorage.GetBlobContainerClient(id);
                         await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
-                        teacher = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").CreateItemAsync<TmdUser>(teacher, new PartitionKey("Base"));
+                        teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync<TmdUser>(teacher, new PartitionKey("Base"));
                     }
                 }
                 //換取AuthToken,提供給前端

+ 6 - 6
TEAMModelOS/Controllers/Syllabus/FavoriteController.cs

@@ -58,20 +58,20 @@ namespace TEAMModelOS.Controllers
                 {
 
                     request.id = Guid.NewGuid().ToString();
-                    request = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    request = await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(request.id, new PartitionKey($"{request.code}"));
                     if (response.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
                         var info = json.ToObject<Favorite>();
-                        request = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
                     }
                     else
                     {
-                        request = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                        request = await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                     }
                 }
                 return Ok(new { room = request });
@@ -98,7 +98,7 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
                 var client = _azureCosmos.GetCosmosClient();
               
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Favorite>(queryText: $"select value(c) from c ",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Favorite>(queryText: $"select value(c) from c ",
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Favorite-{code}") }))
                 {
                     favorites.Add(item);
@@ -127,7 +127,7 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
                 //
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                var room = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Favorite>(id.GetString(), new PartitionKey($"Favorite-{code}"));
+                var room = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Favorite>(id.GetString(), new PartitionKey($"Favorite-{code}"));
                 return Ok();
             }
             catch (Exception ex)

+ 24 - 24
TEAMModelOS/Controllers/Syllabus/ShareController.cs

@@ -76,7 +76,7 @@ namespace TEAMModelOS.Controllers
                 //需要判断id== req.issuer  才能进行授权操作
                 if (request.scope.Equals("school"))
                 {
-                    Syllabus syllabusD = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(request.syllabusId, new PartitionKey($"Syllabus-{request.school}"));
+                    Syllabus syllabusD = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Syllabus>(request.syllabusId, new PartitionKey($"Syllabus-{request.school}"));
                     if (request.opt .Equals("del"))
                     {
                         if (syllabusD.auth.IsNotEmpty())
@@ -90,16 +90,16 @@ namespace TEAMModelOS.Controllers
                             syllabusAuths.ForEach(x => {
                                 syllabusD.auth.Remove(x);
                             });
-                            await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.school}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.school}"));
                             request.tmdInfo.ForEach(async x => {
-                                await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.id}"));
                             });
 
                         }
                     }
                     else if (request.opt.Equals("add") || request.opt.Equals("edit"))
                     {
-                        var schresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(request.school.ToString(), new PartitionKey("Base"));
+                        var schresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(request.school.ToString(), new PartitionKey("Base"));
                         string schname = string.Empty;
                         if (schresponse.Status == 200)
                         {
@@ -114,7 +114,7 @@ namespace TEAMModelOS.Controllers
                         (Syllabus syllabus, List<Share> shares) = DoAuth(request, syllabusD);
                         foreach (var x in shares)
                         {
-                            await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
                             //发送共编或分享通知
                             Notification notification = new Notification
                             {
@@ -132,14 +132,14 @@ namespace TEAMModelOS.Controllers
                             var location = _option.Location;
                             var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
                         }
-                        await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.school}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.school}"));
 
 
                     }
                 }
                 else if (request.scope.Equals("private"))
                 {
-                    Syllabus syllabusD = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(request.syllabusId, new PartitionKey($"Syllabus-{request.issuer}"));
+                    Syllabus syllabusD = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Syllabus>(request.syllabusId, new PartitionKey($"Syllabus-{request.issuer}"));
                     if (request.opt .Equals("del"))
                     {
                         if (syllabusD.auth.IsNotEmpty())
@@ -154,10 +154,10 @@ namespace TEAMModelOS.Controllers
                             syllabusAuths.ForEach(x => {
                                 syllabusD.auth.Remove(x);
                             });
-                            await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.issuer}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.issuer}"));
                             request.tmdInfo.ForEach(async x => {
                                 try {
-                                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.id}"));
+                                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{request.type}-{x.id}"));
                                 } catch 
                                 {
                                     //仅处理找不到数据的情况
@@ -169,7 +169,7 @@ namespace TEAMModelOS.Controllers
                     {
                         (Syllabus vlm, List<Share> shares) = DoAuth(request, syllabusD);
                         foreach (var x in shares) {
-                            await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
                             //发送共编或分享通知
                             Notification notification = new Notification
                             {
@@ -187,7 +187,7 @@ namespace TEAMModelOS.Controllers
                             var location = _option.Location;
                             var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
                         }
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Syllabus>(syllabusD, new PartitionKey($"Syllabus-{request.issuer}"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<Syllabus>(syllabusD, new PartitionKey($"Syllabus-{request.issuer}"));
                     }
                 }
                 return Ok(new { code = 200 });
@@ -297,15 +297,15 @@ namespace TEAMModelOS.Controllers
                 if (ids.ValueKind.Equals(JsonValueKind.Array)) {
                     List<string> idss = ids.ToObject<List<string>>();
                     foreach (var id in idss) {
-                        Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
+                        Share share = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
                         if ($"{opt}".Equals("agree"))
                         {
                             share.agree = 1;
-                            await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, $"{id}", new PartitionKey($"Share-{type}-{code}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Share>(share, $"{id}", new PartitionKey($"Share-{type}-{code}"));
                         }
                         else if ($"{opt}".Equals("ignore"))
                         {
-                            await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
                         }
 
                         Syllabus syllabus = null;
@@ -313,7 +313,7 @@ namespace TEAMModelOS.Controllers
                         {
                             try
                             {
-                                syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.school}"));
+                                syllabus = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.school}"));
                             }
                             catch
                             {
@@ -324,7 +324,7 @@ namespace TEAMModelOS.Controllers
                         {
                             try
                             {
-                                syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.issuer}"));
+                                syllabus = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.issuer}"));
                             }
                             catch
                             {
@@ -352,11 +352,11 @@ namespace TEAMModelOS.Controllers
                             }
                             if (share.scope .Equals("school"))
                             {
-                                syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.school}"));
+                                syllabus = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.school}"));
                             }
                             else if (share.scope .Equals("private"))
                             {
-                                syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.issuer}"));
+                                syllabus = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.issuer}"));
                             }
                         }
                     }
@@ -382,7 +382,7 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("type", out JsonElement type)) { return BadRequest(); }
                 if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
                 if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
-                await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
                 return Ok(new { status = 200 });
             } catch (Exception ex)
             {
@@ -413,7 +413,7 @@ namespace TEAMModelOS.Controllers
                 if (id.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrEmpty(id.GetString())) {
                     queryText.Append($" and c.id='{id}'");
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Share>(queryText: queryText.ToString(),
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Share>(queryText: queryText.ToString(),
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Share-{type}-{code}") }))
                 {
                     shares.Add(item);
@@ -471,27 +471,27 @@ namespace TEAMModelOS.Controllers
                 {
                     code = request.school;
                     var queryslt = $"SELECT  value(c) FROM c where c.id in ({sidSql})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Syllabus>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{request.school}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Syllabus>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{request.school}") }))
                     {
                         List<SyllabusTree> trees = SyllabusService.ListToTree(item.children);
                         SyllabusTreeNode tree = new SyllabusTreeNode() { id = item.id, scope = item.scope, trees = trees, volumeId = item.volumeId, auth = item.auth };
                         treeNodes.Add(tree);
 
                     }
-                    volume = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Volume>(request.volumeId, new PartitionKey($"Volume-{code}"));
+                    volume = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Volume>(request.volumeId, new PartitionKey($"Volume-{code}"));
                     
                 }
                 else if (request.scope .Equals("private"))
                 {
                     code = request.issuer;
                     var queryslt = $"SELECT  value(c) FROM c where c.id in ({sidSql})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Syllabus>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{request.issuer}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Syllabus>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{request.issuer}") }))
                     {
                         List<SyllabusTree> trees = SyllabusService.ListToTree(item.children);
                         SyllabusTreeNode tree = new SyllabusTreeNode() { id = item.id, scope = item.scope, trees = trees, volumeId = item.volumeId, auth = item.auth };
                         treeNodes.Add(tree);
                     }
-                    volume = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Volume>(request.volumeId, new PartitionKey($"Volume-{code}"));
+                    volume = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Volume>(request.volumeId, new PartitionKey($"Volume-{code}"));
                 }
                 else
                 {

+ 23 - 22
TEAMModelOS/Controllers/Syllabus/SyllabusController.cs

@@ -18,6 +18,7 @@ using Azure.Cosmos;
 using TEAMModelOS.Services.Common;
 using Microsoft.Extensions.Options;
 using System.Text;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -61,14 +62,14 @@ namespace TEAMModelOS.Controllers
                 StringBuilder queryText = new StringBuilder($"SELECT  c.id as syllabusId,c.volumeId,rnodes.link ,children.id as treeid  FROM c join children  in  c.children join rnodes in children.rnodes    where rnodes.link in ({lks}) ");
                 if (_scope.ValueKind.Equals(JsonValueKind.String) && _scope.GetString() .Equals("school"))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LinkDto>(queryText: queryText.ToString(),
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LinkDto>(queryText: queryText.ToString(),
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{_code}") }))
                     {
                         links.Add(item);
                     }
                 }
                 else if (_scope.ValueKind.Equals(JsonValueKind.String) && _scope.GetString() .Equals("private")) {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<LinkDto>(queryText: queryText.ToString(),
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LinkDto>(queryText: queryText.ToString(),
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{_code}") }))
                     {
                         links.Add(item);
@@ -127,7 +128,7 @@ namespace TEAMModelOS.Controllers
                     {
                         try
                         {
-                            syllabus = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(syllabusTree.id, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                            syllabus = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Syllabus>(syllabusTree.id, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                         }
                         catch
                         {
@@ -148,7 +149,7 @@ namespace TEAMModelOS.Controllers
                             syllabus.ttl = -1;
                             syllabus.volumeId = syllabusTree.volumeId;
                             syllabus.scope = syllabusTree.scope;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                         }
                         else
                         {
@@ -160,14 +161,14 @@ namespace TEAMModelOS.Controllers
                             SyllabusService.TreeToList(syllabusTree.trees, nodes, now);
                             syllabus.children = nodes;
                             syllabusTree.auth = syllabus.auth;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus,syllabus.id, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Syllabus>(syllabus,syllabus.id, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                         }
 
                     }
                     else {
                         try
                         {
-                            syllabus = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(syllabusTree.id, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                            syllabus = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Syllabus>(syllabusTree.id, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                         }
                         catch
                         {
@@ -187,7 +188,7 @@ namespace TEAMModelOS.Controllers
                             syllabus.ttl = -1;
                             syllabus.volumeId = syllabusTree.volumeId;
                             syllabus.scope = syllabusTree.scope;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                         }
                         else
                         {
@@ -199,7 +200,7 @@ namespace TEAMModelOS.Controllers
                             SyllabusService.TreeToList(syllabusTree.trees, nodes, now);
                             syllabus.children = nodes;
                             syllabusTree.auth = syllabus.auth;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                         }
                     }
                 }
@@ -222,9 +223,9 @@ namespace TEAMModelOS.Controllers
                         scope = syllabusTree.scope
                     };
                     if (syllabusTree.scope .Equals("school")) {
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                     } else {
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Syllabus>(syllabus, new Azure.Cosmos.PartitionKey($"Syllabus-{syllabusTree.codeval}"));
                     }
                 }
             }
@@ -253,8 +254,8 @@ namespace TEAMModelOS.Controllers
             try {
                 if (scope.ToString().Equals("school"))
                 {
-                      volume = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Volume>($"{volumeId}", new PartitionKey($"{volumeCode}"));
-                      await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
+                      volume = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Volume>($"{volumeId}", new PartitionKey($"{volumeCode}"));
+                      await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
 
                     requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{volume.school}") }))
                     {
@@ -265,8 +266,8 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    volume = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Volume>($"{volumeId}", new PartitionKey($"{volumeCode}"));
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
+                    volume = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Volume>($"{volumeId}", new PartitionKey($"{volumeCode}"));
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
                      requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{volume.creatorId}") }))
                     {
                         List<SyllabusTree> trees = SyllabusService.ListToTree(item.children);
@@ -322,15 +323,15 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 if (scope.ToString().Equals("school"))
                 {
-                    Syllabus syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    Syllabus syllabus = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     if (syllabus.auth.IsNotEmpty()) {
                         foreach (var a in syllabus.auth)
                         {
                             try
                             {
-                                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                Share share = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                                 share.agree = -1;
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                             }
                             catch (Exception ex)
                             {
@@ -338,21 +339,21 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                     }
-                    var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     return Ok(new { code = response.Status });
                 }
                 else
                 {
-                    Syllabus syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    Syllabus syllabus = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     if (syllabus.auth.IsNotEmpty())
                     {
                         foreach (var a in syllabus.auth)
                         {
                             try
                             {
-                                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                Share share = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                                 share.agree = -1;
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                             }
                             catch (Exception ex)
                             {
@@ -360,7 +361,7 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                     }
-                    var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     return Ok(new { code = response.Status });
                 }
             }

+ 20 - 19
TEAMModelOS/Controllers/Syllabus/VolumeController.cs

@@ -16,6 +16,7 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -65,8 +66,8 @@ namespace TEAMModelOS.Controllers
                 List<Syllabus> syllabus = new List<Syllabus>();
                 if (scope.ToString().Equals("school"))
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{code}") })) {
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{code}") })) {
                         syllabus.Add(item);
                     }
                     if (syllabus.IsNotEmpty())
@@ -75,23 +76,23 @@ namespace TEAMModelOS.Controllers
                             if (s.auth.IsNotEmpty()) {
                                 foreach (var a in s.auth) {
                                     try {
-                                        Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        Share share = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                                         share.agree = -1;
-                                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share,s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Share>(share,s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                                     } catch (Exception ex) {
                                         ///仅用于处理查不到该数据的问题
                                     }
                                 }
                             }
                         }
-                        var sresponse = await client.GetContainer("TEAMModelOS", "School").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{code}");
+                        var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{code}");
                     }
                     return Ok(new { code = response.Status });
                 }
                 else
                 {
-                    var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{code}") }))
+                    var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{code}") }))
                     {
                         syllabus.Add(item);
                     }
@@ -105,9 +106,9 @@ namespace TEAMModelOS.Controllers
                                 {
                                     try
                                     {
-                                        Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        Share share = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                                         share.agree = -1;
-                                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Share>(share, s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
                                     }
                                     catch (Exception ex)
                                     {
@@ -116,7 +117,7 @@ namespace TEAMModelOS.Controllers
                                 }
                             }
                         }
-                        var sresponse = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{code}");
+                        var sresponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{code}");
                     }
                     return Ok(new { code = response.Status });
                 }
@@ -157,14 +158,14 @@ namespace TEAMModelOS.Controllers
                     //私有课纲
                     if (scope.GetString() .Equals("private"))
                     {
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Volume>(queryText: $"select value(c) from c where c.status = {status}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Volume-{code}") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Volume>(queryText: $"select value(c) from c where c.status = {status}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Volume-{code}") }))
                         {
                             volumes.Add(item);
                         }
                     }
                     else if (scope.GetString() .Equals("school"))
                     {
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Volume>(queryText: $"select value(c) from c where c.status = {status} and c.periodId = '{periodCode}' and c.subjectId = '{subjectCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Volume-{code}") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Volume>(queryText: $"select value(c) from c where c.status = {status} and c.periodId = '{periodCode}' and c.subjectId = '{subjectCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Volume-{code}") }))
                         {
                             volumes.Add(item);
                         }
@@ -233,10 +234,10 @@ namespace TEAMModelOS.Controllers
                 try {
                     if (request.scope.Equals("school"))
                     {
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Volume>(request, request.id, new Azure.Cosmos.PartitionKey(request.code));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Volume>(request, request.id, new Azure.Cosmos.PartitionKey(request.code));
                     }
                     else if (request.scope.Equals("private")) {
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Volume>(request, request.id, new Azure.Cosmos.PartitionKey(request.code));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Volume>(request, request.id, new Azure.Cosmos.PartitionKey(request.code));
                     }
                       
                 }
@@ -254,7 +255,7 @@ namespace TEAMModelOS.Controllers
                     {
                         sql.Append($" and c.name = '{request.name}' ");
                         List<Volume> volumes = new List<Volume>();
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher")
                         .GetItemQueryIterator<Volume>(queryText: sql.ToString(), requestOptions: new Azure.Cosmos.QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey(request.code) }))
                         {
                             volumes.Add(item);
@@ -274,7 +275,7 @@ namespace TEAMModelOS.Controllers
                         sql.Append($" and c.periodId = '{request.periodId}' and  c.subjectId = '{request.subjectId}'" +
                             $" and c.gradeId = {request.gradeId} and c.semesterId = '{request.semesterId}' and c.name = '{request.name}' ");
                         List<Volume> volumes = new List<Volume>();
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School")
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
                         .GetItemQueryIterator<Volume>(queryText: sql.ToString(), requestOptions: new Azure.Cosmos.QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey(request.code) })) {
                             volumes.Add(item);
                         }
@@ -290,10 +291,10 @@ namespace TEAMModelOS.Controllers
                     request.id = System.Guid.NewGuid().ToString();
                     if (request.scope.Equals("private"))
                     {
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(request, new PartitionKey(request.code));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(request, new PartitionKey(request.code));
                     }
                     else {
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(request, new PartitionKey(request.code));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(request, new PartitionKey(request.code));
                     }
                 }
                 catch (Exception ex)
@@ -317,7 +318,7 @@ namespace TEAMModelOS.Controllers
             //            school=request.school,
             //            scope=request.scope
             //        };
-            //        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(share, new PartitionKey($"{share.code}"));
+            //        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(share, new PartitionKey($"{share.code}"));
             //    }
             //}
             return Ok(request);

+ 12 - 11
TEAMModelOS/Controllers/Teacher/CommentController.cs

@@ -20,6 +20,7 @@ using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using System.Linq;
 using TEAMModelOS.Filter;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -95,7 +96,7 @@ namespace TEAMModelOS.Controllers
 
             //List<object> comments = new List<object>();
             //var query = $"select c.id,c.comment from c";
-            //await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Comment-{id}") }))
+            //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Comment-{id}") }))
             //{
             //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
 
@@ -160,7 +161,7 @@ namespace TEAMModelOS.Controllers
             {
                 var client = _azureCosmos.GetCosmosClient();
                 List<ExamClassResult> examClassResults = new List<ExamClassResult>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
                     queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and array_contains(c.studentIds,'{studentId}')",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
                 {
@@ -229,11 +230,11 @@ namespace TEAMModelOS.Controllers
                         result.mark = annotation;
                     }
                     result.mark[index].Add(builder.ToString());*/
-                    classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
+                    classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
                 }
                 await Task.WhenAll(tasks);
                /* //变更blob 大小
-                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-{school}"));
+                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-{school}"));
                 info.size = await _azureStorage.GetBlobContainerClient(school.ToString()).GetBlobsSize($"exam/{id}");
                 var messageBlob = new ServiceBusMessage(new { id = Guid.NewGuid().ToString(), progress = "annotation", root = $"exam/{id}", name = school }.ToJsonString());
 
@@ -262,7 +263,7 @@ namespace TEAMModelOS.Controllers
             //获取学校的名单:
             List<Schedule> schedules = new List<Schedule>();
             string scheduleSql = $"SELECT   c.schedule  FROM c join scdl in c.schedule where c.pk='Course' and scdl.teacherId='{id}'";
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(scheduleSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(scheduleSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school}") }))
             {
                 schedules.AddRange(item.schedule);
             }
@@ -309,7 +310,7 @@ namespace TEAMModelOS.Controllers
                 if (!string.IsNullOrWhiteSpace(school) && classes.ToList().IsNotEmpty()) {
                     string querySchool = $" SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime   FROM c {joinSqlClasses}   where   {pksql}    {classesSql}";
                     //查询数据归属学校的
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<MQActivity>(querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{school}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<MQActivity>(querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{school}") }))
                     {
                         if (item.progress.Equals("going", StringComparison.OrdinalIgnoreCase)) {
                             datas.Add(item);
@@ -327,7 +328,7 @@ namespace TEAMModelOS.Controllers
                 {
                     string querySchool = $" SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime   FROM c {joinSqlStulist}   where   {pksql}    {stuListsSql}";
                     //查询数据归属学校的
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<MQActivity>(querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{school}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<MQActivity>(querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{school}") }))
                     {
                         if (item.progress.Equals("going", StringComparison.OrdinalIgnoreCase))
                         {
@@ -338,7 +339,7 @@ namespace TEAMModelOS.Controllers
                 }
                 string queryTeacher = $" SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime  FROM c   where   {pksql}  ";
                 //查询数据归属个人的
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<MQActivity>(queryTeacher, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{id}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<MQActivity>(queryTeacher, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{id}") }))
                 {
                     acount += 1;
                     if (item.progress.Equals("going", StringComparison.OrdinalIgnoreCase))
@@ -498,7 +499,7 @@ namespace TEAMModelOS.Controllers
                 //string querySchool = $" SELECT distinct  value c   FROM c {joinSqlClasses} {joinSqlSubjects}  where {stimesql}  {etimesql}  {progresssql}  {typesql}  {andSqlSubjects}  {tgSql}";
                 string querySchoolclss = $" SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime   FROM c {joinSqlClasses}   where   {pksql}    {classesSql}";
                 //查询数据归属学校的
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(querySchoolclss, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"{type}-{school}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(querySchoolclss, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"{type}-{school}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -516,7 +517,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
                 string querySchoollist = $" SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime   FROM c {joinSqlStulist}   where   {pksql}    {andSqlStulist}";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(querySchoollist, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"{type}-{school}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(querySchoollist, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"{type}-{school}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -547,7 +548,7 @@ namespace TEAMModelOS.Controllers
             }
             string queryTeacher = $" SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime  FROM c   where   {pksql}  ";
             //查询数据归属学校的
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryTeacher, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"{type}-{id}") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryTeacher, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"{type}-{id}") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)

+ 28 - 28
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -69,14 +69,14 @@ namespace TEAMModelOS.Controllers
             }
             var (userid, _, _, _) = HttpContext.GetAuthTokenInfo();
             try { 
-                Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(userid, new PartitionKey("Base"));
+                Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>(userid, new PartitionKey("Base"));
                 switch (true) {
                     //修改默认学校
                     case bool when  $"{_opt}".Equals("UpdateDefaultSchool", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty($"{_defaultSchool}"):
                         if (teacher.schools.Select(x => x.schoolId).Contains($"{_defaultSchool}"))
                         {
                             teacher.defaultSchool = $"{_defaultSchool}";
-                            await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, userid, new PartitionKey("Base"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, userid, new PartitionKey("Base"));
                             return Ok(new { teacher, status = 1 });
                         }
                         else {
@@ -114,7 +114,7 @@ namespace TEAMModelOS.Controllers
                 int total = 0;
                 int tsize = 0;
                 try {
-                    Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
+                    Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
                     teacher.name = $"{name}";
                     teacher.picture = $"{picture}";
                     ///教师的个人空间
@@ -128,7 +128,7 @@ namespace TEAMModelOS.Controllers
                             string statusNow = sc.status!=null?sc.status:"";
                             if (statusNow .Equals("join") || statusNow .Equals("invite") || statusNow.Equals("request")) {
                                 dynamic schoolExtobj = new ExpandoObject();
-                                var schoolJson = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{sc.schoolId}", new PartitionKey("Base"));
+                                var schoolJson = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{sc.schoolId}", new PartitionKey("Base"));
                                 var school = await JsonDocument.ParseAsync(schoolJson.ContentStream);
                                 schoolExtobj.schoolId = sc.schoolId;
                                 schoolExtobj.name = school.RootElement.GetProperty("name") ;
@@ -136,14 +136,14 @@ namespace TEAMModelOS.Controllers
                                 schoolExtobj.time = sc.time;
                                 schoolExtobj.picture = school.RootElement.GetProperty("picture");
                                 
-                                var sctch = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{sc.schoolId}"));
+                                var sctch = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{sc.schoolId}"));
                                 if (sctch.Status == 200)
                                 {
                                     var jsonDoc = await JsonDocument.ParseAsync(sctch.ContentStream);
                                     SchoolTeacher schoolTeacher = jsonDoc.RootElement.ToObject<SchoolTeacher>();
                                     schoolTeacher.name = $"{name}";
                                     schoolTeacher.picture = $"{picture}";
-                                    await  client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(schoolTeacher, id, new PartitionKey($"Teacher-{sc.schoolId}"));
+                                    await  client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(schoolTeacher, id, new PartitionKey($"Teacher-{sc.schoolId}"));
                                     if (jsonDoc.RootElement.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
                                     {
                                         total += _size.GetInt32();
@@ -167,7 +167,7 @@ namespace TEAMModelOS.Controllers
                             teacher.size = 1;
                         }
                     }
-                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
                     //預設學校ID
                     defaultschool = teacher.defaultSchool;
                 } catch(CosmosException ex) 
@@ -188,14 +188,14 @@ namespace TEAMModelOS.Controllers
                         };
                         var container = _azureStorage.GetBlobContainerClient(id);
                         await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
-                        teacher = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
+                        teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
                         total = teacher.size;
                         tsize = teacher.size;
                     } 
                 }
                 //私人課程
                 List<object> courses = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id, c.name, c.classes, c.notice ,c.scope from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id, c.name, c.classes, c.notice ,c.scope from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -209,7 +209,7 @@ namespace TEAMModelOS.Controllers
 
                 //老師個人課綱  TODO 暂时不取
                 List<SyllabusRole> syllabus = new List<SyllabusRole>();
-                //await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.name, c.scope, c.resourceCount, c.itemCount, c.children from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{id}") }))
+                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.name, c.scope, c.resourceCount, c.itemCount, c.children from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{id}") }))
                 //{
                 //    var jsons = await JsonDocument.ParseAsync(item.ContentStream);
                 //    if (jsons.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -270,7 +270,7 @@ namespace TEAMModelOS.Controllers
                 List<string> roles = new List<string>();
                 List<string> permissions = new List<string>();
                 int size = 0;
-                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{school_code}"));
+                var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{school_code}"));
                 if (response.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -307,7 +307,7 @@ namespace TEAMModelOS.Controllers
 
                 //TODO JJ,调整为取得学校基础设置数据,取代下方學校學制、年級
                 object school_base = null;
-                response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
+                response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey("Base"));
                 if (response.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
@@ -316,7 +316,7 @@ namespace TEAMModelOS.Controllers
 
                 //取得班级
                 List<object> school_classes = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.school, ARRAY_LENGTH(c.students) AS studCount FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.school, ARRAY_LENGTH(c.students) AS studCount FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
                 {
                     var jsonc = await JsonDocument.ParseAsync(item.ContentStream);
                     foreach (var classeinfo in jsonc.RootElement.GetProperty("Documents").EnumerateArray())
@@ -326,14 +326,14 @@ namespace TEAMModelOS.Controllers
                 }
                 //取得教室
                 List<Room> school_rooms = new List<Room>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ",
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ",
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Room-{school_code}") }))
                 {
                     school_rooms.Add(item);
                 }
                 //List<object> periods = new List<object>();
                 //List<object> grades = new List<object>();
-                //var responsesch = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey($"Base"));
+                //var responsesch = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(school_code.ToString(), new PartitionKey($"Base"));
                 //if (responsesch.Status == 200)
                 //{
                 //    var jsons = await JsonDocument.ParseAsync(responsesch.ContentStream);
@@ -363,7 +363,7 @@ namespace TEAMModelOS.Controllers
                 //該老師排定的學校課程
                 List<object> school_courses = new List<object>();
                 var query = $"SELECT c.id, c.name, c.teacher, cc.course, c.scope FROM c JOIN cc IN c.courses JOIN cct IN cc.teachers WHERE cct.id = '{id}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{school_code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{school_code}") }))
                 {
                     var jsoncm = await JsonDocument.ParseAsync(item.ContentStream);
                     if (jsoncm.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -402,7 +402,7 @@ namespace TEAMModelOS.Controllers
 
                 //校本課綱 [式樣未定 先不取]
                 List<SyllabusRole> school_syllabus = new List<SyllabusRole>();
-                //await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.name, c.period, c.grade, c.semester, c.subject, c.scope, c.resourceCount, c.itemCount, c.children from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{school_code}") }))
+                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.name, c.period, c.grade, c.semester, c.subject, c.scope, c.resourceCount, c.itemCount, c.children from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{school_code}") }))
                 //{
                 //    var jsons = await JsonDocument.ParseAsync(item.ContentStream);
                 //    if (jsons.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -464,7 +464,7 @@ namespace TEAMModelOS.Controllers
                 Dictionary<string, List<Dictionary<string, string>>> managerSchDic = new Dictionary<string, List<Dictionary<string, string>>>();
                 string managerWhereOption = (!string.IsNullOrWhiteSpace(sqlSchoolId)) ? $" AND c.code = 'Teacher-{sqlSchoolId}'" : string.Empty;
                 string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, 'admin', true) AND c.pk = 'Teacher' AND c.status = 'join'{managerWhereOption}";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() {} ))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() {} ))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -490,7 +490,7 @@ namespace TEAMModelOS.Controllers
                 //有管理模組的學校
                 List<string> baseModuleSchList = new List<string>();
                 string baseModuleWhereOption = (!string.IsNullOrWhiteSpace(sqlSchoolId)) ? $" AND c.id = '{sqlSchoolId}'" : string.Empty;
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id FROM c JOIN serviceProduct IN c.service.product WHERE serviceProduct.prodCode = 'IPDYZYLC'{baseModuleWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id FROM c JOIN serviceProduct IN c.service.product WHERE serviceProduct.prodCode = 'IPDYZYLC'{baseModuleWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -503,7 +503,7 @@ namespace TEAMModelOS.Controllers
                 //學校資料
                 List<object> schools = new List<object>();
                 string schoolWhereOption = (!string.IsNullOrWhiteSpace(sqlSchoolId)) ? $" WHERE c.id = '{sqlSchoolId}'" : string.Empty;
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.name, c.region, c.province, c.city, c.picture FROM c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id, c.name, c.region, c.province, c.city, c.picture FROM c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     var jsons = await JsonDocument.ParseAsync(item.ContentStream);
                     if (jsons.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -585,7 +585,7 @@ namespace TEAMModelOS.Controllers
                 jwt.Payload.TryGetValue("picture", out object picture);
                 var client = _azureCosmos.GetCosmosClient();
                 //在老師表找出老師,處理該學校狀態 (老師基本資料應該要存在)
-                Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
+                Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
                 if (teacher.schools == null)
                     teacher.schools = new List<Teacher.School>();
                 var school = teacher.schools?.FirstOrDefault(x => x.schoolId.Equals(school_code.GetString(), StringComparison.OrdinalIgnoreCase));
@@ -612,8 +612,8 @@ namespace TEAMModelOS.Controllers
                     {
                         teacher.size = 2;
                     }
-                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
-                    var sresponse = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id, new PartitionKey($"Teacher-{school_code}"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
+                    var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id, new PartitionKey($"Teacher-{school_code}"));
                     return Ok(new { stauts = 1 });
                 }
                 else {
@@ -622,9 +622,9 @@ namespace TEAMModelOS.Controllers
                     {
                         teacher.size = 2;
                     }
-                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
                     //在學校表處理該學校教師帳號的狀態
-                    var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{school_code}"));
+                    var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id, new PartitionKey($"Teacher-{school_code}"));
                     if (sresponse.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
@@ -644,7 +644,7 @@ namespace TEAMModelOS.Controllers
                                 steacher.permissions = dft;
                             }
                         }
-                        var response = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(steacher, id, new PartitionKey($"Teacher-{school_code}"));
+                        var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(steacher, id, new PartitionKey($"Teacher-{school_code}"));
                     }
                     else
                     {
@@ -661,13 +661,13 @@ namespace TEAMModelOS.Controllers
                             size = 0,
                             status = grant_type.GetString()
                         };
-                        var response = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(st, new PartitionKey($"Teacher-{school_code}"));
+                        var response = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(st, new PartitionKey($"Teacher-{school_code}"));
                     }
                     Notification notification = null;
                     
                     List<SchoolTeacher> teachers = new List<SchoolTeacher>();
                     var queryslt = $"SELECT  value(c)  FROM c join A1 in c.roles   where  A1 in ('admin')";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolTeacher>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
                     {
                         teachers.Add(item);
                     }

+ 16 - 14
TEAMModelOS/Controllers/XTest/DataMigrationController.cs

@@ -28,14 +28,16 @@ namespace TEAMModelOS.Controllers
     public class DataMigrationController : ControllerBase
     {
         ///Teacher表
-        ///     复制的数据
-        ///     Base  ==>>Student
-        ///     迁移的数据   StuCourse  ==>> Student
-        ///                  Activity   ==>> Student
-        ///                  AbilitySub ==>> Student
-        ///                  ClassVideo ==>> Student
-        ///                  Debate     ==>> Student
-        ///                  Appraise   ==>> Student
+        ///     
+        ///     复制的数据  
+        ///     Base  ==>>Student   //IES5&教研中心
+        ///     迁移的数据   StuCourse  ==>> Student  //IES5
+        ///                  Activity   ==>> Student  //IES5
+        ///                  
+        ///                  AbilitySub ==>> Student  //IES5  教研中心
+        ///                  ClassVideo ==>> Student  //IES5  教研中心
+        ///                  Debate     ==>> Student  //IES5  教研中心
+        ///                  Appraise   ==>> Student  //IES5  教研中心
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureCosmosFactory _azureCosmos;
@@ -59,19 +61,19 @@ namespace TEAMModelOS.Controllers
             var client = _azureCosmos.GetCosmosClient();
             List<Teacher> items = new List<Teacher>();
             List<Task<Teacher>> update_teachers = new List<Task<Teacher>>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) {
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) {
                 items.Add(item);
                 if (item.size > 0)
                 {
                     if (item.pk == null)
                     {
                         item.pk = "Teacher";
-                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(item, item.id, partitionKey: new PartitionKey("Base"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(item, item.id, partitionKey: new PartitionKey("Base"));
                     }
-                    await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync<Teacher>(item, partitionKey: new PartitionKey("Base"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync<Teacher>(item, partitionKey: new PartitionKey("Base"));
                 }
                 else {
-                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Teacher>(item.id, partitionKey: new PartitionKey("Base"));
+                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<Teacher>(item.id, partitionKey: new PartitionKey("Base"));
                 }
             }
             return Ok(items);
@@ -89,9 +91,9 @@ namespace TEAMModelOS.Controllers
             var client = _azureCosmos.GetCosmosClient();
             List<Teacher> items = new List<Teacher>();
             List<Task<Teacher>> update_teachers = new List<Task<Teacher>>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<TmdUser>(requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<TmdUser>(requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
-                await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<TmdUser>(item,item.id, partitionKey: new PartitionKey("Base"));
+                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<TmdUser>(item,item.id, partitionKey: new PartitionKey("Base"));
             }
             return Ok(items);
         }

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

@@ -20,7 +20,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.Services.Common;
-
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelOS.Controllers
 {
@@ -49,9 +49,9 @@ namespace TEAMModelOS.Controllers
             List<ItemInfo> noPeriodId = new List<ItemInfo>();
             List<ItemInfo> noSubjectId = new List<ItemInfo>();
             List<ItemInfo> noGradeIds = new List<ItemInfo>();
-            School school=  await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>("hbcn", partitionKey: new PartitionKey("Base"));
+            School school=  await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>("hbcn", partitionKey: new PartitionKey("Base"));
             Random random = new Random();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-hbcn") }))
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-hbcn") }))
             {
                 if (string.IsNullOrEmpty(item.periodId))
                 {
@@ -83,7 +83,7 @@ namespace TEAMModelOS.Controllers
                         }
                     });
                     item.gradeIds = grds;
-                    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<ItemInfo>(item, item.id, new PartitionKey(item.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<ItemInfo>(item, item.id, new PartitionKey(item.code));
                 }
                 items.Add(item);
             }
@@ -108,7 +108,7 @@ namespace TEAMModelOS.Controllers
             }
             if (noGradeIds.IsNotEmpty()) {
                 var ids = noGradeIds.Select(x => x.id);
-                await client.GetContainer("TEAMModelOS", "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
+                await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
                 foreach(var rm in noGradeIds)
                 {
                     items.Remove(rm);
@@ -117,7 +117,7 @@ namespace TEAMModelOS.Controllers
             if (noPeriodId.IsNotEmpty())
             {
                 var ids = noPeriodId.Select(x => x.id);
-                await client.GetContainer("TEAMModelOS", "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
+                await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
                 foreach (var rm in noPeriodId)
                 {
                     items.Remove(rm);
@@ -126,7 +126,7 @@ namespace TEAMModelOS.Controllers
             if (noSubjectId.IsNotEmpty())
             {
                 var ids = noSubjectId.Select(x => x.id);
-                await client.GetContainer("TEAMModelOS", "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
+                await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
                 foreach (var rm in noSubjectId)
                 {
                     items.Remove(rm);
@@ -135,7 +135,7 @@ namespace TEAMModelOS.Controllers
             if (unMatch.IsNotEmpty())
             {
                 var ids = unMatch.Select(x => x.id);
-                await client.GetContainer("TEAMModelOS", "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
+                await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-hbcn");
                 foreach (var rm in unMatch)
                 {
                     items.Remove(rm);
@@ -153,7 +153,7 @@ namespace TEAMModelOS.Controllers
             });
             itemConds.ForEach(async cond =>
             {
-                await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(cond, new PartitionKey(cond.code));
+                await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(cond, new PartitionKey(cond.code));
             });
             return Ok(new { noGradeIds, itemConds });
         }
@@ -173,15 +173,15 @@ namespace TEAMModelOS.Controllers
             {
                 var client = _azureCosmos.GetCosmosClient();
                 //先处理未关联课程的教师私人名单 
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: "select value(c) from c ", requestOptions: new  QueryRequestOptions{PartitionKey= new PartitionKey("StuList") })) {
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: "select value(c) from c ", requestOptions: new  QueryRequestOptions{PartitionKey= new PartitionKey("StuList") })) {
                     string scdsql = $"SELECT value(A1) FROM c  join A1 in c.schedule  where    A1.stulist='{item.id}'";
                     int count = 0;
-                    await foreach (var schedule in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Schedule>(queryText: scdsql ))
+                    await foreach (var schedule in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Schedule>(queryText: scdsql ))
                     {
                         count += 1;
                     }
                     if (count == 0) {
-                      await  client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(item.id, new PartitionKey("StuList"));
+                      await  client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(item.id, new PartitionKey("StuList"));
                     }
                 }
                 HashSet<string> plistId = new HashSet<string>();
@@ -190,7 +190,7 @@ namespace TEAMModelOS.Controllers
                 //List<Course> pcourses = new List<Course>();
                 //处理私人名单
                 string sql = "select value(c) from c where c.pk='Course' ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Course>(queryText: sql))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: sql))
                 {
                     if (item.schedule.IsNotEmpty()) {
                         foreach (var scd in item.schedule) {
@@ -200,7 +200,7 @@ namespace TEAMModelOS.Controllers
                                 pkeyValuePairs.Add(new KeyValuePair<string, string>(scd.stulist, tmdid));
                                 item.creatorId = tmdid;
                                 item.scope = "private";
-                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
                             }
                         }
                     }
@@ -208,14 +208,14 @@ namespace TEAMModelOS.Controllers
                 List<string> pfaildId = new List<string>();
                 foreach (var list in plistId) {
                     try {
-                        StuList stuList= await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuList>(list, new PartitionKey("StuList"));
+                        StuList stuList= await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuList>(list, new PartitionKey("StuList"));
                         var a =  pkeyValuePairs.Where(x => x.Key == list).FirstOrDefault();
                         if (stuList.students.IsNotEmpty()) {
                             stuList.school = stuList.students[0].code.Replace("Base-", "");
                         }
                         stuList.creatorId = a.Value;
                         stuList.scope = "private";
-                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuList>(stuList, list, new PartitionKey("StuList"));
+                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuList>(stuList, list, new PartitionKey("StuList"));
                     } catch (CosmosException ex) {
                         pfaildId.Add(list);
                     }
@@ -225,7 +225,7 @@ namespace TEAMModelOS.Controllers
                 //处理学校的名单
                 HashSet<string> slistId = new HashSet<string>();
                 List<KeyValuePair<string, string>> skeyValuePairs = new List<KeyValuePair<string, string>>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(queryText: sql))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: sql))
                 {
                     if (item.schedule.IsNotEmpty())
                     {
@@ -238,7 +238,7 @@ namespace TEAMModelOS.Controllers
                                 skeyValuePairs.Add(new KeyValuePair<string, string>(scd.stulist, school));
                                 item.scope = "school";
                                 item.school = school;
-                                await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
                             }
                         }
                     }
@@ -249,10 +249,10 @@ namespace TEAMModelOS.Controllers
                 {
                     try
                     {
-                        StuList stuList = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<StuList>(list.Key, new PartitionKey($"StuList-{list.Value}"));
+                        StuList stuList = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<StuList>(list.Key, new PartitionKey($"StuList-{list.Value}"));
                         stuList.scope = "school";
                         stuList.school = list.Value;
-                        await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<StuList>(stuList, list.Key, new PartitionKey(stuList.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<StuList>(stuList, list.Key, new PartitionKey(stuList.code));
                     }
                     catch (CosmosException ex)
                     {

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

@@ -114,7 +114,7 @@ namespace TEAMModelOS.Controllers
             var client = _azureCosmos.GetCosmosClient();
             string aaa = "0";
             try { 
-                ItemResponse<Student> a = await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<Student>("1111111", new PartitionKey($"Course-111111"));
+                ItemResponse<Student> a = await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<Student>("1111111", new PartitionKey($"Course-111111"));
                 Ok(a.GetRawResponse().Status);
             } catch (CosmosException ex) {
                 if (ex.Response.Status == 404) {
@@ -124,7 +124,7 @@ namespace TEAMModelOS.Controllers
 
             try
             {
-                ItemResponse<Student> a = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<Student>("1111111", new PartitionKey($"Course-111111"));
+                ItemResponse<Student> a = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<Student>("1111111", new PartitionKey($"Course-111111"));
                 Ok(a.GetRawResponse().Status);
             }
             catch (CosmosException ex)
@@ -136,7 +136,7 @@ namespace TEAMModelOS.Controllers
             }
             try
             {
-                var a = await client.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync("1111111", new PartitionKey($"Course-111111"));
+                var a = await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemStreamAsync("1111111", new PartitionKey($"Course-111111"));
                 Ok(a.Status);
             }
             catch (CosmosException ex)
@@ -149,7 +149,7 @@ namespace TEAMModelOS.Controllers
 
             try
             {
-                var a = await client.GetContainer("TEAMModelOS", "Student").ReadItemStreamAsync("1111111", new PartitionKey($"Course-111111"));
+                var a = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemStreamAsync("1111111", new PartitionKey($"Course-111111"));
                 Ok(a.Status);
             }
             catch (CosmosException ex)
@@ -175,7 +175,7 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 List<ItemInfo> items = new List<ItemInfo>();
                 var queryslt = $"SELECT  value(c) FROM c where  c.pid = null ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-hbcn") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-hbcn") }))
                 {
 
                     items.Add(item);
@@ -191,7 +191,7 @@ namespace TEAMModelOS.Controllers
                 });
                 itemConds.ForEach(async cond =>
                 {
-                    await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(cond, new PartitionKey(cond.code));
+                    await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(cond, new PartitionKey(cond.code));
                 });
                 return   Ok(new { itemConds });
             }
@@ -238,7 +238,7 @@ namespace TEAMModelOS.Controllers
                         {
                             var urlsSize = await ContainerClient.GetBlobsSize(item);
                             Bloblog bloblog = new Bloblog { id = Guid.NewGuid().ToString(), code = $"Bloblog-{name}", pk = "Bloblog", time = now, size = urlsSize != null && urlsSize.HasValue ? urlsSize.Value : 0, type = prefix };
-                           await client.GetContainer("TEAMModelOS", tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code)) ;
+                           await client.GetContainer(Constant.TEAMModelOS, tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code)) ;
                         }
                     }
                      
@@ -273,7 +273,7 @@ namespace TEAMModelOS.Controllers
                 var query = $"select c.id from c ";
                 if (scope.ToString().Equals("school"))
                 {
-                    var ids = client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") });
+                    var ids = client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") });
                     await foreach (var id in ids)
                     {
                         using var json = await JsonDocument.ParseAsync(id.ContentStream);
@@ -281,12 +281,12 @@ namespace TEAMModelOS.Controllers
                         //批量删除
                         foreach (var obj in jsonList)
                         {
-                            tasksFiles.Add(client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(obj.GetProperty("id").ToString(), new PartitionKey($"{code}")));
+                            tasksFiles.Add(client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(obj.GetProperty("id").ToString(), new PartitionKey($"{code}")));
                         }
                     }
                 }
                 else if (scope.ToString().Equals("teacher")) {
-                    var ids = client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") });
+                    var ids = client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") });
                     await foreach (var id in ids)
                     {
                         using var json = await JsonDocument.ParseAsync(id.ContentStream);
@@ -294,7 +294,7 @@ namespace TEAMModelOS.Controllers
                         //批量删除
                         foreach (var obj in jsonList)
                         {
-                            //tasksFiles.Add(client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(obj.GetProperty("id").ToString(), new PartitionKey($"{code}")));
+                            //tasksFiles.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(obj.GetProperty("id").ToString(), new PartitionKey($"{code}")));
                         }
                     }
                 }

+ 1 - 0
TEAMModelOS/Services/Analysis/AchievementService.cs

@@ -1,3 +1,4 @@
+using HTEXLib.COMM.Helpers;
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 17 - 17
TEAMModelOS/Services/Common/ActivityStudentService.cs

@@ -53,7 +53,7 @@ namespace TEAMModelOS.Services.Common
                 //1.再次检查投票
                 var client = _azureCosmos.GetCosmosClient();
                 ///TODO 检查是否在投票范围内,包括在tmdids 及班级  但是需要处理认证金钥中的班级问题
-                await foreach (var item in client.GetContainer("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").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}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     vote = item;
@@ -148,15 +148,15 @@ namespace TEAMModelOS.Services.Common
                     {
                         if (!string.IsNullOrEmpty(school))
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{school}-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{school}-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{school}-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{school}-{userid}"));
                         }
                         else
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
                         }
 
                     }
@@ -164,9 +164,9 @@ namespace TEAMModelOS.Services.Common
                     {
                         if (ex.Status == 404)
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(vote.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
                         }
 
                     }
@@ -425,7 +425,7 @@ namespace TEAMModelOS.Services.Common
             }
             List<StuActivity> datas = new List<StuActivity>();
             var client = _azureCosmos.GetCosmosClient();
-            string containerId = "";
+            string containerId = "Student";
             string PartitionKey = "";
             if (!string.IsNullOrWhiteSpace(school) && userType.Equals("schoolid"))
             {
@@ -434,12 +434,12 @@ namespace TEAMModelOS.Services.Common
             }
             else
             {
-                containerId = "Teacher";
+                containerId = "Student";
                 PartitionKey = $"Activity-{id}";
             }
             string querySchool = $" SELECT distinct  value c   FROM c   {joinSqlSubjects}  where {stimesql}  {etimesql} and c.pk='Activity'   {typesql}  {andSqlSubjects}  ";
             //查询数据归属学校的
-            await foreach (var item in client.GetContainer("TEAMModelOS", containerId).GetItemQueryStreamIterator(querySchool, continuationToken: continuationToken,
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, containerId).GetItemQueryStreamIterator(querySchool, continuationToken: continuationToken,
                 requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey(PartitionKey) }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -485,7 +485,7 @@ namespace TEAMModelOS.Services.Common
                 var client = _azureCosmos.GetCosmosClient();
                 Survey survey = null;
                 ///TODO 检查是否在投票范围内,包括在tmdids 及班级  但是需要处理认证金钥中的班级问题
-                await foreach (var item in client.GetContainer("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").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}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     survey = item;
@@ -667,16 +667,16 @@ namespace TEAMModelOS.Services.Common
                     {
                         if (!string.IsNullOrEmpty(school))
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{school}-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{school}-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{school}-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{school}-{userid}"));
 
                         }
                         else
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
                         }
 
                     }
@@ -684,9 +684,9 @@ namespace TEAMModelOS.Services.Common
                     {
                         if (ex.Status == 404)
                         {
-                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
+                            StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(survey.id, new PartitionKey($"Activity-{userid}"));
                             activity.taskStatus = taskStatus;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
                         }
                     }
                 }

+ 1 - 1
TEAMModelOS/Services/Common/SheetService.cs

@@ -17,7 +17,7 @@ namespace TEAMModelOS.Services.Common
             string id = $"{Utils.CreatSaltString(7, _num09)}";
             for (int i = 0; i < 10; i++)
             {
-                Response response = await client.GetContainer("TEAMModelOS", tbname).ReadItemStreamAsync($"{id}", new PartitionKey(sheetCode)); 
+                Response response = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync($"{id}", new PartitionKey(sheetCode)); 
                 if (response.Status == 404)
                 {
                     break;

+ 1 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -14,7 +14,7 @@
     <PackageReference Include="Caching.CSRedis" Version="3.6.50" />
     <PackageReference Include="CSRedisCore" Version="3.6.5" />
     <PackageReference Include="DotNetZip" Version="1.15.0" />
-    <PackageReference Include="HTEXLib" Version="5.2108.31" />
+   
     <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
     <PackageReference Include="VueCliMiddleware" Version="5.0.0" />
   </ItemGroup>