|
@@ -378,5 +378,128 @@ namespace TEAMModelOS.SDK
|
|
await Task.WhenAll(tasks);
|
|
await Task.WhenAll(tasks);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static async Task DeleteActivity(CosmosClient client, DingDing _dingDing, ActivityList activityList) {
|
|
|
|
+ List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();
|
|
|
|
+ if (activityList.groupLists.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ var group = activityList.groupLists;
|
|
|
|
+ foreach (var keys in group)
|
|
|
|
+ {
|
|
|
|
+ foreach (KeyValuePair<string, List<string>> pp in keys)
|
|
|
|
+ {
|
|
|
|
+ ps.Add((pp.Key, pp.Value));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<string> classes = ExamService.getClasses(activityList.classes, activityList.stuLists);
|
|
|
|
+ (List<RMember> tmdIds, List<RGroupList> classLists) = await GroupListService.GetStutmdidListids(client, _dingDing, classes, activityList.school, ps);
|
|
|
|
+ var addStudentsCls = tmdIds.FindAll(x => x.type == 2);
|
|
|
|
+ var addTmdidsCls = tmdIds.FindAll(x => x.type == 1);
|
|
|
|
+ List<string> tmds = new List<string>();
|
|
|
|
+ if (addTmdidsCls.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ tmds.AddRange(addTmdidsCls.Select(x => x.id).ToList());
|
|
|
|
+ }
|
|
|
|
+ List<StuActivity> stuActivities = new List<StuActivity>();
|
|
|
|
+ List<StuActivity> tmdActivities = new List<StuActivity>();
|
|
|
|
+ List<StuActivity> tchActivities = new List<StuActivity>();
|
|
|
|
+ if (tmds.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ tmds.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ tmdActivities.Add(new StuActivity
|
|
|
|
+ {
|
|
|
|
+ id = activityList.id,
|
|
|
|
+ code = $"Activity-{x}",
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (addStudentsCls.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ addStudentsCls.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ stuActivities.Add(new StuActivity
|
|
|
|
+ {
|
|
|
|
+ id = activityList.id,
|
|
|
|
+ code = $"Activity-{x.code.Replace("Base-", "")}-{x.id}",
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, activityList.tchLists, activityList.school, ps);
|
|
|
|
+ (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.TeacherVote }, 0);
|
|
|
|
+ if (tchList.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ list.tmdids = tchList.Select(x => x.id).ToList();
|
|
|
|
+ School school = null;
|
|
|
|
+ if (!string.IsNullOrEmpty(activityList.school))
|
|
|
|
+ {
|
|
|
|
+ school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(activityList.school, new Azure.Cosmos.PartitionKey("Base"));
|
|
|
|
+ list.school = school.id;
|
|
|
|
+ list.standard = school.standard;
|
|
|
|
+ }
|
|
|
|
+ tchList.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ tchActivities.Add(new StuActivity
|
|
|
|
+ {
|
|
|
|
+ id = activityList.id,
|
|
|
|
+ code = $"Activity-{x.id}",
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ await ActivityService.DeleteStuActivity(client, _dingDing, stuActivities, tmdActivities, tchActivities);
|
|
|
|
+ }
|
|
|
|
+ public static async Task<string> DeleteStuActivity(CosmosClient client, DingDing _dingDing, List<StuActivity> stuActivities, List<StuActivity> tmdActivities, List<StuActivity> tchActivities)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ if (stuActivities.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ foreach (var x in stuActivities)
|
|
|
|
+ {
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemStreamAsync(x.id, new PartitionKey(x.code));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (tmdActivities.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ foreach (var x in tmdActivities)
|
|
|
|
+ {
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemStreamAsync(x.id, new PartitionKey(x.code));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (tchActivities.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ foreach (var x in tchActivities)
|
|
|
|
+ {
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(x.id, new PartitionKey(x.code));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-OS,TriggerStuActivity-DeleteStuActivity\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public class ActivityList
|
|
|
|
+ {
|
|
|
|
+ public string id { get; set; }
|
|
|
|
+ public string school { get; set; }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 行政班
|
|
|
|
+ /// </summary>
|
|
|
|
+ public List<string> classes { get; set; } = new List<string>();
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 学生名单(包含自定义个人学生名单,学校教学班)
|
|
|
|
+ /// </summary>
|
|
|
|
+ public List<string> stuLists { get; set; } = new List<string>();
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 教研组名单
|
|
|
|
+ /// </summary>
|
|
|
|
+ public List<string> tchLists { get; set; } = new List<string>();
|
|
|
|
+ public List<Dictionary<string, List<string>>> groupLists { get; set; } = new List<Dictionary<string, List<string>>>();
|
|
}
|
|
}
|
|
}
|
|
}
|