Bläddra i källkod

新增CosmosDB异常捕获

zhouj1203@hotmail.com 3 år sedan
förälder
incheckning
b8b7da1210

+ 316 - 305
TEAMModelFunction/TriggerCorrect.cs

@@ -39,378 +39,389 @@ namespace TEAMModelFunction
                 return;
                 return;
             }
             }
             await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}阅卷配置【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在执行", GroupNames.成都开发測試群組);
             await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}阅卷配置【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在执行", GroupNames.成都开发測試群組);
-            Correct correct = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Correct>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
-            
-            if (correct != null)
-            {
-                string PartitionKey = string.Format("{0}{1}{2}", correct.code, "-", correct.progress);
-                List<ChangeRecord> correctRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", PartitionKey } });
-                switch (correct.progress)
+            try {
+                Correct correct = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Correct>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
+
+                if (correct != null)
                 {
                 {
-                    case "pending":
-                        var messageCorrect = new ServiceBusMessage(new { id = input.Id, progress = "going", code = tdata.code }.ToJsonString());
-                        messageCorrect.ApplicationProperties.Add("name", "Correct");
-                        if (correctRecords.Count > 0)
-                        {
-                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrect, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
-                            await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), correctRecords[0].sequenceNumber);
-                            correctRecords[0].sequenceNumber = start;
-                            await _azureStorage.SaveOrUpdate<ChangeRecord>(correctRecords[0]);
-                        }
-                        else
-                        {
-                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrect, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
-                            ChangeRecord changeRecord = new ChangeRecord
+                    string PartitionKey = string.Format("{0}{1}{2}", correct.code, "-", correct.progress);
+                    List<ChangeRecord> correctRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", PartitionKey } });
+                    switch (correct.progress)
+                    {
+                        case "pending":
+                            var messageCorrect = new ServiceBusMessage(new { id = input.Id, progress = "going", code = tdata.code }.ToJsonString());
+                            messageCorrect.ApplicationProperties.Add("name", "Correct");
+                            if (correctRecords.Count > 0)
                             {
                             {
-                                RowKey = input.Id,
-                                PartitionKey = PartitionKey,
-                                sequenceNumber = start,
-                                msgId = messageCorrect.MessageId
-                            };
-                            await _azureStorage.Save<ChangeRecord>(changeRecord);
-                        }
-                        break;
-                    case "going":
-                        //评测id
-                        string eid = correct.id;
-                        //评测的分区键
-                        string ecode = correct.scode;
-                        ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(input.Id, new Azure.Cosmos.PartitionKey($"{ecode}"));
-                        if (correct.subs.IsNotEmpty())
-                        {
-
-                            foreach (var sub in correct.subs)
+                                long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrect, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
+                                await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), correctRecords[0].sequenceNumber);
+                                correctRecords[0].sequenceNumber = start;
+                                await _azureStorage.SaveOrUpdate<ChangeRecord>(correctRecords[0]);
+                            }
+                            else
                             {
                             {
-                                ///生成阅卷教师的阅卷任务列表
-                                if (sub.markers.IsNotEmpty())
+                                long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrect, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
+                                ChangeRecord changeRecord = new ChangeRecord
                                 {
                                 {
-                                    foreach (var marker in sub.markers)
+                                    RowKey = input.Id,
+                                    PartitionKey = PartitionKey,
+                                    sequenceNumber = start,
+                                    msgId = messageCorrect.MessageId
+                                };
+                                await _azureStorage.Save<ChangeRecord>(changeRecord);
+                            }
+                            break;
+                        case "going":
+                            //评测id
+                            string eid = correct.id;
+                            //评测的分区键
+                            string ecode = correct.scode;
+                            ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(input.Id, new Azure.Cosmos.PartitionKey($"{ecode}"));
+                            if (correct.subs.IsNotEmpty())
+                            {
+
+                                foreach (var sub in correct.subs)
+                                {
+                                    ///生成阅卷教师的阅卷任务列表
+                                    if (sub.markers.IsNotEmpty())
                                     {
                                     {
-                                        CorrectTask task = new CorrectTask
+                                        foreach (var marker in sub.markers)
                                         {
                                         {
-                                            ttl = -1,
-                                            pk = "CorrectTask",
-                                            code = "CorrectTask-" + marker.id,
+                                            CorrectTask task = new CorrectTask
+                                            {
+                                                ttl = -1,
+                                                pk = "CorrectTask",
+                                                code = "CorrectTask-" + marker.id,
 
 
-                                            id = Guid.NewGuid().ToString(),
-                                            //评测id 或者阅卷配置id
-                                            cid = correct.id,
-                                            //科目
-                                            subject = sub.id,
-                                            //科目名称
-                                            subjectName = sub.name,
-                                            //评测code
-                                            ecode = correct.scode,
-                                            //阅卷配置code
-                                            scode = correct.code,
-                                            //任务名称
-                                            name = correct.name,
-                                            progress = "going",
-                                            //开始时间
-                                            startTime = correct.startTime,
-                                            //结束时间
-                                            endTime = correct.endTime,
-                                            //批改数量
-                                            count = marker.count,
-                                            //按题阅卷时,题号
-                                            qu = marker.qu,
-                                            //模块数
-                                            model = sub.model,
-                                            type = 1,
-                                            createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
-                                            source = info.source
-                                        };
-                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                                id = Guid.NewGuid().ToString(),
+                                                //评测id 或者阅卷配置id
+                                                cid = correct.id,
+                                                //科目
+                                                subject = sub.id,
+                                                //科目名称
+                                                subjectName = sub.name,
+                                                //评测code
+                                                ecode = correct.scode,
+                                                //阅卷配置code
+                                                scode = correct.code,
+                                                //任务名称
+                                                name = correct.name,
+                                                progress = "going",
+                                                //开始时间
+                                                startTime = correct.startTime,
+                                                //结束时间
+                                                endTime = correct.endTime,
+                                                //批改数量
+                                                count = marker.count,
+                                                //按题阅卷时,题号
+                                                qu = marker.qu,
+                                                //模块数
+                                                model = sub.model,
+                                                type = 1,
+                                                createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
+                                                source = info.source
+                                            };
+                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                        }
                                     }
                                     }
-                                }
 
 
 
 
-                                //生成异常卷处理人员
-                                if (sub.err.IsNotEmpty())
-                                {
-
-                                    foreach (var tId in sub.err)
+                                    //生成异常卷处理人员
+                                    if (sub.err.IsNotEmpty())
                                     {
                                     {
-                                        CorrectTask task = new CorrectTask
-                                        {
-                                            ttl = -1,
-                                            pk = "CorrectTask",
-                                            code = "CorrectTask-" + tId,
 
 
-                                            id = Guid.NewGuid().ToString(),
-                                            //评测id 或者阅卷配置id
-                                            cid = correct.id,
-                                            //科目
-                                            subject = sub.id,
-                                            //科目名称
-                                            subjectName = sub.name,
-                                            //评测code
-                                            ecode = correct.scode,
-                                            //阅卷配置code
-                                            scode = correct.code,
-                                            progress = "going",
-                                            //任务名称
-                                            name = correct.name,
-                                            //开始时间
-                                            startTime = correct.startTime,
-                                            //结束时间
-                                            endTime = correct.endTime,
-                                            //模块数
-                                            model = sub.model,
-                                            type = 2,
-                                            createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
-                                        };
-                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
-                                    }
+                                        foreach (var tId in sub.err)
+                                        {
+                                            CorrectTask task = new CorrectTask
+                                            {
+                                                ttl = -1,
+                                                pk = "CorrectTask",
+                                                code = "CorrectTask-" + tId,
 
 
+                                                id = Guid.NewGuid().ToString(),
+                                                //评测id 或者阅卷配置id
+                                                cid = correct.id,
+                                                //科目
+                                                subject = sub.id,
+                                                //科目名称
+                                                subjectName = sub.name,
+                                                //评测code
+                                                ecode = correct.scode,
+                                                //阅卷配置code
+                                                scode = correct.code,
+                                                progress = "going",
+                                                //任务名称
+                                                name = correct.name,
+                                                //开始时间
+                                                startTime = correct.startTime,
+                                                //结束时间
+                                                endTime = correct.endTime,
+                                                //模块数
+                                                model = sub.model,
+                                                type = 2,
+                                                createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
+                                            };
+                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                        }
 
 
-                                }
 
 
-                                //生成仲裁人员
+                                    }
 
 
-                                if (sub.arb.IsNotEmpty())
-                                {
+                                    //生成仲裁人员
 
 
-                                    foreach (var tId in sub.arb)
+                                    if (sub.arb.IsNotEmpty())
                                     {
                                     {
-                                        CorrectTask task = new CorrectTask
+
+                                        foreach (var tId in sub.arb)
                                         {
                                         {
-                                            ttl = -1,
-                                            pk = "CorrectTask",
-                                            code = "CorrectTask-" + tId,
+                                            CorrectTask task = new CorrectTask
+                                            {
+                                                ttl = -1,
+                                                pk = "CorrectTask",
+                                                code = "CorrectTask-" + tId,
 
 
-                                            id = Guid.NewGuid().ToString(),
-                                            //评测id 或者阅卷配置id
-                                            cid = correct.id,
-                                            //科目
-                                            subject = sub.id,
-                                            //科目名称
-                                            subjectName = sub.name,
-                                            progress = "going",
-                                            //评测code
-                                            ecode = correct.scode,
-                                            //阅卷配置code
-                                            scode = correct.code,
-                                            //任务名称
-                                            name = correct.name,
-                                            //开始时间
-                                            startTime = correct.startTime,
-                                            //结束时间
-                                            endTime = correct.endTime,
-                                            //模块数
-                                            model = sub.model,
-                                            type = 3,
-                                            createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
-                                        };
-                                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
-                                    }
+                                                id = Guid.NewGuid().ToString(),
+                                                //评测id 或者阅卷配置id
+                                                cid = correct.id,
+                                                //科目
+                                                subject = sub.id,
+                                                //科目名称
+                                                subjectName = sub.name,
+                                                progress = "going",
+                                                //评测code
+                                                ecode = correct.scode,
+                                                //阅卷配置code
+                                                scode = correct.code,
+                                                //任务名称
+                                                name = correct.name,
+                                                //开始时间
+                                                startTime = correct.startTime,
+                                                //结束时间
+                                                endTime = correct.endTime,
+                                                //模块数
+                                                model = sub.model,
+                                                type = 3,
+                                                createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
+                                            };
+                                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                        }
 
 
 
 
-                                }
-                                //评测科目
-                                string subjectId = sub.id;
-                                //生成临时作答数据存放到redis
-                                //var redisClient = _azureRedis.GetRedisClient(8);
-                                //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(eid, new Azure.Cosmos.PartitionKey(ecode));
-                                List<ExamClassResult> classResults = new List<ExamClassResult>();
-                                //获取原题配分
-                                int paperIndex = 0;
-                                foreach (ExamSubject subject in info.subjects)
-                                {
-                                    if (subject.id.Equals(subjectId))
-                                    {
-                                        break;
                                     }
                                     }
-                                    else
+                                    //评测科目
+                                    string subjectId = sub.id;
+                                    //生成临时作答数据存放到redis
+                                    //var redisClient = _azureRedis.GetRedisClient(8);
+                                    //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(eid, new Azure.Cosmos.PartitionKey(ecode));
+                                    List<ExamClassResult> classResults = new List<ExamClassResult>();
+                                    //获取原题配分
+                                    int paperIndex = 0;
+                                    foreach (ExamSubject subject in info.subjects)
                                     {
                                     {
-                                        paperIndex++;
+                                        if (subject.id.Equals(subjectId))
+                                        {
+                                            break;
+                                        }
+                                        else
+                                        {
+                                            paperIndex++;
+                                        }
                                     }
                                     }
-                                }
-                                List<double> paperPoint = info.papers[paperIndex].point;
-                                List<List<string>> ans = info.papers[paperIndex].answers;
-                                if (info.scope.Equals("school"))
-                                {
-
-                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
-                                    queryText: $"select value(c) from c where c.examId = '{eid}' and c.subjectId = '{subjectId}'",
-                                    requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.school}") }))
+                                    List<double> paperPoint = info.papers[paperIndex].point;
+                                    List<List<string>> ans = info.papers[paperIndex].answers;
+                                    if (info.scope.Equals("school"))
                                     {
                                     {
-                                        classResults.Add(item);
-                                    }
-                                }
-                                else
-                                {
-                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
+
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
                                         queryText: $"select value(c) from c where c.examId = '{eid}' and c.subjectId = '{subjectId}'",
                                         queryText: $"select value(c) from c where c.examId = '{eid}' and c.subjectId = '{subjectId}'",
-                                        requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
+                                        requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.school}") }))
+                                        {
+                                            classResults.Add(item);
+                                        }
+                                    }
+                                    else
                                     {
                                     {
-                                        classResults.Add(item);
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
+                                            queryText: $"select value(c) from c where c.examId = '{eid}' and c.subjectId = '{subjectId}'",
+                                            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
+                                        {
+                                            classResults.Add(item);
+                                        }
                                     }
                                     }
-                                }
-                                List<Task<ItemResponse<Scoring>>> tasks = new List<Task<ItemResponse<Scoring>>>();
-                                //初始化老师阅卷记录
-                                //List<string> tmds = new List<string>();
-                                /*                                List<string> marks = new List<string>();
-                                                                for (int i = 0; i < correct.num; i++)
-                                                                {
-                                                                    marks.Add("");
-                                                                }*/
-                                foreach (ExamClassResult examClass in classResults)
-                                {
-                                    foreach (string stuId in examClass.studentIds)
+                                    List<Task<ItemResponse<Scoring>>> tasks = new List<Task<ItemResponse<Scoring>>>();
+                                    //初始化老师阅卷记录
+                                    //List<string> tmds = new List<string>();
+                                    /*                                List<string> marks = new List<string>();
+                                                                    for (int i = 0; i < correct.num; i++)
+                                                                    {
+                                                                        marks.Add("");
+                                                                    }*/
+                                    foreach (ExamClassResult examClass in classResults)
                                     {
                                     {
-                                        int index = examClass.studentIds.IndexOf(stuId);
-                                        if (index > -1)
+                                        foreach (string stuId in examClass.studentIds)
                                         {
                                         {
-                                            List<double> scc = examClass.studentScores[index];
-                                            List<Item> items = new List<Item>();
-                                            List<Qs> qss = new List<Qs>();
-                                            int itemIndex = 0;
-                                            foreach (double psc in scc)
+                                            int index = examClass.studentIds.IndexOf(stuId);
+                                            if (index > -1)
                                             {
                                             {
-                                                //初始化异常卷信息,初始化仲裁卷信息
-                                                Qs qs = new Qs();
-                                                List<Info> infos = new List<Info>();
-                                                Item item = new Item
+                                                List<double> scc = examClass.studentScores[index];
+                                                List<Item> items = new List<Item>();
+                                                List<Qs> qss = new List<Qs>();
+                                                int itemIndex = 0;
+                                                foreach (double psc in scc)
                                                 {
                                                 {
-                                                    ssc = paperPoint[itemIndex],
-                                                    scores = infos
-                                                };
-                                                itemIndex++;
-                                                items.Add(item);
-                                                qss.Add(qs);
-                                            }
-                                            //处理学生未作答 生成阅卷数据时 客观题分数为-1的情况
-                                            List<double> scores = new List<double>();
-                                            int n = 0;
-                                            foreach (List<string> answer in ans)
-                                            {
-                                                var scs = examClass.studentScores[index][n];
-
-                                                if (answer.Count > 0)
+                                                    //初始化异常卷信息,初始化仲裁卷信息
+                                                    Qs qs = new Qs();
+                                                    List<Info> infos = new List<Info>();
+                                                    Item item = new Item
+                                                    {
+                                                        ssc = paperPoint[itemIndex],
+                                                        scores = infos
+                                                    };
+                                                    itemIndex++;
+                                                    items.Add(item);
+                                                    qss.Add(qs);
+                                                }
+                                                //处理学生未作答 生成阅卷数据时 客观题分数为-1的情况
+                                                List<double> scores = new List<double>();
+                                                int n = 0;
+                                                foreach (List<string> answer in ans)
                                                 {
                                                 {
-                                                    if (scs == -1)
+                                                    var scs = examClass.studentScores[index][n];
+
+                                                    if (answer.Count > 0)
                                                     {
                                                     {
-                                                        scores.Add(0);
+                                                        if (scs == -1)
+                                                        {
+                                                            scores.Add(0);
+                                                        }
+                                                        else
+                                                        {
+                                                            scores.Add(scs);
+                                                        }
                                                     }
                                                     }
                                                     else
                                                     else
                                                     {
                                                     {
                                                         scores.Add(scs);
                                                         scores.Add(scs);
                                                     }
                                                     }
+                                                    n++;
                                                 }
                                                 }
-                                                else
+                                                Scoring sc = new Scoring
                                                 {
                                                 {
-                                                    scores.Add(scs);
-                                                }
-                                                n++;
-                                            }
-                                            Scoring sc = new Scoring
-                                            {
-                                                id = Guid.NewGuid().ToString(),
-                                                code = "Scoring-" + info.school,
-                                                blob = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "",
-                                                stuId = stuId,
-                                                examId = eid,
-                                                subjectId = subjectId,
-                                                scores = scores,
-                                                count = correct.num,
-                                                //marks = marks,
-                                                items = items,
-                                                qs = qss,
-                                                //endTime = correct.endTime,
-                                                model = sub.model
+                                                    id = Guid.NewGuid().ToString(),
+                                                    code = "Scoring-" + info.school,
+                                                    blob = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "",
+                                                    stuId = stuId,
+                                                    examId = eid,
+                                                    subjectId = subjectId,
+                                                    scores = scores,
+                                                    count = correct.num,
+                                                    //marks = marks,
+                                                    items = items,
+                                                    qs = qss,
+                                                    //endTime = correct.endTime,
+                                                    model = sub.model
 
 
-                                            };
-                                            tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Scoring>(sc, new Azure.Cosmos.PartitionKey(sc.code)));
+                                                };
+                                                tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Scoring>(sc, new Azure.Cosmos.PartitionKey(sc.code)));
+                                            }
+                                            //tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{eid}-{subjectId}", stuId, new { tmdId = tmds, ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "", score = examClass.studentScores[index] }.ToJsonString()));
                                         }
                                         }
-                                        //tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{eid}-{subjectId}", stuId, new { tmdId = tmds, ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "", score = examClass.studentScores[index] }.ToJsonString()));
-                                    }
 
 
+                                    }
+                                    await Task.WhenAll(tasks);
                                 }
                                 }
