市长热线演示版

YearContrast.ashx.cs 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Text;
  6. using System.Data;
  7. namespace HySoft.BaseCallCenter.Web.reportmanage.operationdata.controls
  8. {
  9. /// <summary>
  10. /// YearContrast 的摘要说明
  11. /// </summary>
  12. public class YearContrast : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. string action = context.Request.QueryString["action"];
  18. switch (action)
  19. {
  20. case "getlist":
  21. context.Response.Write(GetDataListHtml(context));//读取数据
  22. break;
  23. }
  24. }
  25. public string GetDataListHtml(HttpContext context)
  26. {
  27. StringBuilder htmlReport = new StringBuilder();//存储生成的HTML
  28. string txtStartTime = context.Request.QueryString["txtStartTime"];
  29. string txtEndTime = context.Request.QueryString["txtEndTime"];
  30. htmlReport.Append("<table cellspacing='0' cellpadding='0' border='1' width='100%'><tr height='35'>");
  31. 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>");
  32. 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;'>"+txtStartTime+"年度</td>");
  33. 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;'>"+txtStartTime+"年度</td>");
  34. 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;'>"+txtEndTime+"年度</td>");
  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;'>" + txtEndTime + "年度</td>");
  36. 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;'>"+txtStartTime+"年度</td>");
  37. 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;'>"+txtEndTime+"年度</td>");
  38. htmlReport.Append("</tr>");
  39. htmlReport.Append("<tr height='35'>");
  40. 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>");
  41. 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>");
  42. 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>");
  43. 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>");
  44. 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>");
  45. 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>");
  46. 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>");
  47. htmlReport.Append("</tr>");
  48. try
  49. {
  50. DataTable dt = new DataTable();
  51. for (int i = 1; i <= 12; i++)
  52. {
  53. string sqltimeCallRecords = "";
  54. int ibgnCt = 0;//总呼叫数
  55. int ibgnjt = 0;//总接听数
  56. double ibgnjtl = 0.00;//接通率
  57. int iendct = 0;//对比呼叫数
  58. int iendjt = 0;//对比接听数
  59. double iendjtl = 0.00;//结束接通率
  60. string strmm = i.ToString();
  61. if (i <= 9)
  62. {
  63. strmm = "0" + i;
  64. }
  65. if (txtStartTime != null && txtStartTime.Trim() != "")
  66. {
  67. sqltimeCallRecords += " and CONVERT(varchar , timecallin, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + "-" + strmm + "-01 00:00:01', 120) ";
  68. sqltimeCallRecords += " and CONVERT(varchar , timecallin, 120)<=CONVERT(varchar , '" + txtStartTime.Trim() + "-" + strmm + "-31 23:59:59', 120) ";
  69. }
  70. dt = DBUtility.DbHelperSQL.Query("select COUNT(*) as ct,(select COUNT(*) from rep_trunk_call_in where PeriodTalking>0 " + sqltimeCallRecords + ") as jt from rep_trunk_call_in where 1=1 " + sqltimeCallRecords).Tables[0];
  71. htmlReport.AppendFormat("<tr>");
  72. 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>", i.ToString());
  73. if (dt != null && dt.Rows.Count > 0)
  74. {
  75. if (dt.Rows[0]["ct"].ToString() != "")
  76. {
  77. ibgnCt = int.Parse(dt.Rows[0]["ct"].ToString());
  78. }
  79. if (dt.Rows[0]["jt"].ToString() != "")
  80. {
  81. ibgnjt = int.Parse(dt.Rows[0]["jt"].ToString());
  82. }
  83. }
  84. 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>", ibgnCt.ToString());
  85. 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>", ibgnjt.ToString());
  86. if (txtEndTime != null && txtEndTime.Trim() != "")
  87. {
  88. sqltimeCallRecords = " and CONVERT(varchar , timecallin, 120)>=CONVERT(varchar , '" + txtEndTime.Trim() + "-" + strmm + "-01 00:00:01', 120) ";
  89. sqltimeCallRecords += " and CONVERT(varchar , timecallin, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + "-" + strmm + "-31 23:59:59', 120) ";
  90. }
  91. dt = DBUtility.DbHelperSQL.Query("select COUNT(*) as ct,(select COUNT(*) from rep_trunk_call_in where PeriodTalking>0 " + sqltimeCallRecords + ") as jt from rep_trunk_call_in where 1=1 " + sqltimeCallRecords).Tables[0];
  92. if (dt != null && dt.Rows.Count > 0)
  93. {
  94. if (dt.Rows[0]["ct"].ToString() != "")
  95. {
  96. iendct = int.Parse(dt.Rows[0]["ct"].ToString());
  97. }
  98. if (dt.Rows[0]["jt"].ToString() != "")
  99. {
  100. iendjt = int.Parse(dt.Rows[0]["jt"].ToString());
  101. }
  102. }
  103. 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>", iendct);
  104. 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>", iendjt);
  105. if (ibgnCt != 0)
  106. {
  107. ibgnjtl = ibgnjt / Convert.ToDouble(ibgnCt);
  108. }
  109. if (iendct != 0)
  110. {
  111. iendjtl = iendjt / Convert.ToDouble(iendct);
  112. }
  113. 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>", (ibgnjtl*100).ToString("0.00") + "%");
  114. 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>", (iendjtl*100).ToString("0.00") + "%");
  115. htmlReport.Append("</tr>");
  116. }
  117. htmlReport.Append("</table>");
  118. }
  119. catch { }
  120. return htmlReport.ToString();
  121. }
  122. public bool IsReusable
  123. {
  124. get
  125. {
  126. return false;
  127. }
  128. }
  129. }
  130. }