/// <summary> /// Raises the BuildingEmptyIndexOnStartup event /// </summary> /// <param name="e"></param> protected virtual void OnBuildingEmptyIndexOnStartup(BuildingEmptyIndexOnStartupEventArgs e) { var handler = BuildingEmptyIndexOnStartup; if (handler != null) { handler(this, e); } }
/// <summary> /// Before any of the index/search collections are accessed, the providers need to be loaded /// </summary> private void EnsureProviders() { if (!_providersInit) { lock (_lock) { // Do this again to make sure _provider is still null if (!_providersInit) { // Load registered providers and point _provider to the default provider _indexProviderCollection = new IndexProviderCollection(); ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.IndexProviders.Providers, _indexProviderCollection, typeof(BaseIndexProvider)); _searchProviderCollection = new SearchProviderCollection(); ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.SearchProviders.Providers, _searchProviderCollection, typeof(BaseSearchProvider)); //set the default if (!string.IsNullOrEmpty(ExamineSettings.Instance.SearchProviders.DefaultProvider)) { _defaultSearchProvider = _searchProviderCollection[ExamineSettings.Instance.SearchProviders.DefaultProvider]; } if (_defaultSearchProvider == null) { throw new ProviderException("Unable to load default search provider"); } _providersInit = true; //check if we need to rebuild on startup if (ExamineSettings.Instance.RebuildOnAppStart) { foreach (var index in _indexProviderCollection.Cast <IIndexer>()) { if (!index.IndexExists()) { var args = new BuildingEmptyIndexOnStartupEventArgs(index); OnBuildingEmptyIndexOnStartup(args); if (!args.Cancel) { index.RebuildIndex(); } } } } } } } }
/// <summary> /// Raises the BuildingEmptyIndexOnStartup event /// </summary> /// <param name="e"></param> protected virtual void OnBuildingEmptyIndexOnStartup(BuildingEmptyIndexOnStartupEventArgs e) { var handler = BuildingEmptyIndexOnStartup; if (handler != null) handler(this, e); }
/// <summary> /// Before any of the index/search collections are accessed, the providers need to be loaded /// </summary> private void EnsureProviders() { if (!_providersInit) { lock (_lock) { // Do this again to make sure _provider is still null if (!_providersInit) { // Load registered providers and point _provider to the default provider _indexProviderCollection = new IndexProviderCollection(); ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.IndexProviders.Providers, _indexProviderCollection, typeof(BaseIndexProvider)); _searchProviderCollection = new SearchProviderCollection(); ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.SearchProviders.Providers, _searchProviderCollection, typeof(BaseSearchProvider)); //set the default if (!string.IsNullOrEmpty(ExamineSettings.Instance.SearchProviders.DefaultProvider)) _defaultSearchProvider = _searchProviderCollection[ExamineSettings.Instance.SearchProviders.DefaultProvider]; if (_defaultSearchProvider == null) throw new ProviderException("Unable to load default search provider"); _providersInit = true; //check if we need to rebuild on startup if (ExamineSettings.Instance.RebuildOnAppStart) { foreach (var index in _indexProviderCollection.Cast<IIndexer>()) { if (!index.IndexExists()) { var args = new BuildingEmptyIndexOnStartupEventArgs(index); OnBuildingEmptyIndexOnStartup(args); if (!args.Cancel) { index.RebuildIndex(); } } } } } } } }
/// <summary> /// Before any of the index/search collections are accessed, the providers need to be loaded /// </summary> private void EnsureProviders() { if (!_providersInit) { lock (_lock) { // Do this again to make sure _provider is still null if (!_providersInit) { // Load registered providers and point _provider to the default provider _indexProviderCollection = new IndexProviderCollection(); ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.IndexProviders.Providers, _indexProviderCollection, typeof(BaseIndexProvider)); _searchProviderCollection = new SearchProviderCollection(); ProvidersHelper.InstantiateProviders(ExamineSettings.Instance.SearchProviders.Providers, _searchProviderCollection, typeof(BaseSearchProvider)); //set the default if (!string.IsNullOrEmpty(ExamineSettings.Instance.SearchProviders.DefaultProvider)) { _defaultSearchProvider = _searchProviderCollection[ExamineSettings.Instance.SearchProviders.DefaultProvider]; } if (_defaultSearchProvider == null) { throw new ProviderException("Unable to load default search provider"); } _providersInit = true; //check if we need to rebuild on startup if (ExamineSettings.Instance.RebuildOnAppStart) { foreach (IIndexer index in _indexProviderCollection) { var rebuild = false; var healthy = true; Exception unhealthyEx = null; var exists = index.IndexExists(); if (!exists) { rebuild = true; } if (!rebuild) { healthy = IsIndexHealthy(index, out unhealthyEx); if (!healthy) { rebuild = true; } } //if it doesn't exist ... or if it's unhealthy/corrupt if (rebuild) { var args = new BuildingEmptyIndexOnStartupEventArgs(index, healthy, unhealthyEx); OnBuildingEmptyIndexOnStartup(args); if (!args.Cancel) { index.RebuildIndex(); } } } } } } } }