private void checkAndUpdateWikiPage(PageReadData data) { // First check revID WikiAPI api = new WikiAPI(); var revIDs = api.GetRevisions(data.WikiPage, data.LastRevision).OrderBy(x => x.RevId).ToList(); if (revIDs.Count <= 1) { // No newer revID return; } var currentRevID = revIDs.Last().RevId; if (data.LastRevision == -1) { // First check send email sendEmail(data); refreshDatabase(data, true, currentRevID); return; } string currentPageContent = api.GetContent(data.WikiPage, currentRevID); string prevPageContent = api.GetContent(data.WikiPage, data.LastRevision); MatchCollection words1 = Regex.Matches(currentPageContent, @"\b(\w+)\b"); MatchCollection words2 = Regex.Matches(prevPageContent, @"\b(\w+)\b"); var hs1 = new HashSet <string>(words1.Cast <Match>().Select(m => m.Value)); var hs2 = new HashSet <string>(words2.Cast <Match>().Select(m => m.Value)); var hs1_mod = new HashSet <string>(hs1); var hs2_mod = new HashSet <string>(hs2); hs2_mod.ExceptWith(hs1); int prevVersionExtraWordCounter = hs2_mod.Count; hs1_mod.ExceptWith(hs2); int newVersionExtraWordCounter = hs1_mod.Count; // Calculate diff, if bigger then sensititvity, then send email if (newVersionExtraWordCounter + prevVersionExtraWordCounter > data.Sensitivity) { sendEmail(data); refreshDatabase(data, true, currentRevID); } else { refreshDatabase(data); } }
private void sourceButton_Click(object sender, EventArgs e) { WikiAPI api = new WikiAPI(); resultText.Text = api.GetContent(titleText.Text); revisionList.DataSource = null; }
private void revisionList_SelectedIndexChanged(object sender, EventArgs e) { var item = (RevisionData)revisionList.SelectedItem; if (item != null) { revText.Text = item.RevId.ToString(); parentText.Text = item.ParentId.ToString(); sizeText.Text = item.Size.ToString(); timeText.Text = item.Timestamp.ToString(); WikiAPI api = new WikiAPI(); resultText.Text = api.GetContent(titleText.Text, item.RevId); } else { revText.Text = ""; parentText.Text = ""; sizeText.Text = ""; timeText.Text = ""; resultText.Text = ""; } }