|
@@ -82,7 +82,22 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
request.startTime = now;
|
|
|
}
|
|
|
-
|
|
|
+ //查询所有学生名单
|
|
|
+ List<string> sids = new List<string>();
|
|
|
+ //List<Student> students = new List<Student>();
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ sids.Add(account.GetProperty("id").GetString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
int stuCount = 0;
|
|
|
for (int i = 0; i < request.classes.Count; i++)
|
|
|
{
|
|
@@ -115,18 +130,33 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
foreach (StuList stuList in stuLists)
|
|
|
{
|
|
|
- foreach (Students students in stuList.students)
|
|
|
+ /*int index = 0;
|
|
|
+ foreach (Students stus in stuList.students)
|
|
|
{
|
|
|
- if (students.code.Contains(code))
|
|
|
+ if (sids.Contains(stus.id))
|
|
|
+ {
|
|
|
+ if (!ids.Contains(stus.id))
|
|
|
+ {
|
|
|
+ ids.Add(stus.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ stuList.students.RemoveAt(index);
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }*/
|
|
|
+ for (int j = 0; j < stuList.students.Count; j++) {
|
|
|
+
|
|
|
+ if (sids.Contains(stuList.students[j].id))
|
|
|
{
|
|
|
- if (!ids.Contains(students.id))
|
|
|
+ if (!ids.Contains(stuList.students[j].id))
|
|
|
{
|
|
|
- ids.Add(students.id);
|
|
|
+ ids.Add(stuList.students[j].id);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ids.Add(students.id);
|
|
|
+ stuList.students.RemoveAt(j);
|
|
|
}
|
|
|
}
|
|
|
if (stuList.tmids.Count > 0)
|
|
@@ -136,6 +166,7 @@ namespace TEAMModelOS.Controllers
|
|
|
ids.Add(tid);
|
|
|
}
|
|
|
}
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -153,20 +184,22 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
foreach (StuList stuList in stuLists)
|
|
|
{
|
|
|
- foreach (Students students in stuList.students)
|
|
|
+ for (int j = 0; j < stuList.students.Count; j++)
|
|
|
{
|
|
|
- if (students.code.Contains(code))
|
|
|
+
|
|
|
+ if (sids.Contains(stuList.students[j].id))
|
|
|
{
|
|
|
- if (!ids.Contains(students.id))
|
|
|
+ if (!ids.Contains(stuList.students[j].id))
|
|
|
{
|
|
|
- ids.Add(students.id);
|
|
|
+ ids.Add(stuList.students[j].id);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ids.Add(students.id);
|
|
|
+ stuList.students.RemoveAt(j);
|
|
|
}
|
|
|
}
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
|
|
|
}
|
|
|
|
|
|
}
|