/// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        public async Task <HumanPosition> UpdateAsync(UserInfo user, HumanPosition humanPosition, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (humanPosition == null)
            {
                throw new ArgumentNullException(nameof(humanPosition));
            }
            var old = HumanPositions.Where(a => a.Id == humanPosition.Id).SingleOrDefault();

            if (old == null)
            {
                throw new Exception("更新的对象不存在");
            }
            old.DepartmentId = humanPosition.DepartmentId;
            old.Name         = humanPosition.Name;
            old.Type         = humanPosition.Type;

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

            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 #3
0
    public void OnEnter()
    {
        //播放跑步动画
        _human_Ani.SetInteger(StaticParameter.Ani_Key_HumanState, 0);
        //计算坐标偏差
        var temp = _camera.position.y - _human.position.y - _difference;

        //确定当前是在标准位置的上方还是下方,<0是在上面,>0是在下面
        if (temp < 0)
        {
            _human_Position = HumanPosition.Up;
        }
        else
        {
            _human_Position = HumanPosition.Down;
        }
        //计算移动速度
        float speed = HumanManager.Nature.Run_Speed;

        if (ItemColliction.SuperMan.WhetherSpeedUp())
        {
            speed = HumanManager.Nature.Run_Speed * 1.5f;
        }

        _add_Once = temp / (60 * _revise_Time);
        _y_Speed  = speed + _add_Once;

        //若坐标偏差小于0.1,则直接修正坐标
        if (Mathf.Abs(temp) < 0.1)
        {
            ResetHumanPosition();
        }
    }
        /// <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))
        {
            HumanPosition humanPosition = new HumanPosition()
            {
                Id            = id,
                UpdateTime    = DateTime.Now,
                ExamineStatus = status
            };

            Context.Attach(humanPosition);
            var entry = Context.Entry(humanPosition);

            entry.Property(x => x.ExamineStatus).IsModified = true;
            entry.Property(x => x.UpdateTime).IsModified    = true;
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException) { throw; }
        }
 /// <summary>
 /// 新增
 /// </summary>
 /// <returns></returns>
 public async Task <HumanPosition> CreateAsync(UserInfo user, HumanPosition humanPosition, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (humanPosition == null)
     {
         throw new ArgumentNullException(nameof(humanPosition));
     }
     if (string.IsNullOrEmpty(humanPosition.Id))
     {
         humanPosition.Id = Guid.NewGuid().ToString();
     }
     humanPosition.CreateTime = DateTime.Now;
     humanPosition.CreateUser = user.Id;
     humanPosition.IsDeleted  = false;
     Context.Add(humanPosition);
     try
     {
         await Context.SaveChangesAsync(cancellationToken);
     }
     catch (DbUpdateException) { throw; }
     return(humanPosition);
 }