| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Text;
- using XYFDRQ.DBUtility;
- public partial class Report_TelDeal_Report : System.Web.UI.Page
- {
- XYFDRQ.BLL.T_Report bll_T_Report = new XYFDRQ.BLL.T_Report();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!this.IsPostBack)
- {
- txtBeginDate.Value = DateTime.Now.ToString("yyyy-MM-01");//赋初值
- txtEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");//赋初值
- }
- AjaxPro.Utility.RegisterTypeForAjax(typeof(Report_TelDeal_Report));
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void btnExtWord_Click(object sender, EventArgs e)
- {
- byte[] content = System.Text.Encoding.Default.GetBytes(txtHideItems.Value);//将string转为二进制字节数组
- HttpResponse clsreponse = System.Web.HttpContext.Current.Response;
- clsreponse.ClearHeaders();
- clsreponse.ClearContent();
- clsreponse.AddHeader("Content-Disposition", "attachment;filename=TZSJFX" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");//xls
- clsreponse.ContentType ="application/msexcel";//设置流的输出格式
- clsreponse.OutputStream.Write(content, 0, content.Length);//输出
- clsreponse.End();
- #region MyRegion
- //HttpResponse resp = Page.Response;
- //resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
- ////下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
- ////filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc .xls .txt .htm
- //resp.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
- ////Response.ContentType指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档
- //resp.ContentType = "application/ms-excel";
- ////向http输出流中写入取得的数据信息
- //resp.Write(txtHideItems.Value);
- ////处理行数据
- //resp.End();
- #endregion
-
- }
- /// <summary>
- /// 导出的Excel表
- /// </summary>
- /// <param name="searchItems"></param>
- /// <returns></returns>
- [AjaxPro.AjaxMethod()]
- public string GetReportTable(AjaxPro.JavaScriptArray searchItems)
- {
- StringBuilder html = new StringBuilder();
- string reportsql = "";
- DataTable dt = new DataTable();
- string[] _operations = GetSearchItems(searchItems);
- html.Append("<h1 style='font-size: 18px;font-weight: bold;color: #333333;text-align:center;width:100%;'><b>来电方式统计表</b></h1>");
- //处理方式0:IVR处理1骚扰电话2自助服务3转值班电话4留言5呼损6人工处理
- string dealType = "全部";
- switch (_operations[2])
- {
- case "0":
- dealType = "IVR处理";
- break;
- case "1":
- dealType = "骚扰电话";
- break;
- case "2":
- dealType = "自助服务";
- break;
- case "3":
- dealType = "转值班电话";
- break;
- case "4":
- dealType = "留言";
- break;
- case "5":
- dealType = "呼损";
- break;
- case "6":
- dealType = "人工处理";
- break;
- }
- html.Append("<div style='width:100%; text-align:right; height:25px;'>处理方式: " + dealType + " </div>");
-
- html.Append("<div style='width:100%; text-align:right;height:25px;'>统计截止日期: " + _operations[0] + "—" + _operations[1] + " </div>");
- html.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" >");
- try
- {
- //开始时间
- if (!string.IsNullOrEmpty(_operations[0]))
- {
- reportsql += " and DATEDIFF(d,BeginTime,'" + _operations[0] + "')<=0";
- }
- //结束时间
- if (!string.IsNullOrEmpty(_operations[1]))
- {
- reportsql += " and DATEDIFF(d,BeginTime,'" + _operations[1] + "')>=0";
- }
- if (!string.IsNullOrEmpty(_operations[2]))
- {
- if (_operations[2] != "全部")
- {
- reportsql += " and DealType="+Convert.ToInt32(_operations[2]);
- }
- }
- dt = bll_T_Report.GetCallInTypeReport(reportsql);
- //标题第一行
- html.Append("<tr style=\"text-align: center;\">");
- html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;width:150px\">时间</td>");
- html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">电话量</td>");
- html.Append("</tr>");
- //int cateCount = 0;
- int allCount = 0;
- if (dt != null && dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- html.Append("<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">");
- //时间
- html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dt.Rows[i]["hrhour"].ToString() + " </td>");
- //电话量
- html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dt.Rows[i]["hrCount"].ToString() + " </td>");
- html.Append("</tr>");
- allCount += Convert.ToInt32(dt.Rows[i]["hrCount"]);//合计
- }
- }
- html.Append("<tr style=\"text-align: center;\"><td colspan=\"1\" class=\"formtabletitle3\" style=\"height: 35px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 10px 3px 2px;text-align:center;\">总计:</td>");
- html.Append("<td class=\"formtabletitle2\" style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 0px solid #FFFFFF;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + allCount + " </td>");
- html.Append("</tr>");
- }
- catch
- { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- html.Append("</table>");
- return html.ToString();
- }
- /// <summary>
- /// 报表线状图
- /// </summary>
- /// <param name="searchItems"></param>
- /// <returns></returns>
- [AjaxPro.AjaxMethod()]
- public string GetReportLines(AjaxPro.JavaScriptArray searchItems)
- {
- //呼叫类型,0呼入
- string[] _operations = GetSearchItems(searchItems);
- string startTime = "";
- string endTime = "";
- int intType = 0;
- //开始时间
- if (!string.IsNullOrEmpty(_operations[0]))
- {
- startTime = _operations[0];
- }
- //结束时间
- if (!string.IsNullOrEmpty(_operations[1]))
- {
- endTime = _operations[1];
- }
- if (!string.IsNullOrEmpty(_operations[2]))
- {
- if (_operations[2]!="全部")
- {
- intType = Convert.ToInt32(_operations[2]);
- }
- else
- {
- intType = 7;
- }
- }
- StringBuilder sbStrHR = new StringBuilder();
- sbStrHR.Append("select DATEPART(HOUR,BeginTime) as hrhour,COUNT(CallId) as hrCount from T_Call_CallRecords where CallType=0");
- if (intType!=7)
- {
- //为全部
- sbStrHR.Append(" and DealType=" + intType);
- }
- sbStrHR.Append(" and DATEDIFF(d,BeginTime,'" + startTime + "')<=0 and DATEDIFF(d,BeginTime,'"+endTime+"')>=0 group by DATEPART(HOUR,BeginTime)");
- DataTable dtHr = DbHelperSQL.Query(sbStrHR.ToString()).Tables[0];
- StringBuilder sb = new StringBuilder();//整个的,题头+sb1+sb2+sb3
- StringBuilder sb1 = new StringBuilder();//横坐标显示的内容
- StringBuilder sb2 = new StringBuilder();//纵坐标显示的值1
- sb.Append("<graph xaxisname=\"时\" yaxisname=\"电话量\" hovercapbg=\"DEDEBE\" hovercapborder=\"889E6D\" rotateNames=\"0\" numdivlines=\"4\" divLineColor=\"CCCCCC\" divLineAlpha=\"80\" decimalPrecision=\"0\" showAlternateHGridColor=\"1\" AlternateHGridAlpha=\"30\" AlternateHGridColor=\"CCCCCC\" caption=\"\" subcaption=\"来电方式统计\" outCnvBaseFontSize='13' baseFontSize='13'>");
- sb1.Append("<categories font=\"宋体, Arial, Helvetica, sans-serif\" fontSize=\"12\" fontColor=\"000000\" >");
- sb2.Append("<dataset seriesname=\"电话量\" color=\"FDC12E\" >");
- for (int i = 0; i < 24; i++)
- {
-
- sb1.Append("<category name=\"" + i + "\" hoverText=\"" + i + "\" />");
- DataRow[] drhr = dtHr.Select("hrhour=" + i);
- if (drhr.Length != 0)
- {
- sb2.Append("<set value=\"" + drhr[0]["hrCount"] + "\" />");
- }
- else
- {
- sb2.Append("<set value=\"0\" />");
- }
- }
- sb.Append(sb1.ToString() + "</categories>" + sb2.ToString() + "</dataset></graph>");
- StringBuilder sbAll = new StringBuilder();
- int StrWidth =700;
- int StrHeight = 390;
- sbAll.Append("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"");
- sbAll.Append("width=\"" + StrWidth + "\" height=\"" + StrHeight + "\" id=\"FCF_MSLine\">");
- sbAll.Append("<param name=\"FlashVars\" value=\"&dataXML=" + System.Web.HttpUtility.UrlEncode(sb.ToString(), System.Text.Encoding.UTF8) + "\" />");
- sbAll.Append("<param name=\"movie\" value=\"ChartsFlash/FCF_MSLine.swf?chartWidth=" + StrWidth + "&chartHeight=" + StrHeight + "\" /></object>");
- return sbAll.ToString();
- }
- private string[] GetSearchItems(AjaxPro.JavaScriptArray searchItems)
- {
- string[] operations = new string[searchItems.Count];
- int i = 0;
- foreach (Object obj in searchItems)
- {
- operations[i] = obj.ToString();
- i++;
- }
- return operations;
- }
- }
|