市长热线演示版

ExecutionEfficiency.aspx.cs 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  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.Data;
  8. using System.Text;
  9. namespace HySoft.BaseCallCenter.Web.reportmanage
  10. {
  11. public partial class ExecutionEfficiency : System.Web.UI.Page
  12. {
  13. protected string TableTitle = null;
  14. protected string TableOne = null;
  15. protected string TableTwo = null;
  16. protected string TableHtml = null;
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. #region Demo
  20. //PrintTable();
  21. //string[] head = { "日期", "工单总量", "工单总用时", "工单平均用时", "指派总用时", "指派平均用时", "接单总用时", "接单平均用时", "处理总用时", "处理平均用时", "回访总用时", "回访平均用时", "结单总用时", "结单平均用时" };
  22. //string[,] body = new string[30, 14];
  23. //for (int i = 0; i < 30; i++)
  24. //{
  25. // for (int j = 0; j < 14; j++)
  26. // {
  27. // if (j == 0)
  28. // body[i, j] = "2015/4/" + (i + 1).ToString();
  29. // else body[i, j] = "";
  30. // }
  31. //}
  32. //string[] sumiteam = { "合计:", "工单总量", "工单总用时", "工单平均用时", "指派总用时", "指派平均用时", "接单总用时", "接单平均用时", "处理总用时", "处理平均用时", "回访总用时", "回访平均用时", "结单总用时", "结单平均用时" };
  33. //TableHtml = createTableTitle("工单流程执行效率") + createTable1(head, body, sumiteam);
  34. #endregion
  35. OutputTable();
  36. }
  37. private void OutputTable()
  38. {
  39. //查询条件
  40. string starttime = txtStartTime.Text.Trim();
  41. string endtime = txtEndTime.Text.Trim();
  42. string type = hidType.Value.Trim().Replace(';', ',');
  43. string level = hidLevel.Value.Trim().Replace(';', ',');
  44. if (string.IsNullOrWhiteSpace(starttime)) { starttime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString("yyyy-MM-dd"); txtStartTime.Text = starttime; }
  45. if (string.IsNullOrWhiteSpace(endtime)) { endtime = DateTime.Today.ToString("yyyy-MM-dd"); txtEndTime.Text = endtime; }
  46. string tabletitle = "工单流程执行效率";
  47. string[] tablehead = { "日期", "工单总量", "工单总用时(小时)", "工单平均用时(小时)", "指派总用时(小时)", "指派平均用时(小时)", "接单总用时(小时)", "接单平均用时(小时)", "处理总用时(小时)", "处理平均用时(小时)", "回访总用时(小时)", "回访平均用时(小时)", "结单总用时(小时)", "结单平均用时(小时)" };
  48. TableHtml = createTable(tabletitle, tablehead, starttime, endtime, type, level);
  49. }
  50. private string createTable(string title, string[] head, string starttime, string endtime, string type, string level)
  51. {
  52. StringBuilder sb = new StringBuilder();
  53. sb.Append(createTableTitle(title));
  54. sb.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align='center'>");
  55. sb.Append(createTableHead(head));
  56. sb.Append(createTableBody(starttime, endtime, type, level));
  57. sb.Append("</table>");
  58. return sb.ToString();
  59. }
  60. private string createTableBody(string starttime, string endtime, string type, string level)
  61. {
  62. //收集数据
  63. List<List<string>> body = new List<List<string>>();
  64. for (DateTime dt = Convert.ToDateTime(starttime); dt <= Convert.ToDateTime(endtime); dt = dt.AddDays(1))
  65. {
  66. List<string> bodyiteam = new List<string>();
  67. bodyiteam.Add(dt.ToShortDateString());
  68. string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", 16);
  69. if (type != "")
  70. sql += " AND F_WORKORDERLEVELID in (" + type + ")";
  71. if (level != "")
  72. sql += " AND F_REPAIRLEVEL in (" + level + ")";
  73. sql += " AND F_STARTTIME>='" + dt.ToShortDateString() + " 00:00:00'";
  74. sql += " AND F_STARTTIME<='" + dt.ToShortDateString() + " 23:59:59'";
  75. sql += " AND F_ENDTIME IS NOT NULL AND F_ENDTIME !=''";
  76. DataTable dtable = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
  77. //今天的总工单量
  78. int todaycount = dtable.Rows.Count;
  79. bodyiteam.Add(todaycount.ToString());
  80. //今天的工单总用时
  81. double todayalltime = 0.00;
  82. TimeSpan tstotal = new TimeSpan();
  83. for (int i = 0; i < dtable.Rows.Count; i++)
  84. {
  85. DateTime dtstart = new DateTime();
  86. DateTime dtend = new DateTime();
  87. if (DateTime.TryParse(dtable.Rows[i]["F_ENDTIME"].ToString(), out dtend) && DateTime.TryParse(dtable.Rows[i]["F_STARTTIME"].ToString(), out dtstart))
  88. {
  89. TimeSpan ts = (TimeSpan)(dtend - dtstart);
  90. tstotal += ts;
  91. }
  92. }
  93. todayalltime = tstotal.TotalSeconds;
  94. bodyiteam.Add(todayalltime.ToString("0.00"));
  95. //今天的平均用时
  96. double todaypercent = 0.00;
  97. if (todayalltime > 0) todaypercent = todayalltime / todaycount;
  98. bodyiteam.Add(todaypercent.ToString("0.00"));
  99. //今天的工单每个状态的总用时
  100. int[] state = new int[] { 4, 6, 7, 8, 9 };
  101. for (int j = 0; j < state.Length; j++)
  102. {
  103. double l = 0.00;
  104. double p = 0.00;
  105. for (int i = 0; i < dtable.Rows.Count; i++)
  106. {
  107. string sqlwhere = string.Format("SELECT SUM([F_ELAPSEDTIME]) FROM [T_Wo_WorkOrderHistory] WHERE [F_WORKORDERSTATEID]='{0}' AND [F_INSTANCEID]='{1}'", state[j], dtable.Rows[i]["F_INSTANCEID"].ToString());
  108. DataTable dtb = DBUtility.DbHelperSQL.Query(sqlwhere).Tables[0];
  109. double m = 0.00;
  110. double.TryParse(dtb.Rows[0][0].ToString(), out m);
  111. l += m;
  112. }
  113. if (todaycount > 0) p = l / todaycount;
  114. bodyiteam.Add(l.ToString("0.00"));
  115. bodyiteam.Add(p.ToString("0.00"));
  116. }
  117. dtable.Dispose();
  118. for (int item =0;item< bodyiteam.Count;item++)
  119. {
  120. if (item == 0 || item == 1) continue;
  121. else bodyiteam[item] = GetTimeInfo(bodyiteam[item]);
  122. }
  123. body.Add(bodyiteam);
  124. }
  125. //打印表格
  126. StringBuilder sb = new StringBuilder();
  127. for (int i = 0; i < body.Count;i++ )
  128. {
  129. if (body[i][1] != "0")
  130. {
  131. sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
  132. foreach (var listiteam in body[i])
  133. {
  134. sb.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #fff;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;\">" + listiteam + "</td>");
  135. }
  136. sb.Append("</tr>");
  137. }
  138. }
  139. //合计数据
  140. List<string> sum = new List<string>();
  141. sum = getSumCountAndAverage(starttime, endtime, 16, type, level);
  142. sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
  143. for (int j = 0; j < sum.Count; j++)
  144. {
  145. sb.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;\">" + sum[j] + "</td>");
  146. }
  147. sb.Append("</tr>");
  148. return sb.ToString();
  149. }
  150. private List<string> getSumCountAndAverage(string starttime, string endtime, int type, string bxtype, string bxlevel)
  151. {
  152. List<string> sum = new List<string>();
  153. sum.Add("合计:");
  154. string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
  155. if (starttime != "")
  156. {
  157. sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
  158. }
  159. if (endtime != "")
  160. {
  161. sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
  162. }
  163. if (bxtype != "")
  164. sql += " AND F_WORKORDERLEVELID in (" + bxtype + ")";
  165. if (bxlevel != "")
  166. sql += " AND F_REPAIRLEVEL in (" + bxlevel + ")";
  167. DataTable dtable = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
  168. //工单总数
  169. int allcount = dtable.Rows.Count;
  170. sum.Add(allcount.ToString());
  171. //工单总用时
  172. double alltime = 0.00;
  173. TimeSpan tstotal = new TimeSpan();
  174. for (int i = 0; i < dtable.Rows.Count; i++)
  175. {
  176. DateTime dtstart = new DateTime();
  177. DateTime dtend = new DateTime();
  178. if (DateTime.TryParse(dtable.Rows[i]["F_ENDTIME"].ToString(), out dtend) && DateTime.TryParse(dtable.Rows[i]["F_STARTTIME"].ToString(), out dtstart))
  179. {
  180. TimeSpan ts = (TimeSpan)(dtend - dtstart);
  181. tstotal += ts;
  182. }
  183. }
  184. alltime = tstotal.TotalSeconds;
  185. sum.Add(alltime.ToString("0.00"));
  186. //平均用时
  187. double average = 0.00;
  188. if (alltime > 0) average = alltime / allcount;
  189. sum.Add(average.ToString("0.00"));
  190. //工单每个状态的总用时及平均用时
  191. int[] state = new int[] { 4, 6, 7, 8, 9 };
  192. for (int j = 0; j < state.Length; j++)
  193. {
  194. double l = 0.00;
  195. double p = 0.00;
  196. for (int i = 0; i < dtable.Rows.Count; i++)
  197. {
  198. string sqlwhere = string.Format("SELECT SUM([F_ELAPSEDTIME]) FROM [T_Wo_WorkOrderHistory] WHERE [F_WORKORDERSTATEID]='{0}' AND [F_INSTANCEID]='{1}'", state[j], dtable.Rows[i]["F_INSTANCEID"].ToString());
  199. DataTable dtb = DBUtility.DbHelperSQL.Query(sqlwhere).Tables[0];
  200. double m = 0.00;
  201. double.TryParse(dtb.Rows[0][0].ToString(), out m);
  202. l += m;
  203. }
  204. if (allcount > 0) p = l / allcount;
  205. sum.Add(l.ToString("0.00"));
  206. sum.Add(p.ToString("0.00"));
  207. }
  208. dtable.Dispose();
  209. for (int item = 0; item < sum.Count; item++)
  210. {
  211. if (item == 0 || item == 1) continue;
  212. else sum[item] = GetTimeInfo(sum[item]);
  213. }
  214. return sum;
  215. }
  216. private string createTableHead(string[] head)
  217. {
  218. StringBuilder sb = new StringBuilder();
  219. sb.Append("<tr style=\"text-align: center;\">");
  220. for (int i = 0; i < head.Length; i++)
  221. {
  222. sb.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;\">" + head[i] + "</td>");
  223. }
  224. sb.Append("</tr>");
  225. return sb.ToString();
  226. }
  227. protected void btnConfirm_Click(object sender, EventArgs e)
  228. {
  229. //PrintTable();
  230. OutputTable();
  231. }
  232. private void PrintTable()
  233. {
  234. string starttime = txtStartTime.Text.Trim();
  235. if (string.IsNullOrWhiteSpace(starttime)) starttime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToShortDateString();
  236. string endtime = txtEndTime.Text.Trim();
  237. if (string.IsNullOrWhiteSpace(endtime)) endtime = DateTime.Today.AddDays(-1).ToShortDateString();
  238. int workordercount = getWorkOrderCount(starttime, endtime, 16);
  239. double workorderalltime = getWorkOrderAllTime(starttime, endtime, 16);
  240. int averagetime = 0;
  241. if (workordercount > 0)
  242. {
  243. averagetime = (int)(workorderalltime / workordercount);
  244. }
  245. TableTitle = createTableTitle("工单流程执行效率");
  246. string[] Head1 = new string[] { "统计项", "统计结果" };
  247. string[,] Body1 = new string[,] { { "工单总数",workordercount.ToString()},
  248. { "工单总用时",GetTimeInfo(workorderalltime.ToString())},
  249. {"工单平均用时",GetTimeInfo(averagetime.ToString())} };
  250. TableOne = createTable(Head1, Body1);
  251. string[] Head2 = new string[] { "", "指派", "接单", "处理", "回访", "结单" };
  252. string[,] Body2 = new string[,] { { "总用时", "", "", "", "", "" },
  253. { "平均用时", "", "", "", "", "" } };
  254. long time4 = getOneStateTime(starttime, endtime, 16, 4);
  255. long time6 = getOneStateTime(starttime, endtime, 16, 6);
  256. long time7 = getOneStateTime(starttime, endtime, 16, 7);
  257. long time8 = getOneStateTime(starttime, endtime, 16, 8);
  258. long time9 = getOneStateTime(starttime, endtime, 16, 9);
  259. Body2[0, 1] = GetTimeInfo(time4.ToString());
  260. Body2[0, 2] = GetTimeInfo(time6.ToString());
  261. Body2[0, 3] = GetTimeInfo(time7.ToString());
  262. Body2[0, 4] = GetTimeInfo(time8.ToString());
  263. Body2[0, 5] = GetTimeInfo(time9.ToString());
  264. if (workordercount > 0)
  265. {
  266. Body2[1, 1] = GetTimeInfo((time4 / workordercount).ToString());
  267. Body2[1, 2] = GetTimeInfo((time6 / workordercount).ToString());
  268. Body2[1, 3] = GetTimeInfo((time7 / workordercount).ToString());
  269. Body2[1, 4] = GetTimeInfo((time8 / workordercount).ToString());
  270. Body2[1, 5] = GetTimeInfo((time9 / workordercount).ToString());
  271. }
  272. TableTwo = createTable(Head2, Body2);
  273. }
  274. /// <summary>
  275. /// 工单总数量
  276. /// </summary>
  277. /// <returns></returns>
  278. private int getWorkOrderCount(string starttime, string endtime, int type)
  279. {
  280. string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
  281. if (starttime != "")
  282. {
  283. sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
  284. }
  285. if (endtime != "")
  286. {
  287. sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
  288. }
  289. return new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0].Rows.Count;
  290. }
  291. /// <summary>
  292. /// 工单总用时
  293. /// </summary>
  294. /// <returns></returns>
  295. private double getWorkOrderAllTime(string starttime, string endtime, int type)
  296. {
  297. string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
  298. if (starttime != "")
  299. {
  300. sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
  301. }
  302. if (endtime != "")
  303. {
  304. sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
  305. }
  306. DataTable dtlist = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
  307. TimeSpan tstotal = new TimeSpan();
  308. for (int i = 0; i < dtlist.Rows.Count; i++)
  309. {
  310. DateTime dtstart = new DateTime();
  311. DateTime dtend = new DateTime();
  312. if (DateTime.TryParse(dtlist.Rows[i]["F_ENDTIME"].ToString(), out dtend) && DateTime.TryParse(dtlist.Rows[i]["F_STARTTIME"].ToString(), out dtstart))
  313. {
  314. TimeSpan ts = (TimeSpan)(dtend - dtstart);
  315. tstotal += ts;
  316. }
  317. }
  318. return tstotal.TotalSeconds;
  319. }
  320. /// <summary>
  321. /// 某种状态的总时间
  322. /// </summary>
  323. /// <param name="state">
  324. /// 工单状态:
  325. /// 12 开始
  326. /// 4 待指派
  327. /// 6 待接单
  328. /// 7 待处理
  329. /// 8 待回访
  330. /// 9 待结单
  331. /// 0 结束
  332. /// </param>
  333. /// <returns></returns>
  334. private long getOneStateTime(string starttime, string endtime, int type, int state)
  335. {
  336. string sql = string.Format("F_WORKORDERSTATEID=0 and F_WORKORDERTYPEID={0}", type);
  337. if (starttime != "")
  338. {
  339. sql += " AND F_STARTTIME>='" + starttime + " 00:00:00'";
  340. }
  341. if (endtime != "")
  342. {
  343. sql += " AND F_ENDTIME<='" + endtime + " 23:59:59'";
  344. }
  345. DataTable dtlist = new BLL.T_Wo_WorkOrderBase().GetList(sql).Tables[0];
  346. long l = 0;
  347. for (int i = 0; i < dtlist.Rows.Count; i++)
  348. {
  349. string sqlwhere = string.Format("SELECT SUM([F_ELAPSEDTIME]) FROM [T_Wo_WorkOrderHistory] WHERE [F_WORKORDERSTATEID]='{0}' AND [F_INSTANCEID]='{1}'", state, dtlist.Rows[i]["F_INSTANCEID"].ToString());
  350. DataTable dt = DBUtility.DbHelperSQL.Query(sqlwhere).Tables[0];
  351. long m = 0;
  352. long.TryParse(dt.Rows[0][0].ToString(), out m);
  353. l += m;
  354. }
  355. return l;
  356. }
  357. /// <summary>
  358. /// 获取不同类型,不同状态的工单数量
  359. /// </summary>
  360. /// <param name="type">工单类型:6.咨询 3.投诉 16.报修</param>
  361. /// <param name="state">
  362. /// 工单状态:
  363. /// 12 开始
  364. /// 4 待指派
  365. /// 6 待接单
  366. /// 7 待处理
  367. /// 8 待回访
  368. /// 9 待结单
  369. /// 0 结束
  370. /// </param>
  371. /// <returns>工单数量</returns>
  372. private int getWorkOrderStateCount(int type, int state)
  373. {
  374. string sqlwhere = string.Format("F_WORKORDERTYPEID='{0}' and F_WORKORDERSTATEID='{1}'", type, state);
  375. return new BLL.T_Wo_WorkOrderBase().GetList(sqlwhere).Tables[0].Rows.Count;
  376. }
  377. /// <summary>
  378. /// 时间转换(将秒转换为易读的时间)
  379. /// </summary>
  380. /// <param name="times">秒</param>
  381. /// <returns></returns>
  382. public string GetTimeInfo1(string times)
  383. {
  384. string res = "";
  385. try
  386. {
  387. double d = Convert.ToDouble(times);
  388. int t = Convert.ToInt32(d);
  389. if (t < 60)
  390. {
  391. res = "" + t + "秒";
  392. }
  393. else if (t < 3600)
  394. {
  395. res = "" + Convert.ToInt32(t / 60).ToString() + "分" + "" + Convert.ToInt32(t % 60).ToString() + "秒";
  396. }
  397. else if (t < 86400)
  398. {
  399. res = "" + Convert.ToInt32(t / 3600).ToString() + "时" + "" + Convert.ToInt32((t % 3600) / 60).ToString() + "分" + "" + Convert.ToInt32((t % 3600) % 60).ToString() + "秒";
  400. }
  401. else
  402. {
  403. res = "" + Convert.ToInt32(t / 86400).ToString() + "天" + "" + Convert.ToInt32((t % 86400) / 3600).ToString() + "时" + "" + Convert.ToInt32(((t % 86400) % 3600) / 60).ToString() + "分" + "" + Convert.ToInt32(((t % 86400) % 3600) % 60).ToString() + "秒";
  404. }
  405. }
  406. catch
  407. { }
  408. return res;
  409. }
  410. /// <summary>
  411. /// 把秒转化成小时
  412. /// </summary>
  413. /// <param name="times">秒</param>
  414. /// <returns></returns>
  415. public string GetTimeInfo(string times)
  416. {
  417. string res = "";
  418. try
  419. {
  420. double d = Convert.ToDouble(times);
  421. res = (d / 3600).ToString("0.00");
  422. }
  423. catch
  424. { }
  425. return res;
  426. }
  427. /// <summary>
  428. /// 表名称
  429. /// </summary>
  430. /// <param name="title">表名</param>
  431. /// <returns></returns>
  432. protected string createTableTitle(string title)
  433. {
  434. StringBuilder sb = new StringBuilder();
  435. sb.Append("<h1 style='font-size: 18px; font-weight: bold; color: #333333; text-align: center;width: 100%;'><b>" + title + "</b></h1>");
  436. return sb.ToString();
  437. }
  438. /// <summary>
  439. /// 表头(表列名)
  440. /// </summary>
  441. /// <param name="head">列名数组</param>
  442. /// <returns></returns>
  443. protected string createTable(string[] head, string[,] body)
  444. {
  445. StringBuilder sb = new StringBuilder();
  446. sb.Append("<table border='0' cellpadding='0' cellspacing='0' width='100%' align='center'>");
  447. sb.Append("<tr 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;\">");
  448. for (int i = 0; i < head.Length; i++)
  449. {
  450. sb.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;\">" + head[i] + "</td>");
  451. }
  452. sb.Append("</tr>");
  453. sb.Append(createTableBody(body));
  454. sb.Append("</table>");
  455. return sb.ToString();
  456. }
  457. private string createTableBody(string[,] body)
  458. {
  459. StringBuilder sb = new StringBuilder();
  460. for (int i = 0; i < body.GetLength(0); i++)
  461. {
  462. sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
  463. for (int j = 0; j < body.GetLength(1); j++)
  464. {
  465. sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #fff;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;\">" + body[i, j] + "</td>");
  466. }
  467. sb.Append("</tr>");
  468. }
  469. return sb.ToString();
  470. }
  471. protected string createTable1(string[] head, string[,] body,string[] sumiteam)
  472. {
  473. StringBuilder sb = new StringBuilder();
  474. sb.Append("<table border='0' cellpadding='0' cellspacing='0' width='100%' align='center'>");
  475. sb.Append("<tr 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;\">");
  476. for (int i = 0; i < head.Length; i++)
  477. {
  478. sb.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;\">" + head[i] + "</td>");
  479. }
  480. sb.Append("</tr>");
  481. sb.Append(createTableBody1(body));
  482. sb.Append("<tr class=\"formtabletitle1\" style=\"height: 25px;background-color: #E4D354;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;\">");
  483. for (int i = 0; i < sumiteam.Length; i++)
  484. {
  485. sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #E4D354;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;\">" + sumiteam[i] + "</td>");
  486. }
  487. sb.Append("</table>");
  488. return sb.ToString();
  489. }
  490. private string createTableBody1(string[,] body)
  491. {
  492. StringBuilder sb = new StringBuilder();
  493. for (int i = 0; i < body.GetLength(0); i++)
  494. {
  495. sb.Append("<tr style=\"text-align: center;\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\">");
  496. for (int j = 0; j < body.GetLength(1); j++)
  497. {
  498. sb.Append("<td class=\"formtabletitle1\" style=\"height: 25px;background-color: #fff;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;\">" + body[i, j] + "</td>");
  499. }
  500. sb.Append("</tr>");
  501. }
  502. return sb.ToString();
  503. }
  504. protected void btnExport_Click(object sender, EventArgs e)
  505. {
  506. string fileName = "工单流程执行效率报表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
  507. Response.Clear();
  508. Response.Charset = "GB2312";
  509. Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
  510. Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName));
  511. Response.ContentType = "application/ms-excel";
  512. Response.Write(TableHtml);
  513. Response.End();
  514. }
  515. }
  516. }