コード例 #1
0
        /// <summary>
        /// 主页
        /// </summary>
        /// <returns>动作结果</returns>
        public ActionResult Index()
        {
            var comData = HttpContext.CreateCommonUseData(ComUseDataFactory, menuCode: "Home", functionCodes: "Query");
            var user    = UserTool <int> .GetCurrUser(comData);

            return(View(UserMenuService.CanAccessMenus(user.Id, comData)));
        }
コード例 #2
0
        public void TestGetAdminUserMenu2()
        {
            UserMenuService   service   = new UserMenuService();
            UserMenuViewModel ViewModel = service.GetAdminMenuViewModel("aa");

            Console.WriteLine(UtilTest.GetJson(ViewModel));
        }
コード例 #3
0
 public AppController()
     : base()
 {
     userAppService = new UserAppService();
     menuService    = new UserMenuService();
     logService     = new UserLogService();
 }
コード例 #4
0
 public CmsInstallerBase()
 {
     installerService = new AppInstallerService();
     appService       = new UserAppService();
     menuService      = new UserMenuService();
     sectionService   = new ContentSectionService();
     tplService       = new ContentCustomTemplateService();
 }
コード例 #5
0
 public SpaceLayoutController()
 {
     skinService     = new SkinService();
     userAppService  = new UserAppService();
     visitorService  = new VisitorService();
     menuService     = new UserMenuService();
     siteSkinService = new SiteSkinService();
 }
コード例 #6
0
        public void TestGetUserMenu()
        {
            UserMenuService   service   = new UserMenuService();
            int               userID    = 2;
            UserMenuViewModel ViewModel = service.GetUserMenuViewModel(userID);

            Console.WriteLine(UtilTest.GetJson(ViewModel));
        }
コード例 #7
0
        public UserHomeInstaller()
        {
            sectionService = new ContentSectionService();
            appService     = new UserAppService();
            menuService    = new UserMenuService();
            appinfoService = new AppInstallerService();

            lbl = lang.getByApp(typeof(ContentApp));
        }
コード例 #8
0
        public void TestSetUserMenu()
        {
            UserMenuService   service   = new UserMenuService();
            int               userID    = 23;
            string            menuIDs   = "1P|3P|4P|4.1|4.2|4.3|4.4|5P|5.1|5.2|5.3|6P|6.1|6.2|6.3|6.4";
            UserMenuViewModel ViewModel = service.SetUserMenu(userID, menuIDs);

            Console.WriteLine(UtilTest.GetJson(ViewModel));
        }
コード例 #9
0
        }//end function IsAuthenticated

        public static bool IsAllowed(string Role, string MenuName, string MenuGroupName)
        {
            IUserAccountService _userAccountService = new UserAccountService(new UserAccountRepository(), new UserAccountValidator());
            IUserAccessService  _userAccessService  = new UserAccessService(new UserAccessRepository(), new UserAccessValidator());
            IUserMenuService    _userMenuService    = new UserMenuService(new UserMenuRepository(), new UserMenuValidator());

            UserAccount userAccount = _userAccountService.GetObjectById(GetUserId());

            if (userAccount == null)
            {
                return(false);
            }
            if (userAccount.IsAdmin)
            {
                return(true);
            }
            UserMenu userMenu = _userMenuService.GetObjectByNameAndGroupName(MenuName, MenuGroupName);

            if (userMenu != null)
            {
                UserAccess userAccess = _userAccessService.GetObjectByUserAccountIdAndUserMenuId(userAccount.Id, userMenu.Id);
                if (userAccess != null)
                {
                    switch (Role.ToLower())
                    {
                    case "manualpricing": return(userAccess.AllowSpecialPricing);

                    case "view": return(userAccess.AllowView);

                    case "create": return(userAccess.AllowCreate);

                    case "edit": return(userAccess.AllowEdit);

                    case "delete": return(userAccess.AllowDelete);

                    case "undelete": return(userAccess.AllowUndelete);

                    case "confirm": return(userAccess.AllowConfirm);

                    case "unconfirm": return(userAccess.AllowUnconfirm);

                    case "paid": return(userAccess.AllowPaid);

                    case "unpaid": return(userAccess.AllowUnpaid);

                    case "reconcile": return(userAccess.AllowReconcile);

                    case "unreconcile": return(userAccess.AllowUnreconcile);

                    case "print": return(userAccess.AllowPrint);
                    }
                }
            }
            return(false);
        }//end function IsAllowed
