예제 #1
0
        public new ActionResult User(long[] ids)
        {
            if (ids.Length == 0)
            {
                FlashInfo("请选择要查看用户的角色。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                var role = session.Load<Role>(m => m.Id.In(ids));
                if (role == null)
                {
                    FlashInfo("请选择要查看用户的角色。");
                    return Close();
                }

                ViewData["roleName"] = role.Name;
                ViewData["roleDeptName"] = role.Department == null ? string.Empty : role.Department.Name;

                var q = new Criteria<FullUser>().Select(m => m.Id)
                    .AndIn<Account>(x => x.Code, y => y.Name, new Criteria<Account>().AndIn<AccountRoleRef>(m => m.Id, n => n.AccountId, n => n.RoleId.In(ids)));
                if (q.Count() == 0)
                {
                    FlashInfo("该角色没有分配给任何用户。");
                }

                ViewData["selectedIds"] = q.PropertieValues<long>();
                q.Reset();
                //q.Reset().AndIn<Role>(m => m.DepartmentId, n => n.DepartmentId, n => n.Id.In(ids));
                var model = q.Find();
                return View(model);
            }
        }
예제 #2
0
        public ActionResult Pintask(long[] ids)
        {
            if (ids.Length == 0)
            {
                FlashInfo("请选择要查看用户的角色。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                var roles = session.Find<Role>(m => m.Id.In(ids));
                if (roles == null || roles.Count == 0)
                {
                    FlashInfo("请选择要查看用户的角色。");
                    return Close();
                }
                ViewData["roleName"] = string.Join(",", roles.Select(m => m.Name));

                var q = new Criteria<Navigation>().Select(m => m.Id).AndIn<AccountNavigationRef>(x => x.Id, y => y.NavigationId,
                    p => p.Type.Equals(AccountNavigationRef.RoleType) && p.OwnerId.In(ids));
                ViewData["selectedIds"] = q.PropertieValues<long>();
                var q2 = new Criteria<Navigation>().AndIn<NavigationPriviledge>(m => m.Id, n => n.NavigationId,
                    n => n.Flag.Equals(NavigationPriviledge.RoleType) && n.OwnerId.In(ids))
                    .And(p => p.Type.Equals(NavigationType.Module));
                var model = q2.Find().ToOrderList();
                return View(model);
            }
        }