示例#1
0
 public JsonResult AddMessageNew(string AcceptIDS, string Title, string Content)
 {
     AjaxResult result = new AjaxResult();
     Message msg = new Message();
     msg.Content = Content;
     msg.Title = Title;
     try
     {
         MessageRule msgR = new MessageRule();
         if (string.IsNullOrEmpty(msg.ID))//新增
         {
             msg.ID = Guid.NewGuid().ToString("N");
             msg.OperatorID = MyTicket.CurrentTicket.UserID;
             msg.CreateDate = DateTime.Now;
             msgR.Add(msg);
             //不选接收人,默认发送给所有人
             if (string.IsNullOrEmpty(AcceptIDS))
             {
                 List<Ajax.Model.Customer> acceptList = new CustomerRule().GetList("");
                 foreach (Ajax.Model.Customer c in acceptList)
                 {
                     AcceptIDS += c.OperatorID + ",";
                 }
             }
             string[] strAcceptIDs = AcceptIDS.Remove(AcceptIDS.Length - 1, 1).Split(',');//Request.Form["txtAcceptIDs"].Split(',');
             //接收人
             OperatorMsgRule omsgR = new OperatorMsgRule();
             List<OperatorMsg> oMsgList = new List<OperatorMsg>();
             foreach (string acceptID in strAcceptIDs)
             {
                 if (string.IsNullOrEmpty(acceptID)) continue;
                 OperatorMsg omsg = new OperatorMsg();
                 omsg.ID = Guid.NewGuid().ToString("N");
                 omsg.Status = 0;//默认为未读
                 omsg.MsgID = msg.ID;
                 omsg.OperatorID = acceptID;
                 oMsgList.Add(omsg);
             }
             omsgR.AddMul(oMsgList);
             result.Success = true;
             result.Message = "公告已经成功发出。";
         }
         else//编辑
         {
             result.Success = msgR.Update(msg);
             result.Message = result.Success ? "公告已经成功修改。" : "公告修改失败!";
         }
     }
     catch (Exception ex)
     {
         result.Success = false;
         result.Message = "操作失败:" + ex.Message;
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
示例#2
0
 public JsonResult GetMsgDetail(string msgID)
 {
     Message ms = new Message();
     if (!string.IsNullOrEmpty(msgID))
     {
         string operatorID = MyTicket.CurrentTicket.UserID;
         ms = new OperatorMsgRule().ReadMsg(msgID, operatorID); //消息已读
     }
     else
     {
         throw new Exception("非法访问");
     }
     return Json(ms.Content, JsonRequestBehavior.AllowGet);
 }