-                                await Task.WhenAll(tasks);
                             }
                             }
-                        }
-                        var messageCorrectEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = tdata.code }.ToJsonString());
-                        messageCorrectEnd.ApplicationProperties.Add("name", "Correct");
-                        if (correctRecords.Count > 0)
-                        {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrectEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
-                            await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), correctRecords[0].sequenceNumber);
-                            correctRecords[0].sequenceNumber = end;
-                            await _azureStorage.SaveOrUpdate<ChangeRecord>(correctRecords[0]);
-                        }
-                        else
-                        {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrectEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
-                            ChangeRecord changeRecord = new ChangeRecord
+                            var messageCorrectEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = tdata.code }.ToJsonString());
+                            messageCorrectEnd.ApplicationProperties.Add("name", "Correct");
+                            if (correctRecords.Count > 0)
                             {
                             {
-                                RowKey = input.Id,
-                                PartitionKey = PartitionKey,
-                                sequenceNumber = end,
-                                msgId = messageCorrectEnd.MessageId
-                            };
-                            await _azureStorage.Save<ChangeRecord>(changeRecord);
-                        }
-                        break;
-                    case "finish":
-                        foreach (var sub in correct.subs)
-                        {
-                            List<string> ids = new List<string>();
-                            ///阅卷教师的阅卷任务列表
-                            if (sub.markers.IsNotEmpty())
+                                long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrectEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
+                                await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), correctRecords[0].sequenceNumber);
+                                correctRecords[0].sequenceNumber = end;
+                                await _azureStorage.SaveOrUpdate<ChangeRecord>(correctRecords[0]);
+                            }
+                            else
                             {
                             {
-                                foreach (var marker in sub.markers)
+                                long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageCorrectEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
+                                ChangeRecord changeRecord = new ChangeRecord
                                 {
                                 {
-                                    ids.Add(marker.id);
-                                    //await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code),new ItemRequestOptions().PostTriggers);
-                                }
+                                    RowKey = input.Id,
+                                    PartitionKey = PartitionKey,
+                                    sequenceNumber = end,
+                                    msgId = messageCorrectEnd.MessageId
+                                };
+                                await _azureStorage.Save<ChangeRecord>(changeRecord);
                             }
                             }
