/// <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 { if (addToWatchlist) { retval.Add(EditPageEx(uploadToNoSpaces, strLogText, editSummary, false, true)); } else { retval.Add(EditPageEx(uploadToNoSpaces, strLogText, editSummary, false)); } } 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); }
private void AWBLogListenerUploadFailed(Exception ex, string sender, AWBLogListener logListener, IAutoWikiBrowser AWB) { logListener.WriteLine("Error: " + ex.Message, sender); ((IMyTraceListener)logListener).SkippedArticle(sender, "Error"); //AWB.AddLogItem(false, logListener); }
void IAutoWikiBrowserCommands.AddLogItem(bool skipped, AWBLogListener logListener) { if (loggingEnabled) { logControl.AddLog(skipped, logListener); } }
/// <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; }
private void AWBLogListenerUploadFailed(Exception ex, string sender, AWBLogListener logListener, IAutoWikiBrowser AWB) { logListener.WriteLine("Error: " + ex.Message, sender); ((IMyTraceListener)logListener).SkippedArticle(sender, "Error"); //AWB.AddLogItem(false, logListener); }
protected virtual EditPageRetvals DoLogEntry(LogEntry logEntry, string logTitle, string logDetails, int pageNumber, DateTime startDate, string uploadTo, string editSummary, string username, bool addLogArticlesToAnAWBList, IAutoWikiBrowser awb, string sender) { AWBLogListener awbLogListener = null; try { editor.Open(logEntry.Location, true); editor.Wait(); string strExistingText = editor.Page.Text; if (DoAWBLogListener(addLogArticlesToAnAWBList, awb)) { if (string.IsNullOrEmpty(sender)) sender = "WikiFunctions DLL"; awbLogListener = new AWBLogListener(logEntry.Location); } Application.DoEvents(); string tableAddition = "|-" + NewCell + "[[" + uploadTo + "|" + logTitle + "]]" + NewCell + logDetails + NewCell + "[[" + uploadTo + "|" + pageNumber + "]]" + (logEntry.LogUserName ? NewCell + "[[User:"******"|" + username + "]]" : "") + NewCell + string.Format("[[{0:d MMMM}]] [[{0:yyyy}]]", startDate) + Environment.NewLine + BotTag; SaveInfo save; if (strExistingText.Contains(BotTag)) { save = editor.SynchronousEditor.Save(strExistingText.Replace(BotTag, tableAddition), editSummary, false, WatchOptions.NoChange); } else { save = editor.SynchronousEditor.Save(strExistingText + Environment.NewLine + "<!--bottag-->" + Environment.NewLine + "{| class=\"wikitable\" width=\"100%\"" + Environment.NewLine + (logEntry.LogUserName ? TableHeaderUserName : TableHeaderNoUserName) + Environment.NewLine + tableAddition, editSummary, false, WatchOptions.NoChange); } EditPageRetvals retval = new EditPageRetvals { Article = logEntry.Location, DiffLink = editor.URL + "index.php?oldid=" + save.NewId + "&diff=prev", ResponseText = save.ResponseXml.OuterXml }; try { if (awbLogListener != null) { awbLogListener.WriteLine("Log entry uploaded", sender); //AWB.AddLogItem(true, AWBLogListener); } } catch { } // errors shouldn't happen here, but even if they do we want to avoid entering the outer catch block logEntry.Success=true; return retval; } catch (Exception ex) { if (awbLogListener != null) AWBLogListenerUploadFailed(ex, sender, awbLogListener, awb); throw; } }
/// <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, true); 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; }
protected virtual EditPageRetvals DoLogEntry(LogEntry logEntry, string logTitle, string logDetails, int pageNumber, DateTime startDate, string uploadTo, string editSummary, string username, bool addLogArticlesToAnAWBList, IAutoWikiBrowser awb, string sender) { AWBLogListener awbLogListener = null; try { editor.Open(logEntry.Location); editor.Wait(); string strExistingText = editor.Page.Text; if (DoAWBLogListener(addLogArticlesToAnAWBList, awb)) { if (string.IsNullOrEmpty(sender)) { sender = "WikiFunctions DLL"; } awbLogListener = new AWBLogListener(logEntry.Location); } Application.DoEvents(); string tableAddition = "|-" + NewCell + "[[" + uploadTo + "|" + logTitle + "]]" + NewCell + logDetails + NewCell + "[[" + uploadTo + "|" + pageNumber + "]]" + (logEntry.LogUserName ? NewCell + "[[User:"******"|" + username + "]]" : "") + NewCell + string.Format("[[{0:d MMMM}]] [[{0:yyyy}]]", startDate) + Environment.NewLine + BotTag; SaveInfo save; if (strExistingText.Contains(BotTag)) { save = editor.SynchronousEditor.Save(strExistingText.Replace(BotTag, tableAddition), editSummary, false, WatchOptions.NoChange); } else { save = editor.SynchronousEditor.Save(strExistingText + Environment.NewLine + "<!--bottag-->" + Environment.NewLine + "{| class=\"wikitable\" width=\"100%\"" + Environment.NewLine + (logEntry.LogUserName ? TableHeaderUserName : TableHeaderNoUserName) + Environment.NewLine + tableAddition, editSummary, false, WatchOptions.NoChange); } EditPageRetvals retval = new EditPageRetvals { Article = logEntry.Location, DiffLink = editor.URL + "index.php?oldid=" + save.NewId + "&diff=prev", ResponseText = save.ResponseXml.OuterXml }; try { if (awbLogListener != null) { awbLogListener.WriteLine("Log entry uploaded", sender); //AWB.AddLogItem(true, AWBLogListener); } } catch { } // errors shouldn't happen here, but even if they do we want to avoid entering the outer catch block logEntry.Success = true; return(retval); } catch (Exception ex) { if (awbLogListener != null) { AWBLogListenerUploadFailed(ex, sender, awbLogListener, awb); } throw; } }
private void InitLog() { mAWBLogListener = new AWBLogListener(mName); }
void IAutoWikiBrowserCommands.AddLogItem(bool Skipped, AWBLogListener LogListener) { logControl.AddLog(Skipped, LogListener); }
protected virtual EditPageRetvals DoLogEntry(LogEntry logEntry, string logTitle, string logDetails, int pageNumber, DateTime startDate, string uploadTo, string editSummary, string username, bool addLogArticlesToAnAWBList, IAutoWikiBrowser awb, string sender) { AWBLogListener awbLogListener = null; try { string strExistingText = GetWikiText(logEntry.Location); if (DoAWBLogListener(addLogArticlesToAnAWBList, awb)) { if (string.IsNullOrEmpty(sender)) { sender = "WikiFunctions DLL"; } awbLogListener = new AWBLogListener(logEntry.Location); } Application.DoEvents(); string tableAddition = "|-" + NewCell + "[[" + uploadTo + "|" + logTitle + "]]" + NewCell + logDetails + NewCell + "[[" + uploadTo + "|" + pageNumber + "]]" + (logEntry.LogUserName ? NewCell + "[[User:"******"|" + username + "]]" : "") + NewCell + string.Format("[[{0:d MMMM}]] [[{0:yyyy}]]", startDate) + Environment.NewLine + BotTag; EditPageRetvals retval; if (strExistingText.Contains(BotTag)) { retval = EditPageEx(logEntry.Location, strExistingText.Replace(BotTag, tableAddition), editSummary, false, true); } else { retval = EditPageAppendEx(logEntry.Location, Environment.NewLine + "<!--bottag-->" + Environment.NewLine + "{| class=\"wikitable\" width=\"100%\"" + Environment.NewLine + (logEntry.LogUserName ? TableHeaderUserName : TableHeaderNoUserName) + Environment.NewLine + tableAddition, editSummary, false); } try { if (awbLogListener != null) { awbLogListener.WriteLine("Log entry uploaded", sender); //AWB.AddLogItem(true, AWBLogListener); } } catch { } // errors shouldn't happen here, but even if they do we want to avoid entering the outer catch block logEntry.Success = true; return(retval); } catch (Exception ex) { if (awbLogListener != null) { AWBLogListenerUploadFailed(ex, sender, awbLogListener, awb); } throw; } }
private void InitLog() { mAWBLogListener = new Logging.AWBLogListener(this.mName); }
/// <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="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 <Editor.EditPageRetvals> LogIt(string Log, string LogTitle, string LogDetails, string UploadTo, List <LogEntry> LinksToLog, int PageNumber, System.DateTime StartDate, bool OpenInBrowser, bool AddToWatchlist, string Username, string LogHeader, bool AddLogTemplate, string EditSummary, string LogSummaryEditSummary, string sender, bool AddLogArticlesToAnAWBList, IAutoWikiBrowser AWB) { List <Editor.EditPageRetvals> retval = new List <Editor.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.ToString() + "}}" + NewLine; } strLogText += LogHeader + Log; Application.DoEvents(); try { if (AddToWatchlist) { retval.Add(base.EditPageEx(uploadToNoSpaces, strLogText, EditSummary, false, true)); } else { retval.Add(base.EditPageEx(uploadToNoSpaces, strLogText, EditSummary, false)); } } catch (Exception ex) { if (awbLogListener != null) { AWBLogListenerUploadFailed(ex, sender, awbLogListener, AWB); } throw; // throw error and exit } //HACK //if (AWBLogListener != null) //{ // AWBLogListener.WriteLine("Log uploaded", sender); //} //AWB.AddLogItem(Article); //AWB.AddLogItem(Article); 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); }
protected virtual Editor.EditPageRetvals DoLogEntry(LogEntry LogEntry, string LogTitle, string LogDetails, int PageNumber, System.DateTime StartDate, string UploadTo, string EditSummary, string Username, bool AddLogArticlesToAnAWBList, IAutoWikiBrowser AWB, string sender) { AWBLogListener awbLogListener = null; Editor.EditPageRetvals retval = new Editor.EditPageRetvals(); try { string strExistingText = WikiFunctions.Editor.GetWikiText(LogEntry.Location); if (DoAWBLogListener(AddLogArticlesToAnAWBList, AWB)) { if (string.IsNullOrEmpty(sender)) sender = "WikiFunctions DLL"; awbLogListener = new AWBLogListener(LogEntry.Location); } Application.DoEvents(); string tableAddition = "|-" + NewCell + "[[" + UploadTo + "|" + LogTitle + "]]" + NewCell + LogDetails + NewCell + "[[" + UploadTo + "|" + PageNumber.ToString() + "]]" + (LogEntry.LogUserName ? NewCell + "[[User:"******"|" + Username + "]]" : "").ToString() + NewCell + string.Format("[[{0:d MMMM}]] [[{0:yyyy}]]", StartDate) + System.Environment.NewLine + BotTag; if (strExistingText.Contains(BotTag)) { retval = base.EditPageEx(LogEntry.Location, strExistingText.Replace(BotTag, tableAddition), EditSummary, false, true); } else { retval = base.EditPageAppendEx(LogEntry.Location, System.Environment.NewLine + "<!--bottag-->" + System.Environment.NewLine + "{| class=\"wikitable\" width=\"100%\"" + System.Environment.NewLine + (LogEntry.LogUserName ? TableHeaderUserName : TableHeaderNoUserName).ToString() + System.Environment.NewLine + tableAddition, EditSummary, false); } try { if (awbLogListener != null) { awbLogListener.WriteLine("Log entry uploaded", sender); //AWB.AddLogItem(true, AWBLogListener); } } catch { } // errors shouldn't happen here, but even if they do we want to avoid entering the outer catch block LogEntry.Success=true; return retval; } catch (Exception ex) { if (awbLogListener != null) AWBLogListenerUploadFailed(ex, sender, awbLogListener, AWB); throw; } }
/// <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="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<Editor.EditPageRetvals> LogIt(string Log, string LogTitle, string LogDetails, string UploadTo, List<LogEntry> LinksToLog, int PageNumber, System.DateTime StartDate, bool OpenInBrowser, bool AddToWatchlist, string Username, string LogHeader, bool AddLogTemplate, string EditSummary, string LogSummaryEditSummary, string sender, bool AddLogArticlesToAnAWBList, IAutoWikiBrowser AWB) { List<Editor.EditPageRetvals> retval = new List<Editor.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.ToString() + "}}" + NewLine; } strLogText += LogHeader + Log; Application.DoEvents(); try { if (AddToWatchlist) { retval.Add(base.EditPageEx(uploadToNoSpaces, strLogText, EditSummary, false, true)); } else { retval.Add(base.EditPageEx(uploadToNoSpaces, strLogText, EditSummary, false)); } } catch (Exception ex) { if (awbLogListener != null) AWBLogListenerUploadFailed(ex, sender, awbLogListener, AWB); throw; // throw error and exit } //HACK //if (AWBLogListener != null) //{ // AWBLogListener.WriteLine("Log uploaded", sender); //} //AWB.AddLogItem(Article); //AWB.AddLogItem(Article); 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; }
/// <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 { if (addToWatchlist) { retval.Add(EditPageEx(uploadToNoSpaces, strLogText, editSummary, false, true)); } else { retval.Add(EditPageEx(uploadToNoSpaces, strLogText, editSummary, false)); } } 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; }