Added background automatic rebuilding at startup.

This commit is contained in:
Matteo Tomasini 2010-04-09 14:28:14 +00:00
parent 554d9c41ab
commit 6f63e7cb95
3 changed files with 34 additions and 0 deletions

View file

@ -189,6 +189,25 @@ namespace ScrewTurn.Wiki {
if(Pages.FindPage(Settings.DefaultPage) == null) CreateMainPage();
Log.LogEntry("ScrewTurn Wiki is ready", EntryType.General, Log.SystemUsername);
System.Threading.ThreadPool.QueueUserWorkItem(ignored => {
if((DateTime.Now - Settings.LastPageIndexing).TotalDays > 7) {
Settings.LastPageIndexing = DateTime.Now;
System.Threading.Thread.Sleep(10000);
using(MemoryStream ms = new MemoryStream()) {
using(StreamWriter wr = new System.IO.StreamWriter(ms)) {
System.Web.HttpContext.Current = new System.Web.HttpContext(new System.Web.Hosting.SimpleWorkerRequest("", "", wr));
foreach(var provider in Collectors.PagesProviderCollector.AllProviders) {
if(!provider.ReadOnly) {
Log.LogEntry("Starting automatic rebuilding index for provider: " + provider.Information.Name, EntryType.General, Log.SystemUsername);
provider.RebuildIndex();
Log.LogEntry("Finished automatic rebuilding index for provider: " + provider.Information.Name, EntryType.General, Log.SystemUsername);
}
}
}
}
}
});
}
/// <summary>