12345678910111213141516171819202122232425262728293031323334353637383940 |
- 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 TeacherWorkService
- {
- public static async Task<string> saveMoreAsync(CosmosClient client, DingDing _dingDing, TeacherWork work)
- {
- try
- {
- work.ttl = -1;
- work.code = "TeacherWork-" + work.school;
- long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- work.createTime = now;
- if (string.IsNullOrEmpty(work.id))
- {
- work.id = Guid.NewGuid().ToString();
- await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(work, new PartitionKey($"{work.code}"));
- }
- else
- {
- await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(work, new PartitionKey($"{work.code}"));
- }
- return work.id;
- }
- catch (Exception e)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-TeacherWorkService-saveMore\n{e.Message}{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return "";
- }
- }
- }
- }
|