コード例 #10
0
 public SysController(RoleService roleService
                      , LogService logService
                      , MenuService menuService
                      , RoleMenuService roleMenuService
                      , UserMenuService userMenuService
                      , UserService userService
                      , IOptions <AppSettings> settings
                      , ConfigInfoService configInfoService
                      , ICacheService cacheService)
 {
     _roleService       = roleService;
     _logService        = logService;
     _menuService       = menuService;
     _roleMenuService   = roleMenuService;
     _userMenuService   = userMenuService;
     _userService       = userService;
     _settings          = settings;
     _appSettings       = _settings.Value;
     _configInfoService = configInfoService;
     _cacheService      = cacheService;
 }
コード例 #11
0
ファイル: UserInitHelper.cs プロジェクト: zuhuizou/wojilu
        public virtual List <IMenu> GetMenus(IMember owner)
        {
            UserMenuService menuService = new UserMenuService();

            return(menuService.GetList(owner));
        }
コード例 #12
0
ファイル: RegUtils.cs プロジェクト: china99ljs/wojilu
        private static void addUserAppAndMenus(User user, MvcContext ctx)
        {
            if (strUtil.IsNullOrEmpty(config.Instance.Site.UserInitApp))
            {
                return;
            }

            IMemberAppService appService  = new UserAppService();
            IMenuService      menuService = new UserMenuService();

            List <String> menus = new List <string>();

            String[] arr = config.Instance.Site.UserInitApp.Split(',');
            foreach (String app in arr)
            {
                if (strUtil.IsNullOrEmpty(app))
                {
                    continue;
                }
                menus.Add(app.Trim());
            }

            if (menus.Contains("home"))
            {
                new UserHomeInstaller().Install(ctx, user, wojilu.lang.get("homepage"), wojilu.Common.AppBase.AccessStatus.Public);
            }

            if (menus.Contains("blog"))
            {
                IMemberApp blogApp = appService.Add(user, "博客", 2);
                // 添加菜单:此处需要明确传入MemberType,否则将会使用ctx.Owner,也就是Site的值,导致bug
                String blogUrl = UrlConverter.clearUrl(alink.ToUserAppFull(blogApp), ctx, typeof(User).FullName, user.Url);
                menuService.AddMenuByApp(blogApp, blogApp.Name, "", blogUrl);
            }

            if (menus.Contains("photo"))
            {
                IMemberApp photoApp = appService.Add(user, "相册", 3);
                String     photoUrl = UrlConverter.clearUrl(alink.ToUserAppFull(photoApp), ctx, typeof(User).FullName, user.Url);
                menuService.AddMenuByApp(photoApp, photoApp.Name, "", photoUrl);
            }

            if (menus.Contains("microblog"))
            {
                IMenu menu = getMenu(user, "微博", alink.ToUserMicroblog(user), ctx);
                menuService.Insert(menu, user, user);
            }

            //if (menus.Contains( "share" )) {
            //    IMenu menu = getMenu( user, "转帖", lnkToUser( new Users.ShareController().Index ), ctx );
            //    menuService.Insert( menu, user, user );
            //}

            if (menus.Contains("friend"))
            {
                IMenu menu = getMenu(user, "好友", lnkToUser(user, new Users.FriendController().FriendList), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("visitor"))
            {
                IMenu menu = getMenu(user, "访客", lnkToUser(user, new Users.VisitorController().Index), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("forumpost"))
            {
                IMenu menu = getMenu(user, "论坛帖子", lnkToUser(user, new Users.ForumController().Topic), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("about"))
            {
                IMenu menu = getMenu(user, "关于我", lnkToUser(user, new Users.ProfileController().Main), ctx);
                menuService.Insert(menu, user, user);
            }

            if (menus.Contains("feedback"))
            {
                IMenu menu = getMenu(user, "留言", lnkToUser(user, new Users.FeedbackController().List), ctx);
                menuService.Insert(menu, user, user);
            }
        }
コード例 #13
0
 public MenuController(UserMenuService userMenuService)
 {
     this._userMenuService = userMenuService;
 }
コード例 #14
0
 public MenuController()
 {
     menuService = new UserMenuService();
     logService  = new UserLogService();
 }