Ejemplo n.º 1
0
 protected decimal GoToHoursShedule(LoadItem item, decimal Load, ScheduleDay dayShedule, int Attempt)
 {
     //можно ли еще добалять пары в этот день или это день для группы заполнен
     if (dayShedule.LimitLessonsNotExceeded(item.Groups, dayShedule.Week, dayShedule.Day))
     {
         List <Position> freePositions = new List <Position>();
         //цикл по доступным часам для этого дня (в будни и выходные часы для проставления пар разные)
         for (int Hour = dayShedule.EarlierPossibleHour; Hour <= dayShedule.LastPossibleHour; Hour++)
         {
             ScheduleTime Time = new ScheduleTime(dayShedule.Week, dayShedule.Day, Hour);
             //выбираем аудиторию
             ScheduleRoom Room = FindRoom(item, Time);
             if (Room != null)
             {
                 freePositions.Add(new Position(Room, Time));
             }
         }
         // добавляем занятия
         if (freePositions.Count > 0)
         {
             Load = PutLessonsOnFreePositions(freePositions, Load, Attempt, item);
         }
     }
     return(Load);
 }
Ejemplo n.º 2
0
        protected virtual bool CanPutToPosition(ScheduleTime time, ScheduleRoom room, LoadItem item)
        {
            ScheduleDay day = Shedule.GetDay(time.Week, time.Day);

            return(time.WeekNumber <= 4 && time.WeekNumber >= 1 && day != null &&
                   day.LimitLessonsNotExceeded(item.Groups, time.Week, time.Day, 1) &&
                   Employments.IsHourFree(item.Teacher, item.Groups, room.Name, time));
        }
Ejemplo n.º 3
0
 protected virtual decimal PutOneLessonOnOneOrTwoWeek(List <Position> freePositions, decimal Load, LoadItem item)
 {
     foreach (Position position in freePositions)
     {
         ScheduleDay day = Shedule.GetDay(position.Time);
         if (day.LimitLessonsNotExceeded(item.Groups, day.Week, day.Day, 1))
         {
             Load = PutLesson(item, position.Time, position.Room, Load);
             if (Load > 0 && CanPutToPosition(GetTimeAfterTwoWeek(position.Time), position.Room, item))
             {
                 Load = PutLesson(item, GetTimeAfterTwoWeek(position.Time), position.Room, Load);
             }
         }
         if (Load == 0)
         {
             break;
         }
     }
     return(Load);
 }
Ejemplo n.º 4
0
        private decimal PutTwoLessonOnWeek(List <Position> Adding, decimal Load, LoadItem item)
        {
            for (int counter = 0; counter < Adding.Count - 1 && Load > 0; counter++)
            {
                Position curr = Adding[counter];
                Position next = Adding[counter + 1];

                ScheduleDay day = Shedule.GetDay(curr.Time);
                if (!IsHoursNear(curr.Time, next.Time) || !day.LimitLessonsNotExceeded(item.Groups, day.Week, day.Day, 2))
                {
                    continue;
                }

                if (CanPutToPosition(curr.Time, curr.Room, item) && CanPutToPosition(next.Time, next.Room, item))
                {
                    Load = PutLesson(item, curr.Time, curr.Room, Load);
                    Load = PutLesson(item, next.Time, next.Room, Load);
                }
            }

            return(Load);
        }
Ejemplo n.º 5
0
        private decimal PutTwoLessonOnTwoWeek(List <Position> freePositions, decimal Load, LoadItem item)
        {
            for (int counter = 0; counter < freePositions.Count - 1 && Load > 0; counter++)
            {
                Position curr = freePositions[counter];
                Position next = freePositions[counter + 1];

                if (curr.Time.WeekNumber > 2 || next.Time.WeekNumber > 2)
                {
                    continue;
                }

                ScheduleTime CurrAfterTwoWeek = GetTimeAfterTwoWeek(curr.Time);
                ScheduleTime NextAfterTwoWeek = GetTimeAfterTwoWeek(next.Time);

                ScheduleDay currDay = Shedule.GetDay(curr.Time);
                ScheduleDay nextDay = Shedule.GetDay(CurrAfterTwoWeek);

                if (!IsHoursNear(curr.Time, next.Time) || !currDay.LimitLessonsNotExceeded(item.Groups, currDay.Week, currDay.Day, 2) ||
                    !nextDay.LimitLessonsNotExceeded(item.Groups, CurrAfterTwoWeek.Week, CurrAfterTwoWeek.Day, 2))
                {
                    continue;
                }

                if (CanPutToPosition(curr.Time, curr.Room, item) && CanPutToPosition(next.Time, next.Room, item) &&
                    CanPutToPosition(CurrAfterTwoWeek, curr.Room, item) && CanPutToPosition(NextAfterTwoWeek, next.Room, item))
                {
                    Load = PutLesson(item, curr.Time, curr.Room, Load);
                    Load = PutLesson(item, next.Time, next.Room, Load);
                    Load = PutLesson(item, CurrAfterTwoWeek, curr.Room, Load);
                    Load = PutLesson(item, NextAfterTwoWeek, next.Room, Load);
                    counter++;
                    return(Load);
                }
            }

            return(Load);
        }