コード例 #1
0
        private Generator.Course RemoveBlockedAndOutsidePeriodImplementations(Generator.Course course)
        {
            _logger.Debug(string.Format(_culture, "Remove blocked implementations and implementations outside the period from course {0}", course.Code));

            if (BlockedDates != null)
            {
                _logger.Debug(string.Format(_culture, "Remove {0} blocked implementations from course {1}", BlockedDates.Count, course.Code));

                int periodEducationPlanDays       = _managementPropertiesDataMapper.FindManagementProperties().PeriodEducationPlanInDays;
                int daysAfterLastCourseEmployable = _managementPropertiesDataMapper.FindManagementProperties().PeriodAfterLastCourseEmployableInDays;

                DateTime endDate = StartDate.GetEndDay(periodEducationPlanDays);

                if (EndDate != null)
                {
                    endDate = EndDate.Value.AddDays(-daysAfterLastCourseEmployable);
                    _logger.Debug(string.Format(_culture, "Period for education plan is {0} days", endDate - StartDate));
                }
                else
                {
                    _logger.Debug(string.Format(_culture, "Period for education plan is {0} days", periodEducationPlanDays));
                }

                var blockedImplementations = course.CourseImplementations.Where(ci => ci.StartDay <StartDate || ci.StartDay.GetEndDay(ci.Days.Count())> endDate || ci.Days.Any(day => BlockedDates.Contains(day)));

                _logger.Debug("Set status of blocked implementations and implementations outside the period on unplannable");
                foreach (var implementation in blockedImplementations)
                {
                    implementation.Status = Status.UNPLANNABLE;
                }
            }

            return(course);
        }