/// <summary> /// Initializes class object /// </summary> /// <param name="professor">Professor ID</param> /// <param name="course">Course ID</param> /// <param name="groups">List of Group ID</param> /// <param name="lab">Class Lab name</param> /// <param name="duration">Class Duration (in hours)</param> public CourseClass(Professor professor, Course course, List<StudentsGroup> groups, string lab, int duration, int class_Id) { _professor = professor; _course = course; _numberOfSeats = 0; _lab = lab; _duration = duration; Class_ID = class_Id; // // bind professor to class // /* for (int prof = 0; prof < _professor.Count; prof++) // multiple professor for a courseClass (One of several professor will be chosen) _professor[prof].AddCourseClass(this); */ _professor.AddCourseClass(this); // // bind student groups to class // foreach (StudentsGroup it in groups) { it.AddCourseClass(this); _groups.Add(it); _numberOfSeats += it.GetNumberOfStudents; } }
// Parse file and store parsed object public void ParseFile(LINQDataContext db) { // clear previously parsed objects _professors.Clear(); _studentGroups.Clear(); _courses.Clear(); _rooms.Clear(); _courseClasses.Clear(); Room.RestartIDs(); // // Save Professor Data // foreach (var any in db.Professors) { ProfessorInfoCompiler pIc = new ProfessorInfoCompiler(); Professor p; if (pIc.StartScanner(any.Schedule)) { p = new Professor(any.ID, any.Name_Professor, pIc.CompiledData); _professors.Add(p.GetId, p); } } // // Save StudentsGroup Data // foreach (var any in db.Groups) { StudentsGroup sg; string sg_name = string.Format(CultureInfo.CurrentCulture, "{0} {1} {2}-{3}", any.Branch.Degree, any.Branch.Branch_Name, any.Semester_Entry_Year, (any.Semester_Entry_FS) ? "1" : "2"); sg = new StudentsGroup(any.ID, sg_name, any.Size_No); _studentGroups.Add(sg.GetId, sg); } // // Save Course Data // foreach (var any in db.Courses) { Course c; c = new Course(any.Course_ID, any.Name_Course); _courses.Add(c.GetId, c); } // // Save Room Data // foreach (var any in db.Rooms) { Room r; r = new Room(any.Room_ID, any.Name_Room, any.Type_Room, any.Size_No); _rooms.Add(r.GetId, r); } // // Save CourseClass Data ----------------------------------------------------------------------------- // foreach (var any in db.Classes) { // // set Professor by best priority // var prof = (from p1 in db.Priority_Professors join p2 in db.Professors on p1.Professor_ID equals p2.ID where (p1.Class_ID == any.Class_ID) orderby p1.Priority select new { p1.Professor_ID, p2.Name_Professor, p2.Schedule }).ToArray()[0]; ProfessorInfoCompiler pIc = new ProfessorInfoCompiler(); Professor p = (pIc.StartScanner(prof.Schedule)) ? new Professor(prof.Professor_ID, prof.Name_Professor, pIc.CompiledData) : new Professor(prof.Professor_ID, prof.Name_Professor, pIc.CompiledData); // // set selected course for class // Course c = new Course(any.Course_ID, any.Course.Name_Course); // // set StudentsGroup in List // List <StudentsGroup> g = new List <StudentsGroup>(); foreach (var lstGroup in (from gil in db.Group_ID_Lists join groups in db.Groups on gil.Group_ID equals groups.ID where gil.Class_ID == any.Class_ID select new { gil.Group_ID, groups.Size_No, sg_name = string.Format(CultureInfo.CurrentCulture, "{0} {1} {2}-{3}", groups.Branch.Degree, groups.Branch.Branch_Name, groups.Semester_Entry_Year, (groups.Semester_Entry_FS) ? "1" : "2") })) { StudentsGroup sg = new StudentsGroup(lstGroup.Group_ID, lstGroup.sg_name, lstGroup.Size_No); g.Add(sg); } // // save class by created data // CourseClass cc = new CourseClass(p, c, g, any.RoomType, (any.Practical_unit + any.Theory_unit), any.Class_ID); _courseClasses.Add(cc); } //---------------------------------------------------------------------------------------------------------------- // db.Dispose(); _isEmpty = false; }
// Parse file and store parsed object public void ParseFile(LINQDataContext db) { // clear previously parsed objects _professors.Clear(); _studentGroups.Clear(); _courses.Clear(); _rooms.Clear(); _courseClasses.Clear(); Room.RestartIDs(); // // Save Professor Data // foreach (var any in db.Professors) { ProfessorInfoCompiler pIc = new ProfessorInfoCompiler(); Professor p; if (pIc.StartScanner(any.Schedule)) { p = new Professor(any.ID, any.Name_Professor, pIc.CompiledData); _professors.Add(p.GetId, p); } } // // Save StudentsGroup Data // foreach (var any in db.Groups) { StudentsGroup sg; string sg_name = string.Format(CultureInfo.CurrentCulture, "{0} {1} {2}-{3}", any.Branch.Degree, any.Branch.Branch_Name, any.Semester_Entry_Year, (any.Semester_Entry_FS) ? "1" : "2"); sg = new StudentsGroup(any.ID, sg_name, any.Size_No); _studentGroups.Add(sg.GetId, sg); } // // Save Course Data // foreach (var any in db.Courses) { Course c; c = new Course(any.Course_ID, any.Name_Course); _courses.Add(c.GetId, c); } // // Save Room Data // foreach (var any in db.Rooms) { Room r; r = new Room(any.Room_ID, any.Name_Room, any.Type_Room, any.Size_No); _rooms.Add(r.GetId, r); } // // Save CourseClass Data ----------------------------------------------------------------------------- // foreach (var any in db.Classes) { // // set Professor by best priority // var prof = (from p1 in db.Priority_Professors join p2 in db.Professors on p1.Professor_ID equals p2.ID where (p1.Class_ID == any.Class_ID) orderby p1.Priority select new { p1.Professor_ID, p2.Name_Professor, p2.Schedule }).ToArray()[0]; ProfessorInfoCompiler pIc = new ProfessorInfoCompiler(); Professor p = (pIc.StartScanner(prof.Schedule)) ? new Professor(prof.Professor_ID, prof.Name_Professor, pIc.CompiledData) : new Professor(prof.Professor_ID, prof.Name_Professor, pIc.CompiledData); // // set selected course for class // Course c = new Course(any.Course_ID, any.Course.Name_Course); // // set StudentsGroup in List // List<StudentsGroup> g = new List<StudentsGroup>(); foreach (var lstGroup in (from gil in db.Group_ID_Lists join groups in db.Groups on gil.Group_ID equals groups.ID where gil.Class_ID == any.Class_ID select new { gil.Group_ID, groups.Size_No, sg_name = string.Format(CultureInfo.CurrentCulture, "{0} {1} {2}-{3}", groups.Branch.Degree, groups.Branch.Branch_Name, groups.Semester_Entry_Year, (groups.Semester_Entry_FS) ? "1" : "2") })) { StudentsGroup sg = new StudentsGroup(lstGroup.Group_ID, lstGroup.sg_name, lstGroup.Size_No); g.Add(sg); } // // save class by created data // CourseClass cc = new CourseClass(p, c, g, any.RoomType, (any.Practical_unit + any.Theory_unit), any.Class_ID); _courseClasses.Add(cc); } //---------------------------------------------------------------------------------------------------------------- // db.Dispose(); _isEmpty = false; }