|
@@ -56,6 +56,7 @@ using TEAMModelOS.Models.Dto;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
|
|
|
using DocumentFormat.OpenXml.Office2021.DocumentTasks;
|
|
|
using Task = System.Threading.Tasks.Task;
|
|
|
+using System.Threading;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -613,20 +614,44 @@ namespace TEAMModelOS.Controllers
|
|
|
tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(evaluation, evaluation.id, new PartitionKey(evaluation.code)));
|
|
|
}
|
|
|
await tasks.TaskPage(10);*/
|
|
|
- List<Task<ItemResponse<ArtEvaluation>>> tasks = new List<Task<ItemResponse<ArtEvaluation>>>();
|
|
|
+ /*List<Task<ItemResponse<ArtEvaluation>>> tasks = new List<Task<ItemResponse<ArtEvaluation>>>();
|
|
|
foreach (ArtEvaluation evaluation in art)
|
|
|
{
|
|
|
evaluation.endTime = 1709112600000;
|
|
|
tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(evaluation, evaluation.id, new PartitionKey(evaluation.code)));
|
|
|
- }
|
|
|
- await tasks.TaskPage(10);
|
|
|
- List<Task<ItemResponse<ExamInfo>>> taskInfo = new List<Task<ItemResponse<ExamInfo>>>();
|
|
|
- foreach (ExamInfo info in infos)
|
|
|
+ }*/
|
|
|
+ //await tasks.TaskPage(10);
|
|
|
+ /* List<Task<ItemResponse<ExamInfo>>> taskInfo = new List<Task<ItemResponse<ExamInfo>>>();
|
|
|
+ foreach (ExamInfo info in infos)
|
|
|
+ {
|
|
|
+ info.period = art.Where(c => c.school.Equals(info.school)).FirstOrDefault().period;
|
|
|
+ taskInfo.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(info, info.id, new PartitionKey(info.code)));
|
|
|
+ }*/
|
|
|
+ string sql = $"SELECT value(c) FROM c ";
|
|
|
+ List<School> schools = new();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
|
|
|
{
|
|
|
- info.endTime = 1709112600000;
|
|
|
- taskInfo.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(info, info.id, new PartitionKey(info.code)));
|
|
|
+ schools.Add(item);
|
|
|
}
|
|
|
- await taskInfo.TaskPage(10);
|
|
|
+ await Parallel.ForEachAsync(art, async(rt,_) => {
|
|
|
+ //School scInfo = new();
|
|
|
+ //School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
|
|
|
+ /*var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{rt.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
|
|
|
+ if (response.Status == 200)
|
|
|
+ {
|
|
|
+ using var cJson = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ scInfo = cJson.ToObject<School>();
|
|
|
+ }*/
|
|
|
+ var periods = schools.Where(c => c.id.Equals(rt.school)).SelectMany(z => z.period).Where(p => p.periodType.Equals(rt.periodType)).ToList();
|
|
|
+ if (periods.Count > 0) {
|
|
|
+ ArtPeriod artPeriod = new() {
|
|
|
+ id = periods.FirstOrDefault().id,
|
|
|
+ name = periods.FirstOrDefault().name
|
|
|
+ };
|
|
|
+ rt.period = artPeriod;
|
|
|
+ }
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(rt, rt.id, new PartitionKey(rt.code));
|
|
|
+ });
|
|
|
return Ok();
|
|
|
}
|
|
|
[ProducesDefaultResponseType]
|