private void CheckPageAccess() { int roleId = 0; bool flag = false; if (Globals.GetCurrentManagerUserId(out roleId, out flag) == 0) { this.Page.Response.Redirect(Globals.ApplicationPath + "/admin/Login.aspx", true); } if (!flag) { if (!ManagerHelper.IsHavePermission(this.ModuleId, this.PageId, roleId)) { //如果进入的页面没有权限,就跳到最近的一个有权限的子页面 IList <RolePermissionInfo> list = ManagerHelper.GetRolePremissonsByRoleId(ManagerHelper.GetCurrentManager().RoleId); //当前角色权限合集 var listModule = list.Where(p => p.PermissionId.StartsWith(this.ModuleId + "_")); if (listModule.Count() > 0) { //得到当前XML中对应栏目的所有子节点 Dictionary <string, NavModule> _moduleList = Navigation.GetNavigation(true).ModuleList; var _modelParentLinq = from item in _moduleList select new { ID = item.Value.ID, Link = item.Value.Link, ItemList = item.Value.ItemList }; var _modelChildList = _modelParentLinq.Where(p => p.ID.Equals(listModule.First().PermissionId.Split('_')[0])).First().ItemList; //获取对应栏目有权限的第一个子节点 NavPageLink currNavPageLink = null; foreach (var item in _modelChildList.Values) { bool isFind = false; foreach (var pageLink in item.PageLinks.Values) { if (pageLink.ID == listModule.First().PermissionId.Split('_')[1]) { currNavPageLink = pageLink; isFind = true; break; } } if (isFind) { break; } } //有对应栏目的权限子节点,则跳转 if (currNavPageLink != null) { base.Response.Redirect(Globals.ApplicationPath + currNavPageLink.Link, true); return; } } //默认处理 this.NotPremissonRedirect(this.ModuleId, roleId, null); } } }
private void LoadPageLinks(NavItem item, XmlNode itemNode) { XmlNodeList xmlNodeList = itemNode.SelectNodes("PageLink"); if (xmlNodeList != null && xmlNodeList.Count != 0) { foreach (XmlNode xmlNode in xmlNodeList) { NavPageLink navPageLink = new NavPageLink { ID = xmlNode.Attributes["ID"].Value, Title = xmlNode.Attributes["Title"].Value }; XmlAttribute xmlAttribute = xmlNode.Attributes["Link"]; if (xmlAttribute != null) { navPageLink.Link = (xmlAttribute.Value.StartsWith("http") ? xmlAttribute.Value : (Globals.ApplicationPath + "/Admin/" + xmlAttribute.Value)); } XmlAttribute xmlAttribute2 = xmlNode.Attributes["Class"]; if (xmlAttribute2 != null) { navPageLink.Class = xmlAttribute2.Value; } XmlAttribute xmlAttribute3 = xmlNode.Attributes["Style"]; if (xmlAttribute3 != null) { navPageLink.Style = xmlAttribute3.Value; } XmlAttribute xmlAttribute4 = xmlNode.Attributes["Target"]; if (xmlAttribute4 != null) { navPageLink.Target = xmlAttribute4.Value; } item.PageLinks.Add(navPageLink.ID, navPageLink); } } }
private void LoadPageLinks(NavItem item, XmlNode itemNode) { XmlNodeList list = itemNode.SelectNodes("PageLink"); if ((list != null) && (list.Count != 0)) { foreach (XmlNode node in list) { NavPageLink link = new NavPageLink { ID = node.Attributes["ID"].Value, Title = node.Attributes["Title"].Value }; XmlAttribute attribute = node.Attributes["Link"]; if (attribute != null) { link.Link = attribute.Value.StartsWith("http") ? attribute.Value : (Globals.ApplicationPath + "/Admin/" + attribute.Value); } XmlAttribute attribute2 = node.Attributes["Class"]; if (attribute2 != null) { link.Class = attribute2.Value; } XmlAttribute attribute3 = node.Attributes["Style"]; if (attribute3 != null) { link.Style = attribute3.Value; } XmlAttribute attribute4 = node.Attributes["Target"]; if (attribute4 != null) { link.Target = attribute4.Value; } item.PageLinks.Add(link.ID, link); } } }