-                            //异常卷处理人员
-                            if (sub.err.IsNotEmpty())
+                            break;
+                        case "finish":
+                            foreach (var sub in correct.subs)
                             {
                             {
-
-                                foreach (var tId in sub.err)
+                                List<string> ids = new List<string>();
+                                ///阅卷教师的阅卷任务列表
+                                if (sub.markers.IsNotEmpty())
                                 {
                                 {
-                                    if (!ids.Contains(tId))
+                                    foreach (var marker in sub.markers)
                                     {
                                     {
-                                        ids.Add(tId);
+                                        ids.Add(marker.id);
+                                        //await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code),new ItemRequestOptions().PostTriggers);
+                                    }
+                                }
+                                //异常卷处理人员
+                                if (sub.err.IsNotEmpty())
+                                {
+
+                                    foreach (var tId in sub.err)
+                                    {
+                                        if (!ids.Contains(tId))
+                                        {
+                                            ids.Add(tId);
+                                        }
                                     }
                                     }
                                 }
                                 }
-                            }
 
 
-                            //仲裁人员
+                                //仲裁人员
 
 
-                            if (sub.arb.IsNotEmpty())
-                            {
-                                foreach (var tId in sub.arb)
+                                if (sub.arb.IsNotEmpty())
+                                {
+                                    foreach (var tId in sub.arb)
+                                    {
+                                        if (!ids.Contains(tId))
+                                        {
+                                            ids.Add(tId);
+                                        }
+                                    }
+                                }
+                                List<CorrectTask> corrects = new List<CorrectTask>();
+                                foreach (string id in ids)
                                 {
                                 {
-                                    if (!ids.Contains(tId))
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<CorrectTask>(
+                                          queryText: $"select value(c) from c where c.cid = '{correct.id}'",
+                                          requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"CorrectTask-{id}") }))
                                     {
                                     {
-                                        ids.Add(tId);
+                                        corrects.Add(item);
                                     }
                                     }
                                 }
                                 }
