| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <%@ WebHandler Language="C#" Class="tree" %>
- using System;
- using System.Web;
- using System.Web.SessionState;
- using System.Data;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using Curtain.DataAccess;
- using DK.XuWei.WebMes;
- /// <summary>
- /// 导航菜单
- /// xuwei create 2019-12-28
- /// </summary>
- public class tree : IHttpHandler, IReadOnlySessionState
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- using(IDataAccess conn = DataAccess.Create())
- {
- //按功能权限过滤显示树菜单(有子节点权限,不具备父节点权限,也要加进来)
- DataTable dt = conn.ExecuteDatatable(@"
- SELECT
- 0 AS id,
- f.FUNCTIONLEVEL AS code,
- f.FUNCTIONNAME AS text,
- f.URL AS url
- FROM
- TP_SYS_FUNCTION f
- WHERE
- f.IS_WEB = '1'
- AND
- ((f.FUNCTIONCODE IN (SELECT FUNCTIONCODE FROM TP_MST_USERRIGHT WHERE USERID = @USERID@))
- OR (f.FUNCTIONCODE IN (SELECT SUBSTR( FUNCTIONCODE, 1, LENGTH( FUNCTIONCODE ) - 2 ) FROM TP_MST_USERRIGHT WHERE USERID = @USERID@ )))
- ORDER BY
- f.FUNCTIONLEVEL,
- f.FUNCTIONCODE
- ",
- new CDAParameter("USERID",context.Session["userId"])
- );
- //添加动态报表菜单=================================
- //使用try容错,避免没有动态报表的出错
- try
- {
- DataTable dtReport = conn.ExecuteDatatable(@"
- SELECT
- REPORTID AS id,
- REPORTCODE AS code,
- REPORTNAME AS text,
- '/mes/dr/drmain/drmain_index.html?id='||REPORTID AS url
- FROM
- T_MST_DR_REPORT
- WHERE
- VALUEFLAG = '1'
- ORDER BY
- REPORTCODE
- ",
- new CDAParameter("USERID",context.Session["userId"])
- );
- dt.Merge(dtReport);
- }
- catch
- {
- }
- //================================================
- string rootId = dt.Rows[0]["id"].ToString();
- string rootCode = dt.Rows[0]["code"].ToString();
- string rootText = dt.Rows[0]["text"].ToString();
- string children = Easyui.TableToEasyUITree(dt, rootCode);
- string jsonStr = "[{\"id\":\"" + rootId + "\",\"text\":\"" + rootText + "\"" + children + "}]";
- context.Response.Write(jsonStr);
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
|