市长热线演示版

CommonDataList.ashx.cs 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using HySoft.Common;
  6. using System.Data;
  7. namespace HySoft.BaseCallCenter.Web.workordermanage.ajax
  8. {
  9. /// <summary>
  10. /// CommonDataList 的摘要说明
  11. /// </summary>
  12. public class CommonDataList : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. string action = CommonRequest.GetQueryString("action");
  18. switch (action)
  19. {
  20. case "getlist":
  21. context.Response.Write(LoadList(context));
  22. break;
  23. }
  24. }
  25. #region 获取数据
  26. private string LoadList(HttpContext context)
  27. {
  28. string intenseid = CommonRequest.GetQueryString("intenseid");
  29. string res = "";
  30. DataTable dt = new DataTable();
  31. string sql = " ";
  32. if (intenseid.Trim() != "")
  33. {
  34. sql += " and F_INSTANCEID = '" + intenseid.Trim() + "' ";
  35. }
  36. try
  37. {
  38. string strpageindex = context.Request.Params["page"];
  39. int pageindex = 1;
  40. string strpagesize = context.Request.Params["pagesize"];
  41. int pagesize = 10;
  42. if (strpageindex.Trim() != "")
  43. {
  44. try
  45. {
  46. pageindex = Convert.ToInt32(strpageindex);
  47. }
  48. catch
  49. { }
  50. }
  51. if (strpagesize.Trim() != "")
  52. {
  53. try
  54. {
  55. pagesize = Convert.ToInt32(strpagesize);
  56. }
  57. catch
  58. { }
  59. }
  60. int recordCount = 0;
  61. Model.PageData<Model.T_Wo_WorkOrderHistory> pageModel = new Model.PageData<Model.T_Wo_WorkOrderHistory>();
  62. dt = BLL.PagerBLL.GetListPager(
  63. "V_WorkOrderHistory",
  64. "F_HISTORYID",
  65. "*",
  66. sql,
  67. "ORDER BY F_HISTORYID ",
  68. pagesize,
  69. pageindex,
  70. true,
  71. out recordCount);
  72. System.Collections.Generic.List<Model.T_Wo_WorkOrderHistory> modelList = new BLL.T_Wo_WorkOrderHistory().DataTableToList(dt);
  73. pageModel.Rows = modelList;
  74. pageModel.Total = recordCount;
  75. System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Model.PageData<Model.T_Wo_WorkOrderHistory>));
  76. using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
  77. {
  78. //JSON序列化
  79. serializer.WriteObject(stream, pageModel);
  80. res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
  81. }
  82. }
  83. catch (Exception err)
  84. {
  85. //res = err.ToString();
  86. }
  87. finally
  88. {
  89. dt.Clear();
  90. dt.Dispose();
  91. }
  92. return res;
  93. }
  94. private string LoadList(string intenseid)
  95. {
  96. string res = "";
  97. DataTable dt = new DataTable();
  98. string sql = "";
  99. try
  100. {
  101. if (intenseid.Trim() != "")
  102. {
  103. sql += " and F_INSTANCEID = '" + intenseid.Trim() + "' ";
  104. }
  105. Model.PageData<Model.T_Wo_WorkOrderHistory> pageModel = new Model.PageData<Model.T_Wo_WorkOrderHistory>();
  106. dt = (new BLL.T_Wo_WorkOrderHistory()).GetListView(" 1=1 " + sql + " ORDER BY F_HISTORYID").Tables[0];
  107. // int recordCount = 0;
  108. // dt = BLL.PagerBLL.GetListPager(
  109. //"V_WorkOrderHistory",
  110. //"F_HISTORYID",
  111. //"*",
  112. //sql,
  113. //"ORDER BY F_HISTORYID ",
  114. //10,
  115. //1,
  116. //true,
  117. //out recordCount);
  118. System.Collections.Generic.List<Model.T_Wo_WorkOrderHistory> modelList = new BLL.T_Wo_WorkOrderHistory().DataTableToListDetail(dt);
  119. //pageModel.Rows = modelList;
  120. //pageModel.Total = dt.Rows.Count;
  121. System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(System.Collections.Generic.List<Model.T_Wo_WorkOrderHistory>));
  122. using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
  123. { //JSON序列化
  124. serializer.WriteObject(stream, modelList);
  125. res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
  126. }
  127. //}
  128. }
  129. catch (Exception err)
  130. {
  131. //res = err.ToString();
  132. }
  133. finally
  134. {
  135. dt.Clear();
  136. dt.Dispose();
  137. }
  138. return res;
  139. }
  140. #endregion
  141. public bool IsReusable
  142. {
  143. get
  144. {
  145. return false;
  146. }
  147. }
  148. }
  149. }