/// <summary> /// Gets course HTML document from Learnweb /// </summary> /// <param name="course">Course</param> /// <returns>Status and course HTML</returns> private (ServiceStatus status, HtmlDocument courseHtml) GetCourse(Course course) { try { var res = client.GetAsync(course.Url); if (res.Result.IsSuccessStatusCode) { clientService.RefreshSession(); string htmlString = res.Result.Content.ReadAsStringAsync().Result; HtmlDocument courseHtml = new HtmlDocument(); courseHtml.LoadHtml(htmlString); return(ServiceStatus.OK, courseHtml); } else { logger.LogError($"Could not load course with id '{course.Id}' ({res.Result.StatusCode})"); return(ServiceStatus.Exception, null); } } catch (Exception ex) { logger.LogError(ex.Message); return(ServiceStatus.UnhandledException, null); } }
/// <summary> /// Refreshes ClientService session /// </summary> /// <returns>ServiceStatus</returns> public ServiceStatus RefreshSession() => clientService.RefreshSession();