Пример #1
0
        private static Boolean IsDayThatCanBeScheduled(EnumDayOfWeeks CurrentDay, List <EnumDayOfWeeks> DaysCanSchedule)
        {
            Boolean Rtn = false;

            foreach (EnumDayOfWeeks d in DaysCanSchedule)
            {
                if (CurrentDay == d)
                {
                    Rtn = true;
                }
            }

            return(Rtn);
        }
Пример #2
0
        //private Boolean IsFirstDateCanBeScheduled(DateTime CurrentDay)
        //{
        //    Boolean Rtn = false;


        //    EnumDayOfWeeks DayOfTheWeek = CustomDateTime.CustomDayOfTheWeek(CurrentDay.DayOfWeek);
        //    int AmountOfDayFound = (from a in SetOfDaysOfWeekCourseCanBeScheulded
        //                            where a == DayOfTheWeek//a.HasFlag(DayOfTheWeek)
        //                            select a).ToList<EnumDayOfWeeks>().Count();
        //    if (AmountOfDayFound > 0)
        //    {
        //        Rtn = true;
        //    }

        //    return Rtn;

        //}

        private void SetAvailableCoursePeriodForFacilitators()
        {
            foreach (FacilitatorPeriod FAP in FacilitatorAvailablePeriods)
            {
                DateTime INITIAL_DATE = FAP.StartDate;

                //Get First Dat That Scheduling Can Start
                DateTime FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FAP.StartDate;
                while (FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date < FAP.EndDate.Date)
                {
                    Boolean IsFirstDayFound = false;
                    while (!IsFirstDayFound)
                    {
                        EnumDayOfWeeks DayOfTheWeek = CustomDateTime.CustomDayOfTheWeek(FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.DayOfWeek);
                        if ((from a in SetOfDaysOfWeekCourseCanBeScheulded
                             where a == DayOfTheWeek//a.HasFlag(DayOfTheWeek)
                             select a).ToList <EnumDayOfWeeks>().Count() > 0)
                        {
                            IsFirstDayFound = true;
                        }
                        else
                        {
                            FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.AddDays(1);
                        }
                    }


                    //DateTime must be inclusive of the initial date so 1 day must be subtracted from the returned possible end date.
                    DateTime EndDateForCurrentPossibleSchedule = CustomDateTime.getCustomDateTime(FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date.AddDays(-1), CourseDuration, SetOfDaysOfWeekCourseCanBeScheulded);
                    if (EndDateForCurrentPossibleSchedule.Date <= FAP.EndDate.Date)
                    {
                        //Add Schedule Option To List
                        ListOfAvailableCoursePeriodByFacilitator.Add(new AvailableCoursePeriodByFacilitatorResultSet()
                        {
                            CourseID        = this.CourseID,
                            CourseName      = this.CourseName,
                            FacilitatorID   = FAP.FacillitatorID,
                            FacilitatorName = FAP.FacilitatorName,
                            CourseStartDate = FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date,
                            CourseEndDate   = EndDateForCurrentPossibleSchedule.Date
                        });
                        FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = EndDateForCurrentPossibleSchedule.Date.AddDays(1);
                    }
                    else
                    {
                        FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FAP.EndDate.Date;
                    }
                }
            }
        }
        private Boolean IsFirstDateCanBeScheduled(DateTime CurrentDay, List <CurriculumCourseDayCanBeScheduled> CurriculumCourseDayCanBeScheduledList)
        {
            Boolean Rtn = false;


            EnumDayOfWeeks DayOfTheWeek     = CustomDateTime.CustomDayOfTheWeek(CurrentDay.DayOfWeek);
            int            AmountOfDayFound = (from a in CurriculumCourseDayCanBeScheduledList
                                               where a.DayOfWeekID == (int)DayOfTheWeek
                                               select a).ToList <CurriculumCourseDayCanBeScheduled>().Count();

            if (AmountOfDayFound > 0)
            {
                Rtn = true;
            }

            return(Rtn);
        }
        private DateTime EnsureSchedulableDate(DateTime SelectedDate)
        {
            Boolean IsValidDay = false;

            //DateTime DateTimeToSelect = new DateTime(SelectedDate.Year, SelectedDate.Month, SelectedDate.Day, 0, 0, 0);
            while (!IsValidDay)
            {
                EnumDayOfWeeks d = Common.CustomDateTime.CustomDayOfTheWeek(SelectedDate.DayOfWeek);
                if (GetDayThatCurriculumCourseCanBeScheduled().Contains(d))
                {
                    IsValidDay = true;
                }
                else
                {
                    SelectedDate = SelectedDate.Date.AddDays(1);
                }
            }
            return(SelectedDate);
        }
