Esempio n. 1
0
        /// <summary>
        /// Adds a document to the indexer
        /// </summary>
        /// <param name="document">Document to be indexed or added to the indexer</param>
        public void add(Doocument document)
        {
            int    id   = document.getID();
            string text = document.getText();

            add(getTokenizedKeywords(text), id);
        }
Esempio n. 2
0
        /// <summary>
        /// Performs the main function of getting the newly added documents and add them to the indexer,
        /// and also get the removed documents and remove them from the indexer
        /// </summary>
        public void run()
        {
            if (rest)
            {
                Thread.Sleep(sleepTime);
            }

            while (true)
            {
                Indexer indexer = Storage.getStorageDetails().getIndexer();

                foreach (string path in Storage.getAddedPaths())
                {
                    int       id       = Storage.getStorageDetails().getAndIncrLastDocumentID();
                    Doocument document = new Doocument(id, path);
                    indexer.add(document);
                    Storage.getStorageDetails().getDocumentList().Add(document);
                    Storage.getStorageDetails().incrNumberOfDocument();
                }

                foreach (Doocument document in Storage.getRemovedDocuments())
                {
                    int id = document.getID();
                    indexer.remove(id);
                }

                Thread.Sleep(20000);//time in milliseconds
            }
        }
Esempio n. 3
0
        /// <summary>
        /// This method gets the Document object by specifying its path
        /// </summary>
        /// <param name="path">the path of the document to be gotten</param>
        /// <returns>the document associated to that path</returns>
        static Doocument getDocumentByPath(string path)
        {
            Doocument doc = null;

            foreach (Doocument document in storageDetails.getDocumentList())
            {
                if (document.getPath() == path)
                {
                    doc = document;
                    break;
                }
            }

            if (doc != null)
            {
                storageDetails.getDocumentList().Remove(doc);
                storageDetails.decrNumberOfDocument();
            }

            return(doc);
        }