|
@@ -235,7 +235,6 @@ namespace TEAMModelOS.CosmosDBTriggers
|
|
|
var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new PartitionKey($"Class-{info.school}"));
|
|
|
if (sresponse.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
{
|
|
|
-
|
|
|
using var json = await JsonDocument.ParseAsync(sresponse.Content);
|
|
|
Class classroom = json.ToObject<Class>();
|
|
|
|
|
@@ -393,6 +392,43 @@ namespace TEAMModelOS.CosmosDBTriggers
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
|
|
|
}
|
|
|
}*/
|
|
|
+
|
|
|
+ //統測活動處理
|
|
|
+ if(!string.IsNullOrWhiteSpace(info.jointExamId))
|
|
|
+ {
|
|
|
+ JointEventGroupDb jointCourse = new JointEventGroupDb();
|
|
|
+ string jointEventId = string.Empty;
|
|
|
+ string jointGroupId = string.Empty;
|
|
|
+ string examCreatorId = string.Empty;
|
|
|
+ ///取得統測活動、老師報名班級
|
|
|
+ var jexamResponse = await client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(info.jointExamId, new PartitionKey($"JointExam"));
|
|
|
+ if (jexamResponse.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(jexamResponse.Content);
|
|
|
+ JointExam jointExam = json.ToObject<JointExam>();
|
|
|
+ jointEventId = jointExam.jointEventId;
|
|
|
+ jointGroupId = jointExam.jointGroupId;
|
|
|
+ examCreatorId = jointExam.creatorId;
|
|
|
+ string jcSql = $"SELECT * FROM c WHERE c.jointEventId = '{jointEventId}' AND c.jointGroupId = '{jointGroupId}' AND c.creatorId = '{examCreatorId}' AND c.type = 'regular' ";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryStreamIteratorSql(queryText: jcSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"JointCourse") }))
|
|
|
+ {
|
|
|
+ using var jsonJc = await JsonDocument.ParseAsync(item.Content);
|
|
|
+ if (jsonJc.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in jsonJc.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ jointCourse = obj.ToObject<JointEventGroupDb>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ///更新 JointCourse
|
|
|
+ if(!string.IsNullOrWhiteSpace(jointCourse.id))
|
|
|
+ {
|
|
|
+ jointCourse = await JointService.CalJointCourseGroupScheduleStatusAsync(client, jointEventId, jointGroupId, examCreatorId, jointCourse, null); //各Schedule Status計算
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<JointEventGroupDb>(jointCourse, jointCourse.id, new PartitionKey(jointCourse.code));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -554,6 +590,43 @@ namespace TEAMModelOS.CosmosDBTriggers
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
|
|
|
}
|
|
|
await SetLearnRecordContent(info, data, _azureStorage, _azureCosmos);
|
|
|
+
|
|
|
+ //統測活動處理
|
|
|
+ if (!string.IsNullOrWhiteSpace(info.jointExamId))
|
|
|
+ {
|
|
|
+ JointEventGroupDb jointCourse = new JointEventGroupDb();
|
|
|
+ string jointEventId = string.Empty;
|
|
|
+ string jointGroupId = string.Empty;
|
|
|
+ string examCreatorId = string.Empty;
|
|
|
+ ///取得統測活動、老師報名班級
|
|
|
+ var jexamResponse = await client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(info.jointExamId, new PartitionKey($"JointExam"));
|
|
|
+ if (jexamResponse.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(jexamResponse.Content);
|
|
|
+ JointExam jointExam = json.ToObject<JointExam>();
|
|
|
+ jointEventId = jointExam.jointEventId;
|
|
|
+ jointGroupId = jointExam.jointGroupId;
|
|
|
+ examCreatorId = jointExam.creatorId;
|
|
|
+ string jcSql = $"SELECT * FROM c WHERE c.jointEventId = '{jointEventId}' AND c.jointGroupId = '{jointGroupId}' AND c.creatorId = '{examCreatorId}' AND c.type = 'regular' ";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryStreamIteratorSql(queryText: jcSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"JointCourse") }))
|
|
|
+ {
|
|
|
+ using var jsonJc = await JsonDocument.ParseAsync(item.Content);
|
|
|
+ if (jsonJc.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in jsonJc.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ jointCourse = obj.ToObject<JointEventGroupDb>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ///更新 JointCourse
|
|
|
+ if (!string.IsNullOrWhiteSpace(jointCourse.id))
|
|
|
+ {
|
|
|
+ jointCourse = await JointService.CalJointCourseGroupScheduleStatusAsync(client, jointEventId, jointGroupId, examCreatorId, jointCourse, null); //各Schedule Status計算
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<JointEventGroupDb>(jointCourse, jointCourse.id, new PartitionKey(jointCourse.code));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|