User:B-bot/source/Daily Page Creator

This task will create daily pages if they do not exist. The list of pages is kept in a table at User:B-bot/Daily page creator pages.

. There appear to be more than two lines. Aborting", null);                       return;                    }

// Loop through the days for (int intDay = -1; intDay <= DaysInAdvance; intDay++) {                       DateTime dtm = DateTime.UtcNow.AddDays(intDay);

String strPageName = String.Format(arrData[0], dtm).Trim; String strTemplate = "";

// Does the page already exist? Page pg = new Page(site, strPageName); pg.Load;

SleepApiDelay;

if (!pg.Exists) {                           // Only create yesterday or today if the category is not empty if ((intDay <= 0) && strPageName.ToLower.StartsWith("category:")) {                               CreateCatIfNeeded(ref site, null, strPageName, strTemplate); }                           else {                               if (UserspaceTest) {                                   LogToEventLog(ref site, MessageType.Informational, "TEST MODE: Would create " + strPageName + " using  .", null); }                               else {                                   LogToEventLog(ref site, MessageType.Informational, "Now creating " + strPageName + " using  .", null); SleepApiDelay; pg.text = strTemplate; pg.Save("Creating dated category using " + strTemplate, false);

intPagesCreated++; }                           }

SleepTaggingDelay; }                       else if (UserspaceTest) {                           LogToEventLog(ref site, MessageType.Informational, "TEST MODE: " + strPageName + " ALREADY EXISTS so in live mode, I would do nothing.  If it didn't exist, I would create it using  .", null);

SleepApiDelay; }                   }                }

LogToEventLog(ref site, MessageType.Finish, "Process complete. Created " + intPagesCreated.ToString + " pages.", null); }           catch (Exception ex) {               SleepApiDelay;

// Use a separate connection for our less-important API calls Site site2 = TryToConnect("https://en.wikipedia.org", Properties.Settings.Default.BotUserName, Properties.Settings.Default.BotPassword);

SleepApiDelay;

LogToEventLog(ref site2, MessageType.Error, "Exception in DailyPageCreator. Aborting task", ex); }       }    }