|
@@ -41,19 +41,23 @@ namespace TEAMModelFunction
|
|
|
//await _dingDing.SendBotMsg($"ServiceBus,CourseChange:{msg}", GroupNames.醍摩豆服務運維群組);
|
|
|
var jsonMsg = JsonDocument.Parse(msg);
|
|
|
CourseChange courseChange = msg.ToObject<CourseChange>();
|
|
|
- if (courseChange == null) {
|
|
|
+ if (courseChange == null)
|
|
|
+ {
|
|
|
return;
|
|
|
}
|
|
|
- foreach (var cls in courseChange.addClass) {
|
|
|
- (List<TmdInfo> addTmdidsCls, List<StuInfo> addStudentsCls,List<ClassListInfo> classLists) = await TriggerStuActivity.GetStuList(client, _dingDing,new List<string> { cls}, courseChange.school);
|
|
|
- foreach (var stu in addStudentsCls) {
|
|
|
+ foreach (var cls in courseChange.addClass)
|
|
|
+ {
|
|
|
+ (List<TmdInfo> addTmdidsCls, List<StuInfo> addStudentsCls, List<ClassListInfo> classLists) = await TriggerStuActivity.GetStuList(client, _dingDing, new List<string> { cls }, courseChange.school);
|
|
|
+ foreach (var stu in addStudentsCls)
|
|
|
+ {
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
- if (!stuCourse.Value.classId.Contains(cls)) {
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+ if (!stuCourse.Value.classId.Contains(cls))
|
|
|
+ {
|
|
|
stuCourse.Value.classId.Add(cls);
|
|
|
}
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
|
{
|
|
@@ -68,11 +72,11 @@ namespace TEAMModelFunction
|
|
|
scope = courseChange.scope,
|
|
|
school = courseChange.school,
|
|
|
creatorId = courseChange.creatorId,
|
|
|
- classId= new List<string> { cls},
|
|
|
+ classId = new List<string> { cls },
|
|
|
pk = "StuCourse",
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
};
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -80,12 +84,12 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
if (!stuCourse.Value.classId.Contains(cls))
|
|
|
{
|
|
|
stuCourse.Value.classId.Add(cls);
|
|
|
}
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
|
{
|
|
@@ -104,7 +108,7 @@ namespace TEAMModelFunction
|
|
|
pk = "StuCourse",
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
};
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -112,16 +116,16 @@ namespace TEAMModelFunction
|
|
|
|
|
|
foreach (var list in courseChange.addList)
|
|
|
{
|
|
|
- (List<TmdInfo> addTmdidsCls, List<StuInfo> addStudentsCls,List<ClassListInfo> classLists) = await TriggerStuActivity.GetStuList(client, _dingDing, new List<string> { list }, courseChange.school);
|
|
|
+ (List<TmdInfo> addTmdidsCls, List<StuInfo> addStudentsCls, List<ClassListInfo> classLists) = await TriggerStuActivity.GetStuList(client, _dingDing, new List<string> { list }, courseChange.school);
|
|
|
foreach (var stu in addStudentsCls)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
|
if (!stuCourse.Value.stulist.Contains(list))
|
|
|
{
|
|
|
stuCourse.Value.stulist.Add(list);
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
|
}
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
@@ -141,7 +145,7 @@ namespace TEAMModelFunction
|
|
|
pk = "StuCourse",
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
};
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -149,13 +153,13 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
if (!stuCourse.Value.stulist.Contains(list))
|
|
|
{
|
|
|
stuCourse.Value.stulist.Add(list);
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
|
{
|
|
@@ -174,20 +178,21 @@ namespace TEAMModelFunction
|
|
|
pk = "StuCourse",
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
};
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- foreach (var delCls in courseChange.delClass) {
|
|
|
- (List<TmdInfo> delTmdidsCls, List<StuInfo> delStudentsCls,List<ClassListInfo> classLists) = await TriggerStuActivity.GetStuList(client, _dingDing, new List<string> { delCls }, courseChange.school);
|
|
|
+ foreach (var delCls in courseChange.delClass)
|
|
|
+ {
|
|
|
+ (List<TmdInfo> delTmdidsCls, List<StuInfo> delStudentsCls, List<ClassListInfo> classLists) = await TriggerStuActivity.GetStuList(client, _dingDing, new List<string> { delCls }, courseChange.school);
|
|
|
foreach (var stu in delStudentsCls)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
-
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+
|
|
|
if (stuCourse.Value.classId.Contains(delCls))
|
|
|
{
|
|
|
stuCourse.Value.classId.Remove(delCls);
|
|
@@ -196,23 +201,24 @@ namespace TEAMModelFunction
|
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
|
{
|
|
|
//当两个列表都不存在时则直接删除
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuCourse>( courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
}
|
|
|
- else {
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
foreach (var tmd in delTmdidsCls)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
if (stuCourse.Value.classId.Contains(delCls))
|
|
|
{
|
|
@@ -222,11 +228,11 @@ namespace TEAMModelFunction
|
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
|
{
|
|
|
//当两个列表都不存在时则直接删除
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -243,7 +249,7 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
if (stuCourse.Value.stulist.Contains(delList))
|
|
|
{
|
|
@@ -253,11 +259,11 @@ namespace TEAMModelFunction
|
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
|
{
|
|
|
//当两个列表都不存在时则直接删除
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -270,7 +276,7 @@ namespace TEAMModelFunction
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
if (stuCourse.Value.stulist.Contains(delList))
|
|
|
{
|
|
@@ -280,11 +286,11 @@ namespace TEAMModelFunction
|
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
|
{
|
|
|
//当两个列表都不存在时则直接删除
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -294,49 +300,6 @@ namespace TEAMModelFunction
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- ////根据新增名单获取 新增的学生id 及timdid
|
|
|
- //(List<string> addTmdids, List<Students> addStudents) = await TriggerStuActivity.GetStuList(client, _dingDing, courseChange.addList, courseChange.school);
|
|
|
- ////根据删除名单获取 新增的学生id 及timdid
|
|
|
- //(List<string> delTmdids, List<Students> delStudents) = await TriggerStuActivity.GetStuList(client, _dingDing, courseChange.delList, courseChange.school);
|
|
|
- //foreach (var addStu in addStudents)
|
|
|
- //{
|
|
|
- // var course = new StuCourse
|
|
|
- // {
|
|
|
- // id = courseChange.id,
|
|
|
- // scode = courseChange.code,
|
|
|
- // name = courseChange.name,
|
|
|
- // code = $"StuCourse-{courseChange.school}-{addStu.id}",
|
|
|
- // scope = courseChange.scope,
|
|
|
- // school = courseChange.school,
|
|
|
- // creatorId = courseChange.creatorId,
|
|
|
- // pk = "StuCourse"
|
|
|
- // };
|
|
|
- // await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(course, new PartitionKey(course.code));
|
|
|
- //}
|
|
|
- //foreach (var addTmd in addTmdids)
|
|
|
- //{
|
|
|
- // var course = new StuCourse
|
|
|
- // {
|
|
|
- // id = courseChange.id,
|
|
|
- // scode = courseChange.code,
|
|
|
- // name = courseChange.name,
|
|
|
- // code = $"StuCourse-{addTmd}",
|
|
|
- // scope = courseChange.scope,
|
|
|
- // //school = courseChange.school,
|
|
|
- // creatorId = courseChange.creatorId,
|
|
|
- // pk = "StuCourse"
|
|
|
- // };
|
|
|
- // await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(course, new PartitionKey(course.code));
|
|
|
- //}
|
|
|
- //foreach (var delStu in delStudents)
|
|
|
- //{
|
|
|
- // await client.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{courseChange.school}-{delStu.id}"));
|
|
|
- //}
|
|
|
- //foreach (var delTmd in delTmdids)
|
|
|
- //{
|
|
|
- // await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{delTmd}"));
|
|
|
- //}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|