示例#1
0
        public static TimMenu FilterUserMenu(TimMenu menu, string userId)
        {
            TimMenu timMenu = new TimMenu();

            timMenu.Id       = menu.Id;
            timMenu.Name     = menu.Name;
            timMenu.Order    = menu.Order;
            timMenu.FatherId = menu.FatherId;
            timMenu.Type     = menu.Type;
            timMenu.Url      = menu.Url;
            foreach (TimMenu menu2 in menu.Children)
            {
                bool flag = menu2.Type == ModuleType.C;
                if (flag)
                {
                    TimMenu timMenu2 = FuncModelUtils.FilterUserMenu(menu2, userId);
                    bool    flag2    = timMenu2 != null && timMenu2.Children.Count > 0;
                    if (flag2)
                    {
                        timMenu.Children.Add(timMenu2);
                    }
                }
                else
                {
                    UserModulePermission modulePermission = PermissionUtils.GetUserModulePermission(userId, menu2.Id);
                    bool flag3 = modulePermission != null && modulePermission.View;
                    if (flag3)
                    {
                        timMenu.Children.Add(menu2);
                    }
                }
            }
            return(timMenu);
        }
示例#2
0
        private static TimMenu BuildFuncModel(int mdId)
        {
            TimMenu timMenu = new TimMenu();
            bool    flag    = mdId == 0;

            if (flag)
            {
                timMenu.Id       = mdId;
                timMenu.Name     = "应用功能模型";
                timMenu.Order    = 0;
                timMenu.FatherId = 0;
                timMenu.Type     = ModuleType.C;
            }
            else
            {
                FuncModel modelById = FuncModelUtils.GetModelById(mdId);
                bool      flag2     = modelById != null;
                if (flag2)
                {
                    timMenu.Id       = modelById.Id;
                    timMenu.Name     = modelById.Name;
                    timMenu.Order    = modelById.Order;
                    timMenu.FatherId = modelById.FatherId;
                    timMenu.Type     = modelById.Type;
                }
            }
            foreach (FuncModel funcModel in FuncModelUtils.GetModelByFatherId(mdId))
            {
                TimMenu utoMenu2 = FuncModelUtils.BuildFuncModel(funcModel.Id);
                bool    flag3    = utoMenu2 != null;
                if (flag3)
                {
                    timMenu.Children.Add(utoMenu2);
                }
            }
            return(timMenu);
        }