Example #1
0
        /// <summary>
        /// 清除角色组织机构关联
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>影响行数</returns>
        public int ClearOrganizationUser(BaseUserInfo userInfo, string roleId)
        {
            var result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseOrganizationManager(dbHelper, userInfo);
                result      = manager.ClearOrganization(userInfo.SystemCode, roleId);
            });

            return(result);
        }
Example #2
0
        /// <summary>
        /// 设置角色中的组织机构
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="organizationIds">组织机构主键数组</param>
        /// <returns>影响行数</returns>
        public int SetOrganizationToRole(BaseUserInfo userInfo, string roleId, string[] organizationIds)
        {
            var result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseOrganizationManager(dbHelper, userInfo);
                result      = manager.ClearOrganization(userInfo.SystemCode, roleId);
                // 小心异常,检查一下参数的有效性
                if (organizationIds != null)
                {
                    result += manager.AddToRole(userInfo.SystemCode, organizationIds, roleId);
                }
            });

            return(result);
        }