tree.ashx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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
  27. 0 AS id,
  28. f.FUNCTIONLEVEL AS code,
  29. f.FUNCTIONNAME AS text,
  30. f.URL AS url
  31. FROM
  32. TP_SYS_FUNCTION f
  33. WHERE
  34. f.IS_WEB = '1'
  35. AND
  36. ((f.FUNCTIONCODE IN (SELECT FUNCTIONCODE FROM TP_MST_USERRIGHT WHERE USERID = @USERID@))
  37. OR (f.FUNCTIONCODE IN (SELECT SUBSTR( FUNCTIONCODE, 1, LENGTH( FUNCTIONCODE ) - 2 ) FROM TP_MST_USERRIGHT WHERE USERID = @USERID@ )))
  38. ORDER BY
  39. f.FUNCTIONLEVEL,
  40. f.FUNCTIONCODE
  41. ",
  42. new CDAParameter("USERID",context.Session["userId"])
  43. );
  44. //添加动态报表菜单=================================
  45. //使用try容错,避免没有动态报表的出错
  46. try
  47. {
  48. DataTable dtReport = conn.ExecuteDatatable(@"
  49. SELECT
  50. REPORTID AS id,
  51. REPORTCODE AS code,
  52. REPORTNAME AS text,
  53. '/mes/dr/drmain/drmain_index.html?id='||REPORTID AS url
  54. FROM
  55. T_MST_DR_REPORT
  56. WHERE
  57. VALUEFLAG = '1'
  58. ORDER BY
  59. REPORTCODE
  60. ",
  61. new CDAParameter("USERID",context.Session["userId"])
  62. );
  63. dt.Merge(dtReport);
  64. }
  65. catch
  66. {
  67. }
  68. //================================================
  69. string rootId = dt.Rows[0]["id"].ToString();
  70. string rootCode = dt.Rows[0]["code"].ToString();
  71. string rootText = dt.Rows[0]["text"].ToString();
  72. string children = Easyui.TableToEasyUITree(dt, rootCode);
  73. string jsonStr = "[{\"id\":\"" + rootId + "\",\"text\":\"" + rootText + "\"" + children + "}]";
  74. context.Response.Write(jsonStr);
  75. }
  76. }
  77. public bool IsReusable
  78. {
  79. get
  80. {
  81. return false;
  82. }
  83. }
  84. }