소스 검색

ServiceBus 调整

liqk 4 년 전
부모
커밋
d073c0ee8a
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      TEAMModelFunction/MonitorCosmosDB.cs

+ 4 - 3
TEAMModelFunction/MonitorCosmosDB.cs

@@ -42,7 +42,7 @@ namespace TEAMModelFunction
             var client = _azureCosmos.GetCosmosClient();
             List<ExamInfo> exams = new List<ExamInfo>();
             string pk = input[0].GetPropertyValue<string>("pk");
-            if (pk.Equals("Exam")) {
+            if (!string.IsNullOrEmpty(pk) &&  pk.Equals("Exam")) {
                 string code = input[0].GetPropertyValue<string>("code");
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id = '{input[0].Id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{code}") }))
                 {
@@ -64,7 +64,7 @@ namespace TEAMModelFunction
                     if (exams[i].progress.Equals("going")) { 
 
                         //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exams[i], exams[i].id.ToString(), new Azure.Cosmos.PartitionKey($"{exams[i].code}"));
-                        for (int j = 0;i< exams[i].subjects.Count;j++) {
+                        for (int j = 0;j< exams[i].subjects.Count;j++) {
                             for (int k = 0; k < exams[i].targetClassIds.Count; k++) {                         
                                 ExamClassResult result = new ExamClassResult();
                                 result.code = "ExamClassResult-" + exams[i].school;
@@ -73,6 +73,7 @@ namespace TEAMModelFunction
                                 result.subjectId = exams[i].subjects[j].id;
                                 result.year = exams[i].year;
                                 result.ttl = -1;
+                                result.pk = typeof(ExamClassResult).Name;
                                 result.info.id = exams[i].targetClassIds[k];
                                 var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(exams[i].targetClassIds[k], new Azure.Cosmos.PartitionKey($"Class-{exams[i].school}"));
                                 if (sresponse.Status == 200)
@@ -94,7 +95,7 @@ namespace TEAMModelFunction
                                 }                               
                                 result.progress = exams[i].progress;
                                 result.school = exams[i].school;
-                                await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
+                                await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
 
                             }
                         }