コード例 #1
0
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.StaffService_SetDeleted);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var userManager           = new PiUserManager(dbProvider, userInfo);
                var staffManager          = new PiStaffManager(dbProvider, userInfo);
                PiStaffEntity staffEntity = null;
                for (int i = 0; i < ids.Length; i++)
                {
                    // 删除相应的用户
                    staffEntity = staffManager.GetEntity(ids[i]);
                    if (staffEntity.UserId != null)
                    {
                        userManager.SetDeleted(staffEntity.UserId);
                    }
                    // 删除职员
                    returnValue += staffManager.SetDeleted(ids[i], true);
                    var staffOrganizeManager = new PiStaffOrganizeManager(dbProvider, userInfo);
                    returnValue += staffOrganizeManager.SetDeleted(new string[] { PiStaffOrganizeTable.FieldStaffId }, new string[] { ids[i] });
                }
            });

            return(returnValue);
        }
コード例 #2
0
        /// <summary>
        /// 员工关联用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffId">员工主键</param>
        /// <param name="userId">用户主键</param>
        /// <returns>影响行数</returns>
        public int SetStaffUser(UserInfo userInfo, string staffId, string userId)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.StaffService_SetStaffUser, "员工主键:" + staffId + ",用户主键:" + userId);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var staffManager = new PiStaffManager(dbProvider, userInfo);
                if (string.IsNullOrEmpty(userId))
                {
                    returnValue = staffManager.SetProperty(staffId, PiStaffTable.FieldUserId, userId);
                }
                else
                {
                    // 一个用户只能帮定到一个帐户上,检查是否已经绑定过这个用户了。
                    string[] staffIds = staffManager.GetIds(new KeyValuePair <string, object>(PiStaffTable.FieldUserId, userId), new KeyValuePair <string, object>(PiStaffTable.FieldDeleteMark, 0));
                    if (staffIds == null || staffIds.Length == 0)
                    {
                        returnValue     = staffManager.SetProperty(staffId, PiStaffTable.FieldUserId, userId);
                        var userManager = new PiUserManager(dbProvider, userInfo);
                        var userEntity  = userManager.GetEntity(userId);
                        returnValue     = staffManager.SetProperty(staffId, PiStaffTable.FieldUserName, userEntity.UserName);
                    }
                }
            });
            return(returnValue);
        }
コード例 #3
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回消息</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <returns>主鍵</returns>
        public string Add(UserInfo userInfo, PiStaffEntity entity, out string statusCode, out string statusMessage, string organizeId = "")
        {
            string returnValue   = string.Empty;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.StaffService_AddStaff);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var manager   = new PiStaffManager(dbProvider, userInfo);
                returnValue   = manager.Add(entity, out returnCode);
                returnMessage = manager.GetStateMessage(returnCode);

                if (returnValue.Length > 0 && returnCode == StatusCode.OKAdd.ToString() && !string.IsNullOrEmpty(organizeId.Trim()))
                {
                    var staffOrganizeEntity = new PiStaffOrganizeEntity
                    {
                        StaffId    = BusinessLogic.ConvertToString(returnValue),
                        OrganizeId = BusinessLogic.ConvertToString(organizeId),
                        Enabled    = 1,
                        DeleteMark = 0
                    };
                    var staffOrganizeManager = new PiStaffOrganizeManager(dbProvider, userInfo);
                    staffOrganizeManager.Add(staffOrganizeEntity);
                }
            });

            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(returnValue);
        }
コード例 #4
0
        /// <summary>
        /// 批量设置表权限控制数据表的刪除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetTablePermissionScopeDeleted(UserInfo userInfo, string[] ids)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.TableColumnsService_SetTablePermissionScopeDeleted);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue = new TablePermissionScopeManager(dbProvider, userInfo).SetDeleted(ids);
            });
            return(returnValue);
        }
