public void IncrementalBuildIndex()
        {
            if (DateTime.UtcNow.Subtract(time_of_last_library_scan).TotalSeconds > LIBRARY_SCAN_PERIOD_SECONDS)
            {
                RescanLibrary();
                time_of_last_library_scan = DateTime.UtcNow;
            }

            bool did_some_work = IncrementalBuildNextDocuments();

            // Flush to disk
            if (did_some_work)
            {
                Logging.Info("+Writing the index master list");
                word_index_manager.WriteMasterList();
                lock (pdf_documents_in_library)
                {
                    SerializeFile.SaveSafely(Filename_DocumentProgressList, pdf_documents_in_library);
                }
                Logging.Info("-Wrote the index master list");

                // Report to user
                UpdateStatus();
            }
        }
Beispiel #2
0
        public void IncrementalBuildIndex()
        {
            if (Utilities.Shutdownable.ShutdownableManager.Instance.IsShuttingDown)
            {
                Logging.Debug特("LibraryIndex::IncrementalBuildIndex: Breaking out due to application termination");
                return;
            }

            if (Common.Configuration.ConfigurationManager.Instance.ConfigurationRecord.DisableAllBackgroundTasks)
            {
                Logging.Debug特("LibraryIndex::IncrementalBuildIndex: Breaking due to DisableAllBackgroundTasks");
                return;
            }

            Init();

            if (DateTime.UtcNow.Subtract(time_of_last_library_scan).TotalSeconds > LIBRARY_SCAN_PERIOD_SECONDS)
            {
                if (RescanLibrary())
                {
                    time_of_last_library_scan = DateTime.UtcNow;
                }
            }

            bool did_some_work = IncrementalBuildNextDocuments();

            // Flush to disk
            if (did_some_work)
            {
                Stopwatch clk = Stopwatch.StartNew();

                Logging.Info("+Writing the index master list");

                Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
                lock (word_index_manager_lock)
                {
                    l1_clk.LockPerfTimerStop();

                    word_index_manager.WriteMasterList();
                }

                Utilities.LockPerfTimer l2_clk = Utilities.LockPerfChecker.Start();
                lock (pdf_documents_in_library_lock)
                {
                    l2_clk.LockPerfTimerStop();
                    SerializeFile.SaveSafely(Filename_DocumentProgressList, pdf_documents_in_library);
                }

                Logging.Info("-Wrote the index master list (time spent: {0} ms", clk.ElapsedMilliseconds);

                // Report to user
                UpdateStatus();
            }
        }
Beispiel #3
0
        public void IncrementalBuildIndex(WebLibraryDetail web_library_detail)
        {
            if (ShutdownableManager.Instance.IsShuttingDown)
            {
                Logging.Debug特("LibraryIndex::IncrementalBuildIndex: Breaking out due to application termination");
                return;
            }

            if (Common.Configuration.ConfigurationManager.Instance.ConfigurationRecord.DisableAllBackgroundTasks)
            {
                Logging.Debug特("LibraryIndex::IncrementalBuildIndex: Breaking due to DisableAllBackgroundTasks");
                return;
            }

            Init(web_library_detail);

            if (time_of_last_library_scan.ElapsedMilliseconds >= LIBRARY_SCAN_PERIOD_SECONDS * 1000)
            {
                if (RescanLibrary(web_library_detail))
                {
                    time_of_last_library_scan.Restart();
                }
            }

            bool did_some_work = IncrementalBuildNextDocuments(web_library_detail);

            // Flush to disk
            if (did_some_work)
            {
                Stopwatch clk = Stopwatch.StartNew();

                Logging.Info("+Writing the index master list");

                // Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
                lock (word_index_manager_lock)
                {
                    // l1_clk.LockPerfTimerStop();

                    word_index_manager?.WriteMasterList();
                }

                //Utilities.LockPerfTimer l2_clk = Utilities.LockPerfChecker.Start();
                lock (pdf_documents_in_library_lock)
                {
                    //l2_clk.LockPerfTimerStop();
                    SerializeFile.SaveSafely(web_library_detail.FILENAME_DOCUMENT_PROGRESS_LIST, pdf_documents_in_library);
                }

                Logging.Info("-Wrote the index master list (time spent: {0} ms", clk.ElapsedMilliseconds);

                // Report to user
                UpdateStatus();
            }
        }
        public LibraryIndex(Library library)
        {
            this.library = library;

            // Try to load a historical progress file
            if (File.Exists(Filename_DocumentProgressList))
            {
                pdf_documents_in_library = (Dictionary <string, PDFDocumentInLibrary>)SerializeFile.LoadSafely(Filename_DocumentProgressList);
            }

            // If there was no historical progress file, start afresh
            if (null == pdf_documents_in_library)
            {
                Logging.Warn("Cound not find any indexing progress, so starting from scratch.");
                pdf_documents_in_library = new Dictionary <string, PDFDocumentInLibrary>();
            }

            word_index_manager = new LuceneIndex(library.LIBRARY_INDEX_BASE_PATH);
            word_index_manager.WriteMasterList();
        }
