Beispiel #1
0
        /// <summary>
        /// 更新审核状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task UpdateExamineStatus(string id, ExamineStatusEnum status, CancellationToken cancellationToken = default(CancellationToken))
        {
            var model = await Store.GetAsync(a => a.Where(b => b.Id == id));

            if (model == null)
            {
                throw new Exception("未找到更新对象");
            }
            UserInfo userInfo = new UserInfo
            {
                Id = model.CreateUser
            };
            HumanInfoChange humanInfoChange = new HumanInfoChange
            {
                ChangeContent = "",
                ChangeId      = model.Id,
                ChangeReason  = "",
                ChangeTime    = DateTime.Now,
                ChangeType    = HumanChangeType.Adjustment,
                CreateTime    = DateTime.Now,
                CreateUser    = model.CreateUser,
                Id            = Guid.NewGuid().ToString(),
                IsDeleted     = false,
                HumanId       = model.HumanId,
                UserId        = model.CreateUser
            };
            await _humanInfoChangeStore.CreateAsync(userInfo, humanInfoChange);

            await Store.UpdateExamineStatus(id, status, cancellationToken);
        }
Beispiel #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        public async Task <HumanInfoChange> UpdateAsync(UserInfo user, HumanInfoChange humanInfoChange, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (humanInfoChange == null)
            {
                throw new ArgumentNullException(nameof(humanInfoChange));
            }
            var old = HumanInfoChanges.Where(a => a.Id == humanInfoChange.Id).SingleOrDefault();

            if (old == null)
            {
                throw new Exception("更新的对象不存在");
            }
            old.ChangeContent = humanInfoChange.ChangeContent;
            old.ChangeId      = humanInfoChange.ChangeId;
            old.ChangeReason  = humanInfoChange.ChangeReason;
            old.ChangeTime    = humanInfoChange.ChangeTime;
            old.ChangeType    = humanInfoChange.ChangeType;
            old.UserId        = humanInfoChange.UserId;

            old.UpdateTime = DateTime.Now;
            old.UpdateUser = user.Id;
            Context.Update(old);
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException) { throw; }
            return(humanInfoChange);
        }
Beispiel #3
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public async Task DeleteAsync(UserInfo user, HumanInfoChange humanInfoChange, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (humanInfoChange == null)
            {
                throw new ArgumentNullException(nameof(humanInfoChange));
            }
            humanInfoChange.DeleteTime = DateTime.Now;
            humanInfoChange.DeleteUser = user.Id;
            humanInfoChange.IsDeleted  = true;
            Context.Attach(humanInfoChange);
            var entry = Context.Entry(humanInfoChange);

            entry.Property(x => x.IsDeleted).IsModified  = true;
            entry.Property(x => x.DeleteUser).IsModified = true;
            entry.Property(x => x.DeleteTime).IsModified = true;
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
Beispiel #4
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <returns></returns>
 public async Task <HumanInfoChange> CreateAsync(UserInfo user, HumanInfoChange humanInfoChange, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (humanInfoChange == null)
     {
         throw new ArgumentNullException(nameof(humanInfoChange));
     }
     if (string.IsNullOrEmpty(humanInfoChange.Id))
     {
         humanInfoChange.Id = Guid.NewGuid().ToString();
     }
     humanInfoChange.CreateTime = DateTime.Now;
     humanInfoChange.CreateUser = user.Id;
     humanInfoChange.IsDeleted  = false;
     Context.Add(humanInfoChange);
     try
     {
         await Context.SaveChangesAsync(cancellationToken);
     }
     catch (DbUpdateException) { throw; }
     return(humanInfoChange);
 }
        /// <summary>
        /// 更新审核状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task UpdateExamineStatus(string id, ExamineStatusEnum status, CancellationToken cancellationToken = default(CancellationToken))
        {
            var model = await Store.GetAsync(a => a.Where(b => b.Id == id));

            if (model == null)
            {
                throw new Exception("未找到更新对象");
            }
            UserInfo userInfo = new UserInfo
            {
                Id = model.CreateUser
            };
            var human = await _humanInfoStore.GetAsync(a => a.Where(b => b.Id == model.HumanId));

            if (human == null)
            {
                throw new Exception("未找到操作的人事信息");
            }
            human.Position     = model.Position;
            human.DepartmentId = model.DepartmentId;
            human.UpdateTime   = DateTime.Now;
            human.UpdateUser   = model.CreateUser;

            HumanSocialSecurity humanSocialSecurity = new HumanSocialSecurity
            {
                EmploymentInjuryInsurance   = model.EmploymentInjuryInsurance,
                HousingProvidentFundAccount = model.HousingProvidentFundAccount,
                InsuredAddress          = model.InsuredAddress,
                MedicalInsuranceAccount = model.MedicalInsuranceAccount,
                SocialSecurityAccount   = model.SocialSecurityAccount,
                EndowmentInsurance      = model.EndowmentInsurance,
                HousingProvidentFund    = model.HousingProvidentFund,
                Id                    = model.HumanId,
                InsuredTime           = model.InsuredTime,
                IsGiveUp              = model.IsGiveUp,
                IsHave                = model.IsHave,
                IsSignCommitment      = model.IsSignCommitment,
                MaternityInsurance    = model.MaternityInsurance,
                MedicalInsurance      = model.MedicalInsurance,
                UnemploymentInsurance = model.UnemploymentInsurance
            };


            HumanSalaryStructure humanSalaryStructure = new HumanSalaryStructure
            {
                BaseWages = model.BaseWages,
                CommunicationAllowance = model.CommunicationAllowance,
                OtherAllowance         = model.OtherAllowance,
                TrafficAllowance       = model.TrafficAllowance,
                GrossPay        = model.GrossPay,
                Id              = model.HumanId,
                PostWages       = model.PostWages,
                ProbationaryPay = model.ProbationaryPay
            };


            HumanInfoChange humanInfoChange = new HumanInfoChange
            {
                ChangeContent = "",
                ChangeId      = model.Id,
                ChangeReason  = "",
                ChangeTime    = DateTime.Now,
                ChangeType    = HumanChangeType.Adjustment,
                CreateTime    = DateTime.Now,
                CreateUser    = model.CreateUser,
                Id            = Guid.NewGuid().ToString(),
                IsDeleted     = false,
                HumanId       = model.HumanId,
                UserId        = model.CreateUser
            };

            await _humanInfoStore.UpdateAsync(userInfo, human);

            await _humanInfoStore.UpdateHumanSalaryStructureAsync(userInfo, humanSalaryStructure);

            await _humanInfoStore.UpdateHumanSocialSecurityAsync(userInfo, humanSocialSecurity);

            await _humanInfoChangeStore.CreateAsync(userInfo, humanInfoChange);

            await Store.UpdateExamineStatus(id, status, cancellationToken);
        }