Esempio n. 1
0
        private void InitializeIndex()
        {
            //IndexWriter w = index.Storage.GetWriter(index.Analyzer);
            StorageIndexManagerInitializationProgressTracker initTracker = new StorageIndexManagerInitializationProgressTracker(watchers.Keys.Select(k => k));

            using (ILuceneWriteContext writer = index.Writer.WriteContext(buffer))
            {
                if (debugging)
                {
                    writer.InfoEvent += (sender, args) => logger.Log("indexdebug", Severity.Critical, args.Message, new { args });
                }

                Sync.Await(watchers.Values.Select(watcher => watcher
                                                  .Initialize(writer, new Progress <StorageIndexChangeLogWatcherInitializationProgress>(
                                                                  progress => tracker.SetProgress($"{initTracker.Capture(progress)}")))));
            }
            OnIndexInitialized(new IndexInitializedEventArgs());
        }
Esempio n. 2
0
        public async Task ResetIndex()
        {
            Stop();
            index.Storage.Purge();

            StorageIndexManagerInitializationProgressTracker initTracker = new StorageIndexManagerInitializationProgressTracker(watchers.Keys.Select(k => k));

            using (ILuceneWriteContext writer = index.Writer.WriteContext(buffer))
            {
                if (debugging)
                {
                    writer.InfoEvent += (sender, args) => logger.Log("indexdebug", Severity.Critical, args.Message, new { args });
                }

                await Task.WhenAll(watchers.Values.Select(watcher => watcher.Reset(writer, 0, new Progress <StorageIndexChangeLogWatcherInitializationProgress>(
                                                                                       progress => tracker.SetProgress($"{initTracker.Capture(progress)}")))));
            }
            OnIndexReset(new IndexResetEventArgs());
            task = scheduler.ScheduleTask("ChangeLogWatcher", b => UpdateIndex(), interval);
        }