Example #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()
             }
         }
     });
 }
Example #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;
     }
 }
Example #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;
     }
 }
Example #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;
     }
 }
Example #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);
 }
Example #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);
 }