public TimetableData(Block[] blocks, Course[] courses, Lecturer[] lecturers, Room[] rooms, Group[] groups) : base() { this.Blocks = blocks; this.Courses = courses; this.Lecturers = lecturers; this.Rooms = rooms; this.Groups = groups; Array.Sort(courses, SortCoursesByLength); }
public Course(string id, string name, Lecturer[] lecturers, Room roomPreference, Group group, bool needsLab, bool isDummy, /*int repeatsPerWeek,*/ int numberOfBlocks) { this.Id = id; this.Name = name; this.Lecturers = lecturers; this.RoomPreference = roomPreference; this.NeedsLab = needsLab; this.IsDummy = isDummy; this.NumberOfBlocks = numberOfBlocks; this.Group = group; Index = globalIndex; globalIndex++; }
private static void AppendRooms(Room[] rooms, StringBuilder output) { output.Append("<rooms>"); foreach (Room r in rooms) { output.Append("<room"); output.Append(" number=\"" + r.Name + "\""); output.Append(" isLab=\"" + r.IsLab + "\""); output.Append("/>"); } output.Append("</rooms>"); }
private static Course[] ParseCources(XPathNavigator navigator, Lecturer[] lecturers, Room[] rooms, Group[] groups) { XPathNodeIterator nodeIterator = navigator.Select("timetableData/courses/course"); List<Course> courses = new List<Course>(); foreach (XPathNavigator node in nodeIterator) { string cId = node.GetAttribute("cId", ""); string name = node.GetAttribute("name", ""); bool needsLab = ParseBoolFromString(node.GetAttribute("needsLab", ""), false); bool isDummy = ParseBoolFromString(node.GetAttribute("isDummy", ""), false); int numberOfBlocks = ParseIntFromString(node.GetAttribute("numberOfBlocks", ""), 1); int repeatsPerWeek = ParseIntFromString(node.GetAttribute("repeatsPerWeek", ""), 1); List<Lecturer> lecturerList = new List<Lecturer>(); Lecturer l0 = GetLecturerWithID(node.GetAttribute("lId0", ""), lecturers); Lecturer l1 = GetLecturerWithID(node.GetAttribute("lId1", ""), lecturers); lecturerList.Add(l0); if (l1 != null) lecturerList.Add(l1); string roomPreference = node.GetAttribute("roomPreference", ""); Room preference = null; foreach (Room room in rooms) { if (room.Name.Equals(roomPreference)) { preference = room; break; } } string gId = node.GetAttribute("gId", ""); Group group = null; foreach (Group g in groups) { if (g.Id.Equals(gId)) { group = g; break; } } for (int repetition = 0; repetition < repeatsPerWeek; repetition++) { courses.Add(new Course(cId, name, lecturerList.ToArray(), preference, group, needsLab, isDummy, numberOfBlocks)); } } return courses.ToArray(); }