|
@@ -178,181 +178,190 @@ namespace TEAMModelFunction
|
|
|
#endregion
|
|
|
if (examClassResults.Count == 0)
|
|
|
{
|
|
|
- foreach (string cla in classes)
|
|
|
+ try
|
|
|
{
|
|
|
- int m = 0;
|
|
|
- foreach (ExamSubject subject in info.subjects)
|
|
|
+ foreach (string cla in classes)
|
|
|
{
|
|
|
- string classCode = "";
|
|
|
- if (string.IsNullOrEmpty(info.school) || !info.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
+ int m = 0;
|
|
|
+ foreach (ExamSubject subject in info.subjects)
|
|
|
{
|
|
|
- classCode = "ExamClassResult-" + info.creatorId;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- classCode = "ExamClassResult-" + info.school;
|
|
|
- }
|
|
|
- ExamClassResult result = new ExamClassResult
|
|
|
- {
|
|
|
- code = classCode,
|
|
|
- examId = info.id,
|
|
|
- id = Guid.NewGuid().ToString(),
|
|
|
- subjectId = subject.id,
|
|
|
- year = info.year,
|
|
|
- scope = info.scope
|
|
|
- };
|
|
|
- result.info.id = cla;
|
|
|
- List<string> ans = new List<string>();
|
|
|
- List<List<string>> anses = new List<List<string>>();
|
|
|
- List<List<Details>> marks = new List<List<Details>>();
|
|
|
- List<double> ansPoint = new List<double>();
|
|
|
- List<string> ids = new List<string>();
|
|
|
- foreach (double p in info.papers[m].point)
|
|
|
- {
|
|
|
- //Details details = new Details();
|
|
|
- //ans.Add(new List<string>());
|
|
|
- anses.Add(new List<string>());
|
|
|
- marks.Add(new List<Details>());
|
|
|
- ansPoint.Add(-1);
|
|
|
- }
|
|
|
- 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(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
|
|
|
- foreach (Period period in sc.period)
|
|
|
+ string classCode = "";
|
|
|
+ if (string.IsNullOrEmpty(info.school) || !info.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ classCode = "ExamClassResult-" + info.creatorId;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ classCode = "ExamClassResult-" + info.school;
|
|
|
+ }
|
|
|
+ ExamClassResult result = new ExamClassResult
|
|
|
{
|
|
|
- if (period.id.Equals(classroom.periodId))
|
|
|
+ code = classCode,
|
|
|
+ examId = info.id,
|
|
|
+ id = Guid.NewGuid().ToString(),
|
|
|
+ subjectId = subject.id,
|
|
|
+ year = info.year,
|
|
|
+ scope = info.scope
|
|
|
+ };
|
|
|
+ result.info.id = cla;
|
|
|
+ List<string> ans = new List<string>();
|
|
|
+ List<List<string>> anses = new List<List<string>>();
|
|
|
+ List<List<Details>> marks = new List<List<Details>>();
|
|
|
+ List<double> ansPoint = new List<double>();
|
|
|
+ List<string> ids = new List<string>();
|
|
|
+ foreach (double p in info.papers[m].point)
|
|
|
+ {
|
|
|
+ //Details details = new Details();
|
|
|
+ //ans.Add(new List<string>());
|
|
|
+ anses.Add(new List<string>());
|
|
|
+ marks.Add(new List<Details>());
|
|
|
+ ansPoint.Add(-1);
|
|
|
+ }
|
|
|
+ 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(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
|
|
|
+ foreach (Period period in sc.period)
|
|
|
{
|
|
|
- foreach (Semester semester in period.semesters)
|
|
|
+ if (period.id.Equals(classroom.periodId))
|
|
|
{
|
|
|
- if (semester.start == 1)
|
|
|
+ foreach (Semester semester in period.semesters)
|
|
|
{
|
|
|
- int year = DateTimeOffset.UtcNow.Year;
|
|
|
- int month = DateTimeOffset.UtcNow.Month;
|
|
|
- int day = DateTimeOffset.UtcNow.Day;
|
|
|
- int time = 0;
|
|
|
- if (month == semester.month)
|
|
|
+ if (semester.start == 1)
|
|
|
{
|
|
|
- time = day >= semester.day ? 0 : 1;
|
|
|
+ int year = DateTimeOffset.UtcNow.Year;
|
|
|
+ int month = DateTimeOffset.UtcNow.Month;
|
|
|
+ int day = DateTimeOffset.UtcNow.Day;
|
|
|
+ int time = 0;
|
|
|
+ if (month == semester.month)
|
|
|
+ {
|
|
|
+ time = day >= semester.day ? 0 : 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ time = month > semester.month ? 0 : 1;
|
|
|
+ }
|
|
|
+ int eyear = year - time;
|
|
|
+ result.gradeId = (eyear - classroom.year).ToString();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- time = month > semester.month ? 0 : 1;
|
|
|
- }
|
|
|
- int eyear = year - time;
|
|
|
- result.gradeId = (eyear - classroom.year).ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //result.info.id = classroom.id;
|
|
|
- result.info.name = classroom.name;
|
|
|
- //result.gradeId = classroom.year.ToString();
|
|
|
- //处理班级人数
|
|
|
- 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)
|
|
|
+ //result.info.id = classroom.id;
|
|
|
+ result.info.name = classroom.name;
|
|
|
+ //result.gradeId = classroom.year.ToString();
|
|
|
+ //处理班级人数
|
|
|
+ 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}") }))
|
|
|
{
|
|
|
- var accounts = json_stu.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
+ using var json_stu = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json_stu.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- ids.Add(account.GetProperty("id").GetString());
|
|
|
+ var accounts = json_stu.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ ids.Add(account.GetProperty("id").GetString());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
|
|
|
- {
|
|
|
- var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList"));
|
|
|
- if (stuResponse.Status == 200)
|
|
|
+ if (info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
|
|
|
- StuList stuList = json.ToObject<StuList>();
|
|
|
- //result.info.id = stuList.id;
|
|
|
- result.info.name = stuList.name;
|
|
|
- //处理发布对象为自选名单(个人)
|
|
|
-
|
|
|
- foreach (Students stus in stuList.students)
|
|
|
+ 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);
|
|
|
+ StuList stuList = json.ToObject<StuList>();
|
|
|
+ //result.info.id = stuList.id;
|
|
|
+ result.info.name = stuList.name;
|
|
|
+ //处理发布对象为自选名单(个人)
|
|
|
|
|
|
- if (!ids.Contains(stus.id))
|
|
|
+ foreach (Students stus in stuList.students)
|
|
|
{
|
|
|
- ids.Add(stus.id);
|
|
|
+
|
|
|
+ if (!ids.Contains(stus.id))
|
|
|
+ {
|
|
|
+ ids.Add(stus.id);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (stuList.tmids.Count > 0)
|
|
|
- {
|
|
|
- foreach (string tid in stuList.tmids)
|
|
|
+ if (stuList.tmids.Count > 0)
|
|
|
{
|
|
|
- ids.Add(tid);
|
|
|
+ foreach (string tid in stuList.tmids)
|
|
|
+ {
|
|
|
+ ids.Add(tid);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList-{info.school}"));
|
|
|
- if (stuResponse.Status == 200)
|
|
|
+ else
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
|
|
|
- StuList stuList = json.ToObject<StuList>();
|
|
|
- //result.info.id = stuList.id;
|
|
|
- result.info.name = stuList.name;
|
|
|
- //处理发布对象为自选名单(校本)
|
|
|
- foreach (Students stus in stuList.students)
|
|
|
+ var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"StuList-{info.school}"));
|
|
|
+ if (stuResponse.Status == 200)
|
|
|
{
|
|
|
- if (!ids.Contains(stus.id))
|
|
|
+ using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
|
|
|
+ StuList stuList = json.ToObject<StuList>();
|
|
|
+ //result.info.id = stuList.id;
|
|
|
+ result.info.name = stuList.name;
|
|
|
+ //处理发布对象为自选名单(校本)
|
|
|
+ foreach (Students stus in stuList.students)
|
|
|
{
|
|
|
- ids.Add(stus.id);
|
|
|
+ if (!ids.Contains(stus.id))
|
|
|
+ {
|
|
|
+ ids.Add(stus.id);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- foreach (string stu in ids)
|
|
|
- {
|
|
|
- result.mark.Add(marks);
|
|
|
- result.studentIds.Add(stu);
|
|
|
- result.studentAnswers.Add(ans);
|
|
|
- result.studentScores.Add(ansPoint);
|
|
|
- result.ans.Add(anses);
|
|
|
- result.sum.Add(0);
|
|
|
- }
|
|
|
+ foreach (string stu in ids)
|
|
|
+ {
|
|
|
+ result.mark.Add(marks);
|
|
|
+ result.studentIds.Add(stu);
|
|
|
+ result.studentAnswers.Add(ans);
|
|
|
+ result.studentScores.Add(ansPoint);
|
|
|
+ result.ans.Add(anses);
|
|
|
+ result.sum.Add(0);
|
|
|
+ }
|
|
|
|
|
|
- //result.progress = info.progress;
|
|
|
- result.school = info.school;
|
|
|
- m++;
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
|
|
|
+ //result.progress = info.progress;
|
|
|
+ result.school = info.school;
|
|
|
+ m++;
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- // 发送信息通知
|
|
|
- var messageEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = code }.ToJsonString());
|
|
|
- messageEnd.ApplicationProperties.Add("name", "Exam");
|
|
|
- if (records.Count > 0)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
- 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(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测going初始化异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
- ChangeRecord changeRecord = new ChangeRecord
|
|
|
+ finally {
|
|
|
+ // 发送信息通知
|
|
|
+ var messageEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = code }.ToJsonString());
|
|
|
+ messageEnd.ApplicationProperties.Add("name", "Exam");
|
|
|
+ if (records.Count > 0)
|
|
|
{
|
|
|
- RowKey = input.Id,
|
|
|
- PartitionKey = "going",
|
|
|
- sequenceNumber = end,
|
|
|
- msgId = messageEnd.MessageId
|
|
|
- };
|
|
|
- await _azureStorage.Save<ChangeRecord>(changeRecord);
|
|
|
- //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
|
|
|
- }
|
|
|
+ long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
+ 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(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
|
+ ChangeRecord changeRecord = new ChangeRecord
|
|
|
+ {
|
|
|
+ RowKey = input.Id,
|
|
|
+ PartitionKey = "going",
|
|
|
+ sequenceNumber = end,
|
|
|
+ msgId = messageEnd.MessageId
|
|
|
+ };
|
|
|
+ await _azureStorage.Save<ChangeRecord>(changeRecord);
|
|
|
+ //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|