public LogUploader(AsyncApiEdit e) { BotTag = "|}<!--/bottag-->"; // doing it this way OUGHT to allow inherited classes to override TableHeaderUserName = "******"; TableHeaderNoUserName = "******"; editor = e.Clone(); }
internal void Init(AsyncApiEdit e, Label ETALabel, PluginSettingsControl.Stats Stats) { if (!TimerEnabled) { ResetVars(); mETALabel = ETALabel; TimerEnabled = true; mStats = Stats; mStats.SkipMisc += mStats_SkipMisc; Timer1_Tick(null, null); } }
internal void Init(AsyncApiEdit e, Label etaLabel, PluginSettingsControl.Stats stats) { if (!TimerEnabled) { ResetVars(); _etaLabel = etaLabel; TimerEnabled = true; _stats = stats; _stats.SkipMisc += StatsSkipMisc; Timer1_Tick(null, null); } }
private AsyncApiEdit CreateEditor(string url, bool php5) { AsyncApiEdit edit = new AsyncApiEdit(url, parentControl, php5) { NewMessageThrows = false }; edit.OpenComplete += OnOpenComplete; edit.SaveComplete += OnSaveComplete; edit.PreviewComplete += OnPreviewComplete; edit.ExceptionCaught += OnExceptionCaught; edit.MaxlagExceeded += OnMaxlagExceeded; edit.LoggedOff += OnLoggedOff; edit.StateChanged += OnStateChanged; edit.Aborted += OnAborted; return edit; }
void OnStateChanged(AsyncApiEdit sender) { if (StateChanged != null) StateChanged(sender); }
void OnMaxlagExceeded(AsyncApiEdit sender, int maxlag, int retryAfter) { if (MaxlagExceeded != null) MaxlagExceeded(sender, maxlag, retryAfter); }
void OnLoggedOff(AsyncApiEdit sender) { if (LoggedOff != null) LoggedOff(sender); }
void OnPreviewComplete(AsyncApiEdit sender, string result) { if (PreviewComplete != null) PreviewComplete(sender, result); }
void OnExceptionCaught(AsyncApiEdit sender, Exception ex) { if (ExceptionCaught != null) ExceptionCaught(sender, ex); }
// Webcontrol event handlers: private void EditorStatusChanged(AsyncApiEdit sender) { if (PluginManager.AWBForm.TheSession.Editor.IsActive) { LoadArticle(); } }
internal void IncrementSavedEdits(AsyncApiEdit sender, SaveInfo save) { IncrementSavedEdits(); }
private void PageSaved(AsyncApiEdit sender, SaveInfo saveInfo) { ClearBrowser(); txtEdit.Text = ""; //TODO:Reinstate as needed //try //{ // if (IsReadOnlyDB()) // { // StartDelayedRestartTimer(null, null); // return; // } //} //catch (Exception) //{ // Start(); //} //lower restart delay if (_restartDelay > 5) _restartDelay -= 1; NumberOfEdits++; LastArticle = ""; listMaker.Remove(TheArticle); NudgeTimer.Stop(); SameArticleNudges = 0; if (EditBoxTab.SelectedTab == tpHistory) EditBoxTab.SelectedTab = tpEdit; if (loggingEnabled) logControl.AddLog(false, TheArticle.LogListener); UpdateOverallTypoStats(); if (listMaker.Count == 0 && _autoSaveEditBoxEnabled) EditBoxSaveTimer.Enabled = false; Retries = 0; // if user has loaded a settings file, save it every 10 edits if autosavesettings is set if (autoSaveSettingsToolStripMenuItem.Checked && (NumberOfEdits % 10 == 0) && !string.IsNullOrEmpty(SettingsFile) && (NumberOfEdits > 5)) SavePrefs(SettingsFile); Start(); }
private void LoggedOff(AsyncApiEdit sender) { DisableButtons(); }
private void CreateEditor() { APIEdit = new AsyncApiEdit(Variables.URLLong, this, Variables.PHP5); APIEdit.PreviewComplete += PreviewComplete; APIEdit.ExceptionCaught += APIEditExceptionCaught; }
private void APIEditExceptionCaught(AsyncApiEdit sender, Exception ex) { StartDelayedRestartTimer(null, null); }
// AWB processing stopped/started: internal void AWBProcessingStart(AsyncApiEdit editor) { foreach (Label lbl in _statLabels) { if (string.IsNullOrEmpty(lbl.Text)) lbl.Text = "0"; } TimerStats1.Visible = true; TimerStats1.Init(editor, ETALabel, PluginStats); PluginManager.StatusText.Text = "Started"; }
private static void EditorAborted(AsyncApiEdit sender) { PluginSettings.AWBProcessingAborted(); }
private static void EditorStatusChanged(AsyncApiEdit sender) { if (AWBForm.TheSession.Editor.IsActive) { if (ActivePlugins.Count > 0) PluginSettings.AWBProcessingStart(sender); } else { DefaultStatusText(); // If AWB has stopped and the list is empty we assume the job is finished, so close the log and upload: if (AWBForm.ListMaker.Count == 0) { AWBForm.TraceManager.Close(); } } }
void OnAborted(AsyncApiEdit sender) { if (Aborted != null) Aborted(sender); }
private void MaxlagExceeded(AsyncApiEdit sender, int maxlag, int retryAfter) { Retries++; if (Retries < MaxRetries) { StartDelayedRestartTimer(retryAfter); } else { Stop(); MessageBox.Show(this, "Maxlag exceeded " + MaxRetries + " times in a row. Processing stopped, please try later when the server is under a less load.", "Stopped", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ApiEditExceptionCaught(AsyncApiEdit sender, Exception ex) { if (ex is InterwikiException) { SkipPage(ex.Message); } else if (ex is SpamlistException) { string message = "Text '" + (ex as SpamlistException).URL + "' is blocked by spam blacklist"; if (!BotMode) { if (!chkSkipSpamFilter.Checked && MessageBox.Show(message + ".\r\nTry and edit again?", "Spam blacklist", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Start(); return; } } SkipPage(message); } else if (ex is ApiErrorException) { switch ((ex as ApiErrorException).ErrorCode) { case "editconflict": //TODO: must be a less crude way MessageBox.Show(this, "There has been an edit conflict. AWB will now re-apply its changes on the updated page.\r\nPlease re-review the changes before saving. Any Custom edits will be lost, and have to be re-added manually.", "Edit conflict"); NudgeTimer.Stop(); Start(); break; case "writeapidenied": NoWriteApiRight(); break; case "customcssprotected": SkipPage("You're not allowed to edit custom CSS pages"); break; case "customjsprotected": SkipPage("You're not allowed to edit custom JavaScript pages"); break; case "badmd5": SkipPage("API MD5 hash error: The page you are editing may contain an unsupported or invalid Unicode character"); break; default: StartDelayedRestartTimer(); break; } } else if (ex is ApiBlankException) { StartDelayedRestartTimer(); } else if (ex is NewMessagesException) { WeHaveNewMessages(); } else if (ex is LoggedOffException) { HandleLogoff(); } else if (ex is CaptchaException) { MessageBox.Show("Captcha required, is the user account autoconfirmed etc?", "Captcha Required"); Stop(); } else if (ex is InvalidTitleException) { SkipPage("Invalid title"); } else if (ex is RedirectToSpecialPageException) { SkipPage("Page is a redirect to a special page"); } else if (ex is WebException || (ex is IOException && ex.Message.Contains("0x2746"))) { // some 404 error or similar, or "Unable to write data to the transport connection: Unknown error (0x2746)" StatusLabelText = ex.Message; if (Tools.WriteDebugEnabled) Tools.WriteTextFile(ex.Message, "Log.txt", true); StartDelayedRestartTimer(); } else if (ex is SharedRepoException) { MessageBox.Show("Cannot move this file to the specified target, as it exists in a shared repo (such as commons).", "Target file exists in shared repo"); } else if (ex is MediaWikiSaysNoException) { MessageBox.Show("MediaWiki prevented you from making that edit. Chances are it's spam filter related", "MediaWiki says no"); SkipPage(""); } else { Stop(); ErrorHandler.Handle(ex); } }
public Session(string url) { Editor = new AsyncApiEdit(url); LoadProjectOptions(); Update(); }
private void PreviewComplete(AsyncApiEdit sender, string result) { LastArticle = txtEdit.Text; Skippable = false; if (webBrowser.Document != null) { webBrowser.Document.OpenNew(false); webBrowser.Document.Write("<html><head>" + sender.HtmlHeaders + "</head><body style=\"background:white; margin:10px; text-align:left;\">" + result + "</html>" ); //webBrowser.BringToFront(); } StatusLabelText = ""; GuiUpdateAfterProcessing(); }
void OnOpenComplete(AsyncApiEdit sender, PageInfo pageInfo) { if (OpenComplete != null) OpenComplete(sender, pageInfo); }
private void OpenComplete(AsyncApiEdit editor, PageInfo page) { PageLoaded(page); }
void OnSaveComplete(AsyncApiEdit sender, SaveInfo saveInfo) { if (SaveComplete != null) SaveComplete(sender, saveInfo); }
private void ApiEditExceptionCaught(AsyncApiEdit sender, Exception ex) { if (ex is InterwikiException) SkipPage(ex.Message); else if (ex is SpamlistException) { string message = "Text '" + (ex as SpamlistException).URL + "' is blocked by spam blacklist"; if (!BotMode) { if (!chkSkipSpamFilter.Checked && MessageBox.Show(message + ".\r\nTry and edit again?", "Spam blacklist", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Start(); return; } } SkipPage(message); } else if (ex is ApiErrorException) { switch ((ex as ApiErrorException).ErrorCode) { case "editconflict": //TODO: must be a less crude way MessageBox.Show(this, "There has been an edit conflict. AWB will now re-apply its changes on the updated page.\r\nPlease re-review the changes before saving. Any Custom edits will be lost, and have to be re-added manually.", "Edit conflict"); NudgeTimer.Stop(); Start(); break; case "writeapidenied": NoWriteApiRight(); break; default: StartDelayedRestartTimer(); break; } } else if (ex is ApiBlankException) { StartDelayedRestartTimer(); } else if (ex is NewMessagesException) { WeHaveNewMessages(); } else if (ex is LoggedOffException) { HandleLogoff(); } else if (ex is CaptchaException) { MessageBox.Show("Captcha required, is the user account autoconfirmed etc?", "Captcha Required"); Stop(); } else if (ex is InvalidTitleException) { SkipPage("Invalid title"); } else if (ex is RedirectToSpecialPageException) { SkipPage("Page is a redirect to a special page"); } else if (ex is WebException) { // some 404 error or similar StatusLabelText = ex.Message; StartDelayedRestartTimer(); } else { Stop(); ErrorHandler.Handle(ex); } }
private void CreateEditor() { apiEdit = new AsyncApiEdit(Variables.URLLong, this, Variables.PHP5); apiEdit.PreviewComplete += PreviewComplete; }