Ejemplo n.º 1
0
        public IEnumerable <UTCourse> FetchItems()
        {
            string sess = WebUrlConstants.UTSCSession;
            IEnumerable <UTCourse> courseInfos   = new UTSCCourseInfoHtmlFetcher(WebUrlConstants.UTSCTimetable, sess).FetchItems();
            List <UTCourse>        courseDetails = new List <UTCourse>();

            IItemFetcher <string> departmentFetcher = new UTSCDepartmentFetcher(WebUrlConstants.UTSCDepartment, sess);

            Parallel.ForEach <string>(departmentFetcher.FetchItems(), new ParallelOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            }, delegate(string url)
                                      //foreach (var url in departmentFetcher.FetchItems())
            {
                IEnumerable <UTCourse> part = new UTSCCourseDetailFetcher(url).FetchItems();
                lock (this)
                {
                    courseDetails.AddRange(part);
                }
            });
            //}

            courseInfos = courseInfos.GroupJoin(courseDetails,
                                                (x => x.Abbr),
                                                (x => x.Abbr),
                                                ((x, y) => (CombineInfoDetail(x, y.FirstOrDefault()))),
                                                new UTCourseAbbrComparer());

            return(courseInfos);
        }
Ejemplo n.º 2
0
        public IEnumerable <SchoolProgram> FetchItems()
        {
            List <SchoolProgram> results = new List <SchoolProgram>();

            IItemFetcher <string> departmentFetcher = new UTSCDepartmentFetcher(WebUrlConstants.UTSCDepartment);

            Parallel.ForEach <string>(departmentFetcher.FetchItems(), new ParallelOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            }, delegate(string url)
                                      //foreach (var url in departmentFetcher.FetchItems())
            {
                IEnumerable <SchoolProgram> part = new UTSCProgramDetailFetcher(url).FetchItems();
                lock (this)
                {
                    results.AddRange(part);
                }
            });
            //}

            return(results);
        }