|
@@ -76,7 +76,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//id pw name classId no year
|
|
|
//retrun 如果有重複則回{ existNo } , 成功則{ id, name, year, classId, no }
|
|
|
var importStuds = request.GetProperty("students").EnumerateArray();
|
|
|
- Dictionary<string, ListChange> dictChange = new Dictionary<string, ListChange>();
|
|
|
+ Dictionary<string, GroupChange> dictChange = new Dictionary<string, GroupChange>();
|
|
|
while (importStuds.MoveNext())
|
|
|
{
|
|
|
JsonElement currStud = importStuds.Current;
|
|
@@ -102,28 +102,28 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(classId))
|
|
|
{
|
|
|
dictChange[classId].stujoin.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = id,
|
|
|
- code = $"Base-{schoolId.GetString()}",
|
|
|
- schoolId = schoolId.GetString()
|
|
|
+ code = $"{schoolId.GetString()}",
|
|
|
+ type=2,
|
|
|
});
|
|
|
}
|
|
|
else {
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId.GetString(),
|
|
|
type = "student",
|
|
|
originCode = schoolId.GetString(),
|
|
|
listid = classId,
|
|
|
- stujoin = new List<Students>
|
|
|
+ stujoin = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= id,
|
|
|
- code= $"Base-{schoolId.GetString()}",
|
|
|
- schoolId=schoolId.GetString()
|
|
|
+ code=schoolId.GetString(),
|
|
|
+ type=2,
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -135,7 +135,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (change.stujoin.Count != 0 || change.stuleave.Count != 0)
|
|
|
{
|
|
|
var messageChange = new ServiceBusMessage(change.ToJsonString());
|
|
|
- messageChange.ApplicationProperties.Add("name", "StuList");
|
|
|
+ messageChange.ApplicationProperties.Add("name", "GroupChange");
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
|
|
|
}
|
|
@@ -313,9 +313,9 @@ namespace TEAMModelOS.Controllers
|
|
|
/// <param name="opt">操作</param>
|
|
|
/// <param name="prestudents">变更前的学生</param>
|
|
|
/// <returns></returns>
|
|
|
- private async Task<Dictionary<string, ListChange>> CheckStudent(string schoolId, List<Student> students , string opt ,List<Student> prestudents) {
|
|
|
+ private async Task<Dictionary<string, GroupChange>> CheckStudent(string schoolId, List<Student> students , string opt ,List<Student> prestudents) {
|
|
|
List<Student> aftstudents=await GeStudentData(schoolId, students);
|
|
|
- Dictionary<string, ListChange> dictChange = new Dictionary<string, ListChange>();
|
|
|
+ Dictionary<string, GroupChange> dictChange = new Dictionary<string, GroupChange>();
|
|
|
if (prestudents.Count >= aftstudents.Count)
|
|
|
{
|
|
|
foreach (var pstu in prestudents)
|
|
@@ -329,29 +329,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(afstu.classId))
|
|
|
{
|
|
|
dictChange[afstu.classId].stujoin.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = afstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type =2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId ,
|
|
|
type = "student",
|
|
|
originCode = schoolId ,
|
|
|
listid =afstu. classId,
|
|
|
- stujoin = new List<Students>
|
|
|
+ stujoin = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= afstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type =2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -364,29 +364,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(pstu.classId))
|
|
|
{
|
|
|
dictChange[pstu.classId].stuleave.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = pstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type=2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = pstu.classId,
|
|
|
- stuleave = new List<Students>
|
|
|
+ stuleave = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= pstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type=2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -402,29 +402,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(afstu.classId))
|
|
|
{
|
|
|
dictChange[afstu.classId].stujoin.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = afstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type = 2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = afstu.classId,
|
|
|
- stujoin = new List<Students>
|
|
|
+ stujoin = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= afstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type = 2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -433,29 +433,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(pstu.classId))
|
|
|
{
|
|
|
dictChange[pstu.classId].stuleave.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = pstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type= 2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = pstu.classId,
|
|
|
- stuleave = new List<Students>
|
|
|
+ stuleave = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= pstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type= 2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -477,29 +477,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(pstu.classId))
|
|
|
{
|
|
|
dictChange[pstu.classId].stuleave.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = pstu.id,
|
|
|
code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ type = 2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = pstu.classId,
|
|
|
- stuleave = new List<Students>
|
|
|
+ stuleave = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= pstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type = 2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -521,29 +521,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(afstu.classId))
|
|
|
{
|
|
|
dictChange[afstu.classId].stujoin.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = afstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type = 2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = afstu.classId,
|
|
|
- stujoin = new List<Students>
|
|
|
+ stujoin = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= afstu.id,
|
|
|
code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ type = 2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -556,29 +556,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(pstu.classId))
|
|
|
{
|
|
|
dictChange[pstu.classId].stuleave.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = pstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type= 2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = pstu.classId,
|
|
|
- stuleave = new List<Students>
|
|
|
+ stuleave = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= pstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type= 2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -594,29 +594,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(afstu.classId))
|
|
|
{
|
|
|
dictChange[afstu.classId].stujoin.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = afstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type = 2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = afstu.classId,
|
|
|
- stujoin = new List<Students>
|
|
|
+ stujoin = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= afstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type = 2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -625,29 +625,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(pstu.classId))
|
|
|
{
|
|
|
dictChange[pstu.classId].stuleave.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = pstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type=2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = pstu.classId,
|
|
|
- stuleave = new List<Students>
|
|
|
+ stuleave = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= pstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type=2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -671,29 +671,29 @@ namespace TEAMModelOS.Controllers
|
|
|
if (dictChange.ContainsKey(afstu.classId))
|
|
|
{
|
|
|
dictChange[afstu.classId].stujoin.Add(
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id = afstu.id,
|
|
|
- code = $"Base-{schoolId }",
|
|
|
- schoolId = schoolId
|
|
|
+ code = $"{schoolId }",
|
|
|
+ type = 2
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ListChange change = new ListChange
|
|
|
+ GroupChange change = new GroupChange
|
|
|
{
|
|
|
scope = "school",
|
|
|
school = schoolId,
|
|
|
type = "student",
|
|
|
originCode = schoolId,
|
|
|
listid = afstu.classId,
|
|
|
- stujoin = new List<Students>
|
|
|
+ stujoin = new List<Member>
|
|
|
{
|
|
|
- new Students
|
|
|
+ new Member
|
|
|
{
|
|
|
id= afstu.id,
|
|
|
- code= $"Base-{schoolId}",
|
|
|
- schoolId=schoolId
|
|
|
+ code= $"{schoolId}",
|
|
|
+ type = 2
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -708,7 +708,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if ( change.stujoin.Count != 0 || change.stuleave.Count != 0)
|
|
|
{
|
|
|
var messageChange = new ServiceBusMessage(change.ToJsonString());
|
|
|
- messageChange.ApplicationProperties.Add("name", "StuList");
|
|
|
+ messageChange.ApplicationProperties.Add("name", "GroupChange");
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
|
|
|
}
|
|
@@ -1610,8 +1610,8 @@ namespace TEAMModelOS.Controllers
|
|
|
try
|
|
|
{
|
|
|
var exceptions = new List<Exception>();
|
|
|
- List<StuList> scStuLists = new List<StuList>();
|
|
|
- List<StuList> teStuLists = new List<StuList>();
|
|
|
+ List<GroupList> scStuLists = new List<GroupList>();
|
|
|
+ List<GroupList> teStuLists = new List<GroupList>();
|
|
|
var container = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
|
|
|
while (students.MoveNext())
|
|
|
{
|
|
@@ -1622,23 +1622,23 @@ namespace TEAMModelOS.Controllers
|
|
|
id = student.GetProperty("id").GetString();
|
|
|
var ret = await container.DeleteItemStreamAsync(id, new PartitionKey($"Base-{schoolId}"));
|
|
|
if (ret.Status == (int)HttpStatusCode.NoContent) sucIds.Add(id);
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 in c.students where A0.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: $"select value(c) from c join A0 in c.members where A0.id = '{id}' and A0.code='{schoolId}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{schoolId}") }))
|
|
|
{
|
|
|
scStuLists.Add(item);
|
|
|
}
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 in c.students where A0.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupList>(queryText: $"select value(c) from c join A0 in c.members where A0.id = '{id}' and A0.code='{schoolId}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList") }))
|
|
|
{
|
|
|
teStuLists.Add(item);
|
|
|
}
|
|
|
if (scStuLists.Count > 0)
|
|
|
{
|
|
|
- foreach (StuList stuList in scStuLists)
|
|
|
+ foreach (GroupList stuList in scStuLists)
|
|
|
{
|
|
|
- for (int j = 0; j < stuList.students.Count; j++)
|
|
|
+ for (int j = 0; j < stuList.members.Count; j++)
|
|
|
{
|
|
|
- if (id.Equals(stuList.students[j].id))
|
|
|
+ if (id.Equals(stuList.members[j].id) && stuList.members[j].code.Equals(schoolId))
|
|
|
{
|
|
|
- stuList.students.RemoveAt(j);
|
|
|
+ stuList.members.RemoveAt(j);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -1647,13 +1647,13 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
if (teStuLists.Count > 0)
|
|
|
{
|
|
|
- foreach (StuList stuList in teStuLists)
|
|
|
+ foreach (GroupList stuList in teStuLists)
|
|
|
{
|
|
|
- for (int j = 0; j < stuList.students.Count; j++)
|
|
|
+ for (int j = 0; j < stuList.members.Count; j++)
|
|
|
{
|
|
|
- if (id.Equals(stuList.students[j].id))
|
|
|
+ if (id.Equals(stuList.members[j].id) && stuList.members[j].code.Equals(schoolId))
|
|
|
{
|
|
|
- stuList.students.RemoveAt(j);
|
|
|
+ stuList.members.RemoveAt(j);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2454,8 +2454,8 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
//取得該學生跑班課名單ID
|
|
|
List<string> stulistidsSch = new List<string>();
|
|
|
- var querysl = $"SELECT c.id FROM c JOIN students IN c.students WHERE students.id = '{id.GetString()}' AND students.code = 'Base-{school_code}'";
|
|
|
- await foreach (var item in schoolClient.GetItemQueryStreamIterator(queryText: querysl, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{school_code}") }))
|
|
|
+ var querysl = $"SELECT c.id FROM c JOIN members IN c.members WHERE members.id = '{id.GetString()}' AND members.code = '{school_code}'";
|
|
|
+ await foreach (var item in schoolClient.GetItemQueryStreamIterator(queryText: querysl, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school_code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -2482,8 +2482,8 @@ namespace TEAMModelOS.Controllers
|
|
|
////個人
|
|
|
//取得該學生跑班課名單ID
|
|
|
Dictionary<string, Dictionary<string, string>> stulistidsTea = new Dictionary<string, Dictionary<string, string>>();
|
|
|
- var queryslt = $"SELECT c.id, c.course.id as courseId, c.course.code as courseCode FROM c JOIN students IN c.students WHERE students.id = '{id.GetString()}' AND students.code = 'Base-{school_code}'";
|
|
|
- await foreach (var item in teacherClient.GetItemQueryStreamIterator(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StuList") }))
|
|
|
+ var queryslt = $"SELECT c.id, c.course.id as courseId, c.course.code as courseCode FROM c JOIN members IN c.members WHERE members.id = '{id.GetString()}' AND members.code = '{school_code}'";
|
|
|
+ await foreach (var item in teacherClient.GetItemQueryStreamIterator(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("GroupList") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
var js = json.RootElement.ToJsonString();
|