public LuceneIndexingJob(TimeSpan frequence, Func<EntitiesContext> contextThunk, TimeSpan timeout, LuceneIndexLocation location) : base("Lucene", frequence, timeout) { _updateIndex = () => { using (var context = contextThunk()) { var indexingService = new LuceneIndexingService( new EntityRepository<Package>(context), new EntityRepository<CuratedPackageVersion>(context), LuceneCommon.GetDirectory(location), null); indexingService.UpdateIndex(); } }; // Updates the index synchronously first time job is created. // For startup code resiliency, we should handle exceptions for the database being down. try { _updateIndex(); } catch (SqlException e) { QuietLog.LogHandledException(e); } catch (DataException e) { QuietLog.LogHandledException(e); } }
private static string GetIndexLocation(LuceneIndexLocation location) { switch (location) { case LuceneIndexLocation.Temp: return Path.Combine(Path.GetTempPath(), "NuGetGallery", "Lucene"); default: return HostingEnvironment.MapPath("~/App_Data/Lucene"); } }
private static string GetIndexLocation(LuceneIndexLocation location) { switch (location) { case LuceneIndexLocation.Temp: return(Path.Combine(Path.GetTempPath(), "NuGetGallery", "Lucene")); default: return(HostingEnvironment.MapPath("~/App_Data/Lucene")); } }
internal static Lucene.Net.Store.Directory GetDirectory(LuceneIndexLocation location) { if (_directorySingleton == null) { var index = GetIndexLocation(location); if (!System.IO.Directory.Exists(index)) { System.IO.Directory.CreateDirectory(index); } var directoryInfo = new DirectoryInfo(index); _directorySingleton = new SimpleFSDirectory(directoryInfo, LuceneLock); } return _directorySingleton; }
internal static Lucene.Net.Store.Directory GetDirectory(LuceneIndexLocation location) { if (_directorySingleton == null) { var index = GetIndexLocation(location); if (!System.IO.Directory.Exists(index)) { System.IO.Directory.CreateDirectory(index); } var directoryInfo = new DirectoryInfo(index); _directorySingleton = new SimpleFSDirectory(directoryInfo, LuceneLock); } return(_directorySingleton); }
public LuceneIndexingJob(TimeSpan frequence, Func <EntitiesContext> contextThunk, TimeSpan timeout, LuceneIndexLocation location) : base("Lucene", frequence, timeout) { _updateIndex = () => { using (var context = contextThunk()) { var indexingService = new LuceneIndexingService( new EntityRepository <Package>(context), new EntityRepository <CuratedPackageVersion>(context), LuceneCommon.GetDirectory(location), null); indexingService.UpdateIndex(); } }; // Updates the index synchronously first time job is created. // For startup code resiliency, we should handle exceptions for the database being down. try { _updateIndex(); } catch (SqlException e) { QuietLog.LogHandledException(e); } catch (DataException e) { QuietLog.LogHandledException(e); } }