Ejemplo n.º 1
0
        public StaffingResult Arrange(SessionPlan sessionPlan)
        {
            sessionPlan = sessionPlan ?? new SessionPlan {
                Requests = new List <Request>()
            };

            var activeRequests = sessionPlan
                                 .Requests
                                 .Where(x => x.Status == (int)RequestStatus.Active)
                                 .ToList();

            var employees = employeeRepository.GetEmployees();

            var filler = new EmployeeFiller();
            var result = filler.FillEmp(activeRequests, employees);

            return(result);
        }
Ejemplo n.º 2
0
        public StaffingResult FindEmployeesForRequest(Request request)
        {
            Guid?requestTitleId = request.RequestDetails.FirstOrDefault()?.TitleId;

            var employees = employeeRepository
                            .GetEmployees()
                            .Where(x => x.TitleId.Equals(requestTitleId.GetValueOrDefault()))
                            .ToList();

            var filler = new EmployeeFiller();

            var expectedScore = filler.CalExpectedScore(request) / request.Number;

            // update matched result for each employee
            employees.ForEach(
                x => x.MatchedResult = new MatchedResult
            {
                MatchedRequest       = request.Id,
                MatchedScore         = x.CalScore(request),
                RequestExpectedScore = expectedScore
            });

            // filter and sort employees by MatchedScore desc
            employees = employees
                        .Where(x => x.MatchedResult.MatchedScore > 0)
                        .OrderByDescending(x => x.MatchedResult.MatchedScore)
                        .ToList();


            var result = filler.ProjectMainProperties(employees);

            return(new StaffingResult
            {
                Result = result,
                ExpectedResult = expectedScore,
                Fitness = CalculateFitness(employees, expectedScore)
            });
        }