Beispiel #1
0
        /// <summary>
        ///  Load the document store from workspace volume
        /// </summary>
        /// <param name="workspaceFolder">Workspace location</param>
        public DocumentStoreModel LoadStore(string workspaceFolder)
        {
            if (_storeIndex == null)
            {
                this._storeIndex = new DocumentIndex(workspaceFolder);

            }

            DocumentStoreModel docStore = new DocumentStoreModel();

            documentLocationFile = Path.Combine(workspaceFolder, "DocumentStore.lucy");
            documentLocationDocFile = Path.Combine(workspaceFolder, "DocumentStoreDoc.lucy");


            if (File.Exists(documentLocationFile))
            {
                using (Stream stream = File.Open(documentLocationFile, FileMode.Open))
                {
                    docStore = (DocumentStoreModel)serializer.Deserialize(stream);
                }
                using (Stream stream = File.Open(documentLocationDocFile, FileMode.Open))
                {
                    _storeIndex.DocumentIdentity = (List<DocumentIdentity>)serializerIndex.Deserialize(stream);
                }

            }
            

            this._storeIndex.PluginManager = new PluginManager();
            _storeIndex.PluginManager.Load();

            return docStore;
        }
Beispiel #2
0
        public void TestAddDocumentToIndex()
        {
            DocumentIndex index = new DocumentIndex(IndexDir);
            index.Add(document1A);
            Assert.IsTrue(index.DocumentIdentity.Count == 1, "One document added");

        }
Beispiel #3
0
        public void TestIndexUnicity()
        {
            DocumentIdentity document1ABis = new DocumentIdentity();
            document1ABis.Checksum = document1A.Checksum;
            document1ABis.FilePath = document1A.FilePath;
            document1ABis.DocumentID = document1A.DocumentID;
            document1ABis.State = IndexationStates.Undefined;

            DocumentIndex index = new DocumentIndex(IndexDir);
            index.Add(document1A);
            index.Add(document1ABis);
            Assert.IsTrue(index.DocumentIdentity.Count == 1, "One different document added");

            document1ABis.State = IndexationStates.NotIndexed;
            index.Add(document1ABis);
            Assert.IsTrue(index.DocumentIdentity.Count == 1, "One different document added");
        }
Beispiel #4
0
 public void TestScan()
 {
     DocumentIndex index = new DocumentIndex(IndexDir);
     PluginManager plugin = new PluginManager();
     plugin.Load();
     index.PluginManager = plugin;
     index.Add(document1A);
     index.Scan();
     foreach (var doc in index.DocumentIdentity)
     {
         Assert.IsTrue(doc.State == IndexationStates.Indexed, "All documents must be index after a scan");
     }
 }
Beispiel #5
0
 public void TestQuery()
 {
     DocumentIndex index = new DocumentIndex(IndexDir);
     PluginManager plugin = new PluginManager();
     plugin.Load();
     index.PluginManager = plugin;
     index.Add(document1A);
     index.Scan();
     var result = index.Search(
         String.Format("Name:\"{0}\"", Path.GetFileNameWithoutExtension(document1A.FilePath)));
     Assert.IsTrue(result.Count() == 1, "Should found 1 doc, found = {0}", result.Count());
 }