| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- using CallCenter.Utility;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.information
- {
- public class InternalMessagesController : BaseController
- {
- BLL.T_SMS_InternalMessages bll = new BLL.T_SMS_InternalMessages();
- /// <summary>
- /// 获取所有列表 分页
- /// </summary>
- /// <returns></returns>
- public ActionResult GetAllList()
- {
- DataTable dt = new DataTable();
- string SMS_Title = HttpUtility.UrlDecode(RequestString.GetQueryString("title"));
- string SMS_ReceiveUserCode = HttpUtility.UrlDecode(RequestString.GetQueryString("receiveUserCode"));
- string SMS_SendUserCode = HttpUtility.UrlDecode(RequestString.GetQueryString("sendUserCode"));
- string SMS_Content = HttpUtility.UrlDecode(RequestString.GetQueryString("content"));
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("strstarttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("strendtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- string sql = string.Empty;
- if (SMS_Title.Trim() != "")
- {
- sql += " and SMS_Title like '%" + SMS_Title + "%'";
- }
- if (SMS_ReceiveUserCode.Trim() != "")
- {
- sql += " and SMS_ReceiveUserCode = '" + SMS_ReceiveUserCode + "'";
- }
- if (SMS_SendUserCode.Trim() != "")
- {
- sql += " and SMS_SendUserCode = '" + SMS_SendUserCode + "'";
- }
- if (SMS_Content.Trim() != "")
- {
- sql += " and SMS_Content like '%" + SMS_Content + "%'";
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- sql += " and datediff(day,SMS_SendUserCode,'" + strstarttime + "')<=0 ";
- }
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and datediff(day,SMS_SendUserCode,'" + strendtime + "')>=0 ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_SMS_InternalMessages",
- "F_Id",
- "*",
- sql,
- "ORDER BY SMS_Id desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取前几条列表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetTopList()
- {
- DataTable dt = new DataTable();
- string strWhere = string.Empty;
- int Top = RequestString.GetInt("top", 5);
- string SMS_ReceiveUserCode = RequestString.GetQueryString("receiveUserCode");
- if (SMS_ReceiveUserCode.Trim() != "")
- {
- strWhere += " and SMS_ReceiveUserCode = '" + SMS_ReceiveUserCode + "'";
- }
- dt = bll.GetList(Top, strWhere, " SMS_Order,SMS_SendTime ").Tables[0];
- var obj = new
- {
- rows = dt,
- total = Top
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取一条详细信息
- /// </summary>
- /// <param name="infoid"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult GetInfo(string infoid)
- {
- if (infoid != null && infoid.Trim() != "")
- {
- Model.T_SMS_InternalMessages model = bll.GetModel(int.Parse(infoid.Trim()));
-
- if (model != null)
- {
- if (model.SMS_IsRead == 0)
- {
- model.SMS_IsRead = 1;
- model.SMS_ReadTime = DateTime.Now;
- bool b = bll.Update(model);
- if (b)
- {
- return Success("获取成功", model);
- }
- else
- {
- return Error("获取失败,无更新权限");
- }
- }
- else {
- return Success("获取成功", model);
- }
- }
- else
- {
- return Error("获取失败");
- };
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- /// <summary>
- /// 保存信息
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult SaveInfo()
- {
- int id = RequestString.GetInt("id", 0);
- string SMS_Title = RequestString.GetFormString("title");
- string SMS_ReceiveUserCode = RequestString.GetFormString("receiveUserCode");
- string SMS_SendUserCode = RequestString.GetFormString("sendUserCode");
- string SMS_Content = RequestString.GetFormString("content");
- int SMS_IsDelete = RequestString.GetInt("isDelete", 0);
- int SMS_IsRead = RequestString.GetInt("isRead", 0);
- int SMS_Order = RequestString.GetInt("order", 0);
- int SMS_IsTop = RequestString.GetInt("isTop", 0);
- if (!string.IsNullOrWhiteSpace(SMS_Title) || !string.IsNullOrWhiteSpace(SMS_ReceiveUserCode) || !string.IsNullOrWhiteSpace(SMS_ReceiveUserCode))
- {
- Model.T_SMS_InternalMessages model = new Model.T_SMS_InternalMessages();
- if (id == 0)
- {
- model.SMS_Title = SMS_Title;
- model.SMS_Content = SMS_Content;
- model.SMS_ReceiveUserCode = SMS_ReceiveUserCode;
- model.SMS_SendUserCode = SMS_SendUserCode;
- model.SMS_IsRead = SMS_IsRead;
- model.SMS_SendTime = DateTime.Now;
- //model.SMS_ReadTime = SMS_ReadTime;
- //model.SMS_DeleteTime = SMS_DeleteTime;
- model.SMS_IsDelete = 0;
- model.SMS_Order = SMS_Order;
- model.SMS_IsTop = SMS_IsTop;
- int n = bll.Add(model);
- if (n > 0)
- {
- return Success("添加成功", n);
- }
- else
- {
- return Error("添加失败");
- }
- }
- else
- {
- model = bll.GetModel(id);
- if (model != null)
- {
- model.SMS_Id = id;
- model.SMS_Title = SMS_Title;
- model.SMS_Content = SMS_Content;
- model.SMS_ReceiveUserCode = SMS_ReceiveUserCode;
- model.SMS_SendUserCode = SMS_SendUserCode;
- model.SMS_IsRead = SMS_IsRead;
- model.SMS_SendTime = model.SMS_SendTime;
- //model.SMS_ReadTime = DateTime.Now;
- //model.SMS_DeleteTime = SMS_DeleteTime;
- model.SMS_IsDelete = 0;
- model.SMS_Order = SMS_Order;
- model.SMS_IsTop = SMS_IsTop;
- if (bll.Update(model))
- {
- return Success("修改成功");
- }
- else
- {
- return Error("修改失败");
- }
- }
- return Error("信息不存在");
- }
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- /// <summary>
- /// 删除信息
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelInfo(string[] ids)
- {
- if (ids != null && ids.Length > 0)
- {
- string idd = " ";
- foreach (string str in ids)
- {
- idd += str + ",";
- }
- if (bll.DeleteList(idd.TrimEnd(',')))
- {
- return Success("删除成功");
- }
- else
- return Error("删除失败");
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- }
- }
|