UU跑腿标准版

basedata.ashx.cs 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.tools
  8. {
  9. /// <summary>
  10. /// basedata 的摘要说明
  11. /// </summary>
  12. public class basedata : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. //取得处事类型
  18. string action = CommonRequest.GetQueryString("action");
  19. switch (action)
  20. {
  21. case "getlist":
  22. context.Response.Write(LoadList(context));
  23. break;
  24. case "delete":
  25. break;
  26. case "clear":
  27. break;
  28. }
  29. }
  30. #region 获取数据
  31. private string LoadList(HttpContext context)
  32. {
  33. string res = "";
  34. DataTable dt = new DataTable();
  35. string sql = " ";
  36. try
  37. {
  38. string key = HttpUtility.UrlDecode(CommonRequest.GetQueryString("key"));
  39. if (key.Trim() != "")
  40. {
  41. sql += " F_DictionaryFlag = '" + key.Trim() + "' ";
  42. }
  43. dt = new BLL.T_Sys_DictionaryValue().GetList(sql).Tables[0];
  44. System.Collections.Generic.List<Model.T_Sys_DictionaryValue> modelList = new BLL.T_Sys_DictionaryValue().DataTableToList(dt);
  45. System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<Model.T_Sys_DictionaryValue>));
  46. using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
  47. {
  48. //JSON序列化
  49. serializer.WriteObject(stream, modelList);
  50. res = System.Text.Encoding.UTF8.GetString(stream.ToArray());
  51. }
  52. }
  53. catch (Exception err)
  54. {
  55. //res = err.ToString();
  56. }
  57. finally
  58. {
  59. dt.Clear();
  60. dt.Dispose();
  61. }
  62. return res;
  63. }
  64. #endregion
  65. public bool IsReusable
  66. {
  67. get
  68. {
  69. return false;
  70. }
  71. }
  72. }
  73. }