public void CreateSchedule(ProgramMode pm) { if (pm == ProgramMode.XML) { this.GetDataFromXML(); } else { this.GetDataFromDb(); } this.CreatingClasses(); List <Class> FirstGroup = new List <Class>(); List <Class> SecondGroup = new List <Class>(); this.Dividing(FirstGroup, SecondGroup); this.create(0, FirstGroup); this.create(3, SecondGroup); if (pm == ProgramMode.Database) { ClassRepo.AddToDb(ResSchedule); } else if (pm == ProgramMode.XML) { ClassRepo.SerializeArray("../../Data/classes.xml", ResSchedule.ToArray()); } else { ClassRepo.AddToDb(ResSchedule); ClassRepo.SerializeDb("../../Data/classes.xml"); } }
public List <Class> GetClassesFromFile() { var ClassesFromFile = ClassRepo.DeserializeArray("../../schedule/Data/classes.xml").ToList(); for (int i = 0; i < ClassesFromFile.Count; i++) { ClassesFromFile[i].Group = Groups.SingleOrDefault(g => g.Id == ResSchedule[i].GroupId); ClassesFromFile[i].Teacher = Teachers.SingleOrDefault(t => t.Id == ResSchedule[i].TeacherId); ClassesFromFile[i].Room = Rooms.SingleOrDefault(r => r.Id == ResSchedule[i].RoomId); ClassesFromFile[i].Subject = Subjects.SingleOrDefault(s => s.Id == ResSchedule[i].SubjectId); } return(ClassesFromFile); }
private void ResetAlgorithm() { ResSchedule?.Clear(); Rooms?.Clear(); Classes?.Clear(); DictionaryOfSubjects?.Clear(); DictionaryOfGroups?.Clear(); Groups?.Clear(); Subjects?.Clear(); GroupSubjects?.Clear(); Teachers?.Clear(); TeacherSubjects?.Clear(); ClassRepo.DeleteAllFromDb(); }
public void CreatingClasses() { foreach (var group in Groups) { DictionaryOfGroups.Add(group.Id, group); } foreach (var subject in Subjects) { DictionaryOfSubjects.Add(subject.Id, subject); } foreach (var subj in Subjects) { List <long?> SubjectTeacher = new List <long?>(); List <long?> SubjectGroup = new List <long?>(); foreach (var teacher in TeacherSubjects) { if (subj.Id == teacher.SubjectId) { SubjectTeacher.Add(teacher.TeacherId); } } foreach (var group in GroupSubjects) { if (subj.Id == group.SubjectId) { SubjectGroup.Add(group.GroupId); } } int i = 0; foreach (var Group in SubjectGroup) { Classes.Add(ClassRepo.CreateClass(0, (long)Group, subj.Id, (long)SubjectTeacher[i], DayOfWeek.Sunday, 0)); i++; i %= SubjectTeacher.Count; } } }
public List <Class> GetClassesFromDb() { return(ClassRepo.GetClassesFromDb()); }