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