-                            }
-                            List<CorrectTask> corrects = new List<CorrectTask>();
-                            foreach (string id in ids)
-                            {
-                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<CorrectTask>(
-                                      queryText: $"select value(c) from c where c.cid = '{correct.id}'",
-                                      requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"CorrectTask-{id}") }))
+                                List<Task<ItemResponse<CorrectTask>>> tasks = new List<Task<ItemResponse<CorrectTask>>>();
+                                foreach (CorrectTask task in corrects)
                                 {
                                 {
-                                    corrects.Add(item);
+                                    task.progress = "finish";
+                                    tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(task, task.id, new Azure.Cosmos.PartitionKey(task.code)));
                                 }
                                 }
+                                await Task.WhenAll(tasks);
                             }
                             }
-                            List<Task<ItemResponse<CorrectTask>>> tasks = new List<Task<ItemResponse<CorrectTask>>>();
-                            foreach (CorrectTask task in corrects)
-                            {
-                                task.progress = "finish";
-                                tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(task, task.id, new Azure.Cosmos.PartitionKey(task.code)));
-                            }
-                            await Task.WhenAll(tasks);
-                        }
-                        break;
+                            break;
+                    }
                 }
                 }
             }
             }
+            catch (CosmosException e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-阅卷异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
+            }
+            
         }
         }
     }
     }
 }
 }

