소스 검색

课纲设计结构

CrazyIter_Bin 4 년 전
부모
커밋
39a1fd3259
3개의 변경된 파일40개의 추가작업 그리고 45개의 파일을 삭제
  1. 20 16
      TEAMModelFunction/NoticeServiceBus.cs
  2. 1 1
      TEAMModelOS.SDK/Models/Cosmos/Common/Inner/SyllabusNode.cs
  3. 19 28
      TEAMModelOS.SDK/Models/Cosmos/Common/Notice.cs

+ 20 - 16
TEAMModelFunction/NoticeServiceBus.cs

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

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/SyllabusNode.cs

@@ -103,7 +103,7 @@ namespace TEAMModelOS.SDK.Models
         public string code { get; set; }
         public string link { get; set; }
         /// <summary>
-        /// 试题 ,试卷,内容资源,
+        /// 试题 ,试卷,内容资源,外部链接(只有link,和name),
         /// </summary>
         public string type { get; set; }
     }

+ 19 - 28
TEAMModelOS.SDK/Models/Cosmos/Common/Notice.cs

@@ -39,32 +39,40 @@ namespace TEAMModelOS.SDK.Models
     ///             tmdid:/receiver/xxxx时间戳排序.json
     /// </summary>
     public class Notice
-    {
+    { 
         /// <summary>
-        /// 消息id 
+        ///  訊息種類 message:訊息,收取會另存至儲存體(blob or table) notice:通知,收取後不另存 
+        /// XXXX通知的业务类型,做什么事情用,具体业务类型再定义。 vote-join 
         /// </summary>
-        public string msgId { get; set; }
+        public string type { get; set; }
+        /// <summary>
+        /// 重要等级 emergency、high、normal、low 1置顶,2非常重要,3重要,4普通消息,5不重要
+        /// </summary>
+        public string priority { get; set; }
         /// <summary>
         /// 發信源服務  IES5
         /// </summary>
         public string from { get; set; } = "IES5";
         /// <summary>
-        ///  訊息種類 message:訊息,收取會另存至儲存體(blob or table) notice:通知,收取後不另存 
-       /// XXXX通知的业务类型,做什么事情用,具体业务类型再定义。 vote-join 
+        /// 服務收信對象 若任一服務皆可收,則不填;指定某服務才收,則填服務名稱 例:HiT
         /// </summary>
-        public string type { get; set; }
+        public string toservice { get; set; }
         /// <summary>
-        /// 重要等级 emergency、high、normal、low 1置顶,2非常重要,3重要,4普通消息,5不重要
+        /// 到期时间,发给接收者的cosmosDB ttl是从当前时间到结束时间为止
         /// </summary>
-        public string priority { get; set; }
+        public long expire { get; set; }
         /// <summary>
         /// 创建时间
         /// </summary>
         public long creation { get; set; }
         /// <summary>
-        /// 到期时间,发给接收者的cosmosDB ttl是从当前时间到结束时间为止
+        /// 消息id 
         /// </summary>
-        public long expire { get; set; }
+        public string msgId { get; set; }
+        /// <summary>
+        /// 正文內容
+        /// </summary>
+        public Body body { get; set; }
         /// <summary>
         /// 创建者
         /// </summary>
@@ -86,11 +94,7 @@ namespace TEAMModelOS.SDK.Models
         /// 被通知的学校学生账号
         /// </summary>
         public List<Students> stuids { get; set; }
-        public  int ttl { get; set;  }
-        /// <summary>
-        /// 正文內容
-        /// </summary>
-        public Body body { get; set; }
+       
     }
 
     /// <summary>
@@ -134,24 +138,11 @@ namespace TEAMModelOS.SDK.Models
     public class Receiver  
     {
         public string id { get; set; }
-        public string pk { get; set; } = "Receiver";
         /// <summary>
         /// 0 已发送,1已查看,2已处理,-1已过期
         /// </summary>
         public int status { get; set; }=0;
         /// <summary>
-        /// 通知接收者
-        /// </summary>
-        public string rid { get; set; }
-        /// <summary>
-        /// 当rid是学校的学生时,学校编码不能为空
-        /// </summary>
-        ///public string school { get; set; }
-        /// <summary>
-        /// 源数据的scope   school则接收者是学校的学生/teacher接收者是醍摩豆账号
-        /// </summary>
-        public string scope { get; set; }
-        /// <summary>
         /// 创建时间
         /// </summary>
         public long ctime { get; set; }