|
@@ -407,83 +407,102 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
/// <param name="client"></param>
|
|
|
/// <param name="data"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<List<string>> FixExamPublish(CosmosClient client, JsonElement data)
|
|
|
+ public static async Task<List<string>> FixExamPublish(CosmosClient client, DingDing _dingDing, JsonElement data, Option _option)
|
|
|
{
|
|
|
List<string> infos = new List<string>();
|
|
|
- var dict = data.GetProperty("publish").GetInt32();
|
|
|
+ //var dict = data.GetProperty("publish").GetInt32();
|
|
|
//List<(string id, string code)> ps = new List<(string id, string code)>();
|
|
|
List<object> exams = new List<object>();
|
|
|
List<Task<ItemResponse<ExamInfo>>> tasks = new List<Task<ItemResponse<ExamInfo>>>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"SELECT value(c) FROM c where c.pk = 'Exam'"))
|
|
|
- {
|
|
|
-
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ try {
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"SELECT value(c) FROM c where c.pk = 'Exam' and c.publish = '0'" ))
|
|
|
{
|
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- if (obj.TryGetProperty("publish", out JsonElement publish))
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
- try
|
|
|
+ if (obj.TryGetProperty("publish", out JsonElement publish))
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(publish.GetString()) && publish.GetString().Equals("0"))
|
|
|
+ try
|
|
|
{
|
|
|
- ExamInfo examInfo = new ExamInfo
|
|
|
+ if (string.IsNullOrEmpty(publish.GetString()) || publish.GetString().Equals("0"))
|
|
|
{
|
|
|
- id = obj.GetProperty("id").GetString(),
|
|
|
- owner = obj.TryGetProperty("owner", out JsonElement owner) ? owner.GetString() : "",
|
|
|
- //examInfo.owner = obj.GetProperty("owner").GetString();
|
|
|
- name = obj.GetProperty("name").GetString(),
|
|
|
- school = obj.GetProperty("school").GetString(),
|
|
|
- creatorId = obj.GetProperty("creatorId").GetString(),
|
|
|
- stuCount = obj.TryGetProperty("stuCount", out JsonElement stuCount) ? stuCount.GetInt32() : 0,
|
|
|
- createTime = obj.GetProperty("createTime").GetInt64(),
|
|
|
- updateTime = obj.TryGetProperty("updateTime", out JsonElement updateTime) ? updateTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
- startTime = obj.GetProperty("startTime").GetInt64(),
|
|
|
- endTime = obj.GetProperty("endTime").GetInt64(),
|
|
|
- year = obj.TryGetProperty("year", out JsonElement year) ? year.GetInt32() : 0,
|
|
|
- source = obj.TryGetProperty("source", out JsonElement source) ? source.GetString() : "0",
|
|
|
- classes = obj.TryGetProperty("classes", out JsonElement classes) ? classes.ToObject<List<string>>() : new List<string>(),
|
|
|
- stuLists = obj.TryGetProperty("stuLists", out JsonElement stuLists) ? stuLists.ToObject<List<string>>() : new List<string>(),
|
|
|
- //examInfo.stuLists = obj.GetProperty("stuLists").ToObject<List<string>>();
|
|
|
- papers = obj.TryGetProperty("papers", out JsonElement papers) ? papers.ToObject<List<PaperSimple>>() : new List<PaperSimple>(),
|
|
|
- type = obj.TryGetProperty("type", out JsonElement type) ? type.GetString() : "",
|
|
|
- period = obj.TryGetProperty("period", out JsonElement period) ? period.ToObject<PeriodSimple>() : new PeriodSimple(),
|
|
|
- grades = obj.TryGetProperty("grades", out JsonElement grades) ? grades.ToObject<List<Grade>>() : new List<Grade>(),
|
|
|
- subjects = obj.GetProperty("subjects").ToObject<List<ExamSubject>>(),
|
|
|
- progress = obj.TryGetProperty("progress", out JsonElement progress) ? progress.GetString() : "finish",
|
|
|
- scope = obj.TryGetProperty("scope", out JsonElement scope) ? scope.GetString() : "school",
|
|
|
- examType = obj.TryGetProperty("examType", out JsonElement examType) ? examType.ToObject<Custom>() : new Custom(),
|
|
|
- status = obj.TryGetProperty("status", out JsonElement status) ? status.GetInt32() : 0,
|
|
|
- average = obj.TryGetProperty("average", out JsonElement average) ? average.GetDouble() : 0,
|
|
|
- sRate = obj.TryGetProperty("sRate", out JsonElement sRate) ? sRate.GetDouble() : 0,
|
|
|
- lostStu = obj.TryGetProperty("lostStu", out JsonElement lostStu) ? lostStu.ToObject<List<string>>() : new List<string>(),
|
|
|
- standard = obj.TryGetProperty("standard", out JsonElement standard) ? standard.GetDouble() : 0,
|
|
|
- size = obj.TryGetProperty("size", out JsonElement size) ? standard.GetInt64() : 0,
|
|
|
- income = obj.TryGetProperty("income", out JsonElement income) ? income.GetInt32() : 0,
|
|
|
- touch = obj.TryGetProperty("touch", out JsonElement touch) ? touch.GetInt32() : 0,
|
|
|
- publish = 0,
|
|
|
- groupLists = obj.TryGetProperty("groupLists", out JsonElement groupLists) ? groupLists.ToObject<List<Dictionary<string, List<string>>>>() : new List<Dictionary<string, List<string>>>(),
|
|
|
- targets = obj.TryGetProperty("targets", out JsonElement targets) ? targets.ToObject<List<JsonElement>>() : new List<JsonElement>()
|
|
|
+ ExamInfo examInfo = new ExamInfo
|
|
|
+ {
|
|
|
+ id = obj.GetProperty("id").GetString(),
|
|
|
+ owner = obj.TryGetProperty("owner", out JsonElement owner) ? owner.GetString() : "",
|
|
|
+ code = obj.TryGetProperty("code", out JsonElement code) ? code.GetString() : "",
|
|
|
+ //examInfo.owner = obj.GetProperty("owner").GetString();
|
|
|
+ name = obj.GetProperty("name").GetString(),
|
|
|
+ school = obj.GetProperty("school").GetString(),
|
|
|
+ creatorId = obj.GetProperty("creatorId").GetString(),
|
|
|
+ stuCount = obj.TryGetProperty("stuCount", out JsonElement stuCount) ? stuCount.GetInt32() : 0,
|
|
|
+ createTime = obj.GetProperty("createTime").GetInt64(),
|
|
|
+ updateTime = obj.TryGetProperty("updateTime", out JsonElement updateTime) ? updateTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
+ startTime = obj.TryGetProperty("startTime", out JsonElement startTime) ? startTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
+ endTime = obj.TryGetProperty("endTime", out JsonElement endTime) ? endTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
+ year = obj.TryGetProperty("year", out JsonElement year) ? year.GetInt32() : 0,
|
|
|
+ source = obj.TryGetProperty("source", out JsonElement source) ? source.GetString() : "0",
|
|
|
+ classes = obj.TryGetProperty("classes", out JsonElement classes) ? classes.ToObject<List<string>>() : new List<string>(),
|
|
|
+ stuLists = obj.TryGetProperty("stuLists", out JsonElement stuLists) ? stuLists.ToObject<List<string>>() : new List<string>(),
|
|
|
+ //examInfo.stuLists = obj.GetProperty("stuLists").ToObject<List<string>>();
|
|
|
+ papers = obj.TryGetProperty("papers", out JsonElement papers) ? papers.ToObject<List<PaperSimple>>() : new List<PaperSimple>(),
|
|
|
+ type = obj.TryGetProperty("type", out JsonElement type) ? type.GetString() : "",
|
|
|
+ period = obj.TryGetProperty("period", out JsonElement period) ? period.ToObject<PeriodSimple>() : new PeriodSimple(),
|
|
|
+ grades = obj.TryGetProperty("grades", out JsonElement grades) ? grades.ToObject<List<Grade>>() : new List<Grade>(),
|
|
|
+ subjects = obj.GetProperty("subjects").ToObject<List<ExamSubject>>(),
|
|
|
+ progress = obj.TryGetProperty("progress", out JsonElement progress) ? progress.GetString() : "finish",
|
|
|
+ scope = obj.TryGetProperty("scope", out JsonElement scope) ? scope.GetString() : "school",
|
|
|
+ examType = obj.TryGetProperty("examType", out JsonElement examType) ? examType.ToObject<Custom>() : new Custom(),
|
|
|
+ status = obj.TryGetProperty("status", out JsonElement status) ? status.GetInt32() : 0,
|
|
|
+ average = obj.TryGetProperty("average", out JsonElement average) ? average.GetDouble() : 0,
|
|
|
+ sRate = obj.TryGetProperty("sRate", out JsonElement sRate) ? sRate.GetDouble() : 0,
|
|
|
+ lostStu = obj.TryGetProperty("lostStu", out JsonElement lostStu) ? lostStu.ToObject<List<string>>() : new List<string>(),
|
|
|
+ standard = obj.TryGetProperty("standard", out JsonElement standard) ? standard.GetDouble() : 0,
|
|
|
+ size = obj.TryGetProperty("size", out JsonElement size) ? size.GetInt64() : 0,
|
|
|
+ income = obj.TryGetProperty("income", out JsonElement income) ? income.GetInt32() : 0,
|
|
|
+ touch = obj.TryGetProperty("touch", out JsonElement touch) ? touch.GetInt32() : 0,
|
|
|
+ publish = 0,
|
|
|
+ groupLists = obj.TryGetProperty("groupLists", out JsonElement groupLists) ? groupLists.ToObject<List<Dictionary<string, List<string>>>>() : new List<Dictionary<string, List<string>>>(),
|
|
|
+ targets = obj.TryGetProperty("targets", out JsonElement targets) ? targets.ToObject<List<JsonElement>>() : new List<JsonElement>()
|
|
|
+ };
|
|
|
+ tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new PartitionKey(examInfo.code)));
|
|
|
+ infos.Add(examInfo.id);
|
|
|
};
|
|
|
- tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new PartitionKey(examInfo.code)));
|
|
|
- infos.Add(examInfo.id);
|
|
|
- };
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- var aa = obj.GetProperty("id").GetString();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location} /fix-data/fix-publish \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //await Task.WhenAll(tasks);
|
|
|
+ int pagesize = 50;
|
|
|
+ if (tasks.Count <= pagesize)
|
|
|
+ {
|
|
|
+ await Task.WhenAll(tasks);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int pages = (tasks.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
|
|
|
+ for (int i = 0; i < pages; i++)
|
|
|
+ {
|
|
|
+ var listssb = tasks.Skip((i) * pagesize).Take(pagesize).ToList();
|
|
|
+ await Task.WhenAll(listssb);
|
|
|
}
|
|
|
}
|
|
|
- await Task.WhenAll(tasks);
|
|
|
- /* info.publish = dict;
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
|
|
|
- infos.Add(info.id);*/
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location} /fix-data/fix-publish \n {e.Message}{e.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
+
|
|
|
/*foreach (var item in exams) {
|
|
|
dynamic dyn = JsonConvert.DeserializeObject(Convert.ToString(item)) ;
|
|
|
foreach (var obj in dyn)
|
|
@@ -514,16 +533,19 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
List<ExamClassResult> results = new List<ExamClassResult>();
|
|
|
List<string> ids = new List<string>();
|
|
|
List<Task<ItemResponse<ExamClassResult>>> tasks = new List<Task<ItemResponse<ExamClassResult>>>();
|
|
|
+ List<Task<ItemResponse<ExamInfo>>> taskInfo = new List<Task<ItemResponse<ExamInfo>>>();
|
|
|
try
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"SELECT value(c) FROM c where c.pk = 'ExamClassResult' and c.scIds <> []"))
|
|
|
+ /*await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"SELECT value(c) FROM c where c.pk = 'ExamClassResult' and c._ts >= 1640966400"))
|
|
|
{
|
|
|
results.Add(item);
|
|
|
//await Task.WhenAll(tasks);
|
|
|
}
|
|
|
+ HashSet<string> examIds = new HashSet<string>();
|
|
|
foreach (var item in results)
|
|
|
{
|
|
|
ids.Add(item.id);
|
|
|
+ examIds.Add(item.examId);
|
|
|
List<int> status = new List<int>();
|
|
|
//List<string> classIds = new List<string>();
|
|
|
//classIds.Add(item.info.id);
|
|
@@ -554,39 +576,35 @@ namespace TEAMModelOS.SDK.Models.Service
|
|
|
}
|
|
|
item.status = vs;
|
|
|
}
|
|
|
- /*if (!string.IsNullOrEmpty(item.info.id) && item.scIds.Count == 0)
|
|
|
- {
|
|
|
- string school = string.Empty;
|
|
|
- if (item.scope.Equals("school"))
|
|
|
- {
|
|
|
- school = item.school;
|
|
|
- }
|
|
|
- (List<RMember> rs, List<RGroupList> groupLists) = await GroupListService.GetStutmdidListids(_coreAPIHttpService, client, _dingDing, classIds, school, null);
|
|
|
- foreach (string id in item.studentIds)
|
|
|
+ *//*if (item.progress == true) {
|
|
|
+ int n = 0;
|
|
|
+ foreach (string sta in item.studentIds)
|
|
|
{
|
|
|
- if (rs.Count == 0)
|
|
|
- {
|
|
|
- item.scIds.Add("");
|
|
|
- }
|
|
|
- else
|
|
|
+ for (int i = 0; i < item.studentScores[n].Count; i++)
|
|
|
{
|
|
|
- var code = rs.FirstOrDefault(c => c.id == id)?.code;
|
|
|
- //var code = rs.Where(x => x.id.Equals(id))?.FirstOrDefault().code;
|
|
|
- if (code != null)
|
|
|
+ if (item.studentScores[n][i] == -1)
|
|
|
{
|
|
|
- item.scIds.Add(code.ToString());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- item.scIds.Add("");
|
|
|
+ item.studentScores[n][i] = 0;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ n++;
|
|
|
}
|
|
|
- }*/
|
|
|
+ }*//*
|
|
|
+
|
|
|
+
|
|
|
tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamClassResult>(item, item.id, new PartitionKey(item.code)));
|
|
|
+ }*/
|
|
|
+ List<ExamInfo> info = new List<ExamInfo>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: $"SELECT value(c) FROM c where c.pk = 'Exam' and c.progress = 'finish' and c._ts >= 1640966400"))
|
|
|
+ {
|
|
|
+ info.Add(item);
|
|
|
+ //await Task.WhenAll(tasks);
|
|
|
+ }
|
|
|
+ foreach (var item in info) {
|
|
|
+ item.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ taskInfo.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(item, item.id, new PartitionKey(item.code)));
|
|
|
}
|
|
|
- await Task.WhenAll(tasks);
|
|
|
+ await Task.WhenAll(taskInfo);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|