public static string GenerateMenuByPrivilege() { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(xmlMenu); StringBuilder sb = new StringBuilder(); int num = 0; var cu = SystemUser.CurrentUser; sb.Append("["); foreach (System.Xml.XmlElement MenuEL in doc.SelectNodes("/MainMenu/Menu")) { if (num > 0) { sb.Append(","); } num++; string title = MenuEL.GetAttribute("Name").ToString().Trim(); string lis = ""; foreach (System.Xml.XmlElement ItemEl in MenuEL.SelectNodes("Item")) { string secname = ItemEl.GetAttribute("Name"); string msg = ""; foreach (XmlElement TabEl in ItemEl.SelectNodes("Tab")) { string p = TabEl.GetAttribute("p").ToString().Trim(); if (cu.CheckPrivilegeString(p)) { string pantitle = TabEl.GetAttribute("Name").ToString().Trim(); string src = TabEl.InnerText; if (msg == "") { msg += pantitle + "," + src; } else { msg += "|" + pantitle + "," + src; } } } if (msg != "") { string RoleName = Task.TaskNum.GetRoleName(); if (RoleName.Equals("房东")) { //if (msg != "字典管理,approot/r/page/Dictionary/zdb.html|字典类型管理,approot/r/page/Dictionary/zdblx.html") //{ string numHtml = ""; int TaskNum = Task.TaskNum.GetTaskNum(msg); if (TaskNum > 0) { numHtml = "<font style=\"color:red;font-size:13px;font-weight:bold\">+" + TaskNum + "</font>"; } lis += "+ '<li class=\"fore\"><a class=\"MenuItem\" href=\"page/TabMenu.html?msg=" + msg + "\" target=\"mainframe\"><img height=16 width=16 align=\"absmiddle\" style=\"border:0\" src=\"../CSS/images/application.png\" /> " + secname + numHtml + "</a></li>'"; // } } else if (RoleName.Equals("门店管理员")) { if (msg != "字典管理,approot/r/page/Dictionary/zdb.html|字典类型管理,approot/r/page/Dictionary/zdblx.html" && msg != "已上线,approot/r/page/Hotel/HotelManage.html|待上线,approot/r/page/Hotel/HotelApply.html") { string numHtml = ""; int TaskNum = Task.TaskNum.GetTaskNum(msg); if (TaskNum > 0) { numHtml = "<font style=\"color:red;font-size:13px;font-weight:bold\">+" + TaskNum + "</font>"; } lis += "+ '<li class=\"fore\"><a class=\"MenuItem\" href=\"page/TabMenu.html?msg=" + msg + "\" target=\"mainframe\"><img height=16 width=16 align=\"absmiddle\" style=\"border:0\" src=\"../CSS/images/application.png\" /> " + secname + numHtml + "</a></li>'"; } } else if (RoleName.Equals("SystemAdministrator")) { if (msg == "字典管理,approot/r/page/Dictionary/zdb.html|字典类型管理,approot/r/page/Dictionary/zdblx.html" || msg == "账户管理,approot/r/page/System/PassWordGL.html") { string numHtml = ""; int TaskNum = Task.TaskNum.GetTaskNum(msg); if (TaskNum > 0) { numHtml = "<font style=\"color:red;font-size:13px;font-weight:bold\">+" + TaskNum + "</font>"; } lis += "+ '<li class=\"fore\"><a class=\"MenuItem\" href=\"page/TabMenu.html?msg=" + msg + "\" target=\"mainframe\"><img height=16 width=16 align=\"absmiddle\" style=\"border:0\" src=\"../CSS/images/application.png\" /> " + secname + numHtml + "</a></li>'"; } } } } if (lis != "") { sb.Append("{"); sb.Append("xtype: 'panel',"); sb.Append("collapsed: false,"); sb.Append("iconCls: 'cf',"); sb.Append("title: '" + title + "',"); sb.Append("html: '<ul class=\"MenuHolder\">'"); sb.Append(lis); sb.Append("+ '</ul>'"); sb.Append("}"); } } sb.Append("]"); return(sb.ToString()); }
public static string GenerateMenuByPrivilege() { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(loadXml()); StringBuilder sb = new StringBuilder(); int num = 0; var cu = SystemUser.CurrentUser; sb.Append("["); foreach (System.Xml.XmlElement MenuEL in doc.SelectNodes("/MainMenu/Menu")) { if (num > 0) { sb.Append(","); } num++; string title = MenuEL.GetAttribute("Name").ToString().Trim(); string lis = ""; foreach (System.Xml.XmlElement ItemEl in MenuEL.SelectNodes("Item")) { string secname = ItemEl.GetAttribute("Name"); string msg = ""; foreach (XmlElement TabEl in ItemEl.SelectNodes("Tab")) { string p = TabEl.GetAttribute("p").ToString().Trim(); string pantitle = TabEl.GetAttribute("Name").ToString().Trim(); string src = TabEl.InnerText; if (msg == "") { msg += pantitle + "," + src; } else { msg += "|" + pantitle + "," + src; } } if (msg != "") { lis += "+ '<li class=\"fore\"><a class=\"MenuItem\" href=\"page/TabMenu.html?msg=" + msg + "\" target=\"mainframe\"><img height=16 width=16 align=\"absmiddle\" style=\"border:0\" src=\"../CSS/images/application.png\" /> " + secname + "</a></li>'"; } } if (lis != "") { sb.Append("{"); sb.Append("xtype: 'panel',"); sb.Append("collapsed: false,"); sb.Append("iconCls: 'cf',"); sb.Append("title: '" + title + "',"); sb.Append("overflowY: 'auto',"); sb.Append("html: '<ul class=\"MenuHolder\">'"); sb.Append(lis); sb.Append("+ '</ul>'"); sb.Append("}"); } } sb.Append("]"); return(sb.ToString()); }