private void AddPdfToIndexe(string fileName) { Task t = new Task(() => { var Pdfdirectory = "C:\\SearchMe"; var pathPdf = Pdfdirectory + "\\" + Guid.NewGuid().ToString() + ".txt"; if (!Directory.Exists(Pdfdirectory)) { Directory.CreateDirectory(Pdfdirectory); } //should change to application startup path if (!File.Exists(pathPdf)) { File.Create(pathPdf).Dispose(); } Utility.WritePdfContentToTxtFile(Pdfdirectory, fileName, pathPdf); DataForIndex dfi = Utility.CreatePdfIndexedDocument(fileName, pathPdf); LuceneBussines lucene = new LuceneBussines(); lucene.CreateIndex(dfi); IndexDocCount++; LableTextChange(DocumentCountLable, IndexDocCount.ToString()); }); t.Start(); }
private void AddSoundToIndexed(string fn) { Task t = new Task(() => { DataForIndex dfi = Utility.CreateSoundIndexDoucment(fn); LuceneBussines lucene = new LuceneBussines(); lucene.CreateIndex(dfi); IndexMp3Count++; LableTextChange(CountFileIndexedLabel, IndexMp3Count.ToString()); }); t.Start(); }
private void AddVideoToIndexed(string fn) { Task t = new Task(() => { DataForIndex dfi = Utility.CreateVideoIndexDoucment(fn); LuceneBussines lucene = new LuceneBussines(); lucene.CreateIndex(dfi); IndexMovieCount++; LableTextChange(Videolblcount, IndexMovieCount.ToString()); }); t.Start(); }
private void AddDocumentToIndexed(string fileName, FilterReaderTimeout timeoutOption) { Task t = new Task(() => { try { var reader = new FilterReader(fileName, string.Empty, disableEmbeddedContent: false, includeProperties: false, readIntoMemory: false, filterReaderTimeout: timeoutOption, timeout: -1); DataForIndex dfi = Utility.CreateDocumentIndex(reader, fileName); LuceneBussines lucene = new LuceneBussines(); lucene.CreateIndex(dfi); IndexDocCount++; LableTextChange(DocumentCountLable, IndexDocCount.ToString()); } catch (Exception ex) { try { var reader = new FilterReader(fileName, string.Empty, disableEmbeddedContent: false, includeProperties: false, readIntoMemory: true, filterReaderTimeout: FilterReaderTimeout.TimeoutWithException, timeout: 5000); if (reader == null) { return; } ; DataForIndex dfi = Utility.CreateDocumentIndex(reader, fileName); LuceneBussines lucene = new LuceneBussines(); lucene.CreateIndex(dfi); IndexDocCount++; LableTextChange(DocumentCountLable, IndexDocCount.ToString()); } catch (Exception) { } } }); t.Start(); }