using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Data;

namespace HySoft.BaseCallCenter.Web.reportmanage.operationdata.controls
{
    /// <summary>
    /// ZuoXiWorkTotal 的摘要说明
    /// </summary>
    public class ZuoXiWorkTotal : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = context.Request.QueryString["action"];

            switch (action)
            {
                case "getlist":
                    context.Response.Write(GetDataListHtml(context));//读取数据
                    break;
            }
        }
        public string GetDataListHtml(HttpContext context)
        {
            StringBuilder htmlReport = new StringBuilder();//存储生成的HTML
            htmlReport.Append("<table cellspacing='0' cellpadding='0' border='1' width='100%'><tr height='35'>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>部门</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>坐席</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>坐席工号</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼入电话数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>坐席接通量</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼损量</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>接通率</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼损率</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>平均排队时间</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>接听通话次数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>通话分钟数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>通话秒数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>平均接听通话秒数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>平均振铃秒数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼入占有率</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>用户评价</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>坐席登录次数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>工作时长分钟数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>平均操作分钟数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>置忙次数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>休息时长分钟数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>置忙平均休息分钟数</td>");
            htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>质检平均成绩</td>");
            htmlReport.Append("</tr>");
            try
            {
                string txtStartTime = context.Request.QueryString["txtStartTime"];
                string txtEndTime = context.Request.QueryString["txtEndTime"];
                string sqltimeCallRecords = "";
                if (txtStartTime != null && txtStartTime.Trim() != "")
                {
                    sqltimeCallRecords += " and CONVERT(varchar , TimeAlerting, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
                }
                if (txtEndTime != null && txtEndTime.Trim() != "")
                {
                    sqltimeCallRecords += " and CONVERT(varchar , TimeAlerting, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
                }

                int ijtcs=0;//接听通话次数 
                int ithms=0;//通话秒数
                int  izlms=0;//振铃秒数
                int ipjjtms = 0;//平均接听秒数
                int ipjzlms = 0;//平均振铃秒数
                double ihrzyl = 0.00;//呼入占有率
                int izxdlcs = 0;//坐席登录次数
                int idlsc = 0;//登录时长
                int iWorktime = 0;//工作时长
                int izmcs = 0;//置忙次数
                int ixxsc = 0;//休息时长
                int ipjczsc = 0;//平均操作时长
                int ipjzmxxsc = 0;//平均置忙休息时长


                int itrunkct = 0;//总数
                int itrunkjj = 0;//总接听
                int itrunkhs = 0;//呼损量
                int itrunkpjsc=0;//平均排队时间
                double itrunkjtl = 0.00;//接通率
                double itrunkhsl = 0.00;//互损率
                double itrunkpjpd = 0.00;//平均排队
                DataTable dtdpt = null;
                if (context.Request.QueryString["dpt"] != null && context.Request.QueryString["dpt"].ToString() != "")
                {
                    dtdpt = DBUtility.DbHelperSQL.Query("select F_DeptId,F_DeptName,F_Remark from  T_Sys_Department where F_ParentId!=0 and F_DeptId=" + context.Request.QueryString["dpt"].ToString()).Tables[0];
                }
                else 
                {
                    dtdpt = DBUtility.DbHelperSQL.Query("select F_DeptId,F_DeptName,F_Remark from  T_Sys_Department where F_ParentId!=0").Tables[0];
                }
                if (dtdpt != null && dtdpt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtdpt.Rows)
                    {

                        DataTable dt = new DataTable();
                        string sql = "SELECT F_UserCode,F_UserName,F_WorkNumber,F_UserId FROM T_Sys_UserAccount where f_seatFlag=1 and F_DeptId=" + dr["F_DeptId"] + " and F_WorkNumber!='' order by  F_WorkNumber asc";
                        dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (!string.IsNullOrEmpty(dt.Rows[i]["F_WorkNumber"].ToString()))
                            {
                                htmlReport.AppendFormat("<tr>");
                                if (i == 0)
                                {
                                    htmlReport.Append("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;' ");
                                    if (dt.Rows.Count > 1)
                                    {
                                        htmlReport.Append(" rowspan='" + dt.Rows.Count + "'");
                                    }
                                    htmlReport.Append(">" + dr["F_DeptName"].ToString() + "</td>");
                                }

                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt.Rows[i]["F_UserName"].ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt.Rows[i]["F_WorkNumber"].ToString());

                                if (i == 0)
                                {//呼入电话

                                    string strsql = "";
                                    if (txtStartTime != null && txtStartTime.Trim() != "")
                                    {
                                        strsql += " and CONVERT(varchar , TimeCallIn, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
                                    }
                                    if (txtEndTime != null && txtEndTime.Trim() != "")
                                    {
                                        strsql += " and CONVERT(varchar , TimeCallIn, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
                                    }

                                    DataTable dtTrunk = DBUtility.DbHelperSQL.Query("select COUNT(*) as ct,(select COUNT(*) from rep_trunk_call_in where PeriodTalking>0 and  CalleeNum='" + dr["F_Remark"] + "' "+strsql+") as jt,SUM(DATEDIFF(Second,timewantagent,timeconnected)) as dd from rep_trunk_call_in where CalleeNum='" + dr["F_Remark"] + "' "+strsql).Tables[0];

                                    if (dtTrunk != null && dtTrunk.Rows.Count > 0) 
                                    {
                                        if (dtTrunk.Rows[0]["ct"].ToString() != "")
                                        {
                                            itrunkct = int.Parse(dtTrunk.Rows[0]["ct"].ToString());
                                        }
                                        else 
                                        {
                                            itrunkct = 0;
                                        }
                                        if (dtTrunk.Rows[0]["jt"].ToString() != "")
                                        {
                                            itrunkjj = int.Parse(dtTrunk.Rows[0]["jt"].ToString());
                                        }
                                        else 
                                        {
                                            itrunkjj = 0;
                                        }
                                        if (dtTrunk.Rows[0]["dd"].ToString() != "")
                                        {
                                            itrunkpjsc = int.Parse(dtTrunk.Rows[0]["dd"].ToString());
                                        }
                                        else 
                                        {
                                            itrunkpjsc = 0;
                                        }
                                    }
                                    itrunkhs = itrunkct - itrunkjj;
                                    if (itrunkct != 0)
                                    {
                                        itrunkjtl = itrunkjj / double.Parse(itrunkct.ToString());
                                        itrunkhsl = itrunkhs / double.Parse(itrunkct.ToString());
                                        itrunkpjpd = itrunkpjsc / double.Parse(itrunkct.ToString());
                                    }
                                    else 
                                    {
                                        itrunkjtl = 0.00;
                                        itrunkhsl = 0.00;
                                        itrunkpjpd = 0.00;
                                    }

                                    htmlReport.Append("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;' ");
                                    if (dt.Rows.Count > 1)
                                    {
                                        htmlReport.Append(" rowspan='" + dt.Rows.Count + "'");
                                    }
                                    htmlReport.Append(">" + itrunkct + "</td>");

                                    htmlReport.Append("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;' ");
                                    if (dt.Rows.Count > 1)
                                    {
                                        htmlReport.Append(" rowspan='" + dt.Rows.Count + "'");
                                    }
                                    htmlReport.Append(">" + itrunkjj + "</td>");

                                    htmlReport.Append("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;' ");
                                    if (dt.Rows.Count > 1)
                                    {
                                        htmlReport.Append(" rowspan='" + dt.Rows.Count + "'");
                                    }
                                    htmlReport.Append(">" + itrunkhs + "</td>");

                                    htmlReport.Append("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;' ");
                                    if (dt.Rows.Count > 1)
                                    {
                                        htmlReport.Append(" rowspan='" + dt.Rows.Count + "'");
                                    }
                                    htmlReport.Append(">" +(itrunkjtl*100).ToString("0.00") + "%</td>");

                                    htmlReport.Append("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;' ");
                                    if (dt.Rows.Count > 1)
                                    {
                                        htmlReport.Append(" rowspan='" + dt.Rows.Count + "'");
                                    }
                                    htmlReport.Append(">" + (itrunkhsl*100).ToString("0.00") + "%</td>");

                                    htmlReport.Append("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;' ");
                                    if (dt.Rows.Count > 1)
                                    {
                                        htmlReport.Append(" rowspan='" + dt.Rows.Count + "'");
                                    }
                                    htmlReport.Append(">" + itrunkpjpd.ToString("0.00") + "</td>");
                                }

                               
                                DataTable dtext = DBUtility.DbHelperSQL.Query("select COUNT(*) as ct,SUM(PeriodTalking) as sc,SUM(PeriodAlerting) as pa from rep_ext_call_in where CalleeAgentID=" + dt.Rows[i]["F_WorkNumber"] + " " + sqltimeCallRecords).Tables[0];
                                if (dtext != null && dtext.Rows.Count > 0)
                                {
                                    if (dtext.Rows[0]["ct"].ToString() != "")
                                    {
                                        ijtcs = int.Parse(dtext.Rows[0]["ct"].ToString());//接听次数
                                    }
                                    else 
                                    {
                                        ijtcs = 0;
                                    }
                                    if (dtext.Rows[0]["sc"].ToString() != "")
                                    {
                                        ithms = int.Parse(dtext.Rows[0]["sc"].ToString());//通话秒数
                                    }
                                    else 
                                    {
                                        ithms = 0;
                                    }
                                    if (dtext.Rows[0]["pa"].ToString() != "")
                                    {
                                        izlms = int.Parse(dtext.Rows[0]["pa"].ToString());//振铃秒数
                                    }
                                    else 
                                    {
                                        izlms = 0;
                                    }
                                }
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", ijtcs.ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (ithms / 60).ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", ithms.ToString());
                                if (ijtcs != 0)
                                {
                                    ipjjtms = ithms / ijtcs;//平均接通秒数
                                    ipjzlms = izlms / ijtcs;//平均振铃秒数
                                }
                                else 
                                {
                                    ipjjtms = 0;//平均接通秒数
                                    ipjzlms = 0;//平均振铃秒数
                                }
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", ipjjtms.ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", ipjzlms.ToString());


                                //坐席登录次数
                                DataTable dtAgent = DBUtility.DbHelperSQL.Query("select COUNT(*) as dl,SUM(LoginTimes) as dlsc,SUM(reposenum) as zm,SUM(ReposeTimes) as xx from rep_agent_detail where AgentId=" + dt.Rows[i]["F_WorkNumber"] + " " + sqltimeCallRecords.Replace("TimeAlerting", "TimeLogin")).Tables[0];
                                if (dtAgent != null && dtAgent.Rows.Count > 0)
                                {
                                    if (dtAgent.Rows[0]["dl"] != null && dtAgent.Rows[0]["dl"].ToString() != "")
                                    {
                                        izxdlcs = int.Parse(dtAgent.Rows[0]["dl"].ToString());//登录次数
                                    }
                                    else 
                                    {
                                        izxdlcs = 0;
                                    }
                                    if (dtAgent.Rows[0]["dlsc"] != null && dtAgent.Rows[0]["dlsc"].ToString() != "")
                                    {
                                        idlsc = int.Parse(dtAgent.Rows[0]["dlsc"].ToString());//登录时长
                                    }
                                    else {
                                        idlsc = 0;
                                    }
                                    if (dtAgent.Rows[0]["zm"] != null && dtAgent.Rows[0]["zm"].ToString() != "")
                                    {
                                        izmcs = int.Parse(dtAgent.Rows[0]["zm"].ToString());//置忙次数
                                    }
                                    else 
                                    {
                                        izmcs = 0;
                                    }
                                    if (dtAgent.Rows[0]["xx"] != null && dtAgent.Rows[0]["xx"].ToString() != "")
                                    {
                                        ixxsc = int.Parse(dtAgent.Rows[0]["xx"].ToString());//休息时长
                                    }
                                    else 
                                    {
                                        ixxsc = 0;
                                    }

                                }
                                iWorktime = idlsc - ixxsc;//工作时长
                                if (izxdlcs != 0)
                                {
                                    ipjczsc = iWorktime / izxdlcs;//平均操作秒数
                                }
                                else 
                                {
                                    ipjczsc = 0;
                                }
                                if (izmcs != 0)
                                {
                                    ipjzmxxsc = ixxsc / izmcs;//置忙平均操作时长
                                }
                                else 
                                {
                                    ipjzmxxsc = 0;
                                }

                                //呼入占有率
                                if (iWorktime != 0)
                                {
                                    ihrzyl = ithms / Convert.ToDouble(iWorktime);
                                }
                                else 
                                {
                                    ihrzyl = 0.00;
                                }
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (ihrzyl * 100).ToString("0.00") + "%");
                                //用户评价
                                string sqlpj = "";
                                if (txtStartTime != null && txtStartTime.Trim() != "")
                                {
                                    sqlpj += " and CONVERT(varchar , BeginTime, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
                                }
                                if (txtEndTime != null && txtEndTime.Trim() != "")
                                {
                                    sqlpj += " and CONVERT(varchar , BeginTime, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
                                }
                                object obj = DBUtility.DbHelperSQL.GetSingle("select count(*) from T_Call_CallRecords where MYD is not null and userid in(select f_userid from T_Sys_UserAccount where f_worknumber='" + dt.Rows[i]["F_WorkNumber"] + "') " + sqlpj);
                                string myd = "";
                                if (obj != null)
                                {
                                    myd = obj.ToString();
                                }
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", myd);

                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", izxdlcs.ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (iWorktime / 60).ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (ipjczsc / 60).ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", izmcs.ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (ixxsc / 60).ToString());
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (ipjzmxxsc / 60).ToString());

                                DataSet dszj = DBUtility.DbHelperSQL.Query("select convert(int,SUM(f_qcscore)) as fs,COUNT(*) as fsct from T_Call_CallRecords where F_QCState=1 and UserId=" + dt.Rows[i]["F_UserId"] + sqlpj);
                                int zfs = 0;
                                if (dszj != null && dszj.Tables.Count > 0)
                                {
                                    DataTable dtzj = dszj.Tables[0];
                                    if (dtzj.Rows.Count > 0 && dtzj.Rows[0]["fs"].ToString() != "" && dtzj.Rows[0]["fsct"].ToString() != "")
                                    {
                                        zfs = Convert.ToInt32(dtzj.Rows[0]["fs"].ToString()) / int.Parse(dtzj.Rows[0]["fsct"].ToString());
                                    }
                                }
                                htmlReport.AppendFormat("<td  align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", zfs.ToString());



                                htmlReport.Append("</tr>");
                            }
                        }







                    }

                }






                htmlReport.Append("</table>");
            }
            catch { }

            return htmlReport.ToString();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
        
    }
}