+ 5 - 3
TEAMModelFunction/TriggerExam.cs

@@ -102,7 +102,7 @@ namespace TEAMModelFunction
                             try
                             try
                             {
                             {
                                 //处理活动中间件
                                 //处理活动中间件
-                                List<string> classes = await Activity(info,client,_dingDing,sub);
+                                List<string> classes = await Activity(info, client, _dingDing, sub);
                                 //向学生或醍摩豆账号发起通知
                                 //向学生或醍摩豆账号发起通知
                                 #region
                                 #region
                                 //Notice notice = new Notice()
                                 //Notice notice = new Notice()
@@ -234,7 +234,7 @@ namespace TEAMModelFunction
                                                         {
                                                         {
                                                             ids.Add(stus.id);
                                                             ids.Add(stus.id);
                                                         }
                                                         }
-                                                    }                                           
+                                                    }
                                                 }
                                                 }
                                             }
                                             }
                                             else
                                             else
@@ -452,8 +452,10 @@ namespace TEAMModelFunction
                 }
                 }
 
 
             }
             }
-            catch (Exception e)
+            catch (CosmosException e)
             {
             {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+            } catch (Exception e) {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测结算异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测结算异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
             }
             }
 
 

+ 4 - 0
TEAMModelFunction/TriggerExamLite.cs

@@ -156,6 +156,10 @@ namespace TEAMModelFunction
                 }
                 }
 
 
             }
             }
