|
@@ -18,78 +18,89 @@ namespace TEAMModelFunction
|
|
public class TriggerStuActivity
|
|
public class TriggerStuActivity
|
|
{
|
|
{
|
|
|
|
|
|
- public static async Task<string> SaveStuActivity(CosmosClient client,List<StuActivity> stuActivities,List<StuActivity> tmdActivities) {
|
|
|
|
- if (stuActivities.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- foreach (var x in stuActivities)
|
|
|
|
|
|
+ public static async Task<string> SaveStuActivity(CosmosClient client, DingDing _dingDing, List<StuActivity> stuActivities,List<StuActivity> tmdActivities) {
|
|
|
|
+ try {
|
|
|
|
+ if (stuActivities.IsNotEmpty())
|
|
{
|
|
{
|
|
- await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(x, new PartitionKey(x.code));
|
|
|
|
|
|
+ foreach (var x in stuActivities)
|
|
|
|
+ {
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(x, new PartitionKey(x.code));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (tmdActivities.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- foreach (var x in tmdActivities)
|
|
|
|
|
|
+ if (tmdActivities.IsNotEmpty())
|
|
{
|
|
{
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(x, new PartitionKey(x.code));
|
|
|
|
|
|
+ foreach (var x in tmdActivities)
|
|
|
|
+ {
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(x, new PartitionKey(x.code));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,TriggerStuActivity-SaveStuActivity\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
}
|
|
}
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
-
|
|
|
|
- public static async Task<(List<string> tmdids,List<Students> studentss)> GetStuList( CosmosClient client, List<string> classes,string school) {
|
|
|
|
- List<string> tmdids = new List<string>();
|
|
|
|
- List<Students> studentss = new List<Students>();
|
|
|
|
- if (!classes.IsNotEmpty()) { return (tmdids, studentss); }
|
|
|
|
- List<string> sqlList = new List<string>();
|
|
|
|
- classes.ForEach(x => { sqlList.Add($" '{x}' "); });
|
|
|
|
- string sql = string.Join(" , ", sqlList);
|
|
|
|
- List<StuList> schList = new List<StuList>();
|
|
|
|
- List<Student> students = new List<Student>();
|
|
|
|
- if (!string.IsNullOrEmpty(school)) {
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
|
|
- {
|
|
|
|
- schList.Add(item);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ public static async Task<(List<string> tmdids, List<Students> studentss)> GetStuList(CosmosClient client, DingDing _dingDing, List<string> classes, string school) {
|
|
|
|
+ try {
|
|
|
|
+ List<string> tmdids = new List<string>();
|
|
|
|
+ List<Students> studentss = new List<Students>();
|
|
|
|
+ if (!classes.IsNotEmpty()) { return (tmdids, studentss); }
|
|
|
|
+ List<string> sqlList = new List<string>();
|
|
|
|
+ classes.ForEach(x => { sqlList.Add($" '{x}' "); });
|
|
|
|
+ string sql = string.Join(" , ", sqlList);
|
|
|
|
+ List<StuList> schList = new List<StuList>();
|
|
|
|
+ List<Student> students = new List<Student>();
|
|
|
|
+ if (!string.IsNullOrEmpty(school)) {
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
|
|
+ {
|
|
|
|
+ schList.Add(item);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
|
|
|
|
+ {
|
|
|
|
+ students.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<StuList> tchLists = new List<StuList>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
|
|
{
|
|
{
|
|
- students.Add(item);
|
|
|
|
|
|
+ tchLists.Add(item);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ schList.ForEach(x => {
|
|
|
|
+ if (x.students.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ studentss.AddRange(x.students);
|
|
|
|
+ }
|
|
|
|
+ if (x.tmids.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ tmdids.AddRange(x.tmids);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ tchLists.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ if (x.students.IsNotEmpty()) {
|
|
|
|
+ studentss.AddRange(x.students);
|
|
|
|
+ }
|
|
|
|
+ if (x.tmids.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ tmdids.AddRange(x.tmids);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ students.ForEach(x => {
|
|
|
|
+ studentss.Add(new Students { id = x.id, code = x.code, schoolId = x.schoolId });
|
|
|
|
+ });
|
|
|
|
+ return (tmdids, studentss);
|
|
}
|
|
}
|
|
- List<StuList> tchLists = new List<StuList>();
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
|
|
|
|
|
|
+ catch (Exception ex)
|
|
{
|
|
{
|
|
- tchLists.Add(item);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,TriggerStuActivity-SaveStuActivity\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
}
|
|
}
|
|
-
|
|
|
|
- schList.ForEach(x => {
|
|
|
|
- if (x.students.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- studentss.AddRange(x.students);
|
|
|
|
- }
|
|
|
|
- if (x.tmids.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- tmdids.AddRange(x.tmids);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- tchLists.ForEach(x =>
|
|
|
|
- {
|
|
|
|
- if (x.students.IsNotEmpty()) {
|
|
|
|
- studentss.AddRange(x.students);
|
|
|
|
- }
|
|
|
|
- if (x.tmids.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- tmdids.AddRange(x.tmids);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- students.ForEach(x => {
|
|
|
|
- studentss.Add(new Students { id = x.id, code = x.code,schoolId=x.schoolId });
|
|
|
|
- });
|
|
|
|
- return (tmdids,studentss);
|
|
|
|
|
|
+ return (null, null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|