getFunction.ashx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <%@ WebHandler Language="C#" Class="getFunction" %>
  2. using System;
  3. using System.Web;
  4. using System.Web.SessionState;
  5. using System.Data;
  6. using System.Text;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using Newtonsoft.Json;
  10. using Newtonsoft.Json.Linq;
  11. using Curtain.DataAccess;
  12. using DK.XuWei.WebMes;
  13. public class getFunction : IHttpHandler, IReadOnlySessionState
  14. {
  15. public void ProcessRequest(HttpContext context)
  16. {
  17. context.Response.ContentType = "text/plain";
  18. using(IDataAccess conn = DataAccess.Create())
  19. {
  20. DataTable dt = conn.ExecuteDatatable(@"
  21. SELECT
  22. FUNCTIONCODE AS id,
  23. FUNCTIONLEVEL AS code,
  24. FUNCTIONNAME AS text,
  25. URL AS url
  26. FROM
  27. TP_SYS_FUNCTION
  28. WHERE
  29. IS_WEB = '1'
  30. ORDER BY
  31. FUNCTIONLEVEL,
  32. FUNCTIONCODE
  33. ");
  34. string rootId = dt.Rows[0]["id"].ToString();
  35. string rootCode = dt.Rows[0]["code"].ToString();
  36. string rootText = dt.Rows[0]["text"].ToString();
  37. string children = Easyui.TableToEasyUITree(dt, rootCode);
  38. string jsonStr = "[{\"id\":\"" + rootId + "\",\"text\":\"" + rootText + "\"" + children + "}]";
  39. context.Response.Write(jsonStr);
  40. }
  41. }
  42. public bool IsReusable
  43. {
  44. get
  45. {
  46. return false;
  47. }
  48. }
  49. }