Beispiel #1
0
        public override int ProcessCreateRoleRequest(CreateRole rpc)
        {
            Session session = Session.Get(rpc);

            long roleid = _trole.Insert(new BRoleData()
            {
                Name = rpc.Argument.Name
            });

            // duplicate name check
            if (false == _trolename.TryAdd(rpc.Argument.Name, new BRoleId()
            {
                Id = roleid
            }))
            {
                return(ReturnCode(ResultCodeCreateRoleDuplicateRoleName));
            }

            var account = _taccount.GetOrAdd(session.Account);

            account.Roles.Add(roleid);

            // initialize role data
            Game.App.Instance.Game_Bag.GetBag(roleid).SetCapacity(50);

            session.SendResponse(rpc);
            return(Procedure.Success);
        }
Beispiel #2
0
        public async Task <IActionResult> CreateRole(CreateRole model)
        {
            if (ModelState.IsValid)
            {
                IdentityRole identityRole = new IdentityRole //create a new identity role instance
                {
                    Name = model.RoleName
                };

                IdentityResult result = await roleManager.CreateAsync(identityRole);

                if (result.Succeeded)
                {
                    return(RedirectToAction("ListRoles", "administration"));
                }

                foreach (IdentityError error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }
            }


            return(View(model));
        }
        public async Task<ActionResult> Index()
        {
            serviceId = "AC";
            serviceSort = 10000;
            if (serviceDao.Entities.Where(m => m.Id == serviceId).Count() > 0)
            {
                return Content("数据库中已经存在数据库,不需要重新生成。");
            }
            //部门
            CreateDepartment();

            var service = new CreateService(serviceId, "统一授权中心", 1, "http://int.zhongyi-itl.com/");
            await this.commandService.Execute(service);

            var user = new CreateUser("sysadmin", "系统管理员", "Sysadmin", "*****@*****.**", "15817439909", "系统管理员");
            await this.commandService.Execute(user);

            var role = new CreateRole("系统管理员", 0);
            await this.commandService.Execute(role);
            await this.commandService.Execute(new SetUserRoles(user.AggregateRootId, new string[] { role.AggregateRootId }));


            var menu = new CreateMenu("统一授权中心", (int)MenuType.Web, "", "", serviceSort);
            await this.commandService.Execute(menu);
            var menuRoot = menu.AggregateRootId;

            var module = new CreateModule(serviceId, "System", "系统管理", serviceSort);
            await this.commandService.Execute(module);
            var moduleId = module.AggregateRootId;

            menu = new CreateMenu("系统管理", (int)MenuType.Web, "", "", serviceSort + 10, menuRoot);
            await this.commandService.Execute(menu);
            var menuId = menu.AggregateRootId;

            string moduleId2 = await QuickModule("Sys", "Department", "部门信息", moduleId, menuId, 11);

            var permission = new CreatePermission("DepartmentUser", "设置用户", moduleId2);
            await this.commandService.Execute(permission);

            //角色管理
            module = new CreateModule(serviceId, "Role", "角色管理", serviceSort + 16, moduleId);
            await this.commandService.Execute(module);
            permission = new CreatePermission("ViewRole", "查看", module.AggregateRootId);
            await this.commandService.Execute(permission);
            var viewRolePermissionId = permission.AggregateRootId;
            menu = new CreateMenu("角色管理", (int)MenuType.Web, "Sys/RoleList.aspx", "", serviceSort + 16, menuId, permission.AggregateRootId);
            await this.commandService.Execute(menu);
            permission = new CreatePermission("NewRole", "新增", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ModifyRole", "编辑", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("DeleteRole", "删除", module.AggregateRootId);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("PermissionRole", "分配权限", module.AggregateRootId);
            await this.commandService.Execute(permission);
            await this.commandService.Execute(new SetRolePermissions(role.AggregateRootId, new string[] { viewRolePermissionId, permission.AggregateRootId }));

            //用户管理
            moduleId2 = await QuickModule("Sys", "User", "用户管理", moduleId, menuId, 21);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("ChangePwdUser", "修改密码", moduleId2);
            await this.commandService.Execute(permission);
            permission = new CreatePermission("RoleUser", "分配角色", moduleId2);
            await this.commandService.Execute(permission);
            await QuickModule("Sys", "Service", "服务管理", moduleId, menuId, 26);
            await QuickModule("Sys", "Module", "模块管理", moduleId, menuId, 31);
            await QuickModule("Sys", "Menu", "菜单管理", moduleId, menuId, 36);
            await QuickModule("Sys", "Authority", "权限管理", moduleId, menuId, 41);

            CreateRole();
            return Content("");
        }
        private async void CreateRole()
        {
            var role = new CreateRole("在职员工", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("离职员工", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("领导层", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("财务", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("综合管理", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("产品研发", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("专业认证", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("讯息技术", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("项目室", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("商务室", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("猎头经理", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("猎头顾问", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("猎头研究员", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("前海培训业务总监", 0);
            await this.commandService.Execute(role);

            role = new CreateRole("前海培训客户经理", 0);
            await this.commandService.Execute(role);
        }