/// <summary> /// 锁定用户 /// </summary> /// <param name="taskId">任务标识</param> /// <param name="userInfo">用户</param> /// <param name="userName">用户名</param> /// <returns>是否成功锁定</returns> public bool LockUser(string taskId, BaseUserInfo userInfo, string userName) { bool result = false; var parameter = ServiceInfo.Create(taskId, userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) => { // BaseLogManager.Instance.Add(result, this.serviceName, AppMessage.LogOnService_LockUser, MethodBase.GetCurrentMethod()); var userManager = new BaseUserManager(userInfo); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldUserName, userName)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0)); BaseUserEntity userEntity = BaseEntity.Create <BaseUserEntity>(userManager.GetDataTable(parameters)); // 判断是否为空的 if (userEntity != null && !string.IsNullOrEmpty(userEntity.Id)) { // 被锁定15分钟,不允许15分钟内登录,这时间是按服务器的时间来的。 var userLogOnManager = new BaseUserLogOnManager(); BaseUserLogOnEntity userLogOnEntity = userLogOnManager.GetObject(userEntity.Id); userLogOnEntity.LockStartDate = DateTime.Now; userLogOnEntity.LockEndDate = DateTime.Now.AddMinutes(BaseSystemInfo.PasswordErrorLockCycle); result = userLogOnManager.UpdateObject(userLogOnEntity) > 0; } }); return(result); }
/// <summary> /// 离职处理 /// </summary> /// <param name="id">主键</param> /// <returns>影响行数</returns> public int Leave(BaseUserEntity userEntity, BaseUserLogOnEntity userLogOnEntity, string comment) { int result = 0; if (userEntity != null) { // 更新用户实体 this.UpdateObject(userEntity); } // 更新登录信息 if (userLogOnEntity != null) { BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager(this.UserInfo); userLogOnManager.UpdateObject(userLogOnEntity); } // 填写评论 if (!string.IsNullOrWhiteSpace(comment)) { SQLBuilder sqlBuilder = new SQLBuilder(BaseSystemInfo.ServerDbType); sqlBuilder.BeginInsert(BaseCommentEntity.TableName); sqlBuilder.SetValue(BaseCommentEntity.FieldId, System.Guid.NewGuid().ToString("N")); sqlBuilder.SetValue(BaseCommentEntity.FieldCategoryCode, BaseUserEntity.TableName); sqlBuilder.SetValue(BaseCommentEntity.FieldObjectId, userEntity.Id); sqlBuilder.SetValue(BaseCommentEntity.FieldContents, comment); sqlBuilder.SetValue(BaseCommentEntity.FieldWorked, 1); sqlBuilder.SetValue(BaseCommentEntity.FieldDepartmentId, userEntity.DepartmentId); sqlBuilder.SetValue(BaseCommentEntity.FieldDepartmentName, userEntity.DepartmentName); sqlBuilder.SetValue(BaseCommentEntity.FieldCreateUserId, this.UserInfo.Id); sqlBuilder.SetValue(BaseCommentEntity.FieldCreateBy, this.UserInfo.RealName); sqlBuilder.SetDBNow(BaseCommentEntity.FieldCreateOn); sqlBuilder.SetValue(BaseCommentEntity.FieldIPAddress, this.UserInfo.IPAddress); sqlBuilder.SetValue(BaseCommentEntity.FieldEnabled, 1); sqlBuilder.SetValue(BaseCommentEntity.FieldDeletionStateCode, 0); sqlBuilder.EndInsert(); } // 2016-03-17 吉日嘎拉 停止吉信的号码 if (userEntity != null && !string.IsNullOrEmpty(userEntity.NickName)) { AfterLeaveStopIM(userEntity); } // 2016-03-17 吉日嘎拉 停止吉信的号码 if (userEntity != null && !string.IsNullOrEmpty(userEntity.Id)) { BaseUserContactEntity userContactEntity = BaseUserContactManager.GetObjectByCache(userEntity.Id); { if (userContactEntity != null && !string.IsNullOrEmpty(userContactEntity.CompanyMail)) { ChangeUserMailStatus(userContactEntity.CompanyMail, true); } } } return(result); }
/// <summary> /// 更新K8员工后,同步到中天baseuser表 /// 传入dbhelper 方法调用使用事务 避免部分同步成功 /// </summary> /// <param name="entity"></param> /// <param name="userCenterDbHelper"></param> public void AfterUpdateEmployee(TAB_EMPLOYEEEntity entity, IDbHelper userCenterDbHelper) { int count = 0; BaseUserEntity userEntity = new BaseUserEntity(); userEntity.Id = entity.ID.ToString(); userEntity.UserFrom = "PDA"; userEntity.UserPassword = entity.BAR_PASSWORD; userEntity.Code = entity.EMPLOYEE_CODE; userEntity.UserName = entity.EMPLOYEE_NAME; userEntity.RealName = entity.EMPLOYEE_NAME; userEntity.Description = entity.PHONE; userEntity.CompanyName = entity.OWNER_SITE; // 1、更新baseuser中的所属网点 if (string.IsNullOrEmpty(userEntity.CompanyId)) { BaseOrganizeEntity organizeEntity = new BaseOrganizeManager(userCenterDbHelper).GetObjectByName(userEntity.CompanyName); if (organizeEntity != null) { userEntity.CompanyId = organizeEntity.Id.ToString(); } } userEntity.DepartmentName = entity.DEPT_NAME; userEntity.WorkgroupName = entity.GROUP_NAME; userEntity.HomeAddress = entity.ADDRESS; userEntity.IDCard = entity.ID_CARD; // 2、员工操作类型,按签名处理 userEntity.Signature = entity.EMPLOYEE_TYPE; userEntity.SortCode = int.Parse(entity.ID.ToString()); userEntity.ModifiedOn = entity.UPDATETIME; BaseUserManager userManager = new BaseUserManager(userCenterDbHelper, Utilities.UserInfo); // if (!userManager.Exists(userEntity.Id)) count = userManager.UpdateObject(userEntity); if (count == 0) { userManager.AddObject(userEntity); } // 3、如果有电话,同步到baseusercontact中 BaseUserContactEntity userContactEntity = new BaseUserContactEntity(); userContactEntity.Id = entity.ID.ToString(); userContactEntity.Telephone = entity.PHONE; BaseUserContactManager userContactManager = new DotNet.Business.BaseUserContactManager(userCenterDbHelper, Utilities.UserInfo); count = userContactManager.UpdateObject(userContactEntity); if (count == 0) { userContactManager.AddObject(userContactEntity); } // 4、新增员工时,同步baseuser员工的密码 BaseUserLogOnEntity userLogOnEntity = new BaseUserLogOnEntity(); userLogOnEntity.Id = entity.ID.ToString(); userLogOnEntity.UserPassword = entity.BAR_PASSWORD; BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager(userCenterDbHelper, Utilities.UserInfo); count = userLogOnManager.UpdateObject(userLogOnEntity); if (count == 0) { userLogOnManager.AddObject(userLogOnEntity); } // 5、中转附加费和派件附加费,再确认 BaseUserExpressManager userExpressManager = new BaseUserExpressManager(userCenterDbHelper, Utilities.UserInfo); BaseUserExpressEntity userExpressEntity = new BaseUserExpressEntity(); userExpressEntity.Id = entity.ID; userExpressEntity.DISPATCH_ADD_FEE = entity.DISPATCH__ADD_FEE; userExpressEntity.TRANSFER_ADD_FEE = entity.TRANSFER_ADD_FEE; userExpressEntity.OWNER_RANGE = entity.OWNER_RANGE; count = userExpressManager.UpdateObject(userExpressEntity); if (count == 0) { userExpressManager.Add(userExpressEntity, false); } }
public int ImportUser(System.Data.IDataReader dataReader, BaseOrganizeManager organizeManager, BaseUserLogOnManager userLogOnManager, BaseUserContactManager userContactManager) { int result = 0; BaseUserEntity userEntity = this.GetObject(dataReader["ID"].ToString()); if (userEntity == null) { userEntity = new BaseUserEntity(); userEntity.Id = dataReader["ID"].ToString(); } userEntity.Id = dataReader["ID"].ToString(); userEntity.UserFrom = "K8"; userEntity.UserName = dataReader["USER_NAME"].ToString(); userEntity.IDCard = dataReader["ID_Card"].ToString(); userEntity.Code = dataReader["EMPLOYEE_CODE"].ToString(); userEntity.RealName = dataReader["REAL_NAME"].ToString(); if (string.IsNullOrWhiteSpace(userEntity.RealName)) { userEntity.RealName = dataReader["EMPLOYEE_NAME"].ToString(); } userEntity.NickName = dataReader["ONLY_USER_NAME"].ToString(); userEntity.CompanyName = dataReader["OWNER_SITE"].ToString(); userEntity.Description = dataReader["REMARK"].ToString(); // 把被删除的数据恢复过来 userEntity.DeletionStateCode = 0; if (string.IsNullOrEmpty(userEntity.CompanyId)) { userEntity.CompanyId = organizeManager.GetProperty(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldFullName, userEntity.CompanyName), BaseOrganizeEntity.FieldId); if (string.IsNullOrEmpty(userEntity.CompanyId)) { System.Console.WriteLine("无CompanyId " + userEntity.Id + ":" + userEntity.UserName + ":" + userEntity.RealName); return(0); } } // 不是内部组织机构的才进行调整 if (string.IsNullOrEmpty(userEntity.DepartmentId)) { userEntity.DepartmentName = dataReader["DEPT_NAME"].ToString(); } if (!string.IsNullOrEmpty(dataReader["IM_NAME"].ToString())) { // userEntity.QQ = dataReader["IM_NAME"].ToString(); } userEntity.Enabled = int.Parse(dataReader["BL_LOCK_FLAG"].ToString()); System.Console.WriteLine("ImportK8User:"******":" + userEntity.RealName); // 02:可以把读取到的数据能写入到用户中心的。 result = this.UpdateObject(userEntity); if (result == 0) { this.AddObject(userEntity); } // 添加用户密码表 BaseUserLogOnEntity userLogOnEntity = userLogOnManager.GetObject(userEntity.Id); if (userLogOnEntity == null) { userLogOnEntity = new BaseUserLogOnEntity(); userLogOnEntity.Id = userEntity.Id; // 邦定mac地址 userLogOnEntity.CheckIPAddress = 1; userLogOnEntity.UserPassword = dataReader["USER_PASSWD"].ToString(); userLogOnEntity.Salt = dataReader["SALT"].ToString(); // 是否检查机器码 MAC地址 int checkIPAddress = 1; int.TryParse(dataReader["BL_CHECK_COMPUTER"].ToString(), out checkIPAddress); userLogOnEntity.CheckIPAddress = checkIPAddress; if (!string.IsNullOrEmpty(dataReader["CHANGEPASSWORDDATE"].ToString())) { userLogOnEntity.ChangePasswordDate = DateTime.Parse(dataReader["CHANGEPASSWORDDATE"].ToString()); } userLogOnManager.AddObject(userLogOnEntity); } else { userLogOnEntity.Id = userEntity.Id; userLogOnEntity.UserPassword = dataReader["USER_PASSWD"].ToString(); userLogOnEntity.Salt = dataReader["SALT"].ToString(); if (!string.IsNullOrEmpty(dataReader["CHANGEPASSWORDDATE"].ToString())) { userLogOnEntity.ChangePasswordDate = DateTime.Parse(dataReader["CHANGEPASSWORDDATE"].ToString()); } result = userLogOnManager.UpdateObject(userLogOnEntity); } // 用户的联系方式 BaseUserContactEntity userContactEntity = userContactManager.GetObject(userEntity.Id); if (userContactEntity == null) { userContactEntity = new BaseUserContactEntity(); userContactEntity.Id = userEntity.Id; userContactEntity.QQ = dataReader["QQ"].ToString(); userContactEntity.Mobile = dataReader["Mobile"].ToString(); userContactEntity.Email = dataReader["Email"].ToString(); userContactManager.AddObject(userContactEntity); } else { if (!string.IsNullOrEmpty(dataReader["QQ"].ToString())) { userContactEntity.QQ = dataReader["QQ"].ToString(); } if (!string.IsNullOrEmpty(dataReader["Mobile"].ToString())) { userContactEntity.Mobile = dataReader["Mobile"].ToString(); } if (!string.IsNullOrEmpty(dataReader["Email"].ToString())) { userContactEntity.Email = dataReader["Email"].ToString(); } userContactManager.UpdateObject(userContactEntity); } return(result); }