示例#1
0
        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;
            }
        }
示例#2
0
        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;
            }
        }