鄂尔多斯-招源科技

CallblackController.cs 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.tel
  10. {
  11. public class CallblackController : BaseController
  12. {
  13. //获取黑名单列表
  14. public ActionResult GetList()
  15. {
  16. ActionResult res = NoToken("未知错误,请重新登录");
  17. if (Request.IsAuthenticated)
  18. {
  19. string sql = "";
  20. DataTable dt = new DataTable();
  21. string strtelnum = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  22. string strsettime = HttpUtility.UrlDecode(RequestString.GetQueryString("settime"));
  23. string strremovetime = HttpUtility.UrlDecode(RequestString.GetQueryString("removetime"));
  24. string strpageindex = RequestString.GetQueryString("page");
  25. int pageindex = 1;
  26. string strpagesize = RequestString.GetQueryString("pagesize");
  27. int pagesize = 10;
  28. if (strtelnum != null && strtelnum.Trim() != "")
  29. {
  30. sql += " and F_TelPhone= '" + strtelnum.Trim() + "' ";
  31. }
  32. if (strsettime.Trim() != "" && strsettime != "undefined")
  33. {
  34. sql += " and F_SetTime > '" + Convert.ToDateTime(strsettime.Trim()) + "' ";
  35. }
  36. if (strremovetime.Trim() != "" && strremovetime != "undefined")
  37. {
  38. sql += " and F_RemoveTime < '" + Convert.ToDateTime(strremovetime.Trim()) + "' ";
  39. }
  40. if (strpageindex.Trim() != "")
  41. {
  42. pageindex = Convert.ToInt32(strpageindex);
  43. }
  44. if (strpagesize.Trim() != "")
  45. {
  46. pagesize = Convert.ToInt32(strpagesize);
  47. }
  48. int recordCount = 0;
  49. dt = BLL.PagerBLL.GetListPager(
  50. "T_Call_Blacklist",
  51. "F_BlackId",
  52. "*",
  53. sql,
  54. "ORDER BY F_BlackId desc",
  55. pagesize,
  56. pageindex,
  57. true,
  58. out recordCount);
  59. var obj = new
  60. {
  61. state = "success",
  62. message = "成功",
  63. rows = dt,
  64. total = recordCount
  65. };
  66. res = Content(obj.ToJson());
  67. }
  68. return res;
  69. }
  70. //获取黑名单
  71. public ActionResult GetBlack(string blackid)
  72. {
  73. ActionResult res = NoToken("未知错误,请重新登录");
  74. if (Request.IsAuthenticated)
  75. {
  76. if (blackid != null && blackid.Trim() != "")
  77. {
  78. BLL.T_Call_Blacklist dBLL = new BLL.T_Call_Blacklist();
  79. Model.T_Call_Blacklist dModel = dBLL.GetModel(int.Parse(blackid.Trim()));
  80. if (dModel != null)
  81. {
  82. res = Success("获取黑名单成功", dModel);
  83. }
  84. else
  85. {
  86. res = Error("获取黑名单失败");
  87. }
  88. }
  89. else
  90. {
  91. res = Error("获取参数失败");
  92. }
  93. }
  94. return res;
  95. }
  96. //添加黑名单
  97. public ActionResult AddBlack(string blackid,string telphone,string settime,string removetime,string des)
  98. {
  99. ActionResult res = NoToken("未知错误,请重新登录");
  100. if (Request.IsAuthenticated)
  101. {
  102. res = Error("操作失败");
  103. if (blackid != null && blackid.Trim() != "")
  104. {
  105. BLL.T_Call_Blacklist dBLL = new BLL.T_Call_Blacklist();
  106. Model.T_Call_Blacklist dModel = dBLL.GetModel(int.Parse(blackid.Trim()));
  107. if (dModel != null)
  108. {
  109. dModel.F_TelPhone = telphone.Trim();
  110. dModel.F_SetTime = Convert.ToDateTime(settime.Trim());
  111. dModel.F_RemoveTime = Convert.ToDateTime(removetime.Trim());
  112. dModel.F_Describe = des.Trim();
  113. dModel.F_InterceptNum += 1;
  114. bool b = dBLL.Update(dModel);
  115. if (b)
  116. {
  117. res = Success("编辑成功");
  118. }
  119. else
  120. {
  121. res = Error("编辑失败");
  122. }
  123. }
  124. }
  125. else
  126. {
  127. Model.T_Call_Blacklist dModel = new Model.T_Call_Blacklist();
  128. dModel.F_TelPhone = telphone.Trim();
  129. dModel.F_SetTime = Convert.ToDateTime(settime.Trim());
  130. dModel.F_RemoveTime = Convert.ToDateTime(removetime.Trim());
  131. dModel.F_Describe = des.Trim();
  132. dModel.F_InterceptNum = 1;
  133. int b = new BLL.T_Call_Blacklist().Add(dModel);
  134. if (b > 0)
  135. {
  136. res = Success("添加成功");
  137. }
  138. else
  139. {
  140. res = Error("添加失败");
  141. }
  142. }
  143. }
  144. return res;
  145. }
  146. //删除黑名单记录
  147. public ActionResult DelCallBlack(string[] ids)
  148. {
  149. ActionResult res = NoToken("未知错误,请重新登录");
  150. if (ids!=null&&ids.Length>0)
  151. {
  152. string idd = " ";
  153. foreach (string str in ids)
  154. {
  155. idd += str + ",";
  156. }
  157. if (new BLL.T_Call_Blacklist().DeleteList(idd.TrimEnd(',')))
  158. {
  159. res = Success("删除成功");
  160. }
  161. else
  162. res = Error("删除失败");
  163. }
  164. else
  165. {
  166. res = Error("请选择要删除的记录");
  167. }
  168. return res;
  169. }
  170. }
  171. }