|
@@ -49,11 +49,11 @@ namespace TEAMModelFunction
|
|
foreach (var stu in addStudentsCls) {
|
|
foreach (var stu in addStudentsCls) {
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ 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)) {
|
|
if (!stuCourse.Value.classId.Contains(cls)) {
|
|
stuCourse.Value.classId.Add(cls);
|
|
stuCourse.Value.classId.Add(cls);
|
|
}
|
|
}
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
}
|
|
}
|
|
catch (CosmosException ex)
|
|
catch (CosmosException ex)
|
|
{
|
|
{
|
|
@@ -72,7 +72,7 @@ namespace TEAMModelFunction
|
|
pk = "StuCourse",
|
|
pk = "StuCourse",
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
};
|
|
};
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -80,12 +80,12 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
if (!stuCourse.Value.classId.Contains(cls))
|
|
if (!stuCourse.Value.classId.Contains(cls))
|
|
{
|
|
{
|
|
stuCourse.Value.classId.Add(cls);
|
|
stuCourse.Value.classId.Add(cls);
|
|
}
|
|
}
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
}
|
|
}
|
|
catch (CosmosException ex)
|
|
catch (CosmosException ex)
|
|
{
|
|
{
|
|
@@ -104,7 +104,7 @@ namespace TEAMModelFunction
|
|
pk = "StuCourse",
|
|
pk = "StuCourse",
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
};
|
|
};
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -117,11 +117,11 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
|
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
if (!stuCourse.Value.stulist.Contains(list))
|
|
if (!stuCourse.Value.stulist.Contains(list))
|
|
{
|
|
{
|
|
stuCourse.Value.stulist.Add(list);
|
|
stuCourse.Value.stulist.Add(list);
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{stu.schoolId}-{stu.id}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (CosmosException ex)
|
|
catch (CosmosException ex)
|
|
@@ -141,7 +141,7 @@ namespace TEAMModelFunction
|
|
pk = "StuCourse",
|
|
pk = "StuCourse",
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
};
|
|
};
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -149,11 +149,11 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
if (!stuCourse.Value.stulist.Contains(list))
|
|
if (!stuCourse.Value.stulist.Contains(list))
|
|
{
|
|
{
|
|
stuCourse.Value.stulist.Add(list);
|
|
stuCourse.Value.stulist.Add(list);
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -174,7 +174,7 @@ namespace TEAMModelFunction
|
|
pk = "StuCourse",
|
|
pk = "StuCourse",
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
};
|
|
};
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -186,7 +186,7 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
if (stuCourse.Value.classId.Contains(delCls))
|
|
if (stuCourse.Value.classId.Contains(delCls))
|
|
{
|
|
{
|
|
@@ -196,10 +196,10 @@ namespace TEAMModelFunction
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
{
|
|
{
|
|
//当两个列表都不存在时则直接删除
|
|
//当两个列表都不存在时则直接删除
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>( courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuCourse>( courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -212,7 +212,7 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
if (stuCourse.Value.classId.Contains(delCls))
|
|
if (stuCourse.Value.classId.Contains(delCls))
|
|
{
|
|
{
|
|
@@ -222,11 +222,11 @@ namespace TEAMModelFunction
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
{
|
|
{
|
|
//当两个列表都不存在时则直接删除
|
|
//当两个列表都不存在时则直接删除
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -243,7 +243,7 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
if (stuCourse.Value.stulist.Contains(delList))
|
|
if (stuCourse.Value.stulist.Contains(delList))
|
|
{
|
|
{
|
|
@@ -253,11 +253,11 @@ namespace TEAMModelFunction
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
{
|
|
{
|
|
//当两个列表都不存在时则直接删除
|
|
//当两个列表都不存在时则直接删除
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{courseChange.school}-{stu.id}"));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -270,7 +270,7 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ ItemResponse<StuCourse> stuCourse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
if (stuCourse.Value.stulist.Contains(delList))
|
|
if (stuCourse.Value.stulist.Contains(delList))
|
|
{
|
|
{
|
|
@@ -280,11 +280,11 @@ namespace TEAMModelFunction
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
|
|
{
|
|
{
|
|
//当两个列表都不存在时则直接删除
|
|
//当两个列表都不存在时则直接删除
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -294,6 +294,49 @@ 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)
|
|
catch (Exception ex)
|
|
{
|
|
{
|