/// <summary> /// 获得数据列表 /// </summary> public List<Ajax.Model.Message> DataTableToList(DataTable dt) { List<Ajax.Model.Message> modelList = new List<Ajax.Model.Message>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Ajax.Model.Message model; for (int n = 0; n < rowsCount; n++) { model = new Ajax.Model.Message(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = dt.Rows[n]["ID"].ToString(); } if (dt.Rows[n]["Title"] != null && dt.Rows[n]["Title"].ToString() != "") { model.Title = dt.Rows[n]["Title"].ToString(); } if (dt.Rows[n]["Content"] != null && dt.Rows[n]["Content"].ToString() != "") { model.Content = dt.Rows[n]["Content"].ToString(); } if (dt.Rows[n]["OperatorID"] != null && dt.Rows[n]["OperatorID"].ToString() != "") { model.OperatorID = dt.Rows[n]["OperatorID"].ToString(); } if (dt.Rows[n]["CreateDate"] != null && dt.Rows[n]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } modelList.Add(model); } } return modelList; }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Message model) { using (DBHelper db = DBHelper.Create()) { db.Insert<Message>(model); } }
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); }
/// <summary> /// 获得数据列表 /// </summary> public List <Ajax.Model.Message> DataTableToList(DataTable dt) { List <Ajax.Model.Message> modelList = new List <Ajax.Model.Message>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Ajax.Model.Message model; for (int n = 0; n < rowsCount; n++) { model = new Ajax.Model.Message(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = dt.Rows[n]["ID"].ToString(); } if (dt.Rows[n]["Title"] != null && dt.Rows[n]["Title"].ToString() != "") { model.Title = dt.Rows[n]["Title"].ToString(); } if (dt.Rows[n]["Content"] != null && dt.Rows[n]["Content"].ToString() != "") { model.Content = dt.Rows[n]["Content"].ToString(); } if (dt.Rows[n]["OperatorID"] != null && dt.Rows[n]["OperatorID"].ToString() != "") { model.OperatorID = dt.Rows[n]["OperatorID"].ToString(); } if (dt.Rows[n]["CreateDate"] != null && dt.Rows[n]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } modelList.Add(model); } } return(modelList); }
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); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Ajax.Model.Message model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Ajax.Model.Message model) { dal.Add(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Message model) { using (DBHelper db = DBHelper.Create()) { db.Update<Message>(model); return true; } }