/// <summary> /// Upload log to the wiki, and optionally add log entries to central log pages /// </summary> /// <param name="log">The log text</param> /// <param name="logTitle">The log title</param> /// <param name="logDetails">Details of the job being logged</param> /// <param name="uploadTo">Which page to write the log to</param> /// <param name="linksToLog">A collection of LogEntry objects detailing pages to list the log page on. Send an empty collection if not needed.</param> /// <param name="pageNumber">Log page number</param> /// <param name="startDate">When the job started</param> /// <param name="openInBrowser">True if the log page should be opened in the web browser after uploading, otherwise false</param> /// <param name="addToWatchlist">True if the log page should be added to the user's watchlist, otherwise false</param> /// <param name="username">The user id of the user performing the task</param> /// <param name="logHeader">Header text</param> /// <param name="addLogTemplate">True if a {{log}} template should be added</param> /// <param name="editSummary">The edit summary</param> /// <param name="logSummaryEditSummary">The edit summary when listing the log page on the LogEntry pages (if applicable)</param> /// <param name="sender"></param> /// <param name="addLogArticlesToAnAWBList">True if an IAutoWikiBrowser object is being sent and the AWB log tab should be written to</param> /// <param name="awb">An IAutoWikiBrowser object, may be null</param> public virtual List<EditPageRetvals> LogIt(string log, string logTitle, string logDetails, string uploadTo, List<LogEntry> linksToLog, int pageNumber, DateTime startDate, bool openInBrowser, bool addToWatchlist, string username, string logHeader, bool addLogTemplate, string editSummary, string logSummaryEditSummary, string sender, bool addLogArticlesToAnAWBList, IAutoWikiBrowser awb) { List<EditPageRetvals> retval = new List<EditPageRetvals>(); string uploadToNoSpaces = uploadTo.Replace(" ", "_"); string strLogText = ""; AWBLogListener awbLogListener = null; if (DoAWBLogListener(addLogArticlesToAnAWBList, awb)) awbLogListener = new AWBLogListener(uploadTo); if (addLogTemplate) { strLogText = "{{log|name=" + uploadToNoSpaces + "|page=" + pageNumber + "}}" + Environment.NewLine; } strLogText += logHeader + log; Application.DoEvents(); try { editor.Open(uploadToNoSpaces); editor.Wait(); SaveInfo save = editor.SynchronousEditor.Save(strLogText, editSummary, false, WatchOptions.NoChange); retval.Add(new EditPageRetvals { Article = uploadToNoSpaces, DiffLink = editor.URL + "index.php?oldid=" + save.NewId + "&diff=prev", ResponseText = save.ResponseXml.OuterXml }); } catch (Exception ex) { if (awbLogListener != null) AWBLogListenerUploadFailed(ex, sender, awbLogListener, awb); throw; // throw error and exit } Application.DoEvents(); foreach (LogEntry logEntry in linksToLog) { retval.Add(DoLogEntry(logEntry, logTitle, logDetails, pageNumber, startDate, uploadTo, logSummaryEditSummary, username, addLogArticlesToAnAWBList, awb, sender)); Application.DoEvents(); } if (openInBrowser) OpenLogInBrowser(uploadTo); return retval; }
public string ProcessArticle(IAutoWikiBrowser sender, IProcessArticleEventArgs eventargs) { string res; if (ActivePlugins.Count == 0) { return(eventargs.ArticleText); } Article theArticle; StatusText.Text = "Processing " + eventargs.ArticleTitle; AWBForm.TraceManager.ProcessingArticle(eventargs.ArticleTitle, eventargs.NameSpaceKey); foreach (PluginBase p in ActivePlugins) { try { if (!p.AmReady && p.AmGeneric) { MessageBox.Show( "The generic template plugin \"" + p.PluginShortName + "\"isn't properly configured.", "Can't start", MessageBoxButtons.OK, MessageBoxIcon.Error); StopAWB(); goto SkipOrStop; } } catch { StopAWB(); goto SkipOrStop; } } switch (eventargs.NameSpaceKey) { case Namespace.Article: if (_pluginSettings.ManuallyAssess) { if (eventargs.Exists == Exists.Yes) { StatusText.Text += ": Click Preview to read the article; " + "click Save or Ignore to load the assessments form"; _assessmentsObject.ProcessMainSpaceArticle(eventargs.ArticleTitle); eventargs.EditSummary = "Clean up"; goto SkipOrStop; } //FIXME var eaArticleES = eventargs.EditSummary; var eaArticleSkip = eventargs.Skip; res = Skipping(ref eaArticleES, "", SkipReason.ProcessingMainArticleDoesntExist, eventargs.ArticleText, ref eaArticleSkip); eventargs.EditSummary = eaArticleES; eventargs.Skip = eaArticleSkip; goto ExitMe; } goto SkipBadNamespace; //break; case Namespace.Talk: AsyncApiEdit editor = AWBForm.TheSession.Editor.Clone(); editor.Open(Tools.ConvertFromTalk(eventargs.ArticleTitle), false); editor.Wait(); if (!editor.Page.Exists) { // FIXME var eaNotExistsES = eventargs.EditSummary; var eaNotExistsSkip = eventargs.Skip; res = Skipping(ref eaNotExistsES, "", SkipReason.ProcessingTalkPageArticleDoesntExist, eventargs.ArticleText, ref eaNotExistsSkip, eventargs.ArticleTitle); eventargs.EditSummary = eaNotExistsES; eventargs.Skip = eaNotExistsSkip; } else { theArticle = new Article(eventargs.ArticleText, eventargs.ArticleTitle, eventargs.NameSpaceKey); bool reqPhoto = ReqPhotoParamNeeded(theArticle); if (_pluginSettings.ManuallyAssess) { // reqphoto byref if (!_assessmentsObject.ProcessTalkPage(theArticle, _pluginSettings, ref reqPhoto)) { eventargs.Skip = true; goto SkipOrStop; } } else { reqPhoto = ProcessTalkPageAndCheckWeAddedReqPhotoParam(theArticle, reqPhoto); // We successfully added a reqphoto param } // FIXME var eaTalkSkip = eventargs.Skip; var eaTalkES = eventargs.EditSummary; res = FinaliseArticleProcessing(theArticle, ref eaTalkSkip, ref eaTalkES, eventargs.ArticleText, reqPhoto); eventargs.Skip = eaTalkSkip; eventargs.EditSummary = eaTalkES; } break; case Namespace.CategoryTalk: case 101: //101 is Portal Talk case Namespace.ProjectTalk: case Namespace.TemplateTalk: case Namespace.FileTalk: if (_pluginSettings.ManuallyAssess) { MessageBox.Show( "The plugin has received a non-standard namespace talk page in " + "manual assessment mode. Please remove this item from the list and start again.", "Manual Assessments", MessageBoxButtons.OK, MessageBoxIcon.Error); StopAWB(); goto SkipOrStop; } theArticle = new Article(eventargs.ArticleText, eventargs.ArticleTitle, eventargs.NameSpaceKey); foreach (PluginBase p in ActivePlugins) { p.ProcessTalkPage(theArticle, Classification.Code, Importance.NA, false, false, false, ProcessTalkPageMode.NonStandardTalk, false); if (theArticle.PluginManagerGetSkipResults == SkipResults.SkipBadTag) { break; // TODO: might not be correct. Was : Exit For } } // FIXME var eaMiscSkip = eventargs.Skip; var eaMiscES = eventargs.EditSummary; res = FinaliseArticleProcessing(theArticle, ref eaMiscSkip, ref eaMiscES, eventargs.ArticleText, false); eventargs.Skip = eaMiscSkip; eventargs.EditSummary = eaMiscES; break; default: goto SkipBadNamespace; } if (!eventargs.Skip) { //TempHackInsteadOfDefaultSettings: if (AWBForm.EditSummaryComboBox.Text == "clean up") { AWBForm.EditSummaryComboBox.Text = "Tagging"; } } ExitMe: if (!_pluginSettings.ManuallyAssess) { DefaultStatusText(); } AWBForm.TraceManager.Flush(); return(res); SkipBadNamespace: //FIXME var eaES = eventargs.EditSummary; var eaSkip = eventargs.Skip; res = Skipping(ref eaES, "", SkipReason.BadNamespace, eventargs.ArticleText, ref eaSkip); eventargs.EditSummary = eaES; eventargs.Skip = eaSkip; goto ExitMe; SkipOrStop: res = eventargs.ArticleText; goto ExitMe; }