123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using Azure.Cosmos;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK.DI;
- namespace TEAMModelOS.SDK.Models.Service
- {
- public static class ExamService
- {
- public static List<string> getClasses(List<string> cla, List<string> stus)
- {
- List<string> classes = new List<string>();
- try
- {
- if (cla.Count > 0)
- {
- foreach (string cl in cla)
- {
- classes.Add(cl);
- }
- }
- if (stus.Count > 0)
- {
- foreach (string stu in stus)
- {
- classes.Add(stu);
- }
- }
- return classes;
- }
- catch (Exception)
- {
- return classes;
- }
- }
- public static async Task<string> saveMoreAsync(CosmosClient client, DingDing _dingDing, ExamLite trExam)
- {
- try
- {
- trExam.ttl = -1;
- trExam.code = "ExamLite-" + trExam.school;
- long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- trExam.createTime = now;
- if (string.IsNullOrEmpty(trExam.id))
- {
- trExam.id = Guid.NewGuid().ToString();
- await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(trExam, new PartitionKey($"{trExam.code}"));
- }
- else
- {
- await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(trExam, new PartitionKey($"{trExam.code}"));
- }
- return trExam.id;
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ExamService-saveMore\n{e.Message}{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return "";
- }
- }
- }
- }
|