/// <summary> /// 发送消息 /// </summary> public void DoSend(params string[] receiverIds) { if (receiverIds == null || receiverIds.Length <= 0) { if (!String.IsNullOrEmpty(this.ReceiverId)) { receiverIds = this.ReceiverId.Split(',', ';'); } } if (receiverIds != null && receiverIds.Length > 0) { SysUser[] users = SysUser.FindAllByPrimaryKeys(receiverIds); foreach (SysUser tuser in users) { SysMessage msg = new SysMessage(); msg.SenderId = this.SenderId; msg.SenderName = this.SenderName; msg.Title = this.Title; msg.MessageContent = this.MessageContent; msg.Attachment = this.Attachment; msg.SendTime = DateTime.Now; msg.ReceiverId = tuser.UserID; msg.ReceiverName = tuser.Name; msg.DoCreate(); } } }
/// <summary> /// 消息发送操作 /// </summary> public static void Send(string senderId, string title, string content, string attachment, params string[] receiverIds) { if (receiverIds != null && receiverIds.Length > 0) { SysUser sender = SysUser.Find(senderId); SysMessage msg = new SysMessage(); msg.SenderId = sender.UserID; msg.SenderName = sender.Name; msg.Title = title; msg.MessageContent = content; msg.Attachment = attachment; msg.DoSend(receiverIds); } else { throw new MessageException("接收人不能为空。"); } }