public void checkForUpdates(Semester newUpdate) { bool changed = false; Semester oldData = (Semester)Settings.Default.semester; if (oldData != null) { foreach (Note note in newUpdate.noten) { if(oldData.noten.Any(m => m.modulbezeichnung == note.modulbezeichnung)) { Note oldNote = oldData.noten.Single(m => m.modulbezeichnung == note.modulbezeichnung); if (oldNote.note != note.note) { changed = changed ? true : true; oldNote.changed = true; note.changed = true; } } } if (changed) { noteChanged = true; } else { noteChanged = false; } } }
public Semester parse() { string[] stringSeparators = new string[] {" "}; Semester semester = new Semester(); HtmlDocument doc = new HtmlDocument(); // doc.Load("C:\\Users\\HenrikPHessel\\Desktop\\Studentenportal - Rheinische Fachhochschule Köln.htm"); if(htmlContent == null) { pullNotes(); } doc.LoadHtml(htmlContent); // Pull Semester var semesterHtml = doc.DocumentNode.SelectNodes("//*[contains(concat( \" \", @class, \" \" ), concat( \" \", \"semester_bez\", \" \" ))]"); semester.semester = semesterHtml.First().InnerText; semester.noten = new List<Note>(); var notenHtml = doc.DocumentNode.SelectNodes("//td"); bool isDone = false; foreach (HtmlNode link in notenHtml) { if(isDone) break; if (link.InnerText.Contains("Termin")) { HtmlNode next = link.ParentNode.NextSibling; while (next.ChildNodes.Count() > 1) { Note note = new Note(); note.modulbezeichnung = HttpUtility.HtmlDecode(next.ChildNodes[0].InnerText.Split(stringSeparators, StringSplitOptions.None)[0]); note.note = next.ChildNodes[1].InnerText; note.changed = false; semester.noten.Add(note); next = next.NextSibling; if (next == null || next.ChildNodes.Count() == 1) { isDone = true; break; } } } } Settings.Default.lastupdated = DateTime.Now; Settings.Default.Save(); return semester; }