Beispiel #5
0
        private void Init(WebLibraryDetail web_library_detail)
        {
            // have we been here before?
            if (LibraryIndexIsLoaded)
            {
                return;
            }

            // Utilities.LockPerfTimer l5_clk = Utilities.LockPerfChecker.Start();
            lock (libraryIndexInit_is_pending_lock)
            {
                // l5_clk.LockPerfTimerStop();

                //Utilities.LockPerfTimer l4_clk = Utilities.LockPerfChecker.Start();
                lock (pdf_documents_in_library_lock)
                {
                    lock (word_index_manager_lock)
                    {
                        //l4_clk.LockPerfTimerStop();
                        if (null != pdf_documents_in_library && null != word_index_manager)
                        {
                            Logging.Warn("LibraryIndex has already been initialized.");
                            return;
                        }
                    }
                }

                Logging.Info("Try to load a historical progress file: {0}", web_library_detail.FILENAME_DOCUMENT_PROGRESS_LIST);
                try
                {
                    if (File.Exists(web_library_detail.FILENAME_DOCUMENT_PROGRESS_LIST))
                    {
                        Stopwatch clk = Stopwatch.StartNew();
                        Logging.Info("+Loading historical progress file: {0}", web_library_detail.FILENAME_DOCUMENT_PROGRESS_LIST);
                        //Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
                        lock (pdf_documents_in_library_lock)
                        {
                            //l1_clk.LockPerfTimerStop();
                            pdf_documents_in_library = (Dictionary <string, PDFDocumentInLibrary>)SerializeFile.LoadSafely(web_library_detail.FILENAME_DOCUMENT_PROGRESS_LIST);
                        }
                        Logging.Info("-Loaded historical progress file: {0} (time spent: {1} ms)", web_library_detail.FILENAME_DOCUMENT_PROGRESS_LIST, clk.ElapsedMilliseconds);
                    }
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "FAILED to load historical progress file \"{0}\". Will start indexing afresh.", web_library_detail.FILENAME_DOCUMENT_PROGRESS_LIST);
                    //Utilities.LockPerfTimer l2_clk = Utilities.LockPerfChecker.Start();
                    lock (pdf_documents_in_library_lock)
                    {
                        //l2_clk.LockPerfTimerStop();
                        pdf_documents_in_library = null;
                    }
                }

                // If there was no historical progress file, start afresh
                //Utilities.LockPerfTimer l3_clk = Utilities.LockPerfChecker.Start();
                lock (pdf_documents_in_library_lock)
                {
                    //l3_clk.LockPerfTimerStop();
                    if (null == pdf_documents_in_library)
                    {
                        Logging.Warn("Could not find any indexing progress, so starting from scratch.");
                        pdf_documents_in_library = new Dictionary <string, PDFDocumentInLibrary>();
                    }
                }

                // Utilities.LockPerfTimer l6_clk = Utilities.LockPerfChecker.Start();
                lock (word_index_manager_lock)
                {
                    // l6_clk.LockPerfTimerStop();
                    word_index_manager = new LuceneIndex(web_library_detail.LIBRARY_INDEX_BASE_PATH);
                    word_index_manager.WriteMasterList();
                }

                LibraryIndexIsLoaded = true;
            }
        }