|
@@ -39,6 +39,8 @@ using System.Net;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json;
|
|
using System.Security.Policy;
|
|
using System.Security.Policy;
|
|
using System.Net.Http.Headers;
|
|
using System.Net.Http.Headers;
|
|
|
|
+using Microsoft.AspNetCore.Hosting;
|
|
|
|
+
|
|
namespace TEAMModelOS.Function
|
|
namespace TEAMModelOS.Function
|
|
{
|
|
{
|
|
public class IESServiceBusTrigger
|
|
public class IESServiceBusTrigger
|
|
@@ -58,10 +60,11 @@ namespace TEAMModelOS.Function
|
|
private readonly HttpTrigger _httpTrigger;
|
|
private readonly HttpTrigger _httpTrigger;
|
|
private readonly BackgroundWorkerQueue _backgroundWorkerQueue;
|
|
private readonly BackgroundWorkerQueue _backgroundWorkerQueue;
|
|
private readonly IHttpClientFactory _httpClient;
|
|
private readonly IHttpClientFactory _httpClient;
|
|
|
|
+ private readonly IWebHostEnvironment _environment;
|
|
public IESServiceBusTrigger(ILogger<IESServiceBusTrigger> logger, HttpTrigger httpTrigger, SnowflakeId snowflakeId, CoreAPIHttpService coreAPIHttpService,
|
|
public IESServiceBusTrigger(ILogger<IESServiceBusTrigger> logger, HttpTrigger httpTrigger, SnowflakeId snowflakeId, CoreAPIHttpService coreAPIHttpService,
|
|
AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis,
|
|
AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis,
|
|
AzureServiceBusFactory serviceBus, IOptionsSnapshot<Option> option,
|
|
AzureServiceBusFactory serviceBus, IOptionsSnapshot<Option> option,
|
|
- IConfiguration configuration, BackgroundWorkerQueue backgroundWorkerQueue, IHttpClientFactory httpClient)
|
|
|
|
|
|
+ IConfiguration configuration, BackgroundWorkerQueue backgroundWorkerQueue, IHttpClientFactory httpClient, IWebHostEnvironment hostingEnvironment)
|
|
{
|
|
{
|
|
_logger = logger;
|
|
_logger = logger;
|
|
_azureCosmos = azureCosmos;
|
|
_azureCosmos = azureCosmos;
|
|
@@ -77,6 +80,7 @@ namespace TEAMModelOS.Function
|
|
_httpTrigger = httpTrigger;
|
|
_httpTrigger = httpTrigger;
|
|
_backgroundWorkerQueue = backgroundWorkerQueue;
|
|
_backgroundWorkerQueue = backgroundWorkerQueue;
|
|
_httpClient=httpClient;
|
|
_httpClient=httpClient;
|
|
|
|
+ _environment = hostingEnvironment;
|
|
}
|
|
}
|
|
[Function("GenPDF")]
|
|
[Function("GenPDF")]
|
|
public async Task Run(
|
|
public async Task Run(
|
|
@@ -852,19 +856,20 @@ namespace TEAMModelOS.Function
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
|
|
- _backgroundWorkerQueue.QueueBackgroundWorkItem(async task => {
|
|
|
|
|
|
+ _backgroundWorkerQueue.QueueBackgroundWorkItem(async task =>
|
|
|
|
+ {
|
|
|
|
|
|
//await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-名单成员变更-GroupChange\n{msg}", GroupNames.醍摩豆服務運維群組);
|
|
//await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-名单成员变更-GroupChange\n{msg}", GroupNames.醍摩豆服務運維群組);
|
|
//await _dingDing.SendBotMsg($"名单变化{msg}", GroupNames.成都开发測試群組);
|
|
//await _dingDing.SendBotMsg($"名单变化{msg}", GroupNames.成都开发測試群組);
|
|
|
|
|
|
- int add = groupChange.tmdjoin.Count-groupChange.tmdleave.Count+groupChange.stujoin.Count-groupChange.stuleave.Count;
|
|
|
|
|
|
+ int add = groupChange.tmdjoin.Count - groupChange.tmdleave.Count + groupChange.stujoin.Count - groupChange.stuleave.Count;
|
|
if (groupChange.scope.Equals("private") && (groupChange.type.Equals("student") || groupChange.type.Equals("class") || groupChange.type.Equals("teach")))
|
|
if (groupChange.scope.Equals("private") && (groupChange.type.Equals("student") || groupChange.type.Equals("class") || groupChange.type.Equals("teach")))
|
|
{
|
|
{
|
|
- await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new Accumulate { client=groupChange.client, count=add, id= groupChange.listid, scope="teacher", key= "grouplist", name=groupChange.name, target= groupChange.creatorId });
|
|
|
|
|
|
+ await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new Accumulate { client = groupChange.client, count = add, id = groupChange.listid, scope = "teacher", key = "grouplist", name = groupChange.name, target = groupChange.creatorId });
|
|
}
|
|
}
|
|
- if (groupChange.scope.Equals("school") && (groupChange.type.Equals("student") || groupChange.type.Equals("class") || groupChange.type.Equals("teach")))
|
|
|
|
|
|
+ if (groupChange.scope.Equals("school") && (groupChange.type.Equals("student") || groupChange.type.Equals("class") || groupChange.type.Equals("teach")))
|
|
{
|
|
{
|
|
- await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new Accumulate { client=groupChange.client, count=add, id= groupChange.listid, scope="school", key= "grouplist", name=groupChange.name, target=groupChange.school });
|
|
|
|
|
|
+ await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new Accumulate { client = groupChange.client, count = add, id = groupChange.listid, scope = "school", key = "grouplist", name = groupChange.name, target = groupChange.school });
|
|
}
|
|
}
|
|
//名单变动修改学生课程关联信息
|
|
//名单变动修改学生课程关联信息
|
|
//await StuListService.FixStuCourse(client, stuListChange);
|
|
//await StuListService.FixStuCourse(client, stuListChange);
|
|
@@ -900,7 +905,7 @@ namespace TEAMModelOS.Function
|
|
if (groupChange.stuleave.Count > 0)
|
|
if (groupChange.stuleave.Count > 0)
|
|
await BIStats.SetTypeAddStats(client, _dingDing, groupChange.school, "Student", -groupChange.stuleave.Count);//BI统计增/减量
|
|
await BIStats.SetTypeAddStats(client, _dingDing, groupChange.school, "Student", -groupChange.stuleave.Count);//BI统计增/减量
|
|
}
|
|
}
|
|
- if ((groupChange.type.Equals("class") || groupChange.type.Equals("teach") || groupChange.type.Equals("student")) && "school".Equals(groupChange.scope) && "upsert".Equals(groupChange.status) && !string.IsNullOrWhiteSpace(groupChange.school))
|
|
|
|
|
|
+ if ((groupChange.type.Equals("class") || groupChange.type.Equals("teach") || groupChange.type.Equals("student")) && "school".Equals(groupChange.scope) && "upsert".Equals(groupChange.status) && !string.IsNullOrWhiteSpace(groupChange.school))
|
|
{
|
|
{
|
|
|
|
|
|
var data = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, new List<string> { groupChange.listid }, groupChange.school);
|
|
var data = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, new List<string> { groupChange.listid }, groupChange.school);
|
|
@@ -917,10 +922,10 @@ namespace TEAMModelOS.Function
|
|
GroupListSemester groupListSemester = data.groups.First().ToJsonString().ToObject<GroupListSemester>();
|
|
GroupListSemester groupListSemester = data.groups.First().ToJsonString().ToObject<GroupListSemester>();
|
|
groupListSemester.id = id;
|
|
groupListSemester.id = id;
|
|
groupListSemester.code = code;
|
|
groupListSemester.code = code;
|
|
- groupListSemester.pk="GroupListSemester";
|
|
|
|
- groupListSemester.semesterId=dataSemester.currSemester.id;
|
|
|
|
- groupListSemester.groupListId=data.groups.First().id;
|
|
|
|
- groupListSemester.studyYear=dataSemester.studyYear;
|
|
|
|
|
|
+ groupListSemester.pk = "GroupListSemester";
|
|
|
|
+ groupListSemester.semesterId = dataSemester.currSemester.id;
|
|
|
|
+ groupListSemester.groupListId = data.groups.First().id;
|
|
|
|
+ groupListSemester.studyYear = dataSemester.studyYear;
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync<GroupListSemester>(groupListSemester, new PartitionKey(groupListSemester.code));
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync<GroupListSemester>(groupListSemester, new PartitionKey(groupListSemester.code));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -988,9 +993,10 @@ namespace TEAMModelOS.Function
|
|
List<ItemInfo> items = new List<ItemInfo>();
|
|
List<ItemInfo> items = new List<ItemInfo>();
|
|
School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{itemCondDto.key}", new PartitionKey("Base"));
|
|
School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{itemCondDto.key}", new PartitionKey("Base"));
|
|
var period = school.period.Find(z => z.id.Equals(itemCondDto.filed));
|
|
var period = school.period.Find(z => z.id.Equals(itemCondDto.filed));
|
|
- string subjectIn =string.Empty;
|
|
|
|
- if (period!=null && period.subjects.IsNotEmpty()) {
|
|
|
|
- subjectIn =$" and c.subjectId in({string.Join(",", period.subjects.Select(x=>$"'{x.id}'"))})";
|
|
|
|
|
|
+ string subjectIn = string.Empty;
|
|
|
|
+ if (period != null && period.subjects.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ subjectIn = $" and c.subjectId in({string.Join(",", period.subjects.Select(x => $"'{x.id}'"))})";
|
|
}
|
|
}
|
|
var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where c.periodId='{itemCondDto.filed}' and c.pid= null {subjectIn} ";
|
|
var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where c.periodId='{itemCondDto.filed}' and c.pid= null {subjectIn} ";
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.key}") }))
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.key}") }))
|
|
@@ -1259,7 +1265,8 @@ namespace TEAMModelOS.Function
|
|
List<LessonUpdate> updates = new List<LessonUpdate>();
|
|
List<LessonUpdate> updates = new List<LessonUpdate>();
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- _backgroundWorkerQueue.QueueBackgroundWorkItem(async task => {
|
|
|
|
|
|
+ _backgroundWorkerQueue.QueueBackgroundWorkItem(async task =>
|
|
|
|
+ {
|
|
|
|
|
|
//更新课堂记录
|
|
//更新课堂记录
|
|
if (data.TryGetProperty("lesson_id", out JsonElement _lessonId) && !string.IsNullOrEmpty($"{_lessonId}"))
|
|
if (data.TryGetProperty("lesson_id", out JsonElement _lessonId) && !string.IsNullOrEmpty($"{_lessonId}"))
|
|
@@ -1787,9 +1794,9 @@ namespace TEAMModelOS.Function
|
|
|
|
|
|
{
|
|
{
|
|
await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
|
|
await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
|
|
- { client="hiteach", count=1, id=schoolBase.id, key="lesson-create", name=schoolBase.name, scope="school", target=schoolBase.id });
|
|
|
|
|
|
+ { client = "hiteach", count = 1, id = schoolBase.id, key = "lesson-create", name = schoolBase.name, scope = "school", target = schoolBase.id });
|
|
await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
|
|
await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
|
|
- { client="hiteach", count=1, id=lessonRecord.tmdid, key="lesson-create", name="课例", scope="teacher", target=lessonRecord.tmdid });
|
|
|
|
|
|
+ { client = "hiteach", count = 1, id = lessonRecord.tmdid, key = "lesson-create", name = "课例", scope = "teacher", target = lessonRecord.tmdid });
|
|
}
|
|
}
|
|
var space = await BlobService.GetSurplusSpace(school, scope, $"{Environment.GetEnvironmentVariable("Option:Location")}", _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
|
|
var space = await BlobService.GetSurplusSpace(school, scope, $"{Environment.GetEnvironmentVariable("Option:Location")}", _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
|
|
SchoolSetting setting = null;
|
|
SchoolSetting setting = null;
|
|
@@ -1914,7 +1921,7 @@ namespace TEAMModelOS.Function
|
|
var space = await BlobService.GetSurplusSpace(tmdid, scope, $"{Environment.GetEnvironmentVariable("Option:Location")}", _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
|
|
var space = await BlobService.GetSurplusSpace(tmdid, scope, $"{Environment.GetEnvironmentVariable("Option:Location")}", _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
|
|
//20230208调整之前 if (blobTotal * 1073741824 - blobsize > 2147483648) //剩余空间大于2G
|
|
//20230208调整之前 if (blobTotal * 1073741824 - blobsize > 2147483648) //剩余空间大于2G
|
|
//剩余空间不足,则开启自动清理机制
|
|
//剩余空间不足,则开启自动清理机制
|
|
- if (space.surplus> 0)
|
|
|
|
|
|
+ if (space.surplus > 0)
|
|
{
|
|
{
|
|
//大于0则表示空间充足
|
|
//大于0则表示空间充足
|
|
lessonLimit = -1;
|
|
lessonLimit = -1;
|
|
@@ -2138,7 +2145,7 @@ namespace TEAMModelOS.Function
|
|
//=-1 则表示不限制上传数量
|
|
//=-1 则表示不限制上传数量
|
|
}
|
|
}
|
|
await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
|
|
await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
|
|
- { client="hiteach", count=1, id=lessonRecord.tmdid, key="lesson-create", name="课例", scope="teacher", target=lessonRecord.tmdid });
|
|
|
|
|
|
+ { client = "hiteach", count = 1, id = lessonRecord.tmdid, key = "lesson-create", name = "课例", scope = "teacher", target = lessonRecord.tmdid });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
@@ -2260,12 +2267,12 @@ namespace TEAMModelOS.Function
|
|
await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,LessonRecordExpire()\n{ex.Message}\n{ex.StackTrace}\n\n{jsonMsg.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,LessonRecordExpire()\n{ex.Message}\n{ex.StackTrace}\n\n{jsonMsg.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
}
|
|
}
|
|
finally
|
|
finally
|
|
- {
|
|
|
|
|
|
+ {
|
|
// Complete the message
|
|
// Complete the message
|
|
await messageActions.CompleteMessageAsync(message);
|
|
await messageActions.CompleteMessageAsync(message);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// UseDevelopmentStorage=true
|
|
/// UseDevelopmentStorage=true
|
|
@@ -2286,7 +2293,7 @@ namespace TEAMModelOS.Function
|
|
try
|
|
try
|
|
{
|
|
{
|
|
//await _dingDing.SendBotMsg($"IES5,{Environment.GetEnvironmentVariable("Option:Location")},Imei AF call\n{msg.ToJsonString()}", GroupNames.成都开发測試群組);
|
|
//await _dingDing.SendBotMsg($"IES5,{Environment.GetEnvironmentVariable("Option:Location")},Imei AF call\n{msg.ToJsonString()}", GroupNames.成都开发測試群組);
|
|
-
|
|
|
|
|
|
+
|
|
if (json.RootElement.TryGetProperty("channel", out JsonElement channel) &&
|
|
if (json.RootElement.TryGetProperty("channel", out JsonElement channel) &&
|
|
json.RootElement.TryGetProperty("userid", out JsonElement userid) &&
|
|
json.RootElement.TryGetProperty("userid", out JsonElement userid) &&
|
|
json.RootElement.TryGetProperty("school", out JsonElement school) &&
|
|
json.RootElement.TryGetProperty("school", out JsonElement school) &&
|
|
@@ -2309,17 +2316,17 @@ namespace TEAMModelOS.Function
|
|
imei.userid = userid.GetString();
|
|
imei.userid = userid.GetString();
|
|
if (!string.IsNullOrWhiteSpace($"{imeiType}"))
|
|
if (!string.IsNullOrWhiteSpace($"{imeiType}"))
|
|
{
|
|
{
|
|
- imei.imeiType= $"{imeiType}";
|
|
|
|
|
|
+ imei.imeiType = $"{imeiType}";
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- if (imei.id.Length==11)
|
|
|
|
|
|
+ if (imei.id.Length == 11)
|
|
{
|
|
{
|
|
- imei.imeiType="139zhxy";
|
|
|
|
|
|
+ imei.imeiType = "139zhxy";
|
|
}
|
|
}
|
|
- else if (imei.id.Length==15)
|
|
|
|
|
|
+ else if (imei.id.Length == 15)
|
|
{
|
|
{
|
|
- imei.imeiType="tianbo";
|
|
|
|
|
|
+ imei.imeiType = "tianbo";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
await db.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync<Imei>(imei, imei.id);
|
|
await db.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync<Imei>(imei, imei.id);
|
|
@@ -2333,12 +2340,12 @@ namespace TEAMModelOS.Function
|
|
await _dingDing.SendBotMsg($"IES5,{Environment.GetEnvironmentVariable("Option:Location")},Imei AF error\n{ex.Message}\n{ex.StackTrace}{json.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
await _dingDing.SendBotMsg($"IES5,{Environment.GetEnvironmentVariable("Option:Location")},Imei AF error\n{ex.Message}\n{ex.StackTrace}{json.RootElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
}
|
|
}
|
|
finally
|
|
finally
|
|
- {
|
|
|
|
|
|
+ {
|
|
// Complete the message
|
|
// Complete the message
|
|
await messageActions.CompleteMessageAsync(message);
|
|
await messageActions.CompleteMessageAsync(message);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2360,7 +2367,8 @@ namespace TEAMModelOS.Function
|
|
_logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);
|
|
_logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- _backgroundWorkerQueue.QueueBackgroundWorkItem(async task => {
|
|
|
|
|
|
+ _backgroundWorkerQueue.QueueBackgroundWorkItem(async task =>
|
|
|
|
+ {
|
|
var jsonMsg = JsonDocument.Parse(message.Body).RootElement.ToObject<BlobRefreshMessage>();
|
|
var jsonMsg = JsonDocument.Parse(message.Body).RootElement.ToObject<BlobRefreshMessage>();
|
|
if (!string.IsNullOrWhiteSpace($"{jsonMsg.root}") && !string.IsNullOrWhiteSpace($"{jsonMsg.name}"))
|
|
if (!string.IsNullOrWhiteSpace($"{jsonMsg.root}") && !string.IsNullOrWhiteSpace($"{jsonMsg.name}"))
|
|
{
|
|
{
|
|
@@ -2376,12 +2384,14 @@ namespace TEAMModelOS.Function
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- } catch { } finally
|
|
|
|
- {
|
|
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
// Complete the message
|
|
// Complete the message
|
|
await messageActions.CompleteMessageAsync(message);
|
|
await messageActions.CompleteMessageAsync(message);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 統測評量開始結束
|
|
/// 統測評量開始結束
|
|
@@ -2433,7 +2443,8 @@ namespace TEAMModelOS.Function
|
|
public async Task JointEventFunc(
|
|
public async Task JointEventFunc(
|
|
[ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "jointevent-schedule", Connection = "Azure:ServiceBus:ConnectionString")]
|
|
[ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "jointevent-schedule", Connection = "Azure:ServiceBus:ConnectionString")]
|
|
ServiceBusReceivedMessage message,
|
|
ServiceBusReceivedMessage message,
|
|
- ServiceBusMessageActions messageActions)
|
|
|
|
|
|
+ ServiceBusMessageActions messageActions,
|
|
|
|
+ ExecutionContext context)
|
|
{
|
|
{
|
|
_logger.LogInformation("Message ID: {id}", message.MessageId);
|
|
_logger.LogInformation("Message ID: {id}", message.MessageId);
|
|
_logger.LogInformation("Message Body: {body}", message.Body);
|
|
_logger.LogInformation("Message Body: {body}", message.Body);
|
|
@@ -2441,6 +2452,21 @@ namespace TEAMModelOS.Function
|
|
var jsonMsg = JsonDocument.Parse(message.Body).RootElement;
|
|
var jsonMsg = JsonDocument.Parse(message.Body).RootElement;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+ //多國語字典
|
|
|
|
+ //string rootPath = _environment.ContentRootPath;
|
|
|
|
+ //List<string> langList = new List<string>() { "en-us", "zh-cn", "zh-tw" };
|
|
|
|
+ //Dictionary<string, JObject> langDic = new Dictionary<string, JObject>();
|
|
|
|
+ //foreach (string langCode in langList)
|
|
|
|
+ //{
|
|
|
|
+ // string path = Path.Combine(rootPath, $"Lang/{langCode}.json");
|
|
|
|
+ // if (File.Exists(path))
|
|
|
|
+ // {
|
|
|
|
+ // string jsonContent = await File.ReadAllTextAsync(path);
|
|
|
|
+ // JObject jsonObject = JObject.Parse(jsonContent);
|
|
|
|
+ // langDic.Add(langCode, jsonObject);
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+
|
|
jsonMsg.TryGetProperty("jointEventId", out JsonElement jointEventId);
|
|
jsonMsg.TryGetProperty("jointEventId", out JsonElement jointEventId);
|
|
jsonMsg.TryGetProperty("jointScheduleId", out JsonElement jointScheduleId);
|
|
jsonMsg.TryGetProperty("jointScheduleId", out JsonElement jointScheduleId);
|
|
jsonMsg.TryGetProperty("progress", out JsonElement progress);
|
|
jsonMsg.TryGetProperty("progress", out JsonElement progress);
|
|
@@ -2452,7 +2478,7 @@ namespace TEAMModelOS.Function
|
|
bool updFlg = false;
|
|
bool updFlg = false;
|
|
string code = "JointEvent";
|
|
string code = "JointEvent";
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
-
|
|
|
|
|
|
+
|
|
JointEvent jointEvent = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<JointEvent>(jointEventId.ToString(), new PartitionKey($"{code}"));
|
|
JointEvent jointEvent = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<JointEvent>(jointEventId.ToString(), new PartitionKey($"{code}"));
|
|
if (jointEvent != null)
|
|
if (jointEvent != null)
|
|
{
|
|
{
|
|
@@ -2529,6 +2555,57 @@ namespace TEAMModelOS.Function
|
|
}
|
|
}
|
|
//寄發Email
|
|
//寄發Email
|
|
///取得收信者Email ※ jointCourse.creatorEmail
|
|
///取得收信者Email ※ jointCourse.creatorEmail
|
|
|
|
+ //List<dynamic> users = new List<dynamic>();
|
|
|
|
+ //if (jointEventSchedule.type.Equals("exam"))
|
|
|
|
+ //{
|
|
|
|
+ // //一般競賽 ※挑戰賽 名單架構確定後再取
|
|
|
|
+ // if (jointEventSchedule.examType.Equals("regular"))
|
|
|
|
+ // {
|
|
|
|
+ // await foreach (var jc in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryStreamIteratorSql(queryText: $"SELECT DISTINCT c.creatorId, c.creatorName, c.creatorEmail FROM c WHERE c.jointEventId = '{jointEvent.id}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"JointCourse") }))
|
|
|
|
+ // {
|
|
|
|
+ // using var json = await JsonDocument.ParseAsync(jc.Content);
|
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ // {
|
|
|
|
+ // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ // {
|
|
|
|
+ // EmailUser user = new EmailUser();
|
|
|
|
+ // user.tmid = (obj.TryGetProperty("creatorId", out JsonElement _creatorId)) ? _creatorId.GetString() : string.Empty;
|
|
|
|
+ // user.name = (obj.TryGetProperty("creatorName", out JsonElement _creatorName)) ? _creatorName.GetString() : string.Empty;
|
|
|
|
+ // user.email = (obj.TryGetProperty("creatorEmail", out JsonElement _creatorEmail)) ? _creatorEmail.GetString() : string.Empty;
|
|
|
|
+ // if (!string.IsNullOrWhiteSpace(user.tmid) && !string.IsNullOrWhiteSpace(user.email))
|
|
|
|
+ // {
|
|
|
|
+ // users.Add(user);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //if (users.Count > 0)
|
|
|
|
+ //{
|
|
|
|
+ // //取得模板ID ※國際站就用繁體,大陸站就用簡體 [待定]
|
|
|
|
+ // string location = Environment.GetEnvironmentVariable("Option:Location");
|
|
|
|
+ // string tid = (location.Contains("China")) ? "" : "d-833d40ac6397414b852b91e2fa45850a";
|
|
|
|
+ // string lang = (location.Contains("China")) ? "zh-cn" : "zh-tw";
|
|
|
|
+ // //取得通知內文
|
|
|
|
+ // string mailTitle = string.Empty;
|
|
|
|
+ // string mailBody = string.Empty;
|
|
|
|
+ // JObject jsonObject = langDic[lang];
|
|
|
|
+ // if (jsonObject.TryGetValue("joint-schedule-start", out JToken msgToken))
|
|
|
|
+ // {
|
|
|
|
+ // JArray msgArray = (JArray)msgToken;
|
|
|
|
+ // mailTitle = msgArray[0].ToString();
|
|
|
|
+ // mailBody = $"{msgArray[1].ToString()}";
|
|
|
|
+ // }
|
|
|
|
+ // foreach (dynamic user in users)
|
|
|
|
+ // {
|
|
|
|
+ // if (!string.IsNullOrWhiteSpace(tid)) //※大陸站無模板,暫時不發
|
|
|
|
+ // {
|
|
|
|
+ // mailBody = mailBody.Replace("{tmdname}", user.name).Replace("{event}", jointEventSchedule.name);
|
|
|
|
+ // await _coreAPIHttpService.SendMail(new Dictionary<string, object> { { "to", user.email }, { "tid", tid }, { "vars", new { name = user.name } } }, location, _configuration);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
break;
|
|
break;
|
|
case "finish":
|
|
case "finish":
|
|
string pk = string.Format("{0}{1}{2}{3}{4}{5}{6}", "JointEvent", "-", $"{jointEventId}", "-", "schedule", "-", "going");
|
|
string pk = string.Format("{0}{1}{2}{3}{4}{5}{6}", "JointEvent", "-", $"{jointEventId}", "-", "schedule", "-", "going");
|
|
@@ -2584,5 +2661,11 @@ namespace TEAMModelOS.Function
|
|
//await _dingDing.SendBotMsg($"ServiceBus,RefreshBlob:\n容器名:{name}\n文件夹:{u}\n计算时长:{dis}\n文件夹大小:{blobsize}", GroupNames.醍摩豆服務運維群組);
|
|
//await _dingDing.SendBotMsg($"ServiceBus,RefreshBlob:\n容器名:{name}\n文件夹:{u}\n计算时长:{dis}\n文件夹大小:{blobsize}", GroupNames.醍摩豆服務運維群組);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private class EmailUser
|
|
|
|
+ {
|
|
|
|
+ public string tmid { get; set; }
|
|
|
|
+ public string name { get; set; }
|
|
|
|
+ public string email { get; set; }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|