Пример #5
0
        public static EnumDayOfWeeks CustomDayOfTheWeek(DayOfWeek Day)
        {
            EnumDayOfWeeks CustomDay = EnumDayOfWeeks.Monday;

            switch (Day)
            {
            case System.DayOfWeek.Monday:
                CustomDay = EnumDayOfWeeks.Monday;
                break;

            case System.DayOfWeek.Tuesday:
                CustomDay = EnumDayOfWeeks.Tuesday;
                break;

            case System.DayOfWeek.Wednesday:
                CustomDay = EnumDayOfWeeks.Wednesday;
                break;

            case System.DayOfWeek.Thursday:
                CustomDay = EnumDayOfWeeks.Thursday;
                break;

            case System.DayOfWeek.Friday:
                CustomDay = EnumDayOfWeeks.Friday;
                break;

            case System.DayOfWeek.Saturday:
                CustomDay = EnumDayOfWeeks.Saturday;
                break;

            case System.DayOfWeek.Sunday:
                CustomDay = EnumDayOfWeeks.Sunday;
                break;
            }

            return(CustomDay);
        }
Пример #6
0
        public List <AvailableOffSitePeriods> GetAllAvailableOffSitePeriods()
        {
            List <AvailableOffSitePeriods> AOSP          = new List <AvailableOffSitePeriods>();
            DateTime FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = CourseSearchPeriodStartDate.Date;

            while (FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date < CourseSearchPeriodEndDate.Date)
            {
                // Ensure that this course can start on this day... eg Monday through Thursday
                while (FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date < CourseSearchPeriodEndDate.Date)
                {
                    Boolean IsFirstDayFound = false;
                    while (!IsFirstDayFound)
                    {
                        EnumDayOfWeeks DayOfTheWeek = CustomDateTime.CustomDayOfTheWeek(FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.DayOfWeek);
                        if ((from a in SetOfDaysOfWeekCourseCanBeScheulded
                             where a == DayOfTheWeek//a.HasFlag(DayOfTheWeek)
                             select a).ToList <EnumDayOfWeeks>().Count() > 0)
                        {
                            IsFirstDayFound = true;
                        }
                        else
                        {
                            FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.AddDays(1);
                        }
                    }
                    //Inclusive of the start date ( that why subtrtact day from the start date.
                    DateTime EndDateForCurrentPossibleSchedule = CustomDateTime.getCustomDateTime(FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date.AddDays(-1), CourseDuration, SetOfDaysOfWeekCourseCanBeScheulded);


                    ///get all possible cominations for the period
                    foreach (FacilitatorPeriod FP in FacilitatorAvailablePeriods.OrderBy(a => a.StartDate))
                    {
                        //Deterine if the Period is greater than the course period(Course Duration) else cant schedule in this period.
                        if (FP.GetAmountOfDaysInPeriod() >= CourseDuration)
                        {
                            //Determine if the facilitator could fall into this course period
                            if (FP.StartDate.Date <= FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date && EndDateForCurrentPossibleSchedule.Date <= FP.EndDate.Date)
                            {
                                // this period can fit into this course period.
                                //List<OnSiteVenuePeriod> OnSiteVenueAvailablePeriods
                                foreach (OffSiteVenuePeriod OSVAP in OffSiteVenueAvailablePeriods)
                                {
                                    //Deterine if the Period is greater than the course period(Course Duration) else cant schedule in this period.
                                    if (OSVAP.GetAmountOfDaysInPeriod() >= CourseDuration)
                                    {
                                        if (OSVAP.StartDate <= FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date && EndDateForCurrentPossibleSchedule.Date <= OSVAP.EndDate.Date)
                                        {
                                            AOSP.Add(new AvailableOffSitePeriods()
                                            {
                                                CourseID               = base.CourseID,
                                                CourseName             = base.CourseName,
                                                CourseStartDate        = FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.Date,
                                                CourseEndDate          = EndDateForCurrentPossibleSchedule.Date,
                                                FacilitatorID          = FP.FacillitatorID,
                                                FacilitatorName        = FP.FacilitatorName,
                                                VenueID                = OSVAP.VenueID,
                                                VenueName              = OSVAP.VenueName,
                                                VenueAssociatedCompany = OSVAP.VenueAssociatedCompany
                                            });
                                        }
                                    }
                                }
                            }
                        }
                    }
                    FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET = FIRST_DAY_CAN_BE_SCHEDULED_FROM_SET.AddDays(1);
                }
            }
            return(AOSP);
        }