//////////////////////////////////////////////////////////////////////////////////////////////////////
        /// 角色模块关联关系相关
        //////////////////////////////////////////////////////////////////////////////////////////////////////

        #region public string[] GetScopeModuleIdsByRoleId(UserInfo userInfo, string roleId, string permissionItemCode) 获取指定角色在某个权限域下所有模块主键数组
        /// <summary>
        /// 获取指定角色在某个权限域下所有模块主键数组
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <returns>模块主键数组</returns>
        public string[] GetScopeModuleIdsByRoleId(UserInfo userInfo, string roleId, string permissionItemCode)
        {
            string[] returnValue = null;
            var      parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_GetScopeModuleIdsByRoleId);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                returnValue = new RoleScopeManager(dbProvider, userInfo).GetModuleIds(roleId, permissionItemCode);
            });
            return(returnValue);
        }
        /// <summary>
        /// 清除指定角色所有权限范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <returns>影响的行数</returns>
        public int ClearRolePermissionScope(UserInfo userInfo, string roleId, string permissionItemCode)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_ClearRolePermissionScope, "角色主键:" + roleId);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue = new RoleScopeManager(dbProvider, userInfo).ClearRolePermissionScope(roleId, permissionItemCode);
            });
            return(returnValue);
        }
        /// <summary>
        /// 清除指定角色的所有权限
        ///
        /// 1.清除角色的用户归属。
        /// 2.清除角色的模块权限。
        /// 3.清除角色的操作权限。
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>影响的行数</returns>
        public int ClearRolePermissionByRoleId(UserInfo userInfo, string roleId)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_ClearRolePermissionByRoleId, "角色主键:" + roleId);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue += new PiUserRoleManager(dbProvider, userInfo).EliminateRoleUser(roleId);
                returnValue += new RolePermissionManager(dbProvider, userInfo).RevokeAll(roleId);
                returnValue += new RoleScopeManager(dbProvider, userInfo).RevokeAll(roleId);
            });
            return(returnValue);
        }
        /// <summary>
        /// 撤消指定角色某个权限域的模块授权范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <param name="revokeModuleId">撤消模块主键数组</param>
        /// <returns>影响的行数</returns>
        public int RevokeRoleModuleScope(UserInfo userInfo, string roleId, string permissionItemCode, string revokeModuleId)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_RevokeRoleModuleScope, "角色主键:" + roleId + ",模块主键:" + revokeModuleId);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                if (revokeModuleId != null)
                {
                    returnValue += new RoleScopeManager(dbProvider, userInfo).RevokeModule(roleId, permissionItemCode, revokeModuleId);
                }
            });
            return(returnValue);
        }
        /// <summary>
        /// 授予角色某个权限域的模块授权范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <param name="grantModuleIds">授予模块主键数组</param>
        /// <returns>影响的行数</returns>
        public int GrantRoleModuleScope(UserInfo userInfo, string roleId, string permissionItemCode, string[] grantModuleIds)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_GrantRoleModuleScope, "角色主键:" + roleId + ",授予模块主键数组:" + BusinessLogic.ArrayToList(grantModuleIds));

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                if (grantModuleIds != null)
                {
                    returnValue += new RoleScopeManager(dbProvider, userInfo).GrantModules(roleId, permissionItemCode, grantModuleIds);
                }
            });
            return(returnValue);
        }
        /// <summary>
        /// 撤消角色的某个权限域的组织范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="permissionItemId">操作权限主键</param>
        /// <param name="revokeOrganizeIds">撤消的组织主键数组</param>
        /// <returns>影响的行数</returns>
        public int RevokeRoleOrganizeScope(UserInfo userInfo, string roleId, string permissionItemId, string[] revokeOrganizeIds)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_RevokeRoleOrganizeScope, "角色主键:" + roleId + ",撤消的组织主键数组:" + BusinessLogic.ArrayToList(revokeOrganizeIds));

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                if (revokeOrganizeIds != null && revokeOrganizeIds.Length > 0)
                {
                    returnValue += new RoleScopeManager(dbProvider, userInfo).RevokeOrganizes(roleId, permissionItemId, revokeOrganizeIds);
                }
            });
            return(returnValue);
        }
        /// <summary>
        /// 授予角色某个权限域的用户范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <param name="grantUserIds">授予用户主键数组</param>
        /// <returns>影响的行数</returns>
        public int GrantRoleUserScope(UserInfo userInfo, string roleId, string permissionItemCode, string[] grantUserIds)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_GrantRoleUserScope);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                if (grantUserIds != null)
                {
                    returnValue += new RoleScopeManager(dbProvider, userInfo).GrantUsers(roleId, permissionItemCode, grantUserIds);
                }
            });
            return(returnValue);
        }