| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- using BizCom;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Web;
- namespace SiteCore.Handler
- {
- public class GetPurview : BaseHandler, IHttpHandler
- {
- static string staffJson = "\"state\":\"open\",\"attributes\" : <\"id\" : \"{0}\" >,\"data\" : <\"title\" : \"{1}\",http://localhost:14900/Handler/GetCaptchaImage.ashx?6.71640579441537\"attributes\" : < \"href\" : \"javascript:void(0);\" > >,\"children\" : [{2}]";
- static string json = "\"attributes\" : <\"id\" : \"{0}\" >,\"data\" : <\"title\" : \"{1}\",\"attributes\" : < \"href\" : \"javascript:void(0);\" > >,\"children\" : [{2}]";
- private string key = "ID";
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "application/jason";
- if (context.Request.QueryString["type"] != null)
- {
- string sType = context.Request.QueryString["type"].ToLower();
- if (context.Request.QueryString["type"] != null)
- {
- DataTable dt = null;
- switch (sType)
- {
- case "xmodular":
- {
- dt = XModular.GetModular();
- GetResource(new DataView(dt), "系统模块");
- break;
- }
- case "xpms":
- {
- if (UrlParmsCheck("oId"))
- {
- string oId = GetString("oId");
- dt = XPermission.GetPermission(oId);
- IList<string> list = new List<string>();
- foreach (DataRow dr in dt.Rows)
- {
- list.Add(dr["ID"].ToString());
- }
- ReturnJsonMsg("success", string.Join(",", list.ToArray()));
- return;
- }
- ReturnJsonMsg("success", "");
- break;
- }
- //case "app_org_pms":
- // {
- // if (UrlParmsCheck("oId"))
- // {
- // string oId = GetString("oId");
- // dt = CeErpAppPermission.GetPermission("0", oId);
- // IList<string> list = new List<string>();
- // foreach (DataRow dr in dt.Rows)
- // {
- // list.Add(dr["ID"].ToString());
- // }
- // ReturnJsonMsg("success", string.Join(",", list.ToArray()));
- // return;
- // }
- // ReturnJsonMsg("success", "");
- // break;
- // }
- //case "app_org_post":
- // {
- // if (UrlParmsCheck("oId,pId"))
- // {
- // string oId = GetString("oId");
- // string pId = GetString("pId");
- // StringBuilder sql = new StringBuilder();
- // sql.AppendFormat("select stuff((select ','+convert(varchar,modularid) from ce_erpapppermission where orgid={0} and postID=0 FOR XML PATH('')), 1, 1, '') ;", oId);
- // sql.AppendFormat("select ModularID as ID from ce_erpapppermission where orgid={0} and postID={1} ;", oId, pId);
- // DataSet ds = CeErpPost.ExecuteDataset(sql.ToString());
- // DataTable pDt = ds.Tables[0];
- // if (pDt != null && pDt.Rows.Count > 0)
- // {
- // string pids = pDt.Rows[0][0].ToString();
- // DataTable mdt = getAppModular();
- // DataView mDv = new DataView(mdt);
- // mDv.RowFilter = "id in (" + pids + ")";
- // if (mDv.Count > 0)
- // {
- // StringBuilder str = new StringBuilder();
- // //DataTable nmDt = new DataView(mDv.ToTable());
- // string s = string.Format(json, "root", "APP权限", GetResource(new DataView(mDv.ToTable()), 0)).Replace("<", "{").Replace(">", "}");
- // str.Append("\"orgData\":[{" + s + ",\"state\":\"open\"" + "}],");
- // dt = ds.Tables[1];
- // IList<string> list = new List<string>();
- // foreach (DataRow dr in dt.Rows)
- // {
- // list.Add(dr["ID"].ToString());
- // }
- // str.AppendFormat("\"postData\":\"{0}\"", string.Join(",", list.ToArray()));
- // ReturnSuccess("[{" + str.ToString() + "}]");
- // }
- // }
- // }
- // break;
- // }
- case "modular":
- {
- dt = CeErpModular.GetModular();
- GetResource(new DataView(dt), "系统模块");
- break;
- }
- case "org_post":
- {
- if (UrlParmsCheck("oId,pId"))
- {
- string oId = GetString("oId");
- string pId = GetString("pId");
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpModular where ID in( select ModularID from ce_erppermission where orgid=" + oId + " and postID=0) and isDel=0 order by sort asc ;");
- sql.AppendFormat("select ModularID as ID from view_erppermission where orgid={0} and postID={1} and isDel=0 ;", oId, pId);
- //sql.AppendFormat("select ID,DefaultPageModuleID as pmId,IndexPageReport as ipp from ce_erppost where id={0} ;", pId);
- // sql.AppendFormat("select * from view_ErpPostToIndexPage where postid={0} ;", pId);
- DataSet ds = CeErpPost.ExecuteDataset(sql.ToString());
- StringBuilder str = new StringBuilder();
- dt = ds.Tables[0];
- DataView dv = new DataView(dt);
- string s = string.Format(json, "root", "系统模块", GetResource(dv, 0)).Replace("<", "{").Replace(">", "}");
- str.Append("\"orgData\":[{" + s + ",\"state\":\"open\"" + "}],");
- dt = ds.Tables[1];
- IList<string> list = new List<string>();
- foreach (DataRow dr in dt.Rows)
- {
- list.Add(dr["ID"].ToString());
- }
- str.AppendFormat("\"postData\":\"{0}\"", string.Join(",", list.ToArray()));
- //str.AppendFormat("\"settingData\":{0}", JsonString.DataTable2AjaxJson(ds.Tables[2]));
- //str.AppendFormat("\"piData\":{0}", JsonString.DataTable2AjaxJson(ds.Tables[3]));
- ReturnSuccess("[{" + str.ToString() + "}]");
- }
- break;
- }
- case "org_modular":
- {
- if (UrlParmsCheck("oId"))
- {
- string oId = GetString("oId");
- dt = CeErpModular.GetOrgModular(oId);
- GetResource(new DataView(dt), "系统模块");
- }
- break;
- }
- case "org_pms":
- {
- if (UrlParmsCheck("oId"))
- {
- string oId = GetString("oId");
- dt = CeErpPermission.GetPermission("0", oId);
- IList<string> list = new List<string>();
- foreach (DataRow dr in dt.Rows)
- {
- list.Add(dr["ID"].ToString());
- }
- ReturnJsonMsg("success", string.Join(",", list.ToArray()));
- return;
- }
- ReturnJsonMsg("success", "");
- break;
- }
- case "post_pms":
- {
- if (UrlParmsCheck("pId,oId"))
- {
- string oId = GetString("oId");
- string pId = GetString("pId");
- dt = CeErpPermission.GetPermission(pId, oId);
- IList<string> list = new List<string>();
- foreach (DataRow dr in dt.Rows)
- {
- list.Add(dr["ID"].ToString());
- }
- ReturnJsonMsg("success", string.Join(",", list.ToArray()));
- return;
- }
- ReturnJsonMsg("success", "");
- break;
- }
- }
- }
- }
- else
- {
- //ReturnJsonMsg("error", "服务器错误");
- }
- }
- private void GetSimpleResource(DataView dv)
- {
- if (dv != null && dv.Count > 0)
- {
- string root = dv[0]["Name"].ToString();
- int id = Convert.ToInt32(dv[0]["ID"]);
- string str = string.Format(staffJson, id, root, GetSimpleResource(dv, id)).Replace("<", "{").Replace(">", "}");
- Utils.CommonHelper.ReturnSuccess("[{" + str + ",\"state\":\"open\"" + "}]");
- }
- }
- private string GetSimpleResource(DataView dv, int parentID)
- {
- dv.RowFilter = "ParentID=" + parentID;
- if (dv.Count > 0)
- {
- ArrayList arrayList = new ArrayList();
- foreach (DataRowView drv in dv)
- {
- string tmp = string.Format(staffJson, drv[key], drv["Name"], GetResource(dv, Convert.ToInt32(drv["ID"])));//.Replace("<", "{").Replace(">", "}");
- arrayList.Add("{" + tmp + "}");
- }
- string[] tArr = (string[])arrayList.ToArray(typeof(string));
- return string.Join(",", tArr);
- }
- else
- {
- return "";
- }
- }
- private void GetResource(DataView dv, string rootName)
- {
- if (dv != null && dv.Count > 0)
- {
- string str = string.Format(json, "root", rootName, GetResource(dv, 0)).Replace("<", "{").Replace(">", "}");
- //string str = GetResource(dv, 0);
- Utils.CommonHelper.ReturnSuccess("[{" + str + ",\"state\":\"open\"" + "}]");
- }
- }
- //获取系统模块
- private string GetResource(DataView dv, int parentID)
- {
- dv.RowFilter = "ParentID=" + parentID;
- if (dv.Count > 0)
- {
- ArrayList arrayList = new ArrayList();
- foreach (DataRowView drv in dv)
- {
- string tmp = string.Format(json, drv[key], drv["Name"], GetResource(dv, Convert.ToInt32(drv["ID"])));//.Replace("<", "{").Replace(">", "}");
- arrayList.Add("{" + tmp + "}");
- }
- string[] tArr = (string[])arrayList.ToArray(typeof(string));
- return string.Join(",", tArr);
- }
- else
- {
- return "";
- }
- }
- }
- }
|