12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using Azure.Cosmos;
- using HTEXLib.COMM.Helpers;
- using Microsoft.Azure.Documents;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Models;
- using TEAMModelOS.SDK.Models.Cosmos.Common;
- namespace TEAMModelFunction
- {
- public static class TriggerStudy
- {
- public static async void Trigger(AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
- CosmosClient client, Document input, TriggerData tdata, AzureRedisFactory _azureRedis)
- {
- try
- {
- if ((tdata.status != null && tdata.status.Value == 404) || tdata.ttl > 0)
- {
- return;
- }
- var adid = tdata.id;
- var adcode = "";
- string blobcntr = null;
- if (tdata.scope.Equals("school"))
- {
- adcode = $"Activity-{tdata.school}";
- blobcntr = tdata.school;
- }
- else
- {
- adcode = $"Activity-{tdata.creatorId}";
- blobcntr = tdata.creatorId;
- }
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作", GroupNames.成都开发測試群組);
- Study study = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
- //List<ChangeRecord> voteRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", vote.progress } });
- if (study != null)
- {
- (List<TmdInfo> tchList,_ ) = await TriggerStuActivity.GetTchList(client, _dingDing, study.tchLists, study.school);
- List<StuActivity> tchActivities = new List<StuActivity>();
- if (tchList.IsNotEmpty())
- {
- tchList.ForEach(x =>
- {
- tchActivities.Add(new StuActivity
- {
- pk = "Activity",
- id = study.id,
- code = $"Activity-{x.id}",
- type = "Study",
- name = study.name,
- startTime = study.startTime,
- endTime = study.endTime,
- scode = study.code,
- scope = study.scope,
- school = study.school,
- creatorId = study.creatorId,
- subjects = new List<string> { "" },
- blob = null,
- owner = study.owner,
- createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
- taskStatus = -1,
- classIds = study.tchLists
- });
- });
- }
- await TriggerStuActivity.SaveStuActivity(client, _dingDing, null, null, tchActivities);
- }
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修活动异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
- }
- }
- }
- }
|