12345市长热线标准版-后端

InternalMessagesController.cs 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using CallCenter.Utility;
  2. using CallCenterApi.Interface.Controllers.Base;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. namespace CallCenterApi.Interface.Controllers.information
  10. {
  11. public class InternalMessagesController : BaseController
  12. {
  13. BLL.T_SMS_InternalMessages bll = new BLL.T_SMS_InternalMessages();
  14. /// <summary>
  15. /// 获取所有列表 分页
  16. /// </summary>
  17. /// <returns></returns>
  18. public ActionResult GetAllList()
  19. {
  20. DataTable dt = new DataTable();
  21. string SMS_Title = HttpUtility.UrlDecode(RequestString.GetQueryString("title"));
  22. string SMS_ReceiveUserCode = HttpUtility.UrlDecode(RequestString.GetQueryString("receiveUserCode"));
  23. string SMS_SendUserCode = HttpUtility.UrlDecode(RequestString.GetQueryString("sendUserCode"));
  24. string SMS_Content = HttpUtility.UrlDecode(RequestString.GetQueryString("content"));
  25. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("strstarttime"));
  26. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("strendtime"));
  27. string strpageindex = RequestString.GetQueryString("page");
  28. int pageindex = 1;
  29. string strpagesize = RequestString.GetQueryString("pagesize");
  30. int pagesize = 10;
  31. string sql = string.Empty;
  32. if (SMS_Title.Trim() != "")
  33. {
  34. sql += " and SMS_Title like '%" + SMS_Title + "%'";
  35. }
  36. if (SMS_ReceiveUserCode.Trim() != "")
  37. {
  38. sql += " and SMS_ReceiveUserCode = '" + SMS_ReceiveUserCode + "'";
  39. }
  40. if (SMS_SendUserCode.Trim() != "")
  41. {
  42. sql += " and SMS_SendUserCode = '" + SMS_SendUserCode + "'";
  43. }
  44. if (SMS_Content.Trim() != "")
  45. {
  46. sql += " and SMS_Content like '%" + SMS_Content + "%'";
  47. }
  48. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  49. {
  50. sql += " and datediff(day,SMS_SendUserCode,'" + strstarttime + "')<=0 ";
  51. }
  52. if (strendtime.Trim() != "" && strendtime != "undefined")
  53. {
  54. sql += " and datediff(day,SMS_SendUserCode,'" + strendtime + "')>=0 ";
  55. }
  56. if (strpageindex.Trim() != "")
  57. {
  58. pageindex = Convert.ToInt32(strpageindex);
  59. }
  60. if (strpagesize.Trim() != "")
  61. {
  62. pagesize = Convert.ToInt32(strpagesize);
  63. }
  64. int recordCount = 0;
  65. dt = BLL.PagerBLL.GetListPager(
  66. "T_SMS_InternalMessages",
  67. "F_Id",
  68. "*",
  69. sql,
  70. "ORDER BY SMS_Id desc",
  71. pagesize,
  72. pageindex,
  73. true,
  74. out recordCount);
  75. var obj = new
  76. {
  77. rows = dt,
  78. total = recordCount
  79. };
  80. return Content(obj.ToJson());
  81. }
  82. /// <summary>
  83. /// 获取前几条列表
  84. /// </summary>
  85. /// <returns></returns>
  86. public ActionResult GetTopList()
  87. {
  88. DataTable dt = new DataTable();
  89. string strWhere = string.Empty;
  90. int Top = RequestString.GetInt("top", 5);
  91. string SMS_ReceiveUserCode = RequestString.GetQueryString("receiveUserCode");
  92. if (SMS_ReceiveUserCode.Trim() != "")
  93. {
  94. strWhere += " and SMS_ReceiveUserCode = '" + SMS_ReceiveUserCode + "'";
  95. }
  96. dt = bll.GetList(Top, strWhere, " SMS_Order,SMS_SendTime ").Tables[0];
  97. var obj = new
  98. {
  99. rows = dt,
  100. total = Top
  101. };
  102. return Content(obj.ToJson());
  103. }
  104. /// <summary>
  105. /// 获取一条详细信息
  106. /// </summary>
  107. /// <param name="infoid"></param>
  108. /// <returns></returns>
  109. [Authority]
  110. public ActionResult GetInfo(string infoid)
  111. {
  112. if (infoid != null && infoid.Trim() != "")
  113. {
  114. Model.T_SMS_InternalMessages model = bll.GetModel(int.Parse(infoid.Trim()));
  115. if (model != null)
  116. {
  117. if (model.SMS_IsRead == 0)
  118. {
  119. model.SMS_IsRead = 1;
  120. model.SMS_ReadTime = DateTime.Now;
  121. bool b = bll.Update(model);
  122. if (b)
  123. {
  124. return Success("获取成功", model);
  125. }
  126. else
  127. {
  128. return Error("获取失败,无更新权限");
  129. }
  130. }
  131. else {
  132. return Success("获取成功", model);
  133. }
  134. }
  135. else
  136. {
  137. return Error("获取失败");
  138. };
  139. }
  140. else
  141. {
  142. return Error("获取参数失败");
  143. }
  144. }
  145. /// <summary>
  146. /// 保存信息
  147. /// </summary>
  148. /// <returns></returns>
  149. [Authority]
  150. public ActionResult SaveInfo()
  151. {
  152. int id = RequestString.GetInt("id", 0);
  153. string SMS_Title = RequestString.GetFormString("title");
  154. string SMS_ReceiveUserCode = RequestString.GetFormString("receiveUserCode");
  155. string SMS_SendUserCode = RequestString.GetFormString("sendUserCode");
  156. string SMS_Content = RequestString.GetFormString("content");
  157. int SMS_IsDelete = RequestString.GetInt("isDelete", 0);
  158. int SMS_IsRead = RequestString.GetInt("isRead", 0);
  159. int SMS_Order = RequestString.GetInt("order", 0);
  160. int SMS_IsTop = RequestString.GetInt("isTop", 0);
  161. if (!string.IsNullOrWhiteSpace(SMS_Title) || !string.IsNullOrWhiteSpace(SMS_ReceiveUserCode) || !string.IsNullOrWhiteSpace(SMS_ReceiveUserCode))
  162. {
  163. Model.T_SMS_InternalMessages model = new Model.T_SMS_InternalMessages();
  164. if (id == 0)
  165. {
  166. model.SMS_Title = SMS_Title;
  167. model.SMS_Content = SMS_Content;
  168. model.SMS_ReceiveUserCode = SMS_ReceiveUserCode;
  169. model.SMS_SendUserCode = SMS_SendUserCode;
  170. model.SMS_IsRead = SMS_IsRead;
  171. model.SMS_SendTime = DateTime.Now;
  172. //model.SMS_ReadTime = SMS_ReadTime;
  173. //model.SMS_DeleteTime = SMS_DeleteTime;
  174. model.SMS_IsDelete = 0;
  175. model.SMS_Order = SMS_Order;
  176. model.SMS_IsTop = SMS_IsTop;
  177. int n = bll.Add(model);
  178. if (n > 0)
  179. {
  180. return Success("添加成功", n);
  181. }
  182. else
  183. {
  184. return Error("添加失败");
  185. }
  186. }
  187. else
  188. {
  189. model = bll.GetModel(id);
  190. if (model != null)
  191. {
  192. model.SMS_Id = id;
  193. model.SMS_Title = SMS_Title;
  194. model.SMS_Content = SMS_Content;
  195. model.SMS_ReceiveUserCode = SMS_ReceiveUserCode;
  196. model.SMS_SendUserCode = SMS_SendUserCode;
  197. model.SMS_IsRead = SMS_IsRead;
  198. model.SMS_SendTime = model.SMS_SendTime;
  199. //model.SMS_ReadTime = DateTime.Now;
  200. //model.SMS_DeleteTime = SMS_DeleteTime;
  201. model.SMS_IsDelete = 0;
  202. model.SMS_Order = SMS_Order;
  203. model.SMS_IsTop = SMS_IsTop;
  204. if (bll.Update(model))
  205. {
  206. return Success("修改成功");
  207. }
  208. else
  209. {
  210. return Error("修改失败");
  211. }
  212. }
  213. return Error("信息不存在");
  214. }
  215. }
  216. else
  217. {
  218. return Error("获取参数失败");
  219. }
  220. }
  221. /// <summary>
  222. /// 删除信息
  223. /// </summary>
  224. /// <param name="ids"></param>
  225. /// <returns></returns>
  226. [Authority]
  227. public ActionResult DelInfo(string[] ids)
  228. {
  229. if (ids != null && ids.Length > 0)
  230. {
  231. string idd = " ";
  232. foreach (string str in ids)
  233. {
  234. idd += str + ",";
  235. }
  236. if (bll.DeleteList(idd.TrimEnd(',')))
  237. {
  238. return Success("删除成功");
  239. }
  240. else
  241. return Error("删除失败");
  242. }
  243. else
  244. {
  245. return Error("获取参数失败");
  246. }
  247. }
  248. }
  249. }