Exemple #1
0
 private static MessageItem MakeCommonInfo(ChatMessageDto msgDto)
 {
     return(new MessageItem
     {
         EntityName = "ChatMessage",
         Type = TypeEnum.Message,
         Operation = OperationEnum.Added,
         ChangeTime = DBTimeHelper.DBNowTime(),
         Data =
             new List <CustomKeyValue>
         {
             new CustomKeyValue {
                 Key = "SendUserID", Value = msgDto.SendUserID
             },
             new CustomKeyValue {
                 Key = "Text", Value = msgDto.Message
             },
             new CustomKeyValue {
                 Key = "SendTime", Value = msgDto.SendTime.ToString()
             },
             new CustomKeyValue {
                 Key = "MessageID", Value = msgDto.MessageID.ToString()
             }
         }
     });
 }
Exemple #2
0
 private static bool AnnounceMessageByEnterpriseID(ChatMessageDto msgDto)
 {
     try
     {
         var msg = MakeCommonInfo(msgDto);
         msg.Data.Add(new CustomKeyValue {
             Key = "EnterpriseID", Value = msgDto.EnterpriseID
         });
         return(Send2Msmq(msg));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 private static bool SendChatMessage(ChatMessageDto msgDto)
 {
     try
     {
         var msg = MakeCommonInfo(msgDto);
         msg.Data.Add(new CustomKeyValue {
             Key = "Recipients", Value = msgDto.Recipients
         });
         return(Send2Msmq(msg));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
 public bool AnnounceMessageByDepartMentIDs(ChatMessageDto msgDto)
 {
     try
     {
         var msg = MakeCommonInfo(msgDto);
         msg.Data.AddRange(msgDto.DepartMentIDs.Select(d => new CustomKeyValue {
             Key = "DepartMentID", Value = d.ToString()
         }));
         return(Send2Msmq(msg));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #5
0
 public bool ProcessChatMessage(ChatMessageDto msgDto)
 {
     if (!string.IsNullOrEmpty(msgDto.Recipients))
     {
         return(SendChatMessage(msgDto));
     }
     if (!string.IsNullOrEmpty(msgDto.EnterpriseID))
     {
         return(AnnounceMessageByEnterpriseID(msgDto));
     }
     if (0 != msgDto.DepartMentIDs.Count())
     {
         return(AnnounceMessageByDepartMentIDs(msgDto));
     }
     return(false);
 }
Exemple #6
0
 public bool ProcessChatMessage(ChatMessageDto msgDto)
 {
     if (string.IsNullOrEmpty(msgDto.Recipients))
     {
         throw new KnownException("收信人不能为空");
     }
     if (string.IsNullOrEmpty(msgDto.Message))
     {
         throw new KnownException("发送消息不能为空");
     }
     if (!string.IsNullOrEmpty(msgDto.Recipients))
     {
         return(SendChatMessage(msgDto));
     }
     if (!string.IsNullOrEmpty(msgDto.EnterpriseID))
     {
         return(AnnounceMessageByEnterpriseID(msgDto));
     }
     if (0 != msgDto.DepartMentIDs.Count())
     {
         return(AnnounceMessageByDepartMentIDs(msgDto));
     }
     return(false);
 }