Beispiel #1
0
        public bool CreateRoleDepartment(ref List <string> result)
        {
            WXQ.BusinessCore.systemmanage.DepartmentOp departmentOp = new DepartmentOp(0);

            int  roleId       = 0;
            int  departmentId = 0;
            bool returnvalue  = true;
            ListResult <Enties.Department> departments = departmentOp.GetDepartmentList("", 0, 1, 10);

            if (departments.Result != null && departments.Result.Count > 0)
            {
                departmentId = departments.Result[0].DepartmentId;
            }
            WXQ.BusinessCore.systemmanage.UserOp userOp = new UserOp(0);
            PageModel pageModel = new PageModel
            {
                PageIndex = 1,
                PageSize  = 100
            };

            WXQ.BusinessCore.systemmanage.RoleOp roleOp = new RoleOp(0);
            List <Enties.Role> roles = roleOp.GetRoleList();

            if (roles != null && roles.Count > 0)
            {
                roleId = roles[0].RoleId;
            }

            #region 部门和用户关系

            DepartmentRoleManager departmentRoleManager = new DepartmentRoleManager();
            DepartmentRole        dr = new DepartmentRole
            {
                RoleId       = roleId,
                DepartmentId = departmentId
            };

            if (departmentRoleManager.Insert(dr))
            {
                result.Add("添加部门和角色关系成功");
            }
            else
            {
                result.Add("添加部门和角色关系失败");
            }

            #endregion 部门和用户关系

            return(returnvalue);
        }
Beispiel #2
0
        public bool CreateUserDepartment(ref List <string> result)
        {
            WXQ.BusinessCore.systemmanage.DepartmentOp departmentOp = new DepartmentOp(0);

            int  userId       = 0;
            int  departmentId = 0;
            bool returnvalue  = true;
            ListResult <Enties.Department> departments = departmentOp.GetDepartmentList("", 0, 1, 10);

            if (departments.Result != null && departments.Result.Count > 0)
            {
                departmentId = departments.Result[0].DepartmentId;
            }
            WXQ.BusinessCore.systemmanage.UserOp userOp = new UserOp(0);
            PageModel pageModel = new PageModel
            {
                PageIndex = 1,
                PageSize  = 100
            };

            ListResult <Enties.Users> users = userOp.GetUserList("", pageModel);

            if (users.Result != null && users.Result.Count > 0)
            {
                userId = users.Result[0].UsersId;
            }

            #region 部门和用户关系

            List <int> userIds = new List <int>
            {
                userId
            };
            if (departmentOp.AddUserForDepartment(departmentId, userIds))
            {
                result.Add("添加部门和用户关系成功");
            }
            else
            {
                result.Add("添加部门和用户关系失败");
            }

            #endregion 部门和用户关系

            return(returnvalue);
        }
Beispiel #3
0
        /// <summary>
        /// 创建关系
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool CreateRef(ref List <string> result)
        {
            bool returnvalue = true;
            int  userId      = 0;

            int roleId = 0;

            WXQ.BusinessCore.systemmanage.UserOp userOp = new UserOp(0);
            PageModel pageModel = new PageModel
            {
                PageIndex = 1,
                PageSize  = 100
            };
            ListResult <Enties.Users> users = userOp.GetUserList("", pageModel);

            if (users.Result != null && users.Result.Count > 0)
            {
                userId = users.Result[0].UsersId;
            }
            WXQ.BusinessCore.systemmanage.RoleOp roleOp = new RoleOp(0);
            List <Enties.Role> roles = roleOp.GetRoleList();

            if (roles != null && roles.Count > 0)
            {
                roleId = roles[0].RoleId;

                #region 角色和用户关系

                if (roleOp.AddUserForRole(roleId, userId))
                {
                    result.Add("添加角色和用户关系成功");
                }
                else
                {
                    result.Add("添加角色和用户关系失败");
                }

                #endregion 角色和用户关系
            }

            return(returnvalue);
        }
Beispiel #4
0
        public bool CreateUser(ref List <string> result)
        {
            WXQ.BusinessCore.systemmanage.UserOp op = new UserOp(0);

            WXQ.Enties.Users u = new Enties.Users
            {
                NickName     = "超级管理员",
                UserName     = "******",
                Introduction = "这是一个超级管理员账号,不要删除",
                PassWord     = "******"//密码12345678
            };
            bool returnvalue = op.InsertUsers(u);

            if (returnvalue)
            {
                result.Add("添加管理员成功");
            }
            else
            {
                result.Add("添加管理员失败");
            }

            return(returnvalue);
        }