public void Process() { while (MainQueue.Any()) { var dir = MainQueue.Pop(); if (dir != null) { DocumentsInserted = manager.InsertDocument(dir)?Utililties.ConcurrentIncrement(ref DocumentsInserted):DocumentsInserted; try { foreach (string filePath in System.IO.Directory.GetFiles(dir.FilePath)) { var fd = new FileFolder(filePath); DocumentsInserted = manager.InsertDocument(dir) ? Utililties.ConcurrentIncrement(ref DocumentsInserted) : DocumentsInserted; } if (DocumentsInserted % 20000 == 0) { manager.FushAndOptimize(); } } catch (UnauthorizedAccessException ex) { unDeniedAcccessCount += 1; } } } ThreadCount -= 1; }
public bool UpdateDocument(string Value, FileFolder file) { try { if (file != null) { Document doc = new Document(); doc.Add(new Field("FileName", file.Name, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("FilePath", file.FilePath, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("FileType", Enum.GetName(typeof(FileFolder.FileType), file.Type), Field.Store.YES, Field.Index.NOT_ANALYZED)); Writer.UpdateDocument(new Term("FilePath", Value), doc); //Console.WriteLine(string.Format("File {0} update to index", file.FilePath)); return(true); } return(false); } catch (Exception ex) { logger.WriteToLog(ex.Message); return(false); } }
public bool DeleteDocument(FileFolder file) { try { if (file != null) { Writer.DeleteDocuments(new Term("FilePath", file.FilePath)); //Console.WriteLine(string.Format("File {0} deleted from index", file.FilePath)); return(true); } return(false); } catch (Exception ex) { logger.WriteToLog(ex.Message); return(false); } }
public void Process() { while (MainQueue.Any()) { var dir = MainQueue.Pop(); if (dir!=null) { DocumentsInserted=manager.InsertDocument(dir)?Utililties.ConcurrentIncrement(ref DocumentsInserted):DocumentsInserted; try { foreach (string filePath in System.IO.Directory.GetFiles(dir.FilePath)) { var fd = new FileFolder(filePath); DocumentsInserted = manager.InsertDocument(dir) ? Utililties.ConcurrentIncrement(ref DocumentsInserted) : DocumentsInserted; } if (DocumentsInserted%20000==0) { manager.FushAndOptimize(); } } catch (UnauthorizedAccessException ex) { unDeniedAcccessCount += 1; } } } ThreadCount -= 1; }
public bool UpdateDocument(string Value, FileFolder file) { try { if (file != null) { Document doc = new Document(); doc.Add(new Field("FileName", file.Name, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("FilePath", file.FilePath, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("FileType", Enum.GetName(typeof(FileFolder.FileType), file.Type), Field.Store.YES, Field.Index.NOT_ANALYZED)); Writer.UpdateDocument(new Term("FilePath", Value), doc); //Console.WriteLine(string.Format("File {0} update to index", file.FilePath)); return true; } return false; } catch (Exception ex) { logger.WriteToLog(ex.Message); return false; } }
public bool DeleteDocument(FileFolder file) { try { if (file!=null) { Writer.DeleteDocuments(new Term("FilePath", file.FilePath)); //Console.WriteLine(string.Format("File {0} deleted from index", file.FilePath)); return true; } return false; } catch (Exception ex) { logger.WriteToLog(ex.Message); return false; } }