Esempio n. 1
0
        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="entity">用户实体</param>
        /// <param name="userContactEntity">用户联系方式实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>影响行数</returns>
        public int UpdateUser(BaseUserInfo userInfo, BaseUserEntity entity, BaseUserContactEntity userContactEntity, out string statusCode, out string statusMessage)
        {
            int result = 0;

            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userManager = new BaseUserManager(dbHelper, userInfo);
                // 调用方法,并且返回运行结果,判断重复
                // result = userManager.Update(entity, out StatusCode);
                // 不判断重复直接更新
                if (entity != null)
                {
                    // 2015-12-09 吉日嘎拉 确认更新日志功能
                    result = userManager.Update(entity);
                    // 若是超级管理员,就是名字编号重复了,也应该能修改数据比较好,否则有些事情无法办理下去了,由于历史原因导致数据重复的什么的,也需要能修改才可以。
                    if (userInfo.IsAdministrator)
                    {
                        if (userManager.StatusCode == Status.ErrorUserExist.ToString() ||
                            userManager.StatusCode == Status.ErrorCodeExist.ToString())
                        {
                            result = userManager.UpdateObject(entity);
                        }
                    }
                }
                if (userContactEntity != null)
                {
                    var userContactManager = new BaseUserContactManager(dbHelper, userInfo);
                    userContactManager.SetObject(userContactEntity);
                }
                if (result == 1)
                {
                    userManager.StatusCode = Status.OKUpdate.ToString();
                    returnCode             = userManager.StatusCode;
                }
                userManager.StatusMessage = userManager.GetStateMessage(returnCode);
                // 更新员工信息
                if (entity != null)
                {
                    if (entity.IsStaff != null && entity.IsStaff > 0)
                    {
                        //BaseStaffManager staffManager = new BaseStaffManager(dbHelper, result);
                        //string staffId = staffManager.GetIdByUserId(entity.Id);
                        //if (!string.IsNullOrEmpty(staffId))
                        //{
                        //    BaseStaffEntity staffEntity = staffManager.GetObject(staffId);
                        //    staffEntity.Code = entity.Code;
                        //    staffEntity.Birthday = entity.Birthday;
                        //    staffEntity.Gender = entity.Gender;
                        //    staffEntity.UserName = entity.UserName;
                        //    staffEntity.RealName = entity.RealName;
                        //    staffEntity.QQ = entity.QQ;
                        //    staffEntity.Mobile = entity.Mobile;
                        //    staffEntity.Telephone = entity.Telephone;
                        //    staffEntity.Email = entity.Email;
                        //    staffEntity.CompanyId = entity.CompanyId;
                        //    staffEntity.SubCompanyId = entity.SubCompanyId;
                        //    staffEntity.DepartmentId = entity.DepartmentId;
                        //    staffEntity.WorkgroupId = entity.WorkgroupId;
                        //    staffManager.Update(staffEntity);
                        //}
                    }
                }
                returnCode    = userManager.StatusCode;
                returnMessage = userManager.StatusMessage;
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;

            return(result);
        }