Ejemplo n.º 1
0
        private bool TaskMatch(long taskId, EstimateDataDto dto)
        {
            TaskModel task = _context.TaskModels
                             .Include(x => x.TaskUsers)
                             .Where(x => x.Id == taskId).FirstOrDefault();

            foreach (var taskUser in task.TaskUsers)
            {
                EmployeeUser user = _context.Users.FirstOrDefault(x => x.Id == taskUser.UserId);
                if (UserMatch(user, dto))
                {
                    return(true);
                }
            }

            foreach (var child in _context.TaskModels.Where(x => x.ParentId == task.Id))
            {
                if (TaskMatch(child.Id, dto))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public bool MatchUsers(EstimateDataDto dto)
        {
            if (dto.Id == -1)
            {
                return(true);
            }

            //если ни в одной подзадаче и в текущей нет сотрудника нужного уровня
            return(TaskMatch(dto.Id, dto));
        }
Ejemplo n.º 3
0
        internal EstimateDto GetEstimate(EstimateDataDto dto)
        {
            int baseMinutes = 2000;

            if (dto.Complexity > 0)
            {
                baseMinutes += 500 * dto.Complexity;
            }

            if (dto.Priority == (int)TaskPriority.Critical)
            {
                baseMinutes -= 700;
            }
            if (dto.Priority == (int)TaskPriority.High)
            {
                baseMinutes -= 300;
            }
            if (dto.Priority == (int)TaskPriority.Low)
            {
                baseMinutes += 300;
            }

            if (dto.Type == (int)TaskType.Implementation)
            {
                baseMinutes += 300;
            }

            if (!MatchUsers(dto))
            {
                baseMinutes = (int)(baseMinutes * 1.5);
            }

            int days = baseMinutes / 480 + 1;

            DateTime createdDate = DateTime.Now;

            if (dto.Id != -1)
            {
                var c = _context.TaskModels.Where(x => x.Id == dto.Id).FirstOrDefault().CreatedDate;
                if (c.HasValue)
                {
                    createdDate = c.Value;
                }
            }

            return(new EstimateDto()
            {
                Minutes = baseMinutes,
                Date = AddWorkdays(createdDate, days),
            });
        }
Ejemplo n.º 4
0
        private bool UserMatch(EmployeeUser user, EstimateDataDto dto)
        {
            if (dto.Complexity > 2 || (dto.Priority == (int)TaskPriority.Critical))
            {
                return(user.Level == Level.Senior && user.Experience > 3);
            }
            if (dto.Complexity > 1 || (dto.Priority == (int)TaskPriority.High))
            {
                return(user.Level >= Level.Middle && user.Experience > 1.5m);
            }
            if (dto.Complexity > 0 || (dto.Priority == (int)TaskPriority.Usual))
            {
                return(user.Level >= Level.Junior && user.Experience > 0.5m);
            }

            return(true);
        }
 public EstimateDto GetEstimate([FromBody] EstimateDataDto dto)
 {
     return(_TaskModelService.GetEstimate(dto));
 }