public HttpRequestMessage GetCoursePageHRM(string courseId) { Course course = CourseList.Find(c => c.Id == courseId); HttpRequestMessage hrm; if (course.IsNewWebLearning) { string url = string.Format(@"http://learn.cic.tsinghua.edu.cn/f/student/coursehome/{0}", course.Id); hrm = new HttpRequestMessage(HttpMethod.Get, new Uri(url)); foreach (System.Net.Cookie cookie in web.cc.GetCookies(new Uri("http://learn.cic.tsinghua.edu.cn"))) { hrm.Headers.Cookie.Add(new Windows.Web.Http.Headers.HttpCookiePairHeaderValue(cookie.Name, cookie.Value)); } } else { string url = string.Format(@"http://learn.tsinghua.edu.cn/MultiLanguage/lesson/student/course_locate.jsp?course_id={0}", course.Id); hrm = new HttpRequestMessage(HttpMethod.Get, new Uri(url)); foreach (System.Net.Cookie cookie in web.cc.GetCookies(new Uri("http://learn.tsinghua.edu.cn"))) { hrm.Headers.Cookie.Add(new Windows.Web.Http.Headers.HttpCookiePairHeaderValue(cookie.Name, cookie.Value)); } } return(hrm); }
public async Task <UpdateResult> RefWorkList(string courseId) { Course course = CourseList.Find(c => c.Id == courseId); List <Work> newList = course.IsNewWebLearning ? await web.GetWorkListNew(course.Id):await web.GetWorkListOld(course.Id); Merge.WorkList(course.WorkList, newList); return(UpdateResult.Success); }
public List <Notice> GetNoticeList(string courseId) { Course course = CourseList.Find(c => c.Id == courseId); if (course == null || course.NoticeList == null) { throw new Exception("No record of this course."); } return(course.NoticeList); }
public Notice GetNotice(string courseId, string noticeId) { Course course = CourseList.Find(c => c.Id == courseId); if (course == null) { throw new Exception("No record of this course."); } Notice notice = course.NoticeList.Find(n => n.Id == noticeId); if (notice == null) { throw new Exception("No record of this notice."); } return(notice); }
public async Task <UpdateResult> RefNoticeList(string courseId, bool forceRefresh = false) { Course course = CourseList.Find(c => c.Id == courseId); if (course == null) { throw new Exception("No record of this course."); } if (!(course.UpdateNoticeTime < course.UpdateTime || DateTime.Now - course.UpdateNoticeTime > new TimeSpan(2, 0, 0) || forceRefresh)) { return(UpdateResult.No); } List <Notice> list = course.IsNewWebLearning ? await web.GetNoticeListNew(course.Id) : await web.GetNoticeListOld(course.Id); Merge.NoticeList(course.NoticeList, list); course.UpdateNoticeTime = DateTime.Now; return(UpdateResult.Success); }