Beispiel #1
0
        private void LoadNavigationFromXml()
        {
            XmlNodeList xmlNodeList = this._xmlDoc.SelectNodes("Menu/Module");

            if (xmlNodeList != null && xmlNodeList.Count != 0)
            {
                Navigation._moduleList.Clear();
                foreach (XmlNode xmlNode in xmlNodeList)
                {
                    NavModule navModule = new NavModule
                    {
                        Title = xmlNode.Attributes["Title"].Value,
                        ID    = xmlNode.Attributes["ID"].Value
                    };
                    XmlAttribute xmlAttribute = xmlNode.Attributes["Link"];
                    if (xmlAttribute != null)
                    {
                        navModule.Link = (xmlAttribute.Value.StartsWith("http") ? xmlAttribute.Value : (Globals.ApplicationPath + "/Admin/" + xmlAttribute.Value));
                    }
                    XmlAttribute xmlAttribute2 = xmlNode.Attributes["IsDivide"];
                    if (xmlAttribute2 != null && xmlAttribute2.Value.ToLower() == "true")
                    {
                        navModule.IsDivide = true;
                    }
                    XmlAttribute xmlAttribute3 = xmlNode.Attributes["Class"];
                    if (xmlAttribute3 != null)
                    {
                        navModule.Class = xmlAttribute3.Value;
                    }
                    this.LoadItems(navModule, xmlNode);
                    Navigation._moduleList.Add(navModule.ID, navModule);
                }
            }
        }
Beispiel #2
0
        private void LoadItems(NavModule module, XmlNode moduleNode)
        {
            XmlNodeList xmlNodeList = moduleNode.SelectNodes("Item");

            if (xmlNodeList != null && xmlNodeList.Count != 0)
            {
                foreach (XmlNode xmlNode in xmlNodeList)
                {
                    NavItem      navItem      = new NavItem();
                    XmlAttribute xmlAttribute = xmlNode.Attributes["Title"];
                    if (xmlAttribute != null)
                    {
                        navItem.SpanName = xmlAttribute.Value;
                    }
                    XmlAttribute xmlAttribute2 = xmlNode.Attributes["Class"];
                    if (xmlAttribute2 != null)
                    {
                        navItem.Class = xmlAttribute2.Value;
                    }
                    navItem.ID = xmlNode.Attributes["ID"].Value;
                    module.ItemList.Add(navItem.ID, navItem);
                    this.LoadPageLinks(navItem, xmlNode);
                }
            }
        }
Beispiel #3
0
        public string RenderLeftMenu(string currentModuleId, string currentPageId)
        {
            NavModule     navModule          = Navigation._moduleList[currentModuleId];
            StringBuilder stringBuilder      = new StringBuilder();
            StringBuilder stringBuilderTwo   = new StringBuilder();
            StringBuilder stringBuilderThree = new StringBuilder();

            foreach (NavItem current in navModule.ItemList.Values)
            {
                stringBuilderTwo   = new StringBuilder("");
                stringBuilderThree = new StringBuilder("");
                if (!string.IsNullOrEmpty(current.SpanName))
                {
                    stringBuilderTwo.AppendFormat("<em class=\"{0}\"></em>", current.Class).AppendLine();
                    stringBuilderTwo.AppendFormat("<span>{0}</span>", current.SpanName).AppendLine();
                }

                stringBuilderTwo.AppendFormat("<ul iid=\"{0}\">", current.ID).AppendLine();

                stringBuilderThree = this.AppendLinks(current, currentPageId);

                stringBuilderTwo.AppendLine(stringBuilderThree.ToString());
                stringBuilderTwo.AppendLine("</ul>");
                if (stringBuilderThree.ToString() != "") //下面有内容才加进去
                {
                    stringBuilder.Append(stringBuilderTwo);
                }
            }

            return(stringBuilder.ToString());
        }
Beispiel #4
0
        private void LoadNavigationFromXml()
        {
            XmlNodeList list = this._xmlDoc.SelectNodes("Menu/Module");

            if ((list != null) && (list.Count != 0))
            {
                _moduleList.Clear();
                foreach (XmlNode node in list)
                {
                    NavModule module = new NavModule {
                        Title = node.Attributes["Title"].Value,
                        ID    = node.Attributes["ID"].Value
                    };
                    XmlAttribute attribute = node.Attributes["Link"];
                    if (attribute != null)
                    {
                        module.Link = attribute.Value.StartsWith("http") ? attribute.Value : (Globals.ApplicationPath + "/Admin/" + attribute.Value);
                    }
                    XmlAttribute attribute2 = node.Attributes["IsDivide"];
                    if ((attribute2 != null) && (attribute2.Value.ToLower() == "true"))
                    {
                        module.IsDivide = true;
                    }
                    XmlAttribute attribute3 = node.Attributes["Class"];
                    if (attribute3 != null)
                    {
                        module.Class = attribute3.Value;
                    }
                    this.LoadItems(module, node);
                    _moduleList.Add(module.ID, module);
                }
            }
        }
