Exemplo n.º 1
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="entity">实体</param>
 private void SetObject(SQLBuilder sqlBuilder, BaseUserExpressEntity entity)
 {
     SetObjectExpand(sqlBuilder, entity);
     sqlBuilder.SetValue(BaseUserExpressEntity.FieldTRANSFER_ADD_FEE, entity.TRANSFER_ADD_FEE);
     //增加所属承包区ID
     sqlBuilder.SetValue(BaseUserExpressEntity.FieldOWNER_ID, entity.OWNER_ID);
     sqlBuilder.SetValue(BaseUserExpressEntity.FieldOWNER_RANGE, entity.OWNER_RANGE);
     sqlBuilder.SetValue(BaseUserExpressEntity.FieldDISPATCH_ADD_FEE, entity.DISPATCH_ADD_FEE);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">实体</param>
        public int UpdateObject(BaseUserExpressEntity entity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserExpressEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserExpressEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserExpressEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(this.PrimaryKey, entity.Id);
            return(sqlBuilder.EndUpdate());
        }
        /// <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);
            }
        }
Exemplo n.º 4
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseUserExpressEntity entity);
Exemplo n.º 5
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BaseUserExpressEntity entity)
        {
            string key = string.Empty;

            if (entity != null)
            {
                key = entity.Id.ToString();
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, this.PrimaryKey);
            if (!this.Identity)
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.ReturnId = false;
                sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(this.PrimaryKey, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(this.PrimaryKey, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper);
                        entity.Id = int.Parse(sequenceManager.Increment(this.CurrentTableName));
                        sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserExpressEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserExpressEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserExpressEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserExpressEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserExpressEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserExpressEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                key = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
            {
                return(entity.Id.ToString());
            }
            return(key);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(BaseUserExpressEntity entity)
 {
     return(this.UpdateObject(entity));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 添加, 这里可以人工干预,提高程序的性能
 /// </summary>
 /// <param name="entity">实体</param>
 /// <param name="identity">自增量方式,表主键是否采用自增的策略</param>
 /// <param name="returnId">返回主键,不返回程序允许速度会快,主要是为了主细表批量插入数据优化用的</param>
 /// <returns>主键</returns>
 public string Add(BaseUserExpressEntity entity, bool identity = false, bool returnId = false)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddObject(entity));
 }