コード例 #5
0
        /// <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>
        /// 批量删除数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDeleteQueryEngineDefine(UserInfo userInfo, string[] ids)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.QueryEnginService_BatchDelete);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue = new QueryEngineDefineManager(dbProvider, userInfo).BatchDelete(ids);
            });
            return(returnValue);
        }
コード例 #7
0
        /// <summary>
        /// 清除指定用户的所有权限
        ///
        /// 1.清除用户的角色归属。
        /// 2.清除用户的模块权限。
        /// 3.清除用户的操作权限。
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <returns>受影响的行数</returns>
        public int ClearUserPermissionByUserId(UserInfo userInfo, string userId)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_ClearUserPermissionByUserId);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue = new UserPermissionManager(dbProvider, userInfo).ClearUserPermissionByUserId(userId);
            });

            return(returnValue);
        }
コード例 #8
0
        /// <summary>
        /// 批量移动数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeIds">主键数组</param>
        /// <param name="parentId">父节点主键</param>
        /// <returns>影响行数</returns>
        public int BatchMoveTo(UserInfo userInfo, string[] organizeIds, string parentId)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.OrganizeService_BatchMoveTo, "主键数组:" + BusinessLogic.ArrayToList(organizeIds) + ",父节点:" + parentId);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var organizeManager = new PiOrganizeManager(dbProvider, userInfo);
                returnValue        += organizeIds.Sum(t => organizeManager.MoveTo(t, parentId));
            });
            return(returnValue);
        }
コード例 #9
0
        /// <summary>
        /// 重新生成排序码
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchSetSortCode(UserInfo userInfo, string[] ids)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionItemService_BatchSetSortCode);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue = new PiPermissionItemManager(dbProvider, userInfo).BatchSetSortCode(ids);
            });

            return(returnValue);
        }
コード例 #10
0
        /// <summary>
        /// 批量刪除数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键陣列</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(UserInfo userInfo, string[] ids)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, string.Empty);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var manager = new CiDbLinkDefineManager(dbProvider, userInfo);
                returnValue = manager.Delete(ids);
            });
            return(returnValue);
        }
コード例 #11
0
        /// <summary>
        /// 批量保存角色数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entites">实体列表</param>
        /// <returns>影响的行数</returns>
        public int BatchSave(UserInfo userInfo, List <PiRoleEntity> entites)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.RoleService_BatchSave);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue = new PiRoleManager(dbProvider, userInfo).BatchSave(entites);
            });

            return(returnValue);
        }
コード例 #12
0
        /// <summary>
        /// 批量移动文件到指定文件夹
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids"></param>
        /// <param name="folderId">文件夹主键</param>
        /// <returns>受影响的行数</returns>
        public int BatchMoveTo(UserInfo userInfo, string[] ids, string folderId)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var fileManager = new CiFileManager(dbProvider, userInfo);
                returnValue    += ids.Sum(t => fileManager.MoveTo(t, folderId));
            });
            return(returnValue);
        }
コード例 #13
0
        /// <summary>
        /// 批量删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>受影响的行数</returns>
        public int SetDeleted(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, "SetDeleted");

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var manager = new CiItemsManager(dbProvider, userInfo);
                returnValue = manager.SetDeleted(ids);
            });
            return(returnValue);
        }
コード例 #14
0
        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ExceptionService_BatchDelete);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var manager = new CiExceptionManager(dbProvider, userInfo);
                returnValue = manager.Delete(ids);
            });
            return(returnValue);
        }
コード例 #15
0
        /// <summary>
        /// 批量设置默认角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userIds">用户主键数组</param>
        /// <param name="roleId">默认角色主键</param>
        /// <returns>影响行数</returns>
        public int BatchSetDefaultRole(UserInfo userInfo, string[] userIds, string roleId)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.UserService_BatchSetDefaultRole);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var userManager = new PiUserManager(dbProvider, userInfo);
                returnValue     = userManager.SetProperty(userIds, PiUserTable.FieldRoleId, roleId);
            });
            return(returnValue);
        }
