예제 #1
0
        private List <ControlPanelLocalizedMenuEntity> GetMatchedAuthMenuData(List <ControlPanelLocalizedMenuEntity> menuList, List <AuthFunctionMsg> functionList)
        {
            List <ControlPanelLocalizedMenuEntity> pageItems = menuList.FindAll(menu =>
            {
                if (menu.Type == MenuType.Category)
                {
                    return(true);
                }
                if (menu.Type == MenuType.Link)
                {
                    //保证当前的Link有对应的Page存在
                    var page = menuList.FirstOrDefault(p => p.MenuId.ToString() == menu.LinkPath);
                    if (page != null)
                    {
                        var isExists = false;
                        if (StringUtility.IsNullOrEmpty(page.AuthKey))
                        {
                            isExists = true;
                        }
                        else
                        {
                            isExists = functionList.Exists(function => StringUtility.AreTheSameIgnoreCase(page.ApplicationId, function.ApplicationId) &&
                                                           StringUtility.AreTheSameIgnoreCase(page.AuthKey, function.Name));
                        }

                        if (isExists)
                        {
                            menu.DisplayName   = page.DisplayName;
                            menu.LinkPath      = page.LinkPath;
                            menu.IsDisplayCode = page.IsDisplayCode;
                            menu.StatusCode    = page.StatusCode;
                            return(true);
                        }
                        return(false);
                    }
                    return(false);
                }

                if (menu.Type == MenuType.Page)
                {
                    if (StringUtility.IsNullOrEmpty(menu.AuthKey))
                    {
                        return(true);
                    }
                    var isExists = functionList.Exists(function => StringUtility.AreTheSameIgnoreCase(menu.ApplicationId, function.ApplicationId) && StringUtility.AreTheSameIgnoreCase(menu.AuthKey, function.Name));
                    return(isExists);
                }

                return(false);
            });

            return(pageItems);
        }