+            catch (CosmosException e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+            }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修评测异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修评测异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);

+ 4 - 0
TEAMModelFunction/TriggerHomework.cs

@@ -216,6 +216,10 @@ namespace TEAMModelFunction
 
 
                 }
                 }
             }
             }
+            catch (CosmosException e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+            }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修作业活动异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修作业活动异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);

+ 4 - 0
TEAMModelFunction/TriggerStudy.cs

@@ -161,6 +161,10 @@ namespace TEAMModelFunction
                 }
                 }
 
 
             }
             }
+            catch (CosmosException e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+            }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修活动异常{ex.Message}{ex.StackTrace}{tdata.ToJsonString()}{input}", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修活动异常{ex.Message}{ex.StackTrace}{tdata.ToJsonString()}{input}", GroupNames.成都开发測試群組);

+ 31 - 19
TEAMModelFunction/TriggerSurvey.cs

@@ -24,12 +24,13 @@ using System.Linq;
 
 
 namespace TEAMModelFunction
 namespace TEAMModelFunction
 {
 {
-   public class TriggerSurvey
+    public class TriggerSurvey
     {
     {
-        public static async void Trigger( AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
-               CosmosClient client, Document input, TriggerData tdata,AzureRedisFactory _azureRedis, IConfiguration _configuration)
+        public static async void Trigger(AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
+               CosmosClient client, Document input, TriggerData tdata, AzureRedisFactory _azureRedis, IConfiguration _configuration)
         {
         {
-            try {
+            try
+            {
                 if ((tdata.status != null && tdata.status.Value == 404) || tdata.ttl > 0)
                 if ((tdata.status != null && tdata.status.Value == 404) || tdata.ttl > 0)
                 {
                 {
                     _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Record:{tdata.id}");
                     _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Record:{tdata.id}");
@@ -39,18 +40,18 @@ namespace TEAMModelFunction
                 var adid = tdata.id;
                 var adid = tdata.id;
                 var adcode = "";
                 var adcode = "";
                 string blobcntr = null;
                 string blobcntr = null;
-                if (tdata.scope .Equals("school") )
+                if (tdata.scope.Equals("school"))
                 {
                 {
                     adcode = $"Activity-{tdata.school}";
                     adcode = $"Activity-{tdata.school}";
                     blobcntr = tdata.school;
                     blobcntr = tdata.school;
                 }
                 }
-                else 
+                else
                 {
                 {
                     adcode = $"Activity-{tdata.creatorId}";
                     adcode = $"Activity-{tdata.creatorId}";
                     blobcntr = tdata.creatorId;
                     blobcntr = tdata.creatorId;
                 }
                 }
                 Survey survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
                 Survey survey = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<Survey>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
-                
+
                 if (survey != null)
                 if (survey != null)
                 {
                 {
                     string PartitionKey = string.Format("{0}{1}{2}", survey.code, "-", survey.progress);
                     string PartitionKey = string.Format("{0}{1}{2}", survey.code, "-", survey.progress);
@@ -82,7 +83,8 @@ namespace TEAMModelFunction
                             break;
                             break;
                         case "going":
                         case "going":
                             List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();
                             List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();
-                            if (survey.groupLists.Count >0) {
+                            if (survey.groupLists.Count > 0)
+                            {
                                 var group = survey.groupLists;
                                 var group = survey.groupLists;
                                 foreach (var gp in group)
                                 foreach (var gp in group)
                                 {
                                 {
@@ -91,7 +93,7 @@ namespace TEAMModelFunction
                                         ps.Add((pp.Key, pp.Value));
                                         ps.Add((pp.Key, pp.Value));
                                     }
                                     }
                                 }
                                 }
-                            }                          
+                            }
                             List<string> classes = ExamService.getClasses(survey.classes, survey.stuLists);
                             List<string> classes = ExamService.getClasses(survey.classes, survey.stuLists);
                             (List<RMember> tmdIds, List<RGroupList> classLists) = await GroupListService.GetStutmdidListids(client, _dingDing, classes, survey.school);
                             (List<RMember> tmdIds, List<RGroupList> classLists) = await GroupListService.GetStutmdidListids(client, _dingDing, classes, survey.school);
                             var addStudentsCls = tmdIds.FindAll(x => x.type == 2);
                             var addStudentsCls = tmdIds.FindAll(x => x.type == 2);
@@ -104,7 +106,8 @@ namespace TEAMModelFunction
                             List<StuActivity> tchActivities = new List<StuActivity>();
                             List<StuActivity> tchActivities = new List<StuActivity>();
                             if (addTmdidsCls.IsNotEmpty())
                             if (addTmdidsCls.IsNotEmpty())
                             {
                             {
-                                addTmdidsCls.ForEach(x => {
+                                addTmdidsCls.ForEach(x =>
+                                {
                                     tmdActivities.Add(new StuActivity
                                     tmdActivities.Add(new StuActivity
                                     {
                                     {
                                         pk = "Activity",
                                         pk = "Activity",
@@ -123,13 +126,14 @@ namespace TEAMModelFunction
                                         owner = survey.owner,
                                         owner = survey.owner,
                                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                                         taskStatus = -1,
                                         taskStatus = -1,
-                                        classIds=classes
+                                        classIds = classes
                                     });
                                     });
                                 });
                                 });
                             }
                             }
                             if (addStudentsCls.IsNotEmpty())
                             if (addStudentsCls.IsNotEmpty())
                             {
                             {
-                                addStudentsCls.ForEach(x => {
+                                addStudentsCls.ForEach(x =>
+                                {
                                     stuActivities.Add(new StuActivity
                                     stuActivities.Add(new StuActivity
                                     {
                                     {
                                         pk = "Activity",
                                         pk = "Activity",
@@ -152,7 +156,7 @@ namespace TEAMModelFunction
                                     });
                                     });
                                 });
                                 });
                             }
                             }
-                            (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, survey.tchLists, survey.school,ps);
+                            (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, survey.tchLists, survey.school, ps);
                             (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.TeacherSurvey }, 0);
                             (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.TeacherSurvey }, 0);
                             if (tchList.IsNotEmpty())
                             if (tchList.IsNotEmpty())
                             {
                             {
@@ -164,7 +168,8 @@ namespace TEAMModelFunction
                                     list.school = school.id;
                                     list.school = school.id;
                                     list.standard = school.standard;
                                     list.standard = school.standard;
                                 }
                                 }
-                                tchList.ForEach(x => {
+                                tchList.ForEach(x =>
+                                {
                                     tchActivities.Add(new StuActivity
                                     tchActivities.Add(new StuActivity
                                     {
                                     {
                                         pk = "Activity",
                                         pk = "Activity",
@@ -186,7 +191,7 @@ namespace TEAMModelFunction
                                         classIds = survey.tchLists
                                         classIds = survey.tchLists
                                     });
                                     });
                                 });
                                 });
-                                
+
                             }
                             }
                             await ActivityService.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities, tchActivities);
                             await ActivityService.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities, tchActivities);
                             await StatisticsService.SendServiceBus(list, _configuration, _serviceBus, client);
                             await StatisticsService.SendServiceBus(list, _configuration, _serviceBus, client);
@@ -269,7 +274,7 @@ namespace TEAMModelFunction
                             try
                             try
                             {
                             {
                                 List<string> items = await ContainerClient.List($"survey/{survey.id}/urecord");
                                 List<string> items = await ContainerClient.List($"survey/{survey.id}/urecord");
-                              
+
                                 foreach (string item in items)
                                 foreach (string item in items)
                                 {
                                 {
                                     var Download = await _azureStorage.GetBlobContainerClient(blobcntr).GetBlobClient(item).DownloadAsync();
                                     var Download = await _azureStorage.GetBlobContainerClient(blobcntr).GetBlobClient(item).DownloadAsync();
@@ -319,9 +324,9 @@ namespace TEAMModelFunction
                                         }
                                         }
                                     }
                                     }
                                     questionRecords.Add(question);
                                     questionRecords.Add(question);
-                                    tasks.Add(  _azureStorage.UploadFileByContainer(blobcntr, question.ToJsonString(), "survey", url));
+                                    tasks.Add(_azureStorage.UploadFileByContainer(blobcntr, question.ToJsonString(), "survey", url));
                                 }
                                 }
-                                 await Task.WhenAll(tasks);
+                                await Task.WhenAll(tasks);
                             }
                             }
                             catch (Exception ex)
                             catch (Exception ex)
                             {
                             {
@@ -356,7 +361,14 @@ namespace TEAMModelFunction
                             break;
                             break;
                     }
                     }
                 }
                 }