Beispiel #5
0
        private void LoadItems(NavModule module, XmlNode moduleNode)
        {
            XmlNodeList list = moduleNode.SelectNodes("Item");

            if ((list != null) && (list.Count != 0))
            {
                foreach (XmlNode node in list)
                {
                    NavItem      item      = new NavItem();
                    XmlAttribute attribute = node.Attributes["Title"];
                    if (attribute != null)
                    {
                        item.SpanName = attribute.Value;
                    }
                    XmlAttribute attribute2 = node.Attributes["Class"];
                    if (attribute2 != null)
                    {
                        item.Class = attribute2.Value;
                    }
                    item.ID = node.Attributes["ID"].Value;
                    module.ItemList.Add(item.ID, item);
                    this.LoadPageLinks(item, node);
                }
            }
        }
Beispiel #6
0
        private void CheckRolePermission(NavModule module)
        {
            string link  = module.Link;
            string text  = string.Empty;
            string text2 = string.Empty;

            foreach (KeyValuePair <string, NavItem> current in module.ItemList)
            {
                foreach (KeyValuePair <string, NavPageLink> current2 in current.Value.PageLinks)
                {
                    if (string.Equals(link, current2.Value.Link, StringComparison.CurrentCultureIgnoreCase))
                    {
                        text = current2.Value.ID;
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(text))
                {
                    break;
                }
            }
            int  roleId = 0;
            bool flag   = false;

            Globals.GetCurrentManagerUserId(out roleId, out flag);
            if (!ManagerHelper.IsHavePermission(module.ID, text, roleId))
            {
                foreach (KeyValuePair <string, NavItem> current in module.ItemList)
                {
                    foreach (KeyValuePair <string, NavPageLink> current2 in current.Value.PageLinks)
                    {
                        bool flag2 = ManagerHelper.IsHavePermission(module.ID, current2.Value.ID, roleId);
                        if (flag2)
                        {
                            text2 = current2.Value.Link;
                            break;
                        }
                    }
                    if (!string.IsNullOrEmpty(text2))
                    {
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(text2))
                {
                    module.Link = text2;
                }
            }
        }
Beispiel #7
0
        private void CheckRolePermission(NavModule module)
        {
            string link = module.Link;
            string iD   = string.Empty;
            string str3 = string.Empty;

            foreach (KeyValuePair <string, NavItem> pair in module.ItemList)
            {
                foreach (KeyValuePair <string, NavPageLink> pair2 in pair.Value.PageLinks)
                {
                    if (string.Equals(link, pair2.Value.Link, StringComparison.CurrentCultureIgnoreCase))
                    {
                        iD = pair2.Value.ID;
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(iD))
                {
                    break;
                }
            }
            int  roleId    = 0;
            bool isDefault = false;

            Globals.GetCurrentManagerUserId(out roleId, out isDefault);
            if (!ManagerHelper.IsHavePermission(module.ID, iD, roleId))
            {
                foreach (KeyValuePair <string, NavItem> pair3 in module.ItemList)
                {
                    foreach (KeyValuePair <string, NavPageLink> pair4 in pair3.Value.PageLinks)
                    {
                        if (ManagerHelper.IsHavePermission(module.ID, pair4.Value.ID, roleId))
                        {
                            str3 = pair4.Value.Link;
                            break;
                        }
                    }
                    if (!string.IsNullOrEmpty(str3))
                    {
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(str3))
                {
                    module.Link = str3;
                }
            }
        }
Beispiel #8
0
        public string RenderLeftMenu(string currentModuleId, string currentPageId)
        {
            NavModule     module   = _moduleList[currentModuleId];
            StringBuilder leftMenu = new StringBuilder();

            foreach (NavItem item in module.ItemList.Values)
            {
                if (!string.IsNullOrEmpty(item.SpanName))
                {
                    leftMenu.AppendFormat("<em class=\"{0}\"></em>", item.Class).AppendLine();
                    leftMenu.AppendFormat("<span>{0}</span>", item.SpanName).AppendLine();
                }
                leftMenu.AppendFormat("<ul iid=\"{0}\">", item.ID).AppendLine();
                this.AppendLinks(leftMenu, item, currentPageId);
                leftMenu.AppendLine("</ul>");
            }
            return(leftMenu.ToString());
        }