浏览代码

调整课堂记录更新

zhouj1203@hotmail.com 3 年之前
父节点
当前提交
eaf928563a
共有 1 个文件被更改,包括 24 次插入3 次删除
  1. 24 3
      TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

+ 24 - 3
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -951,9 +951,30 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                     Course course = null;
                                     try
                                     {
-                                        course = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Course>(lessonRecord.courseId, new PartitionKey($"Course-{lessonRecord.school}"));
+                                        var cresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(lessonRecord.courseId, new PartitionKey($"Course-{lessonRecord.school}"));
+                                        if (cresponse.Status == 200)
+                                        {
+                                            using var cJson = await JsonDocument.ParseAsync(cresponse.ContentStream);
+                                            course = cJson.ToObject<Course>();
+                                        }
+                                        else
+                                        {
+                                            var sresponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(lessonRecord.courseId, new PartitionKey($"Course-{lessonRecord.tmdid}"));
+                                            if (sresponse.Status == 200)
+                                            {
+                                                using var cJson = await JsonDocument.ParseAsync(sresponse.ContentStream);
+                                                course = cJson.ToObject<Course>();
+                                            }
+                                            else
+                                            {
+                                                course = null;
+                                            }
+                                        }
                                     }
-                                    catch (CosmosException ex) when (ex.Status != 404)
+                                    catch (Exception ex) {
+                                        await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-查询课程-CosmosDB异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                                    }
+                                    /*catch (CosmosException ex) when (ex.Status != 404)
                                     {
                                         try
                                         {
@@ -963,7 +984,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                         {
                                             course = null;
                                         }
-                                    }
+                                    }*/
                                     if (course != null)
                                     {
                                         lessonRecord.periodId = course.period?.id;