public static DiffTemporaryResult __GetDiff(CoreOperations aw, WikiRevision from, WikiRevision to, Element el, bool pro_info = false) { DiffTemporaryResult result = null; try { String title = el.title; title = title.Replace(' ', '_'); SweepNetPage page = el.page; if (page.list.Count == 0) { return(result); } String data = ""; long start_id, end_id; if (from == null) { from = to; to = null; } bool textflag = false; if (from == null || to == null || from.revid == to.revid) { data = aw.HTTP_W_REQUEST("index.php?oldid=" + (from != null ? from.revid : to.revid) + "&action=raw&ctype=text/css"); if (data.Equals("") || data.Equals("/* Empty */")) { return(result); } data = "<tr width=\"100%\"><td width=\"100%\" colspan=\"4\">" + HttpUtility.HtmlEncode(data).Replace("\n", "<br />") + "</td></tr>"; start_id = -1; end_id = el.page.curr.revid; } else { data = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&titles=" + HttpUtility.UrlEncode(title) + "&rvstartid=" + from.revid + "&rvlimit=1&rvdiffto=" + to.revid); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(data); XmlNode currentNode; currentNode = xmlDoc.DocumentElement.SelectSingleNode("query"); if (currentNode == null) { return(result); } currentNode = currentNode.SelectSingleNode("pages"); if (currentNode == null) { return(result); } currentNode = currentNode.SelectSingleNode("page"); if (currentNode == null) { return(result); } currentNode = currentNode.SelectSingleNode("revisions"); if (currentNode == null) { return(result); } currentNode = currentNode.SelectSingleNode("rev"); if (currentNode == null) { return(result); } currentNode = currentNode.SelectSingleNode("diff"); if (currentNode == null) { return(result); } data = currentNode.InnerText; start_id = page.flagged_rev + 1; end_id = el.page.curr.revid; } String diffrez = "<html><head>" + i18n.GetText("diff_head" + Options.GetOption("diff_style")) + "</head><body width=\"100%\">"; if (pro_info) { diffrez += "<table width=\"100%\" border=\"0\" valign=\"top\"><tr>"; diffrez += "<td width=\"" + (to != null ? "50" : "100") + "%\" valign=\"top\">" + DateTime.Parse(from.timestamp).ToString("dd/MM/yyyy HH:mm") + " " + from.user + "" + (to != null ? "<br />" : "") + " [" + from.size + " байт]" + (from.minor ? " [m] " : "") + " (" + HttpUtility.HtmlEncode(from.comm) + ")" + "</td>"; if (to != null) { diffrez += "<td valign=\"top\">" + DateTime.Parse(to.timestamp).ToString("dd/MM/yyyy HH:mm") + " " + to.user + "<br /> [" + to.size + " байт]" + (to.minor ? " [m] " : "") + " (" + HttpUtility.HtmlEncode(to.comm) + ")" + "</td>"; } diffrez += "</tr></table>"; } else { diffrez += "<table width=\"100%\" border=\"0\"><tr><td colspan=\"2\">" + String.Format("{0} edits have been made by: {1}".T(), (page.GeCountOfEdits(start_id, end_id)), Tools.GetColoredListOfUsers(page.GetHashtableofcontributors(start_id, end_id))) /*page.GetContributors(1).ToArray())*/; if (page.unflagged_count == 1) { diffrez += "; " + "Summary".T() + ": \"" + HttpUtility.HtmlEncode(page.GetLastRevision().comm) + "\""; } diffrez += @"<span id=""authors""></span>";//"<!--SPACE_FOR_AUTHORS_BEGINNING--><!--SPACE_FOR_AUTHORS_ENDING-->"; diffrez += "</td></tr><tr><td align=\"left\" valign=\"bottom\">" + (page.is_flagged ? "Stable revision".T() : "First revision".T()) + " — " + Tools.ConvertTimestampToDate(page.list[0].timestamp) + "</td><td align=\"right\" valign=\"bottom\">Текущая — " + Tools.ConvertTimestampToDate(page.list[page.list.Count - 1].timestamp) + "</td></tr></table>"; } if (!WBcallback.CheckVisbleChanges(data) && !data.Equals("")) { diffrez += "<div align=\"center\"><b>" + "No noticeable changes".T() + "</b></div>"; } diffrez += "<table width=\"100%\" style=\"border-top: solid #000000 1px;\">"; diffrez += "<col width=\"2%\" valign=\"top\"><col width=\"46%\" valign=\"top\"><col width=\"2%\" valign=\"top\"><col width=\"46%\" valign=\"top\">"; List <DiffPiece> pieces = DiffEditor.SplitIntoPieces(ref data); diffrez += data.Equals("") ? "<td colspan=\"4\"><!--diff_is_empty-->" + "These revisions are the same".T() + "</td>" : data; diffrez += "</table>"; diffrez += "<br/><script>"; diffrez += "</script></body></html>"; diffrez = Tools.ReplaceFirst(diffrez, "<span class=\"diffchange", "<span id=\"first_difference\" class=\"diffchange"); diffrez = (Options.GetOptionInt("check_links") == 1 ? WBcallback.ProcessPage(diffrez) : diffrez); return(new DiffTemporaryResult(diffrez, pieces)); } catch (Exception) { return(result); } }
private void _thread_function() { // MessageBox.Show("start_thread"); st: rt = false; thread_restart = false; try { thread_running = true; stop_thread = false; int current_max = Options.GetOptionInt("buff3"); bool skipifnull = Options.GetOptionInt("skip_null") == 1 ? true : false; // MessageBox.Show(current_max + ""); // DiffData dd; CheckAllEvents(); DiffData tmp = new DiffData(); for (int a = 0; a < list.Count; a++) { double rand = list[a].rand; CheckAllEvents(); if (a == current_max) { thread_running = false; return; } if (stop_thread) { thread_running = false; return; } if (thread_restart) { goto st; } if (list[a].data.Equals("")) { // for (int b = 0; b < (a < 2 ? 2 : 1); b++) { tmp = list[a]; if (tmp.skip == true) { break; } CheckAllEvents(); if (thread_restart) { goto st; } if (stop_thread) { thread_running = false; return; } Logging.AddLog("Trying to load diff for \"" + tmp.el.title + "\" #" + (b + 1)); // try if (tmp.el.page.list.Count == 0) { if (tmp.el.check == true) { tmp.el.page.LoadRevision(-1); lock (aw.list.list) { tmp.el.Check(); } if (tmp.el.skip_me) { tmp.skip = true; tmp.el.skipped = true; tmp.data = "В настройках отключено"; break; } } else { tmp.el.skipped = false; tmp.el.page.LoadRevision(tmp.el.stable_id); } } else { if (tmp.el.check == true) { lock (aw.list.list) { tmp.el.Check(); } if (tmp.el.skip_me) { tmp.skip = true; tmp.el.skipped = true; tmp.data = "В настройках отключено"; break; } } } //catch (Exception e) { Logging.AddLog("Exception while loading diff for \"" + tmp.el.title + "\": " + e.Message); continue; } // try if (tmp.el.page.list.Count == 0 || tmp.el.error) { tmp.data = "API error."; } else { if (data_type == 0) { DiffTemporaryResult dtr = DiffBase._GetDiff(aw, tmp.el); tmp.data = dtr.data; tmp.pieces = dtr.pieces; } else { tmp.data = DiffBase._GetView(aw, tmp.el); } } tmp.data = tmp.data.Trim(); if (tmp.Equals("")) { Logging.AddLog("creating diff for \"" + tmp.el.title + "\" failed #" + (b + 1)); continue; } Logging.AddLog("diff for \"" + tmp.el.title + "\" successfully loaded #" + (b + 1) + " [" + tmp.data.Length + "]"); int newid = -1; int fnw = 0; for (newid = 0; newid < list.Count; newid++) { if (list[newid].rand == rand) { fnw = 1; list[newid].data = tmp.data; list[newid].el.loaded = true; list[newid].el.MakeRevisions(); if (list[newid].send_wo_req) { CheckForEvent(list[newid]); list[newid].send_event = true; } if (tmp.data.Contains("<!--diff_is_empty-->") && skipifnull == true && list[newid].send_wo_req == false) { list[newid].skip = true; } break; } } if (fnw == 0) { thread_running = false; Logging.AddLog(list[a] + " ......... 0"); return; } else { } CheckAllEvents(); if (thread_restart) { goto st; } break; } } } CheckAllEvents(); } catch (Exception) { /* MessageBox.Show(e.Message+"\r\n\r\n"+e.StackTrace); */ CheckAllEvents(); thread_running = false; if (thread_restart) { goto st; } return; } thread_running = false; return; }