|
@@ -162,8 +162,10 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
List<Attachment> files = new();
|
|
|
files = request.attachments;
|
|
|
//bool flage = artResult.results.Exists(a => a.taskId == request.acId);
|
|
|
- artResult.results.ForEach(a => {
|
|
|
- if (a.taskId == request.acId) {
|
|
|
+ artResult.results.ForEach(a =>
|
|
|
+ {
|
|
|
+ if (a.taskId == request.acId)
|
|
|
+ {
|
|
|
a.files = files;
|
|
|
}
|
|
|
});
|
|
@@ -242,7 +244,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
//int userType = $"{scope}".Equals(Constant.ScopeStudent) ? 2 : 1;
|
|
|
List<stuFiles> stuFiles = stus.ToObject<List<stuFiles>>();
|
|
|
List<string> value = new List<string>();
|
|
|
- await foreach (var s in stuTask(stuFiles, client,school,artId.GetString(),classId.GetString(), quotaId.GetString(), acId.GetString(), subject.GetString()))
|
|
|
+ await foreach (var s in stuTask(stuFiles, client, school, artId.GetString(), classId.GetString(), quotaId.GetString(), acId.GetString(), subject.GetString()))
|
|
|
{
|
|
|
if (s.code == 1)
|
|
|
{
|
|
@@ -266,7 +268,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
|
|
|
}
|
|
|
|
|
|
- private async IAsyncEnumerable<(int code, string value)> stuTask(List<stuFiles> stuFiles ,CosmosClient client,string school,string artId,string classId,string quotaId,string acId,string subject)
|
|
|
+ private async IAsyncEnumerable<(int code, string value)> stuTask(List<stuFiles> stuFiles, CosmosClient client, string school, string artId, string classId, string quotaId, string acId, string subject)
|
|
|
{
|
|
|
string queryScore = $" select c.id from c where c.artId ='{artId}' and c.quotaId = '{quotaId}' and c.acId = '{acId}' and c.subject = '{subject}'";
|
|
|
List<string> ids = new();
|
|
@@ -282,17 +284,18 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
{
|
|
|
string sId = obj.GetProperty("id").GetString();
|
|
|
ids.Add(sId);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemsAsync<ArtRecord>(ids, "ArtRecord");
|
|
|
- // await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, school, new List<string> { $"art/{artId}" });
|
|
|
+ // await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, school, new List<string> { $"art/{artId}" });
|
|
|
foreach (var request in stuFiles)
|
|
|
{
|
|
|
string value = "";
|
|
|
int code = 0;
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
ArtRecord record = new()
|
|
|
{
|
|
@@ -339,7 +342,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
List<Attachment> files = new();
|
|
|
files = request.attachments;
|
|
|
//bool flage = artResult.results.Exists(a => a.taskId == request.acId);
|
|
|
- artResult.results.ForEach(a => {
|
|
|
+ artResult.results.ForEach(a =>
|
|
|
+ {
|
|
|
if (a.taskId == acId)
|
|
|
{
|
|
|
a.files = files;
|
|
@@ -388,7 +392,9 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(artResult, new PartitionKey($"{artResult.code}"));
|
|
|
}
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
value = request.stuId;
|
|
|
code = 1;
|
|
|
}
|
|
@@ -467,11 +473,11 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
data.status = 404;
|
|
|
await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(data, data.id, new PartitionKey($"Exam-{code}"));
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(art, art.id, new PartitionKey($"{art.code}"));
|
|
|
}
|
|
|
|
|
@@ -497,20 +503,21 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
try
|
|
|
{
|
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
- request.TryGetProperty("periodId", out JsonElement period) ;
|
|
|
- request.TryGetProperty("periodType", out JsonElement periodType) ;
|
|
|
- if (string.IsNullOrWhiteSpace($"{period}") && string.IsNullOrWhiteSpace($"{periodType}")) {
|
|
|
+ request.TryGetProperty("periodId", out JsonElement period);
|
|
|
+ request.TryGetProperty("periodType", out JsonElement periodType);
|
|
|
+ if (string.IsNullOrWhiteSpace($"{period}") && string.IsNullOrWhiteSpace($"{periodType}"))
|
|
|
+ {
|
|
|
return BadRequest();
|
|
|
}
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
StringBuilder stringBuilder = new($"select c.id,c.img,c.name,c.classes,c.code,c.type,c.startTime,c.endTime,c.presenter,c.topic,c.address,c.owner,c.progress from c where (c.status<>404 or IS_DEFINED(c.status) = false )");
|
|
|
string continuationToken = string.Empty;
|
|
|
string token = default;
|
|
|
- if ( !string.IsNullOrWhiteSpace($"{period}") && !string.IsNullOrWhiteSpace($"{periodType}"))
|
|
|
+ if (!string.IsNullOrWhiteSpace($"{period}") && !string.IsNullOrWhiteSpace($"{periodType}"))
|
|
|
{
|
|
|
stringBuilder.Append($" and (c.period.id = '{period}' or c.periodType = '{periodType}')");
|
|
|
}
|
|
|
- if (string.IsNullOrWhiteSpace($"{period}") && !string.IsNullOrWhiteSpace($"{periodType}"))
|
|
|
+ if (string.IsNullOrWhiteSpace($"{period}") && !string.IsNullOrWhiteSpace($"{periodType}"))
|
|
|
{
|
|
|
stringBuilder.Append($" and c.periodType = '{periodType}' ");
|
|
|
}
|
|
@@ -553,9 +560,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
continuationToken = item.GetContinuationToken();
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- //items.Where((x, i) => items.FindIndex(z => z.level == x.level) == i).Select(x => x.level).ToList();
|
|
|
arts = arts.Where((x, i) => arts.FindIndex(z => z.id == x.id) == i).ToList();
|
|
|
return Ok(new { arts });
|
|
|
}
|
|
@@ -589,7 +594,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
(queryText: queryArtExam, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtExam") }))
|
|
|
{
|
|
|
aes.Add(item);
|
|
|
- }
|
|
|
+ }
|
|
|
(List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, art.classes, art.school);
|
|
|
var classes = art.classes.Select(c => new
|
|
|
{
|
|
@@ -609,7 +614,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
});
|
|
|
List<ArtSubjectScore> subjectScores = new List<ArtSubjectScore>();
|
|
|
art.subjects.ForEach(z => { subjectScores.Add(new ArtSubjectScore { subjectId = z.id, score = 0 }); });
|
|
|
- var students = rmembers.Select(z => new StudentArtResult {
|
|
|
+ var students = rmembers.Select(z => new StudentArtResult
|
|
|
+ {
|
|
|
studentId = z.id,
|
|
|
studentName = z.name,
|
|
|
userType = z.type,
|
|
@@ -623,7 +629,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
ttl = -1,
|
|
|
subjectScores = subjectScores,
|
|
|
}).ToList();
|
|
|
- if (students.Any()) {
|
|
|
+ if (students.Any())
|
|
|
+ {
|
|
|
string query = $" select value c.id from c where c.id in({string.Join(",", students.Select(x => $"'{x.id}'"))}) ";
|
|
|
List<string> list = new List<string>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<string>
|
|
@@ -632,24 +639,29 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
list.Add(item);
|
|
|
}
|
|
|
students.RemoveAll(x => list.Contains(x.id));
|
|
|
- students.ForEach(x => {
|
|
|
- art.settings.ForEach(a => {
|
|
|
- a.task.ForEach(z => {
|
|
|
+ students.ForEach(x =>
|
|
|
+ {
|
|
|
+ art.settings.ForEach(a =>
|
|
|
+ {
|
|
|
+ a.task.ForEach(z =>
|
|
|
+ {
|
|
|
ArtQuotaResult quotaResult = new ArtQuotaResult
|
|
|
{
|
|
|
- taskId=z.acId,
|
|
|
- subjectId=z.subject,
|
|
|
- quotaId=a.id,
|
|
|
- quotaType=z.type.Value,
|
|
|
- quotaName=a.quotaname
|
|
|
+ taskId = z.acId,
|
|
|
+ subjectId = z.subject,
|
|
|
+ quotaId = a.id,
|
|
|
+ quotaType = z.type.Value,
|
|
|
+ quotaName = a.quotaname
|
|
|
};
|
|
|
x.results.Add(quotaResult);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
- if (students.Any()) {
|
|
|
+ if (students.Any())
|
|
|
+ {
|
|
|
List<Task<ItemResponse<StudentArtResult>>> responses = new List<Task<ItemResponse<StudentArtResult>>>();
|
|
|
- students.ForEach(z => {
|
|
|
+ students.ForEach(z =>
|
|
|
+ {
|
|
|
responses.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).CreateItemAsync(z, new PartitionKey(z.code)));
|
|
|
});
|
|
|
await Task.WhenAll(responses);
|
|
@@ -660,10 +672,11 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
ae = aes[0];
|
|
|
return Ok(new { art, classes, ae, code = 200 });
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
return Ok(new { art, classes, code = 200 });
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -861,8 +874,9 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- private class stuFiles {
|
|
|
- public string stuId { get; set; }
|
|
|
+ private class stuFiles
|
|
|
+ {
|
|
|
+ public string stuId { get; set; }
|
|
|
public int userType { get; set; }
|
|
|
public string name { get; set; }
|
|
|
public List<Attachment> attachments { get; set; } = new List<Attachment>();
|