|
@@ -37,13 +37,11 @@ namespace TEAMModelFunction
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
|
|
- Console.WriteLine(msg);
|
|
|
|
// List<Task<string>> tasks = new List<Task<string>>();
|
|
// List<Task<string>> tasks = new List<Task<string>>();
|
|
//List<Task> sessionTasks = new List<Task>();
|
|
//List<Task> sessionTasks = new List<Task>();
|
|
var jsonMsg = JsonDocument.Parse(msg);
|
|
var jsonMsg = JsonDocument.Parse(msg);
|
|
Notice notice = msg.ToObject<Notice>();
|
|
Notice notice = msg.ToObject<Notice>();
|
|
var blobcntr = "";
|
|
var blobcntr = "";
|
|
-
|
|
|
|
if (notice.scope.Equals("school"))
|
|
if (notice.scope.Equals("school"))
|
|
{
|
|
{
|
|
blobcntr = notice.school;
|
|
blobcntr = notice.school;
|
|
@@ -59,17 +57,29 @@ namespace TEAMModelFunction
|
|
#if DEBUG
|
|
#if DEBUG
|
|
await _dingDing.SendBotMsg($"NoticeServiceBus-Notice:\n发起通知{msg}", GroupNames.成都开发測試群組);
|
|
await _dingDing.SendBotMsg($"NoticeServiceBus-Notice:\n发起通知{msg}", GroupNames.成都开发測試群組);
|
|
#endif
|
|
#endif
|
|
|
|
+ long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
|
+ long day30 = 2592000L;
|
|
|
|
+ //处理过期时间大于30天
|
|
|
|
+ if (notice.expire - now > day30) {
|
|
|
|
+ notice.expire = now + day30;
|
|
|
|
+ }
|
|
|
|
+ //通知的主体内容
|
|
var urlNotice = $"{notice.msgId}.json";
|
|
var urlNotice = $"{notice.msgId}.json";
|
|
var blobNotice = new
|
|
var blobNotice = new
|
|
{
|
|
{
|
|
notice.type,
|
|
notice.type,
|
|
notice.priority,
|
|
notice.priority,
|
|
|
|
+ notice.from,
|
|
|
|
+ notice.toservice,
|
|
|
|
+ notice.creation,//创建时间
|
|
|
|
+ notice.expire,//到期时间
|
|
|
|
+ notice.msgId,
|
|
|
|
+ notice.creatorId,
|
|
|
|
+ notice.school,
|
|
|
|
+ notice.scope,
|
|
notice.body,
|
|
notice.body,
|
|
- notice.creation,
|
|
|
|
- notice.expire,
|
|
|
|
- notice.creatorId
|
|
|
|
-
|
|
|
|
};
|
|
};
|
|
|
|
+ //通知的接收人的集合信息
|
|
await _azureStorage.UploadFileByContainer(blobcntr, blobNotice.ToJsonString(), "notice", urlNotice);
|
|
await _azureStorage.UploadFileByContainer(blobcntr, blobNotice.ToJsonString(), "notice", urlNotice);
|
|
var urlReceiver = $"{notice.msgId}_receiver.json";
|
|
var urlReceiver = $"{notice.msgId}_receiver.json";
|
|
var blobReceiver = new
|
|
var blobReceiver = new
|
|
@@ -78,7 +88,9 @@ namespace TEAMModelFunction
|
|
notice.tmdids
|
|
notice.tmdids
|
|
};
|
|
};
|
|
await _azureStorage.UploadFileByContainer(blobcntr, blobReceiver.ToJsonString(), "notice", urlReceiver);
|
|
await _azureStorage.UploadFileByContainer(blobcntr, blobReceiver.ToJsonString(), "notice", urlReceiver);
|
|
- long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
|
|
|
+
|
|
|
|
+ //发送通知给用户
|
|
|
|
+
|
|
// "ttl":2592000,不能超过30天(2592000),一天(3600),一周(25200)
|
|
// "ttl":2592000,不能超过30天(2592000),一天(3600),一周(25200)
|
|
|
|
|
|
if (notice.stuids.IsNotEmpty())
|
|
if (notice.stuids.IsNotEmpty())
|
|
@@ -89,12 +101,9 @@ namespace TEAMModelFunction
|
|
Receiver receiver = new Receiver
|
|
Receiver receiver = new Receiver
|
|
{
|
|
{
|
|
id = notice.msgId,
|
|
id = notice.msgId,
|
|
- pk = "Receiver",
|
|
|
|
status = 0,
|
|
status = 0,
|
|
- scope = "school",
|
|
|
|
ctime = now,
|
|
ctime = now,
|
|
urlNotice = $"/notice/{urlNotice}",
|
|
urlNotice = $"/notice/{urlNotice}",
|
|
- rid = $"{stu.schoolId}-{stu.id}"
|
|
|
|
};
|
|
};
|
|
var url = $"{stu.id}/receive/{notice.msgId}.json";
|
|
var url = $"{stu.id}/receive/{notice.msgId}.json";
|
|
await client.HashSetAsync($"Notice:Receiver:{stu.schoolId}-{stu.id}", notice.msgId, $"/student/{url}");
|
|
await client.HashSetAsync($"Notice:Receiver:{stu.schoolId}-{stu.id}", notice.msgId, $"/student/{url}");
|
|
@@ -115,17 +124,12 @@ namespace TEAMModelFunction
|
|
Receiver receiver = new Receiver
|
|
Receiver receiver = new Receiver
|
|
{
|
|
{
|
|
id = notice.msgId,
|
|
id = notice.msgId,
|
|
- pk = "Receiver",
|
|
|
|
status = 0,
|
|
status = 0,
|
|
- //school = stu.schoolId,
|
|
|
|
- scope = "school",
|
|
|
|
-
|
|
|
|
ctime = now,
|
|
ctime = now,
|
|
urlNotice = $"/notice/{urlNotice}",
|
|
urlNotice = $"/notice/{urlNotice}",
|
|
- rid = $"{tmdid}"
|
|
|
|
};
|
|
};
|
|
var url = $"{notice.msgId}.json";
|
|
var url = $"{notice.msgId}.json";
|
|
- await client.HashSetAsync($"Notice:Receiver:{tmdid}", notice.msgId, new { now, url = $"/receive/{url}" }.ToJsonString());
|
|
|
|
|
|
+ await client.HashSetAsync($"Notice:Receiver:{tmdid}", notice.msgId, receiver.ToJsonString());
|
|
//await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync<Receiver>(receiver, new Azure.Cosmos.PartitionKey(receiver.code));
|
|
//await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync<Receiver>(receiver, new Azure.Cosmos.PartitionKey(receiver.code));
|
|
// /student/{stuid}/receive/{notice.sid}.json
|
|
// /student/{stuid}/receive/{notice.sid}.json
|
|
//存放通知到学生容器空间
|
|
//存放通知到学生容器空间
|