Exemplo n.º 1
0
 /// <summary>Gets all modified MediaWiki messages (to be more precise, all messages that are
 /// contained in database), loads them into site.messages PageList (both titles and texts)
 /// and dumps them to XML file.</summary>
 /// <param name="forceLoad">If true, the messages are updated unconditionally. Otherwise
 /// the messages are updated only if they are outdated.</param>
 public void GetModifiedMediaWikiMessages(bool forceLoad)
 {
     if (messages == null)
         messages = new PageList(this);
     string filePathName = "Cache" + Path.DirectorySeparatorChar +
         HttpUtility.UrlEncode(site.Replace("://", ".")) + ".mw_db_msg.xml";
     if (forceLoad == false && File.Exists(filePathName) &&
         (DateTime.Now - File.GetLastWriteTime(filePathName)).Days <= 90)
     {
         messages.FillAndLoadFromXMLDump(filePathName);
         return;
     }
     Console.WriteLine(Bot.Msg("Updating MediaWiki messages dump. Please, wait..."));
     PageList pl = new PageList(this);
     bool prevBotQueryState = botQuery;
     botQuery = false;	// backward compatibility requirement
     pl.FillFromAllPages("!", 8, false, 100000);
     botQuery = prevBotQueryState;
     File.Delete(filePathName);
     pl.SaveXMLDumpToFile(filePathName);
     messages.FillAndLoadFromXMLDump(filePathName);
     Console.WriteLine(Bot.Msg("MediaWiki messages dump updated successfully."));
 }