public async Task <ActionResult> ExportShortCatalogueTitles(string token) { if (PaulRepository.IsUpdating) { return(StatusCode(503)); // Service unavailable } var catalogues = await PaulRepository.GetCourseCataloguesAsync(); return(Json(catalogues.Select(c => c.ShortTitle))); }
public async Task <ActionResult> TestParsing() { var searchString = "L.104.12270"; var course = PaulRepository.Courses.FirstOrDefault(c => c.Id.Contains(searchString)); var parser = new PaulParser(); var courseCatalog = (await PaulRepository.GetCourseCataloguesAsync()).First(); var httpClient = new HttpClient(); var response = await httpClient.GetAsync("https://paul.uni-paderborn.de/scripts/mgrqispi.dll?APPNAME=CampusNet&PRGNAME=COURSEDETAILS&ARGUMENTS=-N000000000000001,-N000443,-N0,-N360765878897321,-N360765878845322,-N0,-N0,-N3,-A4150504E414D453D43616D7075734E6574265052474E414D453D414354494F4E26415247554D454E54533D2D4179675978627166464D546570353271395952533363394A33415A7A346450656F347A72514F7661686C327A34706559594179354333386A6C636975396B71334456666E492D4B6E6872493545326F45672E74437349727130616D55426B4B37627573455048356D4351544F42326B4759696B507333596C316E7555742E6E3D3D"); var doc = new HtmlDocument(); using (var db = new DatabaseContext(PaulRepository.Filename, "")) { db.Attach(courseCatalog); doc.LoadHtml(await response.Content.ReadAsStringAsync()); await parser.UpdateExamDates(doc, db, course); await db.SaveChangesAsync(); } return(Ok()); }
/// <summary> /// Creates a new empty schedule in the database. /// </summary> /// <returns>A ViewModel that represents the new schedule</returns> public async Task <SharedScheduleViewModel> CreateScheduleAsync(string catalogId, ErrorReporter errorReporter) { var catalogs = await PaulRepository.GetCourseCataloguesAsync(); var selectedCatalog = catalogs.FirstOrDefault(o => o.InternalID == catalogId); if (selectedCatalog == null) { errorReporter.Throw( new ArgumentException($"A CourseCatalog with the specified ID '{catalogId}' does not exist"), UserErrorsViewModel.GenericErrorMessage); } // Create a new schedule in DB var schedule = await PaulRepository.CreateNewScheduleAsync(selectedCatalog); var vm = new SharedScheduleViewModel(schedule); _loadedSchedules.Add(schedule.Id, vm); return(vm); }
/// <summary> /// Used to update all category filters for every course catalog /// </summary> /// <param name="allCourses">List of existing courses</param> /// <param name="context">Database context</param> /// <returns></returns> public async Task UpdateCategoryFilters(List <Course> allCourses, DatabaseContext context) { PaulRepository.AddLog("Update for category filters has started!", FatalityLevel.Normal, "Update category filters"); var catalogues = (await PaulRepository.GetCourseCataloguesAsync(context)); foreach (var cat in catalogues) { try { PaulRepository.AddLog($"Update for course catalog {cat.ShortTitle} has started!", FatalityLevel.Normal, ""); await UpdateCategoryFiltersForCatalog(cat, allCourses, context); PaulRepository.AddLog($"Update for course catalog {cat.ShortTitle} completed!", FatalityLevel.Normal, ""); } catch (Exception e) { PaulRepository.AddLog($"Updating Categories failed: {e}", FatalityLevel.Critical, "Nightly Update"); } } PaulRepository.AddLog("Update for category filters completed!", FatalityLevel.Normal, "Update category filters"); }
// GET: api/values public async Task <ActionResult> GetCourseCatalogues() { return(Json(await PaulRepository.GetCourseCataloguesAsync())); }
public async Task RefreshAvailableSemestersAsync() { AvailableSemesters = (await PaulRepository.GetCourseCataloguesAsync()). Where(c => PaulRepository.Courses.Any(course => course.Catalogue.Equals(c))) .OrderByDescending(catalog => GetCourseCatalogOrder(catalog)); }