예제 #1
0
        //
        //  从角色中删除员工
        //

        #region public int RemoveFormRole(string userId, string roleId) 撤销角色权限
        /// <summary>
        /// 从角色中删除员工
        /// </summary>
        /// <param name="userId">员工主键</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>影响行数</returns>
        public int RemoveFormRole(string userId, string roleId)
        {
            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>(BaseUserRoleEntity.FieldUserId, userId));
            parameters.Add(new KeyValuePair <string, object>(BaseUserRoleEntity.FieldRoleId, roleId));
            string tableName = BaseUserRoleEntity.TableName;

            if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
            {
                tableName = BaseSystemInfo.SystemCode + "UserRole";
            }
            BaseUserRoleManager userRoleManager = new BaseUserRoleManager(this.DbHelper, this.UserInfo, tableName);

            return(userRoleManager.Delete(parameters));
        }
예제 #2
0
        public int ClearRole(string userId)
        {
            int returnValue = 0;

            returnValue += this.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldId, userId), new KeyValuePair <string, object>(BaseUserEntity.FieldRoleId, null));

            string tableName = BaseUserRoleEntity.TableName;

            if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
            {
                tableName = BaseSystemInfo.SystemCode + "UserRole";
            }

            BaseUserRoleManager userRoleManager = new BaseUserRoleManager(this.DbHelper, this.UserInfo, tableName);

            returnValue += userRoleManager.Delete(new KeyValuePair <string, object>(BaseUserRoleEntity.FieldUserId, userId));
            return(returnValue);
        }
예제 #3
0
        //
        // 加入到角色
        //


        #region public string AddToRole(string userId, string roleId) 为了提高授权的运行速度
        /// <summary>
        /// 为了提高授权的运行速度
        /// </summary>
        /// <param name="Id">主键</param>
        /// <param name="userId">用户主键</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>主键</returns>
        public string AddToRole(string userId, string roleId)
        {
            string             returnValue    = string.Empty;
            BaseUserRoleEntity userRoleEntity = new BaseUserRoleEntity();

            userRoleEntity.UserId            = int.Parse(userId);
            userRoleEntity.RoleId            = int.Parse(roleId);
            userRoleEntity.Enabled           = 1;
            userRoleEntity.DeletionStateCode = 0;
            string tableName = BaseUserRoleEntity.TableName;

            if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
            {
                tableName = BaseSystemInfo.SystemCode + "UserRole";
            }
            BaseUserRoleManager userRoleManager = new BaseUserRoleManager(this.DbHelper, this.UserInfo, tableName);

            return(userRoleManager.Add(userRoleEntity));
        }