UU跑腿标准版

totalcallreport.aspx.cs 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Text;
  8. using System.Data;
  9. namespace HySoft.BaseCallCenter.Web.reportmanage
  10. {
  11. public partial class totalcallreport : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. }
  16. /// <summary>
  17. /// 获取HighCharts数据
  18. /// </summary>
  19. /// <returns></returns>
  20. public string GetHighCharts(string BeginYear)
  21. {
  22. DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
  23. DateTime dtNow;
  24. if (string.IsNullOrEmpty(BeginYear))
  25. {
  26. dtNow = DateTime.Now;
  27. }
  28. else
  29. {
  30. dtNow = DateTime.Parse(BeginYear);
  31. }
  32. string result = "[";
  33. for (int i = 1; i <= 12; i++)
  34. {
  35. result += "{";
  36. DateTime beginTime = Convert.ToDateTime(dtNow.Year + "-" + i + "-01 00:00:00");
  37. int days = DateTime.DaysInMonth(dtNow.Year, beginTime.Month);
  38. DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
  39. result += "y:" + dtRow.Length + ",";
  40. result += "color:colors[" + ((i - 1) / 3) + "],";
  41. result += "drilldown:{" + GetDrillDown(dtRow, beginTime, days) + "}";
  42. result += "},";
  43. }
  44. result = result.TrimEnd(',');
  45. result += "]";
  46. return result;
  47. }
  48. /// <summary>
  49. /// 获取月份中的天数数据
  50. /// </summary>
  51. /// <param name="dt"></param>
  52. /// <returns></returns>
  53. public string GetDrillDown(DataRow[] DataSource, DateTime SummaryDateTime, int Days)
  54. {
  55. string result = "";
  56. string categories = "[";
  57. string data = "[";
  58. result += "name:'" + SummaryDateTime.Month + "',";
  59. for (int i = 1; i <= Days; i++)
  60. {
  61. categories += "'" + i + "日',";
  62. if (DataSource.Count() > 0)
  63. data += DataSource.CopyToDataTable().Select("begintime >='" + SummaryDateTime.AddDays(i - 1) + "' and beginTime<'" + SummaryDateTime.AddDays(i).AddSeconds(-1) + "'").Length + ",";
  64. else
  65. data += "0" + ",";
  66. }
  67. categories = categories.TrimEnd(',') + "],";
  68. data = data.TrimEnd(',') + "],";
  69. result += "categories:" + categories;
  70. result += "data:" + data;
  71. result += "color:colors[" + (SummaryDateTime.Month - 1) / 3 + "]";
  72. return result;
  73. }
  74. /// <summary>
  75. /// 生成表格的标题和统计字段
  76. /// </summary>
  77. /// <param name="TableTitle">表格的标题</param>
  78. /// <param name="TableHead">表格统计字段</param>
  79. /// <returns></returns>
  80. public StringBuilder CreateTableTitleAndHead(string TableTitle, string beginYear, params object[] TableHead)
  81. {
  82. StringBuilder html = new StringBuilder();
  83. html.Append("<h1 style='font-size: 18px;font-weight: bold;color: #333333;text-align:center;width:100%;'><b>" + TableTitle + "</b></h1>");
  84. html.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"400\" align='center'>");
  85. html.Append("<tr style=\"text-align: center;\">");
  86. for (int i = 0; i < TableHead.Length; i++)
  87. {
  88. //标题第一行
  89. html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;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;\">" + TableHead[i] + "</td>");
  90. }
  91. html.Append("</tr>");
  92. GetTabelData(html, beginYear);
  93. html.Append("</table>");
  94. return html;
  95. }
  96. /// <summary>
  97. /// 获取表格中的统计数据
  98. /// </summary>
  99. /// <returns></returns>
  100. public string GetTabelData(StringBuilder SB, string BeginYear)
  101. {
  102. DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
  103. DateTime dtNow;
  104. int Count = 0;
  105. int DayCount = 0;
  106. string strHtml = "";
  107. if (string.IsNullOrEmpty(BeginYear))
  108. {
  109. dtNow = DateTime.Now;
  110. }
  111. else
  112. {
  113. dtNow = DateTime.Parse(BeginYear);
  114. }
  115. for (int i = 1; i <= 12; i++)
  116. {
  117. DateTime beginTime = Convert.ToDateTime(dtNow.Year + "-" + i + "-01 00:00:00");
  118. int days = DateTime.DaysInMonth(dtNow.Year, beginTime.Month);
  119. DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
  120. if (dtRow.Length > 0)
  121. {
  122. Count += dtRow.Length;
  123. for (int j = 1; j <= days; j++)
  124. {
  125. if (dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length > 0)
  126. {
  127. DayCount += 1;
  128. strHtml += "<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">";
  129. strHtml += "<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;\">" + beginTime.AddDays(j - 1).ToShortDateString() + "&nbsp;</td>";
  130. strHtml += "<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;\">" + dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length + "&nbsp;</td>";
  131. strHtml += "</tr>";
  132. }
  133. }
  134. if (DayCount != 0)
  135. {
  136. SB.Append("<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">");
  137. SB.Append("<td class=\"formtable_td\" rowspan=\"" + (DayCount + 2) + "\" 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;\">" + beginTime.Month + "月&nbsp;</td>");
  138. SB.Append(strHtml);
  139. SB.Append("<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">");
  140. SB.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;background-color: #e4d354;\">总计:&nbsp;</td>");
  141. SB.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;background-color: #e4d354;\">" + dtRow.Length + "&nbsp;</td>");
  142. SB.Append("</tr>");
  143. SB.Append("</tr>");
  144. }
  145. strHtml = "";
  146. DayCount = 0;
  147. }
  148. }
  149. SB.Append("<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">");
  150. SB.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;background-color: #D5EDFE;\">" + dtNow.Year + "年总计:&nbsp;</td>");
  151. SB.Append("<td class=\"formtable_td\" colspan=\"2\" 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;background-color: #D5EDFE;\">" + Count + "&nbsp;</td>");
  152. SB.Append("</tr>");
  153. return SB.ToString();
  154. }
  155. }
  156. }