/// <summary> /// 激活帐户 /// </summary> /// <param name="openId">唯一识别码</param> /// <param name="statusCode">返回状态码</param> /// <returns>用户实体</returns> public BaseUserInfo AccountActivation(string openId, out string statusCode) { // 1.用户是否存在? BaseUserInfo userInfo = null; // 用户没有找到状态 statusCode = StatusCode.UserNotFound.ToString(); // 检查是否有效的合法的参数 if (!String.IsNullOrEmpty(openId)) { BaseUserManager userManager = new BaseUserManager(DbHelper); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldOpenId, openId)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0)); DataTable dataTable = userManager.GetDataTable(parameters); if (dataTable.Rows.Count == 1) { BaseUserEntity userEntity = new BaseUserEntity(dataTable); // 3.用户是否被锁定? if (userEntity.Enabled == 0) { statusCode = StatusCode.UserLocked.ToString(); return(userInfo); } if (userEntity.Enabled == 1) { // 2.用户是否已经被激活? statusCode = StatusCode.UserIsActivate.ToString(); return(userInfo); } if (userEntity.Enabled == -1) { // 4.成功激活用户 statusCode = StatusCode.OK.ToString(); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldId, userEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1)); return(userInfo); } } } return(userInfo); }
/// <summary> /// 删除用户的审核步骤 /// </summary> /// <param name="userId">用户主键</param> /// <returns>影响行数</returns> public int DeleteAuditStepByUser(string userId) { int returnValue = 0; // 1: 若还有当前审核中的记录,不能被删除掉 BaseWorkFlowCurrentManager manager = new BaseWorkFlowCurrentManager(this.DbHelper, this.UserInfo); List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>(3); parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldAuditUserId, userId)); parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldDeletionStateCode, 0)); if (!manager.Exists(parameters)) { // 2: 删除用户的审核步骤。 returnValue = this.SetProperty(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldAuditUserId, userId), new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 1)); // 3: 同时把用户设置为无效。 if (returnValue > 0) { BaseUserManager userManager = new BaseUserManager(this.UserInfo); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldId, userId), new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 0)); } } return returnValue; }
/// <summary> /// 设置用户审核状态 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <param name="auditStates">审核状态</param> /// <returns>影响行数</returns> public int SetUserAuditStates(BaseUserInfo userInfo, string[] ids, AuditStatus auditStates) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldAuditStatus, auditStates.ToString())); // 被审核通过 if (auditStates == AuditStatus.AuditPass) { returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 1)); // returnValue = userManager.SetProperty(ids, BaseUserEntity.FieldAuditStatus, StatusCode.UserIsActivate.ToString()); } // 被退回 if (auditStates == AuditStatus.AuditReject) { returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 0)); returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldAuditStatus, StatusCode.UserLocked.ToString())); } BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_SetUserAuditStates, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return returnValue; }
public int Update(BaseOrganizeEntity organizeEntity, out string statusCode) { int returnValue = 0; // 检查是否已被其他人修改 //if (DbLogic.IsModifed(DbHelper, BaseOrganizeEntity.TableName, organizeEntity.Id, organizeEntity.ModifiedUserId, organizeEntity.ModifiedOn)) //{ // // 数据已经被修改 // statusCode = StatusCode.ErrorChanged.ToString(); //} //else //{ List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseOrganizeEntity.FieldParentId, organizeEntity.ParentId)); parameters.Add(new KeyValuePair<string, object>(BaseOrganizeEntity.FieldFullName, organizeEntity.FullName)); parameters.Add(new KeyValuePair<string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); if (this.Exists(parameters, organizeEntity.Id)) { // 名称已重复 statusCode = StatusCode.ErrorNameExist.ToString(); } else { // 检查编号是否重复 parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseOrganizeEntity.FieldCode, organizeEntity.Code)); parameters.Add(new KeyValuePair<string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); if (organizeEntity.Code.Length > 0 && this.Exists(parameters, organizeEntity.Id)) { // 编号已重复 statusCode = StatusCode.ErrorCodeExist.ToString(); } else { // 1:更新部门的信息 returnValue = this.UpdateEntity(organizeEntity); // 2:组织机构修改时,用户表的公司,部门,工作组数据给同步更新。 BaseUserManager userManager = new BaseUserManager(this.DbHelper, this.UserInfo); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyId, organizeEntity.Id), new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyName, organizeEntity.FullName)); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentId, organizeEntity.Id), new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentName, organizeEntity.FullName)); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupId, organizeEntity.Id), new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupName, organizeEntity.FullName)); // 03:组织机构修改时,文件夹同步更新 BaseFolderManager folderManager = new BaseFolderManager(this.DbHelper, this.UserInfo); folderManager.SetProperty(new KeyValuePair<string, object>(BaseFolderEntity.FieldFolderName, organizeEntity.FullName), new KeyValuePair<string, object>(BaseFolderEntity.FieldId, organizeEntity.Id)); if (returnValue == 1) { statusCode = StatusCode.OKUpdate.ToString(); } else { statusCode = StatusCode.ErrorDeleted.ToString(); } } } //} return returnValue; }
/// <summary> /// 批量打删除标志 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <returns>影响行数</returns> public int SetDeleted(BaseUserInfo userInfo, string[] ids) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo); for (int i = 0; i < ids.Length; i++ ) { // 设置部门为删除状态 returnValue += organizeManager.SetDeleted(ids[i]); // 相应的用户也需要处理 BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyId, null)); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyName, null)); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyId, ids[i]), parameters); parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldSubCompanyId, null)); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldSubCompanyName, null)); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldSubCompanyId, ids[i]), parameters); parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentId, null)); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentName, null)); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentId, ids[i]), parameters); parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupId, null)); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupName, null)); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupId, ids[i]), parameters); // 相应的员工也需要处理 BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo); staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldCompanyId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldCompanyId, null)); staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldSubCompanyId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldSubCompanyId, null)); staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldDepartmentId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldDepartmentId, null)); staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldWorkgroupId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldWorkgroupId, null)); } BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.OrganizeService_SetDeleted, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return returnValue; }
/// <summary> /// 激活帐户 /// </summary> /// <param name="openId">唯一识别码</param> /// <param name="statusCode">返回状态码</param> /// <returns>用户实体</returns> public BaseUserInfo AccountActivation(string openId, out string statusCode) { // 1.用户是否存在? BaseUserInfo userInfo = null; // 用户没有找到状态 statusCode = StatusCode.UserNotFound.ToString(); // 检查是否有效的合法的参数 if (!String.IsNullOrEmpty(openId)) { BaseUserManager userManager = new BaseUserManager(DbHelper); List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldOpenId, openId)); parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldDeletionStateCode, 0)); DataTable dataTable = userManager.GetDataTable(parameters); if (dataTable.Rows.Count == 1) { BaseUserEntity userEntity = new BaseUserEntity(dataTable); // 3.用户是否被锁定? if (userEntity.Enabled == 0) { statusCode = StatusCode.UserLocked.ToString(); return userInfo; } if (userEntity.Enabled == 1) { // 2.用户是否已经被激活? statusCode = StatusCode.UserIsActivate.ToString(); return userInfo; } if (userEntity.Enabled == -1) { // 4.成功激活用户 statusCode = StatusCode.OK.ToString(); userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldId, userEntity.Id), new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 1)); return userInfo; } } } return userInfo; }
/// <summary> /// 设置用户的默认角色 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <param name="roleId">角色主键</param> /// <returns>影响的行数</returns> public int SetDefaultRole(BaseUserInfo userInfo, string userId, string roleId) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); returnValue = userManager.SetProperty(userId, new KeyValuePair<string, object>(BaseUserEntity.FieldRoleId, roleId)); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_SetDefaultRole, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return 0; }