-            } catch (Exception ex) {
+            }
+
+            catch (CosmosException e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+            }
+            catch (Exception ex)
+            {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}问卷调查{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}问卷调查{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
 
 
             }
             }

+ 26 - 16
TEAMModelFunction/TriggerVote.cs

@@ -23,12 +23,13 @@ namespace TEAMModelFunction
     public static class TriggerVote
     public static class TriggerVote
     {
     {
 
 
-        public static async void Trigger( AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
+        public static async void Trigger(AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
             CosmosClient client, Document input, TriggerData tdata, AzureRedisFactory _azureRedis, IConfiguration _configuration)
             CosmosClient client, Document input, TriggerData tdata, AzureRedisFactory _azureRedis, IConfiguration _configuration)
         {
         {
-            try {
+            try
+            {
                 if ((tdata.status != null && tdata.status.Value == 404) || tdata.ttl > 0)
                 if ((tdata.status != null && tdata.status.Value == 404) || tdata.ttl > 0)
-                { 
+                {
                     //异动,且已经有结算记录则不必再继续。
                     //异动,且已经有结算记录则不必再继续。
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Record:{tdata.id}");
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Record:{tdata.id}");
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Count:{tdata.id}");
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Count:{tdata.id}");
@@ -37,19 +38,19 @@ namespace TEAMModelFunction
                 var adid = tdata.id;
                 var adid = tdata.id;
                 var adcode = "";
                 var adcode = "";
                 string blobcntr = null;
                 string blobcntr = null;
-                if (tdata.scope .Equals("school"))
+                if (tdata.scope.Equals("school"))
                 {
                 {
                     adcode = $"Activity-{tdata.school}";
                     adcode = $"Activity-{tdata.school}";
                     blobcntr = tdata.school;
                     blobcntr = tdata.school;
                 }
                 }
-                else  
+                else
                 {
                 {
                     adcode = $"Activity-{tdata.creatorId}";
                     adcode = $"Activity-{tdata.creatorId}";
                     blobcntr = tdata.creatorId;
                     blobcntr = tdata.creatorId;
                 }
                 }
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作", GroupNames.成都开发測試群組);
                 Vote vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
                 Vote vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
-                
+
                 if (vote != null)
                 if (vote != null)
                 {
                 {
                     string PartitionKey = string.Format("{0}{1}{2}", vote.code, "-", vote.progress);
                     string PartitionKey = string.Format("{0}{1}{2}", vote.code, "-", vote.progress);
@@ -93,7 +94,7 @@ namespace TEAMModelFunction
                                 }
                                 }
                             }
                             }
                             List<string> classes = ExamService.getClasses(vote.classes, vote.stuLists);
                             List<string> classes = ExamService.getClasses(vote.classes, vote.stuLists);
-                            (List<RMember> tmdIds, List<RGroupList> classLists) = await GroupListService.GetStutmdidListids(client, _dingDing, classes, vote.school,ps);
+                            (List<RMember> tmdIds, List<RGroupList> classLists) = await GroupListService.GetStutmdidListids(client, _dingDing, classes, vote.school, ps);
                             var addStudentsCls = tmdIds.FindAll(x => x.type == 2);
                             var addStudentsCls = tmdIds.FindAll(x => x.type == 2);
                             var addTmdidsCls = tmdIds.FindAll(x => x.type == 1);
                             var addTmdidsCls = tmdIds.FindAll(x => x.type == 1);
                             //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动" +
                             //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动" +
@@ -111,7 +112,8 @@ namespace TEAMModelFunction
                             List<StuActivity> tchActivities = new List<StuActivity>();
                             List<StuActivity> tchActivities = new List<StuActivity>();
                             if (tmds.IsNotEmpty())
                             if (tmds.IsNotEmpty())
                             {
                             {
-                                tmds.ForEach(x => {
+                                tmds.ForEach(x =>
+                                {
                                     tmdActivities.Add(new StuActivity
                                     tmdActivities.Add(new StuActivity
                                     {
                                     {
                                         pk = "Activity",
                                         pk = "Activity",
@@ -136,12 +138,13 @@ namespace TEAMModelFunction
                             }
                             }
                             if (addStudentsCls.IsNotEmpty())
                             if (addStudentsCls.IsNotEmpty())
                             {
                             {
-                                addStudentsCls.ForEach(x => {
+                                addStudentsCls.ForEach(x =>
+                                {
                                     stuActivities.Add(new StuActivity
                                     stuActivities.Add(new StuActivity
                                     {
                                     {
                                         pk = "Activity",
                                         pk = "Activity",
                                         id = vote.id,
                                         id = vote.id,
-                                        code = $"Activity-{x.code.Replace("Base-","")}-{x.id}",
+                                        code = $"Activity-{x.code.Replace("Base-", "")}-{x.id}",
                                         type = "Vote",
                                         type = "Vote",
                                         name = vote.name,
                                         name = vote.name,
                                         startTime = vote.startTime,
                                         startTime = vote.startTime,
@@ -159,7 +162,7 @@ namespace TEAMModelFunction
                                     });
                                     });
                                 });
                                 });
                             }
                             }
-                            (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, vote.tchLists, vote.school,ps);
+                            (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, vote.tchLists, vote.school, ps);
                             (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.TeacherVote }, 0);
                             (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())
                             if (tchList.IsNotEmpty())
                             {
                             {
@@ -171,7 +174,8 @@ namespace TEAMModelFunction
                                     list.school = school.id;
                                     list.school = school.id;
                                     list.standard = school.standard;
                                     list.standard = school.standard;
                                 }
                                 }
-                                tchList.ForEach(x => {
+                                tchList.ForEach(x =>
+                                {
                                     tchActivities.Add(new StuActivity
                                     tchActivities.Add(new StuActivity
                                     {
                                     {
                                         pk = "Activity",
                                         pk = "Activity",
@@ -193,10 +197,10 @@ namespace TEAMModelFunction
                                         classIds = classes
                                         classIds = classes
                                     });
                                     });
                                 });
                                 });
-                              
+
                             }
                             }
                             //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动,:教研组活动:" +
                             //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动,:教研组活动:" +
-                             
+
                             //   $"{tchActivities.ToJsonString()}\n", GroupNames.成都开发測試群組);
                             //   $"{tchActivities.ToJsonString()}\n", GroupNames.成都开发測試群組);
                             await ActivityService.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities, tchActivities);
                             await ActivityService.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities, tchActivities);
                             await StatisticsService.SendServiceBus(list, _configuration, _serviceBus, client);
                             await StatisticsService.SendServiceBus(list, _configuration, _serviceBus, client);
@@ -299,10 +303,16 @@ namespace TEAMModelFunction
                             break;
                             break;
                     }
                     }
                 }
                 }
-            } catch (Exception ex) {
+            }
+            catch (CosmosException e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+            }
+            catch (Exception ex)
+            {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
             }
-           
+
         }
         }
     }
     }
 }
 }