public Element GetSelected(CoreOperations aw) { Element tmp = null; int s = control.SelectedIndex; if (s == -1) { return(tmp); } TMyListBoxItem t = (TMyListBoxItem)(control.ht[control.Items[s]]); double rand = t.rand; foreach (Element el in aw.list.list) { if (el.rand == rand) { tmp = el; break; } } foreach (Element el in aw.skipped) { if (el.rand == rand) { tmp = el; break; } } return(tmp); }
public List <List <AssetModel> > UploadHistoryFromServerAuto() { var dtMin = dateStart; var dtMax = dateEnd; if (!operations.FillModel(url, dtMin, dtMax, key, ref modelSet, DirSwitcher.Auto)) { modelSet.Clear(); return(modelSet); } if (!modelSet.Any()) { return(modelSet); } var isSomethingMissing = CoreOperations.IsMissingData(period, modelSet); if (isSomethingMissing) { if (!operations.FillMissingData(period, dateStart, key, ref modelSet, DirSwitcher.Auto)) { modelSet.Clear(); return(modelSet); } } return(modelSet); }
public static void ProcessLinkThreaded(CoreOperations aw, string title, HtmlElement he = null) { Thread myThread = new System.Threading.Thread(new System.Threading.ThreadStart(delegate() { ProcessLink(aw, title, he); })); myThread.IsBackground = true; myThread.Start(); }
public static DiffTemporaryResult _GetDiff(CoreOperations aw, Element el) { if (el.stable_id > 0) { return(__GetDiff(aw, el.page.stable, el.page.curr, el)); } else { return(__GetDiff(aw, el.page.curr, null, el)); } }
public static void ProcessClick(WebBrowser wb, CoreOperations aw, String id) { HtmlElement he = wb.Document.GetElementById("id" + id); Thread myThread = new System.Threading.Thread(new System.Threading.ThreadStart(delegate() { ProcessLink(aw, StripTags(he.InnerText).Trim(), he); })); myThread.IsBackground = true; myThread.Start(); }
public RevList(MyRevBox _w, CoreOperations _aw) { control = _w; aw = _aw; control.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mousedown); control.MouseUp += new System.Windows.Forms.MouseEventHandler(this.mouseup); //control.MouseUp += new System.Windows.Forms.MouseEventHandler(this.do_OnMouseDown); // control.DoubleClick += new System.EventHandler(this.do_OnMouseDoubleClick); }
public Editor(Page p, MainForm q) { pg = p; aw = q.aw; f = q; InitializeComponent(); this.Text = "Editor".T(); label1.Text = "Line".T(); go_button.Text = "Go".T(); minor.Text = "Minor?".T(); review.Text = "Review it".T(); savebutton.Text = "Save".T(); closebutton.Text = "Close".T(); }
public bool UploadHistoryFromServer() { var dtMin = dateStart; var dtMax = dateEnd; operations.FillModel(url, dtMin, dtMax, key, ref modelSet, DirSwitcher.Manual); var isSomethingMissing = CoreOperations.IsMissingData(period, modelSet); if (isSomethingMissing) { return(operations.FillMissingData(period, dateStart, key, ref modelSet, DirSwitcher.Manual)); } return(true); }
public LoadData(IOptions <ApplicationSettings> service, string coinName, int period, string currentLocation) { _service = service; modelSet = new List <List <AssetModel> >(); url = _service.Value.CoinApiUrl; key = _service.Value.ApiKey; this.period = period; this.coinName = coinName; dateEnd = DateTime.Now; dateStart = DateTime.Now.AddHours(-1 * period); operations = new CoreOperations(url, coinName, currentLocation, service); manager = new DirectoryManager(service, currentLocation); fileName = "data.csv"; locker = new object(); }
public string GetHash(CoreOperations aw) { String tt = ""; foreach (Element e in aw.list.list) { //if (e.skip_me) { continue; } tt += (1 + e.curr_id + e.rand + e.stable_id + e.size) + (e.loaded ? "y" : "n") + (e.showed ? "y" : "n") + (e.rejected ? "y" : "n") + (e.reviewed ? "y" : "n"); } tt = Tools.GetMD5(tt) + "|"; foreach (Element e in aw.skipped) { //if (e.skip_me) { continue; } tt += (1 + e.curr_id + e.rand + e.stable_id + e.size) + (e.loaded ? "y" : "n") + (e.showed ? "y" : "n") + (e.rejected ? "y" : "n") + (e.reviewed ? "y" : "n"); } tt = Tools.GetMD5(tt); return(tt); }
public static String _GetView(CoreOperations aw, Element el) { try { String title = el.title; title = title.Replace(' ', '_'); SweepNetPage page = el.page; if (page.list.Count == 0) { return(""); } String data = ""; long start_id; if (el.stable_id < 1) { data = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&rvprop=content&titles=" + HttpUtility.UrlEncode(title) + "&rvlimit=1&rvparse=1"); start_id = -1; } else { data = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&rvprop=content&titles=" + HttpUtility.UrlEncode(title) + "&rvstartid=" + el.stable_id + "&rvlimit=1&rvparse=1"); start_id = page.flagged_rev; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(data); XmlNode currentNode; currentNode = xmlDoc.DocumentElement.SelectSingleNode("query"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("pages"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("page"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("revisions"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("rev"); if (currentNode == null) { return(""); } data = currentNode.InnerText; if (data.Equals("") || data == null) { data = "-1"; } String diffrez = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" + Properties.Resources.view_css_style + "</head><body>"; diffrez += "<table width=\"100%\" border=\"0\"><tr><td colspan=\"2\">" + String.Format("{0} edits have been made by: {1}".T(), (page.unflagged_count), Tools.GetColoredListOfUsers(page.GetHashtableofcontributors(start_id + 1))) /*page.GetContributors(1).ToArray())*/; if (page.unflagged_count == 1) { diffrez += "; " + "Summary".T() + ": \"" + HttpUtility.HtmlEncode(page.GetLastRevision().comm) + "\""; } diffrez += "</td></tr><tr><td align=\"left\" valign=\"bottom\">" + "Stable 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>"; diffrez += "<table width=\"100%\" style=\"border-top: solid #000000 1px;\">"; while (data.Contains("<span class=\"mw-editsection\">")) { string delete = ""; int from = data.IndexOf("<span class=\"mw-editsection\">"); int to = data.IndexOf("<span class=\"mw-editsection-bracket\">]</span></span>") + "<span class=\"mw-editsection-bracket\">]</span></span>".Length; if (from >= 0 && to > 0 && to > from) { delete = data.Substring(from, to - from); data = data.Replace(delete, ""); } else { break; } } diffrez += "<tr width=\"100%\"><td>" + data + "</td></tr>"; diffrez += "</table>"; diffrez += "<br/></body></html>"; return(diffrez); } catch (Exception) { return(""); } }
public DiffEditor(CoreOperations _aw) { aw = _aw; timer = new System.Threading.Timer(new TimerCallback(TimerTick), new AutoResetEvent(false), 1000, 1000); }
public AuthorsRequests(CoreOperations aw_) { aw = aw_; }
public static void ProcessLink(CoreOperations aw, string title, HtmlElement html_element = null) { String text = title;//StripTags(he.InnerText).Trim(); bool file = false; if (title.Contains(":")) { string j = title.Substring(0, title.IndexOf(":")).ToLower(); if (Tools.name_to_namespace.ContainsKey(j) && Tools.name_to_namespace[j].Equals("6")) { file = true; } } String data = ""; if (file) { data = aw.HttpGetApi("api.php?format=xml&action=query&prop=info&prop=imageinfo&titles=" + text.Replace(' ', '_')); } else { data = aw.HttpGetApi("api.php?format=xml&action=query&prop=info&titles=" + text.Replace(' ', '_')); } bool ok = !data.Contains("imagerepository=\"\""); if (html_element != null) { if (ok) { html_element.Style = "color:green;"; } else { html_element.Style = "color:red;"; } } if (file) { if (ok) { MessageBox.Show(String.Format(@"file ""{0}"" exists".T(), text), "Result".T()); } //Файл; существует else { MessageBox.Show(String.Format(@"file ""{0}"" does not exist".T(), text), "Result".T()); } //Файл; не существует } else { if (ok) { MessageBox.Show(String.Format(@"page ""{0}"" exists".T(), text), "Result".T()); } //Страница; существует else { MessageBox.Show(String.Format(@"page ""{0}"" does not exist".T(), text), "Result".T()); } //Страница; не существует } }
public DiffCache(CoreOperations a) { aw = a; new Thread(SupportingThread).Start(); }
public static String __GetView(CoreOperations aw, WikiRevision rev, Element el, bool pro_info = false) { try { String title = el.title; title = title.Replace(' ', '_'); SweepNetPage page = el.page; if (page.list.Count == 0) { return(""); } String data = ""; long start_id; if (el.stable_id < 1) { data = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&rvprop=content&titles=" + HttpUtility.UrlEncode(title) + "&rvlimit=1&rvparse=1"); start_id = -1; } else { data = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&rvprop=content&titles=" + HttpUtility.UrlEncode(title) + "&rvstartid=" + el.stable_id + "&rvlimit=1&rvparse=1"); start_id = page.flagged_rev; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(data); XmlNode currentNode; currentNode = xmlDoc.DocumentElement.SelectSingleNode("query"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("pages"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("page"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("revisions"); if (currentNode == null) { return(""); } currentNode = currentNode.SelectSingleNode("rev"); if (currentNode == null) { return(""); } data = currentNode.InnerText; if (data.Equals("") || data == null) { data = "-1"; } String diffrez = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>"; if (pro_info) { diffrez += "<table width=\"100%\" border=\"0\" valign=\"top\"><tr>"; diffrez += "<td width=\"100%\" valign=\"top\">" + DateTime.Parse(rev.timestamp).ToString("dd/MM/yyyy HH:mm") + " " + rev.user + " [" + rev.size + " байт]" + (rev.minor ? " [m] " : "") + " (" + HttpUtility.HtmlEncode(rev.comm) + ")" + "</td>"; diffrez += "</tr></table>"; } else { if (page.unflagged_count == 1) { diffrez += "; " + "Summary".T() + ": \"" + HttpUtility.HtmlEncode(page.GetLastRevision().comm) + "\""; } diffrez += "</td></tr><tr><td align=\"left\" valign=\"bottom\">" + "Stable 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>"; } diffrez += "<table width=\"100%\" style=\"border-top: solid #000000 1px;\">"; diffrez += "<tr width=\"100%\"><td>" + data + "</td></tr>"; diffrez += "</table><br/></body></html>"; return(diffrez); } catch (Exception) { /*MessageBox.Show(e.Message+"\r\n\r\n"+e.StackTrace);*/ return(""); } }
public void UpdateItems(CoreOperations aw, bool check_hash = true) { lock (control) { lock (aw.list.list) { String hash = ""; lock (aw.skipped) { try { //Point p_old = control.AutoScrollOffset; if (control.Visible == false) { return; } // нет смысла if (aw.skipped.Count == 0 && aw.list.Count == 0) { return; } // Сначала проверим, можно ли обойтись без полного обновления control.SuspendLayout(); int wc = aw.list.Count; int s1, s2; if (control.items2_list.Count > 0 && check_hash) { hash = GetHash(aw); if (tmp_hash.Equals(hash)) { return; } } Element tmp; double sel_rand = -1; //if (control.TopIndex > 0) { MessageBox.Show(control.TopIndex + ""); } int top_index = control.TopIndex; String top_rand_s = ""; double top_rand = -1; try { top_rand_s = control.Items[top_index].ToString(); foreach (TMyListBoxItem i in control.items2_list) { if (i.rand_s.Equals(top_rand_s)) { top_rand = i.rand; break; } } } catch { } int new_index = top_index; foreach (TMyListBoxItem e in control.items2_list) { if (e.selected) { sel_rand = e.rand; break; } } int old_sel_id = control.SelectedIndex; control.BeginUpdate(); control.Clear(); for (int a = aw.list.list.Count - 1; a >= 0; a--) { tmp = aw.list.list[a]; if (tmp.skip_me) { continue; } //s1 = -1; s2 = -1; if (tmp.loaded) { s2 = 1; } else { s2 = 0; } if (tmp.reviewed) { s1 = 0; } else if (tmp.rejected) { s1 = 1; } else if (!tmp.showed) { s1 = 2; } else { s1 = 3; } TMyListBoxItem n = new TMyListBoxItem(); n.state1 = s1; n.state2 = s2; n.name = tmp.title; n.pos = a; n.rand = tmp.rand; n.was_ever_reviewed = (tmp.stable_id != -1); n.rand_s = tmp.rand + ""; control.AddAssigned(n.rand_s, n); if (top_rand == n.rand) { new_index = control.Items.Count - 1; } if (tmp.rand == sel_rand) { n.selected = true; } } for (int a = aw.skipped.Count - 1; a >= 0; a--) { if (a < 0) { break; } tmp = aw.skipped.items[a]; if (tmp.skip_me) { continue; } //s1 = -1; s2 = -1; if (tmp.reviewed) { s1 = 0; } else if (tmp.rejected) { s1 = 1; } else if (!tmp.showed) { s1 = 2; } else { s1 = 3; } if (tmp.loaded) { s2 = 1; } else { s2 = 0; } TMyListBoxItem n = new TMyListBoxItem(); n.state1 = s1; n.state2 = s2; n.name = tmp.title; n.pos = a; n.rand = tmp.rand; n.was_ever_reviewed = (tmp.stable_id != -1); n.rand_s = tmp.rand + ""; control.AddAssigned(n.rand_s, n); if (top_rand == n.rand) { new_index = control.Items.Count - 1; } if (tmp.rand == sel_rand) { n.selected = true; } } control.TopIndex = new_index; control.EndUpdate(); // Thread.Sleep(80); control.PerformLayout(); tmp_hash = hash; //control.AutoScrollOffset = new Point(p_old.X, p_old.Y); //if (p_old.Y > 0) { MessageBox.Show(p_old.Y+""); } } catch (InvalidOperationException) { } catch (Exception e) { #if DEBUG MessageBox.Show("Исключение в движке списка: " + e.GetType().ToString() + "|" + e.Message + "|" + e.StackTrace); #endif } } } } }
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); } }
public CoinPerformance DefineTrend(IEnumerable <TableRow> table) { var indicator = new CoreOperations(_appSettings); return(indicator.Indicatior(table)); }