市长热线演示版

callplanfpset.ashx.cs 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using HySoft.Common;
  6. using System.Data;
  7. namespace HySoft.BaseCallCenter.Web.calloutmanage.ajax
  8. {
  9. /// <summary>
  10. /// callplanfpset 的摘要说明
  11. /// </summary>
  12. public class callplanfpset : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. string action = CommonRequest.GetQueryString("action");
  18. switch (action)
  19. {
  20. case "getuserlist":
  21. context.Response.Write(getuserlist(context));
  22. break;
  23. case "getfieldlist":
  24. context.Response.Write(getfieldlist(context));
  25. break;
  26. case "fpdata":
  27. context.Response.Write(fpdata(context));
  28. break;
  29. }
  30. }
  31. private string getfieldlist(HttpContext context)
  32. {
  33. string res = "";
  34. try
  35. {
  36. List<Model.T_Call_PageField> pageModel = new List<Model.T_Call_PageField>();
  37. if (context.Request.Params["taskid"] != null)
  38. pageModel = new BLL.T_Call_PageField().GetModelList("F_TaskId='" + context.Request.Params["taskid"] + "'");
  39. System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<Model.T_Call_PageField>));
  40. using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
  41. {
  42. //JSON序列化
  43. serializer.WriteObject(stream, pageModel);
  44. res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
  45. }
  46. }
  47. catch (Exception err)
  48. {
  49. //res = err.ToString();
  50. }
  51. finally
  52. {
  53. }
  54. return res;
  55. }
  56. private string fpdata(HttpContext context)
  57. {
  58. string res = "";
  59. string type = "0";
  60. string sql = "";
  61. DataTable dt = new DataTable();
  62. try
  63. {
  64. string taskid = context.Request.Params["taskid"];
  65. string arruser = context.Request.Form["txtArrUser"].ToString();
  66. string arrname = context.Request.Form["txtArrName"].ToString();
  67. string arrphone = context.Request.Params["txtArrPhone"];
  68. string fptype = context.Request.Params["fptypepara"];
  69. string fpvalue = context.Request.Params["fpvalue"];
  70. string key = context.Request.Params["key"];
  71. if (fptype.Trim() == "2")
  72. {
  73. //按选择平均分配
  74. dt = new BLL.T_Call_TaskTelNum().GetList(" F_FPState=0 and F_Id in (" + arrphone + ") " + sql).Tables[0];
  75. #region 按选择分配
  76. if (dt != null)
  77. {
  78. arruser = arruser + "#@!";
  79. arruser = arruser.Replace(",#@!", "").Replace("#@!", "");
  80. int count = dt.Rows.Count;
  81. int usercount = arruser.Split(',').Length;
  82. int cqcount = 0;
  83. //抽取类型
  84. cqcount = Convert.ToInt32(count / usercount);
  85. int successcount = 0;
  86. if (cqcount > 0)
  87. {
  88. int m = 0;
  89. int n = 0;
  90. for (int i = 0; i < count; i++)
  91. {
  92. #region 更新分配数据
  93. //更新
  94. if (m < cqcount)
  95. {
  96. if (n < usercount)
  97. {
  98. string uname = arrname.Split(',')[n].ToString();
  99. bool b = new BLL.T_Call_TaskTelNum().UpdateFP(Convert.ToInt32(dt.Rows[i]["F_Id"].ToString()), Convert.ToInt32(arruser.Split(',')[n].ToString()), uname);
  100. if (b)
  101. {
  102. successcount++;
  103. }
  104. }
  105. m++;
  106. }
  107. else
  108. {
  109. n++;
  110. m = 0;
  111. i--;
  112. }
  113. #endregion
  114. }
  115. }
  116. type = "1";
  117. res = "成功分配" + successcount.ToString() + "条数据";
  118. }
  119. #endregion
  120. }
  121. else
  122. {
  123. #region 按数量和比例平均分配
  124. if (taskid.Trim() != "")
  125. {
  126. sql += " and F_TaskId=" + taskid + " ";
  127. }
  128. else
  129. {
  130. sql += " and 1=0 ";
  131. }
  132. if (key.Trim() != "")
  133. {
  134. sql += " and (F_Phone like '%" + key.Trim() + "%' or F_Customer like '%" + key.Trim() + "%' ) ";
  135. }
  136. //按数量平均分配
  137. //按比例平均分配
  138. dt = new BLL.T_Call_TaskTelNum().GetList(" F_FPState=0 " + sql).Tables[0];
  139. if (dt != null)
  140. {
  141. arruser = arruser + "#@!";
  142. arruser = arruser.Replace(",#@!", "").Replace("#@!", "");
  143. int count = dt.Rows.Count;
  144. int usercount = arruser.Split(',').Length;
  145. int cqcount = 0;
  146. //抽取类型
  147. if (fptype.Trim() == "1")
  148. {
  149. //按比例平均分配
  150. cqcount = Convert.ToInt32(Convert.ToInt32(fpvalue.Trim()) * count / (100 * usercount));
  151. }
  152. if (fptype.Trim() == "0")
  153. {
  154. //按数量平均分配
  155. cqcount = Convert.ToInt32(fpvalue.Trim());
  156. }
  157. int successcount = 0;
  158. if (cqcount > 0)
  159. {
  160. int m = 0;
  161. int n = 0;
  162. for (int i = 0; i < count; i++)
  163. {
  164. #region 更新分配数据
  165. //更新
  166. if (m < cqcount)
  167. {
  168. if (n < usercount)
  169. {
  170. string uname=arrname.Split(',')[n].ToString();
  171. bool b = new BLL.T_Call_TaskTelNum().UpdateFP(Convert.ToInt32(dt.Rows[i]["F_Id"].ToString()), Convert.ToInt32(arruser.Split(',')[n].ToString()), uname);
  172. if (b)
  173. {
  174. successcount++;
  175. }
  176. }
  177. m++;
  178. }
  179. else
  180. {
  181. n++;
  182. m = 0;
  183. i--;
  184. }
  185. #endregion
  186. }
  187. }
  188. type = "1";
  189. res = "成功分配" + successcount.ToString() + "条数据";
  190. }
  191. #endregion
  192. }
  193. }
  194. catch (Exception ex)
  195. {
  196. res = ex.ToString();
  197. }
  198. finally
  199. {
  200. dt.Clear();
  201. dt.Dispose();
  202. }
  203. return "{msg:" + type + ",info:\"" + res + "\"}";
  204. }
  205. private string getuserlist(HttpContext context)
  206. {
  207. string strHtml = "";
  208. DataTable dt = new DataTable();
  209. try
  210. {
  211. dt = new BLL.T_Sys_UserAccount().GetList(" F_SeatFlag=1 order by F_UserId ").Tables[0];
  212. if (dt.Rows.Count > 0)
  213. {
  214. strHtml += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align='center'>";
  215. strHtml += "<tr style=\"text-align: center;\">";
  216. strHtml += "<td style=\"height: 15px; width:60px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
  217. strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  218. strHtml += "padding: 1px; text-align: center;\">";
  219. strHtml += "<input id=\"chkAll\" type=\"checkbox\" name=\"chkuserall\" onclick=\"SelectAll()\" /><label for=\"chkAll\">全选</label></td>";
  220. strHtml += "<td style=\"height: 15px; width:90px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
  221. strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  222. strHtml += "padding: 1px; text-align: center;\">用户工号</td>";
  223. strHtml += "<td style=\"height: 15px; width:90px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
  224. strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  225. strHtml += "padding: 1px; text-align: center;\">用户名称</td>";
  226. strHtml += "<td style=\"height: 15px; width:90px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
  227. strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  228. strHtml += "padding: 1px; text-align: center;\">未执行任务</td></tr>";
  229. for (int i = 0; i < dt.Rows.Count; i++)
  230. {
  231. int wzxcount = 0;
  232. string userid = dt.Rows[i]["F_UserId"].ToString();
  233. try
  234. {
  235. wzxcount = new BLL.T_Call_TaskTelNum().GetList(" F_HCState=0 and F_UserId=" + userid + " ").Tables[0].Rows.Count;
  236. }
  237. catch
  238. {
  239. }
  240. strHtml += "<tr align=\"center\" style=\"text-align: center;\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\"";
  241. strHtml += "onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">";
  242. strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  243. strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
  244. strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;\"><input id=\"chkuserid_" + userid + "\" type=\"checkbox\" name=\"chkuser\" /></td>";
  245. strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  246. strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
  247. strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;\">&nbsp;" + dt.Rows[i]["F_UserCode"].ToString() + "</td>";
  248. strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  249. strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
  250. strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;\">&nbsp;<span id='spanuser_" + userid + "'>" + dt.Rows[i]["F_UserName"].ToString().Trim() + "</span></td>";
  251. strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
  252. strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
  253. strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;color:red;\">&nbsp;" + wzxcount.ToString() + "</td></tr>";
  254. }
  255. strHtml += "</table>";
  256. }
  257. }
  258. catch
  259. {
  260. }
  261. finally
  262. {
  263. dt.Clear();
  264. dt.Dispose();
  265. }
  266. return strHtml;
  267. }
  268. public bool IsReusable
  269. {
  270. get
  271. {
  272. return false;
  273. }
  274. }
  275. }
  276. }