コード例 #16
0
        /// <summary>
        /// 批量删除文件列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>受影响的行数</returns>
        public int BatchDelete(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var fileManager = new CiFileManager(dbProvider, userInfo);
                returnValue     = fileManager.Delete(ids);
            });
            return(returnValue);
        }
コード例 #17
0
        /// <summary>
        /// 移除角色用户关联
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>影响行数</returns>
        public int EliminateRoleUser(UserInfo userInfo, string roleId)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.RoleService_EliminateRoleUser, "角色主键:" + roleId);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                returnValue = new PiUserRoleManager(dbProvider, userInfo).EliminateRoleUser(roleId);
            });

            return(returnValue);
        }
コード例 #18
0
        /// <summary>
        /// 批量移动员工到指定组织机构
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">员工主键数组</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <returns>影响行数</returns>
        public int BatchMoveTo(UserInfo userInfo, string[] ids, string organizeId)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.StaffService_BatchMoveTo);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var manager  = new PiStaffOrganizeManager(dbProvider, userInfo);
                returnValue += ids.Sum(t => manager.SetProperty(PiStaffOrganizeTable.FieldStaffId, t, PiStaffOrganizeTable.FieldOrganizeId, organizeId));
            });

            return(returnValue);
        }
コード例 #19
0
        /// <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);
        }
コード例 #20
0
        /// <summary>
        ///  批量逻辑删除角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响的行数</returns>
        public int SetDeleted(UserInfo userInfo, string[] ids)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.RoleService_SetDeleted);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                //TODO:此处还应该把角色相应的权限,所拥有的用户等也做统一处理。
                returnValue = new PiRoleManager(dbProvider, userInfo).SetDeleted(ids);
            });

            return(returnValue);
        }
コード例 #21
0
        /// <summary>
        /// 将用户从角色中移除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="userIds">用户主键</param>
        /// <returns>影响行数</returns>
        public int RemoveUserFromRole(UserInfo userInfo, string roleId, string[] userIds)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.RoleService_RemoveUserFromRole);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                if (userIds != null)
                {
                    returnValue += new PiUserRoleManager(dbProvider, userInfo).RemoveFormRole(userIds, roleId);
                }
            });
            return(returnValue);
        }
        /// <summary>
        /// 授予组织机构某个权限域的模块授权范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <param name="grantModuleId">授予模块主键</param>
        /// <returns>影响的行数</returns>
        public string GrantOrganizeModuleScope(UserInfo userInfo, string organizeId, string permissionItemCode, string grantModuleId)
        {
            string returnValue = string.Empty;
            var    parameter   = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                if (grantModuleId != null)
                {
                    returnValue = new OrganizeScopeManage(dbProvider, userInfo).GrantModule(organizeId, permissionItemCode, grantModuleId);
                }
            });
            return(returnValue);
        }
        /// <summary>
        /// 撤消指定组织机构某个权限域的模块授权范围
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <param name="revokeModuleId">撤消模块主键数组</param>
        /// <returns>影响的行数</returns>
        public int RevokeOrganizeModuleScope(UserInfo userInfo, string organizeId, string permissionItemCode, string revokeModuleId)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                if (revokeModuleId != null)
                {
                    returnValue += new OrganizeScopeManage(dbProvider, userInfo, PiPermissionScopeTable.TableName).RevokeModule(organizeId, permissionItemCode, revokeModuleId);
                }
            });
            return(returnValue);
        }
コード例 #24
0
        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>影响行数</returns>
        public int Delete(UserInfo userInfo, string id)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.UserService_Delete, "主键:" + id);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var userManager = new PiUserManager(dbProvider, userInfo);
                returnValue     = userManager.Delete(id);
                //已经被删除的用户的UserId设置为Null
                userManager.CheckUserStaff();
                returnValue += new UserPermissionManager(dbProvider, userInfo).ClearUserPermissionByUserId(id);
            });
            return(returnValue);
        }
