Example #1
0
 public void RemoveModule(MenuInfo Module)
 {
     _IMenu.Update(Module);
 }
Example #2
0
        private List <MenuInfo> convert(List <ConfigNode> nodes, string Key, string userIdentity, string businessKey)
        {
            var temp = new List <MenuInfo>();

            nodes.ForEach(n =>
            {
                var menu = new MenuInfo()
                {
                    Key  = string.Format("{0}.Menus.{1}", Key, n.NodeName),
                    Name = n.NodeName,
                    Text = n.NodeValue
                };

                n.ChildNodes.ForEach(cn =>
                {
                    switch (cn.NodeName)
                    {
                    case "href":
                        {
                            menu.Href = cn.NodeValue;
                        }
                        break;

                    case "icon":
                        {
                            menu.Icon = cn.NodeValue;
                        }
                        break;

                    case "param":
                        {
                            menu.Param = cn.NodeValue;
                        }
                        break;

                    case "permission":
                        {
                            menu.PermissionKey = cn.NodeValue;
                        }
                        break;

                    case "index":
                        {
                            menu.IndexValue = int.Parse(cn.NodeValue);
                        }
                        break;

                    case "user":
                        {
                            if (!string.IsNullOrEmpty(userIdentity))
                            {
                                menu.IsFavorite = isFavorite(cn, userIdentity);
                            }
                            break;
                        }

                    case "Menus":
                        {
                            menu.SubMenus = convert(cn.ChildNodes, menu.Key, userIdentity, businessKey);
                        }
                        break;
                    }
                });
                //temp.Add(menu);
                if (string.IsNullOrEmpty(menu.PermissionKey) ||
                    _IPermission.Check("data-menus-all", userIdentity, businessKey) > PermissionStatus.Reject ||    //  菜单的全部查看权
                    _IPermission.Check(menu.PermissionKey, userIdentity, businessKey) != PermissionStatus.Reject)
                {
                    temp.Add(menu);
                }
            });

            return(temp.OrderBy(m => m.IndexValue).ToList());
        }