Нет описания

DutyPhoneController.cs 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. namespace CallCenterApi.Interface.Controllers.tel
  11. {
  12. public class DutyPhoneController : BaseController
  13. {
  14. //获取值班电话列表
  15. public ActionResult GetList()
  16. {
  17. ActionResult res = NoToken("未知错误,请重新登录");
  18. if (Request.IsAuthenticated)
  19. {
  20. string sql = "";
  21. DataTable dt = new DataTable();
  22. string strtelnum = HttpUtility.UrlDecode(RequestString.GetQueryString("telnum"));
  23. string strbtime = HttpUtility.UrlDecode(RequestString.GetQueryString("btime"));
  24. string stretime = HttpUtility.UrlDecode(RequestString.GetQueryString("etime"));
  25. int zxzid = RequestString.GetQueryInt("zxzid", 0);
  26. string strpageindex = RequestString.GetQueryString("page");
  27. int pageindex = 1;
  28. string strpagesize = RequestString.GetQueryString("pagesize");
  29. int pagesize = 10;
  30. if (strtelnum.Trim() != "" && strtelnum != "undefined")
  31. {
  32. sql += " and F_ZBDH like '%" + strtelnum.Trim() + "%' ";
  33. }
  34. if (strbtime.Trim() != "" && strbtime != "undefined")
  35. {
  36. sql += " and T_Call_ZBDH.F_CreateTime >= '" + Convert.ToDateTime(strbtime.Trim() + " 00:00:00") + "' ";
  37. }
  38. if (stretime.Trim() != "" && stretime != "undefined")
  39. {
  40. sql += " and T_Call_ZBDH.F_CreateTime <= '" + Convert.ToDateTime(stretime.Trim() + " 23:59:59") + "' ";
  41. }
  42. if (zxzid != 0)
  43. {
  44. sql += " and F_Groupid=" + zxzid;
  45. }
  46. if (strpageindex.Trim() != "")
  47. {
  48. pageindex = Convert.ToInt32(strpageindex);
  49. }
  50. if (strpagesize.Trim() != "")
  51. {
  52. pagesize = Convert.ToInt32(strpagesize);
  53. }
  54. int recordCount = 0;
  55. dt = BLL.PagerBLL.GetListPager(
  56. "T_Call_ZBDH left join T_Sys_SeatGroup on T_Call_ZBDH.F_Groupid=T_Sys_SeatGroup.F_ZXZID",
  57. "F_ZBID",
  58. "T_Call_ZBDH.*,T_Sys_SeatGroup.F_ZXZName",
  59. sql,
  60. "ORDER BY F_ZBID desc",
  61. pagesize,
  62. pageindex,
  63. true,
  64. out recordCount);
  65. var obj = new
  66. {
  67. state = "success",
  68. message = "成功",
  69. rows = dt,
  70. total = recordCount
  71. };
  72. res = Content(obj.ToJson());
  73. }
  74. return res;
  75. }
  76. //获取值班电话
  77. public ActionResult GetDutyPhone(string zbid)
  78. {
  79. ActionResult res = NoToken("未知错误,请重新登录");
  80. if (Request.IsAuthenticated)
  81. {
  82. if (zbid != null && zbid.Trim() != "")
  83. {
  84. BLL.T_Call_ZBDH dBLL = new BLL.T_Call_ZBDH();
  85. Model.T_Call_ZBDH dModel = dBLL.GetModel(int.Parse(zbid.Trim()));
  86. if (dModel != null)
  87. {
  88. res = Success("获取值班电话成功", dModel);
  89. }
  90. else
  91. {
  92. res = Error("获取值班电话失败");
  93. }
  94. }
  95. else
  96. {
  97. res = Error("获取参数失败");
  98. }
  99. }
  100. return res;
  101. }
  102. //添加值班电话
  103. public ActionResult AddDutyPhone(string zbid, string telphone, string des, string groupid)
  104. {
  105. ActionResult res = NoToken("未知错误,请重新登录");
  106. if (Request.IsAuthenticated)
  107. {
  108. res = Error("操作失败");
  109. if (zbid != null && zbid.Trim() != "")
  110. {
  111. BLL.T_Call_ZBDH dBLL = new BLL.T_Call_ZBDH();
  112. Model.T_Call_ZBDH dModel = dBLL.GetModel(int.Parse(zbid.Trim()));
  113. if (dModel != null)
  114. {
  115. dModel.F_ZBDH = telphone.Trim();
  116. dModel.F_Remark = des.Trim();
  117. var gid = int.Parse(groupid.Trim());
  118. dModel.F_Groupid = gid;
  119. var gname = new BLL.T_Sys_SeatGroup().GetModel(gid) == null ? "" : new BLL.T_Sys_SeatGroup().GetModel(gid).F_ZXZName;
  120. dModel.F_GroupName = gname;
  121. bool b = dBLL.Update(dModel);
  122. if (b)
  123. {
  124. res = Success("编辑成功");
  125. }
  126. else
  127. {
  128. res = Error("编辑失败");
  129. }
  130. }
  131. }
  132. else
  133. {
  134. Model.T_Call_ZBDH dModel = new Model.T_Call_ZBDH();
  135. dModel.F_ZBDH = telphone.Trim();
  136. dModel.F_Remark = des.Trim();
  137. dModel.F_CreateBy = CurrentUser.UserData.F_UserName;
  138. dModel.F_CreateID = CurrentUser.UserData.F_UserId;
  139. dModel.F_CreateTime = DateTime.Now;
  140. var gid = int.Parse(groupid.Trim());
  141. dModel.F_Groupid = gid;
  142. var gname = new BLL.T_Sys_SeatGroup().GetModel(gid).F_ZXZName;
  143. dModel.F_GroupName = gname;
  144. int b = new BLL.T_Call_ZBDH().Add(dModel);
  145. if (b > 0)
  146. {
  147. res = Success("添加成功");
  148. }
  149. else
  150. {
  151. res = Error("添加失败");
  152. }
  153. }
  154. }
  155. return res;
  156. }
  157. //删除值班电话
  158. public ActionResult DelDutyPhone(string[] ids)
  159. {
  160. ActionResult res = NoToken("未知错误,请重新登录");
  161. if (ids != null && ids.Length > 0)
  162. {
  163. string idd = " ";
  164. foreach (string str in ids)
  165. {
  166. idd += str + ",";
  167. }
  168. if (new BLL.T_Call_ZBDH().DeleteList(idd.TrimEnd(',')))
  169. {
  170. res = Success("删除成功");
  171. }
  172. else
  173. res = Error("删除失败");
  174. }
  175. else
  176. {
  177. res = Error("请选择要删除的记录");
  178. }
  179. return res;
  180. }
  181. }
  182. }