Ejemplo n.º 1
0
        private void InitMemberShip()
        {
            Permission userPermission = MemberShipDataInitializer.CreatePermission(ResourceSetting.User, "用户管理员许可",
                                                                                   "用户管理员,所有与用户有关的权限、分组、组织单元",
                                                                                   UserOperator.Approve | UserOperator.Lock | UserOperator.Modify |
                                                                                   UserOperator.Read | UserOperator.SetPassword |
                                                                                   UserOperator.Delete |
                                                                                   UserOperator.ReadPrivat);

            Permission rolePermission = MemberShipDataInitializer.CreatePermission(ResourceSetting.Role, "角色管理员许可",
                                                                                   "角色完全控制,包括分配,删除、新增操作",
                                                                                   RoleOperator.Assign | RoleOperator.Modify | RoleOperator.Read);

            Permission memberPermission = MemberShipDataInitializer.CreatePermission(ResourceSetting.Account, "账户管理员可证",
                                                                                     "用户管理自己本身信息的许可证",
                                                                                     AccountOperator.ChangePassword |
                                                                                     AccountOperator.ViewPermission |
                                                                                     AccountOperator.ChangePrivateInfo);

            Permission permissionPermission = MemberShipDataInitializer.CreatePermission(ResourceSetting.Permission,
                                                                                         "许可证管理员", "许可证完全控制",
                                                                                         PermissionOperator.Read | PermissionOperator.Delete |
                                                                                         PermissionOperator.Edit);

            Permission orgPermission = MemberShipDataInitializer.CreatePermission(ResourceSetting.Org, "组织管理许可",
                                                                                  "用户所在部门及下属部门都可以控制",
                                                                                  OrgOperator.Delete);


            Role godRole = CreateRole(ResourceSetting.AdminRoleAccount, "管理员");

            godRole.Permissions.Add(rolePermission);
            godRole.Permissions.Add(userPermission);
            godRole.Permissions.Add(memberPermission);
            godRole.Permissions.Add(permissionPermission);
            godRole.Permissions.Add(orgPermission);

            OrnamentContext.DaoFactory.MemberShipFactory.CreateRoleDao().SaveOrUpdate(godRole);

            UserGroup adminGroup = CreateUserGroup("admin group");

            adminGroup.Roles.Add(godRole);

            IUserGroupDao ugDao = OrnamentContext.DaoFactory.MemberShipFactory.CreateUserGroupDao();

            ugDao.SaveOrUpdate(adminGroup);

            User adminUser = CreateUser(ResourceSetting.AdminRoleAccount, "123456", "*****@*****.**", "admin", "admin");

            adminUser.Roles.Add(godRole);
            adminUser.UserGroups.Add(adminGroup);
            OrnamentContext.DaoFactory.MemberShipFactory.CreateUserDao().SaveOrUpdate(adminUser);
            OrnamentContext.DaoFactory.MemberShipFactory.CreateUserDao().Flush();
            //组织管理员
            IRoleDao roleDao = OrnamentContext.DaoFactory.MemberShipFactory.CreateRoleDao();
            Role     orgRole = CreateRole(ResourceSetting.Org, "组织单元管理员");

            orgRole.Permissions.Add(orgPermission);
            roleDao.SaveOrUpdate(orgRole);
        }
Ejemplo n.º 2
0
 public static void MyClassInitialize(TestContext testContext)
 {
     Console.WriteLine(Assembly.GetExecutingAssembly().ToString());
     container = TestManager.ConfigureUnityContainer("unity");
     userProfileDao = container.Resolve<IUserProfileDao>();
     userService = container.Resolve<IUserService>();
     userGroupDao = container.Resolve<IUserGroupDao>();
     userGroupService = container.Resolve<IUserGroupService>();
 }
        public ActionResult Index(Pagination pagination)
        {
            IUserGroupDao     dao = _factory.CreateUserGroupDao();
            int               total;
            IList <UserGroup> result = dao.FindAll(pagination.CurrentPage, pagination.PageSize, out total);

            pagination.TotalRows = total;
            ViewData["Nav"]      = pagination;
            return(View(result));
        }
Ejemplo n.º 4
0
 public void Save(IUserGroupDao dao)
 {
     if (Id != null)
         Id = Id.Trim();
     UserGroup ug = !String.IsNullOrEmpty(Id) ? dao.Get(Id) : new UserGroup(Name);
     ug.Name = Name;
     ug.Remarks = Remark;
     ug.Roles.Clear();
     ug.Roles.AddAll(Roles);
     dao.SaveOrUpdate(ug);
 }
Ejemplo n.º 5
0
        public static UserGroup CreateUserGroup(string name)
        {
            IUserGroupDao dao = OrnamentContext.DaoFactory.MemberShipFactory.CreateUserGroupDao();
            UserGroup     ug  = dao.GetByName(name);

            if (ug != null)
            {
                return(ug);
            }
            return(new UserGroup(name));
        }
Ejemplo n.º 6
0
        public void Save(IUserGroupDao dao)
        {
            if (Id != null)
            {
                Id = Id.Trim();
            }
            UserGroup ug = !String.IsNullOrEmpty(Id) ? dao.Get(Id) : new UserGroup(Name);

            ug.Name    = Name;
            ug.Remarks = Remark;
            ug.Roles.Clear();
            ug.Roles.AddAll(Roles);
            dao.SaveOrUpdate(ug);
        }
Ejemplo n.º 7
0
        public ActionResult Assign(string[] roles, string[] userGroups, string loginId)
        {
            IRoleDao      roleDao      = _memberShipFactory.CreateRoleDao();
            IUserGroupDao userGroupDao =
                _memberShipFactory.CreateUserGroupDao();
            User user = _memberShipFactory.CreateUserDao().GetByLoginId(loginId);

            user.Roles.Clear();
            foreach (Role role in roleDao.GetRolesByIds(roles))
            {
                user.Roles.Add(role);
            }
            user.UserGroups.Clear();
            foreach (UserGroup ug in userGroupDao.GetUserGroups(userGroups))
            {
                user.UserGroups.Add(ug);
            }
            _memberShipFactory.CreateUserDao().SaveOrUpdate(user);
            _memberShipFactory.CreateUserDao().Flush();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
 public UserGroupBuilder(IUserGroupDao userGroupDao)
 {
     _userGroupDao = userGroupDao;
     _name         = "Gruppe " + _random.Next(1, 9999);
 }
Ejemplo n.º 9
0
 public AccountBuilder(IUserGroupDao userGroupDao)
 {
     _userGroupDao = userGroupDao;
 }
 public UsersUserGroupsParamConverter(IUserGroupDao groupDao, IUserDao userDao)
 {
     _groupDao = groupDao;
     _userDao  = userDao;
 }
Ejemplo n.º 11
0
 public UserGroupMemberShipBuilder(IUserGroupDao userGroupDao)
 {
     _userGroupDao = userGroupDao;
 }
Ejemplo n.º 12
0
 public UserGroupService(IUserGroupDao userGroupDao)
 {
     UserGroupDao = userGroupDao;
 }