/// <summary>
        /// Azures the index builder.
        /// </summary>
        /// <param name="repository">The repository.</param>
        /// <param name="searchProvider">The search provider.</param>
        /// <param name="messageSender">The message sender.</param>
        /// <param name="consumerFactory">The consumer factory.</param>
        /// <param name="observer">The observer.</param>
        /// <param name="queueReader">The queue reader.</param>
        /// <param name="indexBuilders">The index builders.</param>
        public SearchIndexController(IBuildSettingsRepository repository, ISearchProvider searchProvider, IMessageSender messageSender, IConsumerFactory consumerFactory, ISystemObserver observer, IQueueReader queueReader, ISearchIndexBuilder[] indexBuilders)
		{
			_repository = repository;
			_messageSender = messageSender;
			_observer = observer;
			_queueReader = queueReader;
			_consumerFactory = consumerFactory;
            _searchProvider = searchProvider;
            _indexBuilders = indexBuilders;
		}
示例#2
0
        /// <summary>
        /// Builds the index.
        /// </summary>
        /// <param name="rebuild">if set to <c>true</c> [rebuild].</param>
        public void BuildIndex(bool rebuild)
        {
            _IndexBuilderIndex = 1;
            _IndexBuilderCount = SearchConfiguration.Instance.Indexers.Count;
            foreach (IndexerDefinition indexer in SearchConfiguration.Instance.Indexers)
            {
                Logger.Debug(String.Format("Getting the type \"{0}\".", indexer.ClassName));
                ClassInfo classInfo = new ClassInfo(indexer.ClassName);
                Logger.Debug(String.Format("Creating instance of \"{0}\".", classInfo.Type.Name));
                ISearchIndexBuilder builder = ((ISearchIndexBuilder)classInfo.CreateInstance());
                builder.Manager = this;
                IndexBuilder buildIndexer = null;

                try
                {
                    string path = GetApplicationPath(indexer);
                    buildIndexer    = new IndexBuilder(path, rebuild, indexer.Name);
                    builder.Indexer = buildIndexer;
                    if (rebuild)
                    {
                        Logger.Info(String.Format("Starting new index build in \"{0}\" using \"{1}\" indexer.", path, indexer.Name));
                    }
                    else
                    {
                        Logger.Info(String.Format("Starting incremental index build in \"{0}\" using \"{1}\" indexer.", path, indexer.Name));
                    }

                    builder.BuildIndex(rebuild);
                    buildIndexer.SaveBuild(Status.Completed);
                    buildIndexer.Close(!buildIndexer.RebuildIndex);
                    Logger.Info(String.Format("Successfully finished index build in \"{0}\" using \"{1}\" indexer.", path, indexer.Name));
                }
                catch (Exception ex)
                {
                    if (buildIndexer != null)
                    {
                        buildIndexer.Close();
                    }

                    string msg             = String.Format("Build Failed using \"{0}\" indexer. \"{1}\"", indexer.Name, ex.Message);
                    IndexBuildException ne = new IndexBuildException(msg, ex);
                    Logger.Info(msg, ne);
                    throw ne;
                }
                finally
                {
                }
                _IndexBuilderIndex++;
            }
        }
示例#3
0
 public HomeController(ISearchIndexBuilder searchIndexBuilder, ISearcher searcher)
 {
     _searchIndexBuilder = searchIndexBuilder;
     _searcher           = searcher;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchIndexMessageHandler"/> class.
        /// </summary>
        /// <param name="messageSender">The message sender.</param>
        /// <param name="repository">The repository.</param>
        /// <param name="indexBuilders">The index builders.</param>
        public SearchIndexMessageHandler(IMessageSender messageSender, IBuildSettingsRepository repository, ISearchIndexBuilder[] indexBuilders)
		{
			MessageSender = messageSender;
            _repository = repository;
            _indexBuilders = indexBuilders;
		}