Example #1
0
        /// <summary>
        /// Parses the html and puts the new courses into the database
        /// </summary>
        /// <param name="courseCode">The course code</param>
        /// <param name="title">The title of the course</param>
        /// <param name="desc">The description of the course</param>
        /// <param name="campus">The campus</param>
        private void CreateCourseSchedule(string courseCode, string title, string desc, string campus)
        {
            TimetablePage.ClearFilters();
            TimetablePage.EnterCourseCode(courseCode);
            TimetablePage.SearchForCourses();
            TimetablePage.WaitForContentToLoad();

            // Get course info for both the fall and winter term
            List <Course> coursesInfo = new List <Course>();

            // If there are no courses available then output it
            if (Browser.FindElement("id", "courseSearchResultNum").Text == "0 courses found.")
            {
                Console.WriteLine(courseCode + " has no courses!!!");
            }

            else
            {
                var courseTables = Browser.FindElements("xpath", "//table[@class='perCourse']");
                foreach (var courseTable in courseTables)
                {
                    //Course newCourse = GetCourses(courseTable, title, desc, campus);
                    Course newCourse = null;
                    if (newCourse != null)
                    {
                        coursesInfo.Add(newCourse);
                    }
                }
            }
            db.Courses.InsertAllOnSubmit(coursesInfo);
            db.SubmitChanges();
        }
Example #2
0
        /// <summary>
        /// Parses the HTML and populates the courses in the database
        /// If {overrideAllSchedules} is true, it will delete all existing course data from the database
        /// </summary>
        /// <param name="overrideAllSchedules">Whether to delete existing course data or not</param>
        public void CreateCourseSchedules(bool overrideAllSchedules)
        {
            db.ObjectTrackingEnabled = true;

            if (overrideAllSchedules)
            {
                RemoveAllCourseSchedules();
            }

            Browser.Initialize();
            TimetablePage.GotoPage();
            TimetablePage.SelectTerm(new string[] { "F", "S", "Y" });
            TimetablePage.SearchForCourses();
            TimetablePage.WaitForContentToLoad();

            CreateCourseSchedule();

            Browser.Close();
            db.Connection.Close();
            db.Dispose();
        }