zhouj1203@hotmail.com 4 år sedan
förälder
incheckning
8b57e30f5b

+ 13 - 9
TEAMModelFunction/MonitorCosmosDB.cs

@@ -104,14 +104,17 @@ namespace TEAMModelFunction
                                             {
                                                 for (int k = 0; k < info.targetClassIds.Count; k++)
                                                 {
-                                                    ExamClassResult result = new ExamClassResult();
-                                                    result.code = "ExamClassResult-" + info.school;
-                                                    result.examId = info.id;
-                                                    result.id = Guid.NewGuid().ToString();
-                                                    result.subjectId = info.subjects[j].id;
-                                                    result.year = info.year;                                                    
-                                                    result.scope = info.scope;
-                                                    result.pk = typeof(ExamClassResult).Name;
+                                                    ExamClassResult result = new ExamClassResult
+                                                    {
+                                                        code = "ExamClassResult-" + info.school,
+                                                        examId = info.id,
+                                                        id = Guid.NewGuid().ToString(),
+                                                        subjectId = info.subjects[j].id,
+                                                        year = info.year,
+                                                        scope = info.scope,
+                                                        ttl = -1,
+                                                        pk = typeof(ExamClassResult).Name
+                                                    };
                                                     result.info.id = info.targetClassIds[k];
                                                     var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(info.targetClassIds[k], new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
                                                     if (sresponse.Status == 200)
@@ -221,7 +224,8 @@ namespace TEAMModelFunction
                                                 //result.point = info.papers[j].point;
                                                 result.scope = info.scope;
                                                 result.name = info.name;
-                                                result.time = info.startTime;                                 
+                                                result.time = info.startTime;
+                                                result.ttl = -1;
                                                 await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").UpsertItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}"));
                                             }
                                         }

+ 0 - 5
TEAMModelOS.SDK/Models/Cosmos/Common/ExamClassResult.cs

@@ -19,11 +19,7 @@ namespace TEAMModelOS.SDK.Models
             studentAnswers = new List<List<List<string>>>();
             studentScores = new List<List<double>>();
         }
-        public string pk { get; set; }
-        [PartitionKey]
-        public string code { get; set; }
         public string school { get; set; }
-        public string id { get; set; }
         public string examId { get; set; }
         public string subjectId { get; set; }
         public int year { get; set; }
@@ -35,7 +31,6 @@ namespace TEAMModelOS.SDK.Models
         public List<List<List<string>>> studentAnswers { get; set; }
         public List<List<double>> studentScores { get; set; }
         public string scope { get; set; }
-        public int? ttl { get; set; }
     }
 /*    public class PaperSimple {
         public string id { get; set; }

+ 4 - 1
TEAMModelOS/Controllers/Exam/ExamController.cs

@@ -162,7 +162,10 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
-                await _azureCosmos.DeleteAll(examClassResults);
+                foreach (ExamClassResult classResult in examClassResults) {
+                    await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(classResult.id, new PartitionKey($"ExamClassResult-{code}"));
+                }
+                //await _azureCosmos.DeleteAll(examClassResults);
                 return Ok(new { id });