static ProposedCoursesParser() { string classesPageSource = _regnewClient.GetStringAsync(ProposedCoursesUri).Result; var classesPage = new ProposedCoursesPage(classesPageSource); CurrentYear = classesPage.SelectedYear; CurrentSemester = classesPage.SelectedSemester; }
public static UClass ParseClass(IHtmlTableRowElement classRow, int classYear = 0, USemester classSemester = USemester.Unknown) { int courseId = int.Parse(classRow.QuerySelector <IHtmlSpanElement>(slc_classId).TextContent); string courseName = classRow.QuerySelector <IHtmlSpanElement>("td>span[id*=CourseName]").TextContent; string classInstructor = classRow.QuerySelector <IHtmlSpanElement>("td>span[id*=Instructor]").TextContent; int classSection = int.Parse(classRow.QuerySelector <IHtmlSpanElement>(slc_classSection).TextContent); string classDaysString = classRow.QuerySelector <IHtmlSpanElement>("td>span[id*=Day]").TextContent; DayOfWeek[] classDays = DayOfWeekConverter.ToDays(classDaysString).ToArray(); var(classStartTime, classEndTime) = ParseClassTime(classRow.OuterHtml); int.TryParse(classRow.QuerySelector <IHtmlSpanElement>("td>span[id*=MaxStNo]")?.TextContent, out int classCapacity); int.TryParse(classRow.QuerySelector <IHtmlSpanElement>("td>span[id*=RegStNo]")?.TextContent, out int classRegisterdStudentsCount); //To detecet Labs int classFinancialHours = (int)((classDays.Length == 1 ? 1 : (classEndTime - classStartTime).TotalHours) * classDays.Length); classInstructor = classInstructor.Trim(); courseName = courseName.Trim(); return(new UClass(course: new UCourse(courseId, classFinancialHours, courseName), instructorName: classInstructor, days: classDays, startTime: classStartTime, endTime: classEndTime, section: classSection, capacity: classCapacity, numberOfRegisteredStudents: classRegisterdStudentsCount)); }
public static UClass[] ParseClassesTable(IHtmlTableElement classesTable, int classYear = 0, USemester classSemester = USemester.Unknown) { var classes = new ConcurrentBag <UClass>(); Parallel.ForEach(classesTable.Rows.Skip(1), row => classes.Add(ParseClass(row, classYear, classSemester))); return(classes.ToArray()); }