| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using HySoft.Common;
- using System.Data;
- namespace HySoft.BaseCallCenter.Web.calloutmanage.ajax
- {
- /// <summary>
- /// callplanfpset 的摘要说明
- /// </summary>
- public class callplanfpset : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- string action = CommonRequest.GetQueryString("action");
- switch (action)
- {
- case "getuserlist":
- context.Response.Write(getuserlist(context));
- break;
- case "getfieldlist":
- context.Response.Write(getfieldlist(context));
- break;
- case "fpdata":
- context.Response.Write(fpdata(context));
- break;
- }
- }
- private string getfieldlist(HttpContext context)
- {
- string res = "";
- try
- {
- List<Model.T_Call_PageField> pageModel = new List<Model.T_Call_PageField>();
- if (context.Request.Params["taskid"] != null)
- pageModel = new BLL.T_Call_PageField().GetModelList("F_TaskId='" + context.Request.Params["taskid"] + "'");
- System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<Model.T_Call_PageField>));
- using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
- {
- //JSON序列化
- serializer.WriteObject(stream, pageModel);
- res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
- }
- }
- catch (Exception err)
- {
- //res = err.ToString();
- }
- finally
- {
- }
- return res;
- }
- private string fpdata(HttpContext context)
- {
- string res = "";
- string type = "0";
- string sql = "";
- DataTable dt = new DataTable();
- try
- {
- string taskid = context.Request.Params["taskid"];
- string arruser = context.Request.Form["txtArrUser"].ToString();
- string arrname = context.Request.Form["txtArrName"].ToString();
- string arrphone = context.Request.Params["txtArrPhone"];
- string fptype = context.Request.Params["fptypepara"];
- string fpvalue = context.Request.Params["fpvalue"];
- string key = context.Request.Params["key"];
- if (fptype.Trim() == "2")
- {
- //按选择平均分配
- dt = new BLL.T_Call_TaskTelNum().GetList(" F_FPState=0 and F_Id in (" + arrphone + ") " + sql).Tables[0];
- #region 按选择分配
- if (dt != null)
- {
- arruser = arruser + "#@!";
- arruser = arruser.Replace(",#@!", "").Replace("#@!", "");
- int count = dt.Rows.Count;
- int usercount = arruser.Split(',').Length;
- int cqcount = 0;
- //抽取类型
- cqcount = Convert.ToInt32(count / usercount);
- int successcount = 0;
- if (cqcount > 0)
- {
- int m = 0;
- int n = 0;
- for (int i = 0; i < count; i++)
- {
- #region 更新分配数据
- //更新
- if (m < cqcount)
- {
- if (n < usercount)
- {
- string uname = arrname.Split(',')[n].ToString();
- bool b = new BLL.T_Call_TaskTelNum().UpdateFP(Convert.ToInt32(dt.Rows[i]["F_Id"].ToString()), Convert.ToInt32(arruser.Split(',')[n].ToString()), uname);
- if (b)
- {
- successcount++;
- }
- }
- m++;
- }
- else
- {
- n++;
- m = 0;
- i--;
- }
- #endregion
- }
- }
- type = "1";
- res = "成功分配" + successcount.ToString() + "条数据";
- }
- #endregion
- }
- else
- {
- #region 按数量和比例平均分配
- if (taskid.Trim() != "")
- {
- sql += " and F_TaskId=" + taskid + " ";
- }
- else
- {
- sql += " and 1=0 ";
- }
- if (key.Trim() != "")
- {
- sql += " and (F_Phone like '%" + key.Trim() + "%' or F_Customer like '%" + key.Trim() + "%' ) ";
- }
- //按数量平均分配
- //按比例平均分配
- dt = new BLL.T_Call_TaskTelNum().GetList(" F_FPState=0 " + sql).Tables[0];
- if (dt != null)
- {
- arruser = arruser + "#@!";
- arruser = arruser.Replace(",#@!", "").Replace("#@!", "");
- int count = dt.Rows.Count;
- int usercount = arruser.Split(',').Length;
- int cqcount = 0;
- //抽取类型
- if (fptype.Trim() == "1")
- {
- //按比例平均分配
- cqcount = Convert.ToInt32(Convert.ToInt32(fpvalue.Trim()) * count / (100 * usercount));
- }
- if (fptype.Trim() == "0")
- {
- //按数量平均分配
- cqcount = Convert.ToInt32(fpvalue.Trim());
- }
- int successcount = 0;
- if (cqcount > 0)
- {
- int m = 0;
- int n = 0;
- for (int i = 0; i < count; i++)
- {
- #region 更新分配数据
- //更新
- if (m < cqcount)
- {
- if (n < usercount)
- {
- string uname=arrname.Split(',')[n].ToString();
- bool b = new BLL.T_Call_TaskTelNum().UpdateFP(Convert.ToInt32(dt.Rows[i]["F_Id"].ToString()), Convert.ToInt32(arruser.Split(',')[n].ToString()), uname);
- if (b)
- {
- successcount++;
- }
- }
- m++;
- }
- else
- {
- n++;
- m = 0;
- i--;
- }
- #endregion
- }
- }
- type = "1";
- res = "成功分配" + successcount.ToString() + "条数据";
- }
- #endregion
- }
- }
- catch (Exception ex)
- {
- res = ex.ToString();
- }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return "{msg:" + type + ",info:\"" + res + "\"}";
- }
- private string getuserlist(HttpContext context)
- {
- string strHtml = "";
- DataTable dt = new DataTable();
- try
- {
- dt = new BLL.T_Sys_UserAccount().GetList(" F_SeatFlag=1 order by F_UserId ").Tables[0];
- if (dt.Rows.Count > 0)
- {
- strHtml += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align='center'>";
- strHtml += "<tr style=\"text-align: center;\">";
- strHtml += "<td style=\"height: 15px; width:60px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
- strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "padding: 1px; text-align: center;\">";
- strHtml += "<input id=\"chkAll\" type=\"checkbox\" name=\"chkuserall\" onclick=\"SelectAll()\" /><label for=\"chkAll\">全选</label></td>";
- strHtml += "<td style=\"height: 15px; width:90px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
- strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "padding: 1px; text-align: center;\">用户工号</td>";
- strHtml += "<td style=\"height: 15px; width:90px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
- strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "padding: 1px; text-align: center;\">用户名称</td>";
- strHtml += "<td style=\"height: 15px; width:90px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
- strHtml += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "padding: 1px; text-align: center;\">未执行任务</td></tr>";
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- int wzxcount = 0;
- string userid = dt.Rows[i]["F_UserId"].ToString();
- try
- {
- wzxcount = new BLL.T_Call_TaskTelNum().GetList(" F_HCState=0 and F_UserId=" + userid + " ").Tables[0].Rows.Count;
- }
- catch
- {
- }
- strHtml += "<tr align=\"center\" style=\"text-align: center;\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\"";
- strHtml += "onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">";
- strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
- strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;\"><input id=\"chkuserid_" + userid + "\" type=\"checkbox\" name=\"chkuser\" /></td>";
- strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
- strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;\"> " + dt.Rows[i]["F_UserCode"].ToString() + "</td>";
- strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
- strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;\"> <span id='spanuser_" + userid + "'>" + dt.Rows[i]["F_UserName"].ToString().Trim() + "</span></td>";
- strHtml += "<td style=\"vertical-align: middle;text-align: center; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
- strHtml += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 0px;";
- strHtml += "height: 15px; padding-top: 1px; padding-bottom: 1px;color:red;\"> " + wzxcount.ToString() + "</td></tr>";
- }
- strHtml += "</table>";
- }
- }
- catch
- {
- }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return strHtml;
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
- }
|