tree.ashx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <%@ WebHandler Language="C#" Class="tree" %>
  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. /// <summary>
  14. /// 导航菜单
  15. /// xuwei create 2019-12-28
  16. /// </summary>
  17. public class tree : IHttpHandler, IReadOnlySessionState
  18. {
  19. public void ProcessRequest(HttpContext context)
  20. {
  21. context.Response.ContentType = "text/plain";
  22. using(IDataAccess conn = DataAccess.Create())
  23. {
  24. //按功能权限过滤显示树菜单(有子节点权限,不具备父节点权限,也要加进来)
  25. DataTable dt = conn.ExecuteDatatable(@"
  26. SELECT 0 AS id
  27. ,f.functionlevel AS code
  28. ,f.functionname AS text
  29. ,f.url AS url
  30. ,f.functioncode AS functioncode
  31. FROM tp_sys_function f
  32. WHERE f.is_web = '1'
  33. AND f.valueflag = '1'
  34. AND EXISTS
  35. (SELECT 1
  36. FROM (SELECT uf.functionlevel
  37. ,uf.functioncode
  38. FROM tp_mst_userright ur
  39. INNER JOIN tp_sys_function uf
  40. ON uf.functioncode = ur.functioncode
  41. WHERE uf.is_web = '1'
  42. AND uf.valueflag = '1'
  43. AND ur.userid = @USERID@) uu
  44. WHERE ((uu.functionlevel = f.functionlevel AND uu.functioncode = f.functioncode) OR
  45. (uu.functionlevel <> f.functionlevel AND
  46. uu.functionlevel LIKE f.functionlevel || '%'))
  47. )
  48. ORDER BY f.functionlevel
  49. ,f.functioncode
  50. ",
  51. new CDAParameter("USERID",context.Session["userId"])
  52. );
  53. //添加动态报表菜单=================================
  54. //使用try容错,避免没有动态报表的出错
  55. //try
  56. //{
  57. // DataTable dtReport = conn.ExecuteDatatable(@"
  58. // SELECT
  59. // REPORTID AS id,
  60. // REPORTCODE AS code,
  61. // REPORTNAME AS text,
  62. // '/mes/dr/drmain/drmain_index.html?id='||REPORTID AS url
  63. // FROM
  64. // T_MST_DR_REPORT
  65. // WHERE
  66. // VALUEFLAG = '1'
  67. // ORDER BY
  68. // REPORTCODE
  69. // ",
  70. // new CDAParameter("USERID",context.Session["userId"])
  71. // );
  72. // dt.Merge(dtReport);
  73. //}
  74. //catch
  75. //{
  76. //}
  77. //================================================
  78. string rootId = dt.Rows[0]["id"].ToString();
  79. string rootCode = dt.Rows[0]["code"].ToString();
  80. string rootText = dt.Rows[0]["text"].ToString();
  81. string children = Easyui.TableToEasyUITree(dt, rootCode);
  82. string jsonStr = "[{\"id\":\"" + rootId + "\",\"text\":\"" + rootText + "\"" + children + "}]";
  83. context.Response.Write(jsonStr);
  84. }
  85. }
  86. public bool IsReusable
  87. {
  88. get
  89. {
  90. return false;
  91. }
  92. }
  93. }