public int ImportStaff(System.Data.IDataReader dataReader, BaseStaffManager staffManager, BaseUserExpressManager sTAFF_EXPRESSManager, BaseUserManager userManager, BaseUserLogOnManager userLogOnManager) { int result = 0; /* * BaseStaffEntity staffEntity = staffManager.GetObject(dataReader["Id"].ToString()); * if (staffEntity == null) * { * staffEntity = new BaseStaffEntity(); * } * staffEntity.Id = int.Parse(dataReader["Id"].ToString()); * staffEntity.Code = dataReader["EMPLOYEE_CODE"].ToString(); * staffEntity.RealName = dataReader["EMPLOYEE_NAME"].ToString(); * staffEntity.Telephone = dataReader["PHONE"].ToString(); * staffEntity.HomeAddress = dataReader["ADDRESS"].ToString(); * staffEntity.IDCard = dataReader["ID_CARD"].ToString(); * * // staffEntity.CompanyId = dataReader["OWNER_SITE"].ToString(); * staffEntity.CompanyName = dataReader["OWNER_SITE"].ToString(); * // staffEntity.DepartmentId = dataReader["DEPT_NAME"].ToString(); * staffEntity.DepartmentName = dataReader["DEPT_NAME"].ToString(); * // staffEntity.WorkgroupId = dataReader["GROUP_NAME"].ToString(); * staffEntity.WorkgroupName = dataReader["GROUP_NAME"].ToString(); * * System.Console.WriteLine("ImportK8Staff:" + staffEntity.Id + ":" + staffEntity.RealName); * // 02:可以把读取到的数据能写入到用户中心的。 * result = staffManager.UpdateObject(staffEntity); * if (result == 0) * { * staffManager.AddObject(staffEntity); * } */ /* * BaseUserExpressEntity sTAFF_EXPRESSEntity = sTAFF_EXPRESSManager.GetObject(dataReader["Id"].ToString()); * if (sTAFF_EXPRESSEntity == null) * { * sTAFF_EXPRESSEntity = new BaseUserExpressEntity(); * } * sTAFF_EXPRESSEntity.Id = int.Parse(dataReader["Id"].ToString()); * sTAFF_EXPRESSEntity.OWNER_RANGE = dataReader["OWNER_RANGE"].ToString(); * Decimal tRANSFER_ADD_FEE = 0; * if (!string.IsNullOrEmpty(dataReader["TRANSFER_ADD_FEE"].ToString()) && ValidateUtil.IsDouble(dataReader["TRANSFER_ADD_FEE"].ToString())) * { * tRANSFER_ADD_FEE = Decimal.Parse(dataReader["TRANSFER_ADD_FEE"].ToString()); * } * sTAFF_EXPRESSEntity.TRANSFER_ADD_FEE = tRANSFER_ADD_FEE; * Decimal dISPATCH_ADD_FEE = 0; * if (!string.IsNullOrEmpty(dataReader["DISPATCH__ADD_FEE"].ToString()) && ValidateUtil.IsDouble(dataReader["DISPATCH__ADD_FEE"].ToString())) * { * dISPATCH_ADD_FEE = Decimal.Parse(dataReader["DISPATCH__ADD_FEE"].ToString()); * } * sTAFF_EXPRESSEntity.DISPATCH_ADD_FEE = dISPATCH_ADD_FEE; * * System.Console.WriteLine("ImportK8Staffexpress:" + staffEntity.Id + ":" + staffEntity.RealName); * // 02:可以把读取到的数据能写入到用户中心的。 * result = sTAFF_EXPRESSManager.Update(sTAFF_EXPRESSEntity); * if (result == 0) * { * sTAFF_EXPRESSManager.Add(sTAFF_EXPRESSEntity); * } */ BaseUserEntity userEntity = new BaseUserEntity(); userEntity.Id = dataReader["ID"].ToString(); userEntity.UserFrom = "PDA"; userEntity.Code = dataReader["EMPLOYEE_CODE"].ToString(); userEntity.UserName = dataReader["EMPLOYEE_NAME"].ToString(); userEntity.RealName = dataReader["REAL_NAME"].ToString(); userEntity.Description = dataReader["PHONE"].ToString(); userEntity.CompanyName = dataReader["OWNER_SITE"].ToString(); if (string.IsNullOrEmpty(userEntity.CompanyId)) { userEntity.CompanyId = BaseOrganizeManager.GetObjectByNameByCache(userEntity.CompanyName).Id.ToString(); if (string.IsNullOrEmpty(userEntity.CompanyId)) { System.Console.WriteLine("无CompanyId " + userEntity.Id + ":" + userEntity.UserName + ":" + userEntity.RealName); return(0); } } userEntity.DepartmentName = dataReader["DEPT_NAME"].ToString(); userEntity.WorkgroupName = dataReader["GROUP_NAME"].ToString(); userEntity.HomeAddress = dataReader["ADDRESS"].ToString(); userEntity.IDCard = dataReader["ID_CARD"].ToString(); if (!string.IsNullOrEmpty(dataReader["cardnum"].ToString())) { userEntity.IDCard = dataReader["cardnum"].ToString(); } userEntity.Signature = dataReader["EMPLOYEE_TYPE"].ToString(); userEntity.SortCode = int.Parse(dataReader["ID"].ToString()); if (!userEntity.ModifiedOn.HasValue) { userEntity.ModifiedOn = DateTime.Parse(dataReader["UPDATETIME"].ToString()); } else { if (userEntity.ModifiedOn.Value < DateTime.Parse(dataReader["UPDATETIME"].ToString())) { userEntity.ModifiedOn = DateTime.Parse(dataReader["UPDATETIME"].ToString()); } } // 修改日期需要同步 // result = userManager.UpdateObject(userEntity); if (result == 0) { userManager.AddObject(userEntity); BaseUserContactEntity userContactEntity = new BaseUserContactEntity(); userContactEntity.Id = dataReader["ID"].ToString(); userContactEntity.Telephone = dataReader["PHONE"].ToString(); new BaseUserContactManager().AddObject(userContactEntity); BaseUserLogOnEntity userLogOnEntity = new BaseUserLogOnEntity(); userLogOnEntity.Id = dataReader["ID"].ToString(); userLogOnEntity.UserPassword = dataReader["BAR_PASSWORD"].ToString(); userLogOnManager.AddObject(userLogOnEntity); } // 处理角色 /* * string roleName = dataReader["EMPLOYEE_TYPE"].ToString(); * // 看是否在这个角色里,若没有增加上去。 * userManager.AddToRole("PDA", userEntity.Id, roleName); * * // 添加用户密码表 * BaseUserLogOnEntity userLogOnEntity = userLogOnManager.GetObject(userEntity.Id); * if (userLogOnEntity == null) * { * userLogOnEntity = new BaseUserLogOnEntity(); * userLogOnEntity.Id = userEntity.Id; * userLogOnEntity.UserPassword = dataReader["BAR_PASSWORD"].ToString(); * //userLogOnEntity.Salt = dataReader["SALT"].ToString(); * //if (!string.IsNullOrEmpty(dataReader["CHANGEPASSWORDDATE"].ToString())) * //{ * // userLogOnEntity.ChangePasswordDate = DateTime.Parse(dataReader["CHANGEPASSWORDDATE"].ToString()); * //} * userLogOnManager.AddObject(userLogOnEntity); * } * else * { * userLogOnEntity.Id = userEntity.Id; * userLogOnEntity.UserPassword = dataReader["BAR_PASSWORD"].ToString(); * //userLogOnEntity.Salt = dataReader["SALT"].ToString(); * //if (!string.IsNullOrEmpty(dataReader["CHANGEPASSWORDDATE"].ToString())) * //{ * // userLogOnEntity.ChangePasswordDate = DateTime.Parse(dataReader["CHANGEPASSWORDDATE"].ToString()); * //} * result = userLogOnManager.UpdateObject(userLogOnEntity); * } */ 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); } }