コード例 #25
0
        /// <summary>
        /// 用户添加到角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="addRoleIds">加入角色</param>
        /// <returns>影响的行数</returns>
        public int AddUserToRole(UserInfo userInfo, string userId, string[] addRoleIds)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.UserService_AddUserToRole, "用户主键:" + userId + ",加入角色:" + BusinessLogic.ArrayToList(addRoleIds));

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var userRoleManager = new PiUserRoleManager(dbProvider, userInfo);
                if (addRoleIds != null)
                {
                    returnValue += userRoleManager.AddToRole(userId, addRoleIds);
                }
            });
            return(returnValue);
        }
コード例 #26
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.UserService_BatchDelete, "主键数组:" + BusinessLogic.ArrayToList(ids));

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var userManager = new PiUserManager(dbProvider, userInfo);
                returnValue     = userManager.Delete(ids);
                // 用户已经被删除的用户的UserId设置为Null,说白了,是需要整理数据
                userManager.CheckUserStaff();
                if (ids != null && ids.Length > 0)
                {
                    returnValue += ids.Sum(userId => new UserPermissionManager(dbProvider, userInfo).ClearUserPermissionByUserId(userId));
                }
            });
            return(returnValue);
        }
コード例 #27
0
        /// <summary>
        /// 设置用户审核状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <param name="auditStates">审核状态</param>
        /// <returns>影响行数</returns>
        public int SetUserAuditStates(UserInfo userInfo, string[] ids, AuditStatus auditStates)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.UserService_SetUserAuditStates);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var userManager = new PiUserManager(dbProvider, userInfo);
                returnValue     = userManager.SetProperty(ids, PiUserTable.FieldAuditStatus, auditStates.ToString());
                // 被审核通过
                if (auditStates == AuditStatus.AuditPass)
                {
                    returnValue = userManager.SetProperty(ids, PiUserTable.FieldEnabled, 1);
                    // returnValue = userManager.SetProperty(ids, BaseUserEntity.FieldAuditStatus, StatusCode.UserIsActivate.ToString());
                }
                // 被退回
                if (auditStates == AuditStatus.AuditReject)
                {
                    returnValue = userManager.SetProperty(ids, PiUserTable.FieldEnabled, 0);
                    returnValue = userManager.SetProperty(ids, PiUserTable.FieldAuditStatus, StatusCode.UserLocked.ToString());
                }
            });
            return(returnValue);
        }
コード例 #28
0
        /// <summary>
        /// 批量置删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响的行数</returns>
        public int SetDeleted(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;

            if (ids == null || ids.Length <= 0)
            {
                return(returnValue);
            }

            var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.OrganizeService_SetDeleted);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var manager = new PiOrganizeManager(dbProvider, userInfo);
                for (int pos = 0; pos < ids.Length; pos++)
                {
                    //逻辑删除组织机构
                    returnValue += manager.SetDeleted(ids[pos]);
                    //同步处理用户表组织机构相关数据
                    var userManager = new PiUserManager(dbProvider, userInfo);
                    var parameters  = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldCompanyId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldCompanyName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldCompanyId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldSubCompanyId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldSubCompanyName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldSubCompanyId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldDepartmentId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldDepartmentName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldDepartmentId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldSubDepartmentId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldSubDepartmentName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldSubDepartmentId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldWorkgroupId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldWorkgroupName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldWorkgroupId, ids[pos]), parameters);
                    //同步处理员工表组织机构相关数据
                    var staffOrganizeManager = new PiStaffOrganizeManager(dbProvider, userInfo);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiStaffOrganizeTable.FieldOrganizeId, ids[pos])
                    };
                    staffOrganizeManager.SetDeleted(parameters, true);
                }
            });
            return(returnValue);
        }