Example #1
0
        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;
            }
        }
 protected virtual bool DoLogEntry(string LogTitle, string LogDetails, int PageNumber,
     System.DateTime StartDate, string UploadTo, string Location, bool UserNameCell,
     string EditSummary, string Username, bool AddLogArticlesToAnAWBList,
     IAutoWikiBrowser AWB, string sender)
 {
     LogEntry pLogEntry = new LogEntry(Location, UserNameCell);
     DoLogEntry(pLogEntry, LogTitle, LogDetails, PageNumber, StartDate, UploadTo, EditSummary,
         Username, AddLogArticlesToAnAWBList, AWB, sender);
     return pLogEntry.Success;
 }
        public virtual List<Editor.EditPageRetvals> LogIt(string Log, string LogTitle, string LogDetails, string UploadTo, 
            LogEntry LinkToLog, int PageNumber, System.DateTime StartDate, bool OpenInBrowser, 
            bool AddToWatchlist, string Username, string LogHeader)
		{
			List<LogEntry> linksToLog = new List<LogEntry>();
			linksToLog.Add(LinkToLog);

			return LogIt(Log, LogTitle, LogDetails, UploadTo, linksToLog, PageNumber, StartDate, OpenInBrowser, 
                AddToWatchlist, Username, LogHeader);
		}
        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;
            }
        }
        public virtual List<Editor.EditPageRetvals> LogIt(string Log, string LogTitle, string LogDetails, string UploadTo, 
            LogEntry LinkToLog, int PageNumber, System.DateTime StartDate, bool OpenInBrowser, 
            bool AddToWatchlist, string Username)
		{
			return LogIt(Log, LogTitle, LogDetails, UploadTo, LinkToLog, PageNumber, StartDate, OpenInBrowser, 
                AddToWatchlist, Username, "");
		}