Beispiel #1
0
        private void CalculateClassGroupSchedule(ClassGroupSchedule cg)
        {
            if (cg == null)
            {
                Logger.Error($"Null exception: cg");
                throw new ArgumentNullException("cg");
            }
            TrainingProgramSchedule trainingProgram = cg.TrainingProgram;

            if (trainingProgram == null)
            {
                Logger.Error($"Class-group does not containt Training Program.");
                throw new InvalidOperationException($"ClassGroup {cg.Id} does not containt training program.");
            }

            trainingProgram.Timetable = this.timetableService.GetProgramTimetable(trainingProgram.Id);

            List <Course> css = this.UnitOfWork.CourseRepository.GetCourseSubjectByTrainingProgram(trainingProgram.Id).ToList();

            var mapper = config.CreateMapper();

            List <CourseSchedule> courseSubjects = mapper.Map <List <Course>, List <CourseSchedule> >(css);

            trainingProgram.CourseSubjects = courseSubjects;

            int shiftPerDay  = trainingProgram.Timetable.ShiftPerDay;
            int slotPerShift = trainingProgram.Timetable.SlotPerShift;

            foreach (ClassRoomSchedule cr in cg.ClassRooms)
            {
                StoneCastle.Scheduler.Models.TimetableModel tt = this.timetableService.GetWorkingTimeTable(shiftPerDay, slotPerShift);
                tt = tt.Join(trainingProgram.Timetable);

                cr.Timetable = tt;

                // Get Courses
                List <ClassCourse>         courses         = this.UnitOfWork.ClassCourseRepository.GetCoursesByClassRoom(cr.Id).ToList();
                List <ClassCourseSchedule> courseSchedules = mapper.Map <List <ClassCourse>, List <ClassCourseSchedule> >(courses);
                cr.Courses = courseSchedules;
            }
        }
Beispiel #2
0
        private StoneCastle.Scheduler.Models.ClassGroupSchedule GetRandomScheduleGroup(string groupName, int workingShiftInDay)
        {
            TrainingProgramSchedule trainingProgram = new TrainingProgramSchedule()
            {
                Id        = Guid.NewGuid(),
                Timetable = timetableService.GetWorkingTimeTable(this.workingShiftInDay, this.workingSlotPerShift)
                            //Timetable = timetableService.GetTimeTable(this.workingShiftInDay)
            };

            string[] courseSubjectNames = new string[] { "Math", "History", "Geo", "English", "Art", "Literality", "Chemistry" };

            int courseSubjectCount = 0;

            while (courseSubjectCount == 0)
            {
                courseSubjectCount = rand.Next(6);
            }

            for (int i = 0; i < courseSubjectCount; i++)
            {
                CourseSchedule courseSubject = new CourseSchedule()
                {
                    Id = Guid.NewGuid(),
                    //TrainingProgram = trainingProgram,
                    Name           = courseSubjectNames[i],
                    SectionPerWeek = rand.Next(3),
                    HighlightColor = Commons.Ultility.GetHighlightColor(rand),
                };

                trainingProgram.CourseSubjects.Add(courseSubject);
            }

            StoneCastle.Scheduler.Models.ClassGroupSchedule cg = new StoneCastle.Scheduler.Models.ClassGroupSchedule()
            {
                Id              = Guid.NewGuid(),
                Name            = groupName,
                TrainingProgram = trainingProgram
            };

            int classCount = 0;

            while (classCount == 0)
            {
                classCount = rand.Next(6);
            }

            List <StoneCastle.Scheduler.Models.ClassRoomSchedule> classRooms = new List <StoneCastle.Scheduler.Models.ClassRoomSchedule>();

            for (int i = 0; i < classCount; i++)
            {
                StoneCastle.Scheduler.Models.TimetableModel tt = this.timetableService.GetWorkingTimeTable(workingShiftInDay, this.workingSlotPerShift);
                tt = tt.Join(trainingProgram.Timetable);

                StoneCastle.Scheduler.Models.ClassRoomSchedule cr = new StoneCastle.Scheduler.Models.ClassRoomSchedule()
                {
                    Id   = Guid.NewGuid(),
                    Name = $"{groupName}.{(i + 1)}",
                    //ClassGroup = cg,
                    Timetable = tt,
                };

                cg.ClassRooms.Add(cr);
                classRooms.Add(cr);
            }

            // Course
            for (int i = 0; i < courseSubjectCount; i++)
            {
                CourseSchedule courseSubject = ((List <CourseSchedule>)trainingProgram.CourseSubjects)[i];

                StoneCastle.Scheduler.Models.TimetableModel tt = this.timetableService.GetWorkingTimeTable(workingShiftInDay, this.workingSlotPerShift);

                TeacherScheduleModel teacher = new TeacherScheduleModel()
                {
                    Id = Guid.NewGuid(),
                    //FirstName = "Teacher",
                    //LastName = i.ToString(),
                    Timetable = tt
                };

                //for (int j = 0; j < classCount; j++)
                foreach (ClassRoomSchedule classRoom in classRooms)
                {
                    StoneCastle.Scheduler.Models.TimetableModel t = this.timetableService.GetWorkingTimeTable(workingShiftInDay, this.workingSlotPerShift);

                    ClassCourseSchedule course = new ClassCourseSchedule()
                    {
                        Id        = Guid.NewGuid(),
                        Teacher   = teacher,
                        Course    = courseSubject,
                        Timetable = t
                    };

                    classRoom.Courses.Add(course);
                }
            }

            return(cg);
        }