private void TestWordFile( List <PollerTestResult> retValue, String fileName, String type, Byte[] fileContent) { try { OfficeUtils.KillOfficeProcess("WINWORD"); var tempFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(tempFile)) { File.Delete(tempFile); } File.WriteAllBytes(tempFile, fileContent); var conversionError = WordConverter.ConvertToPdf(tempFile, tempFile + ".pdf"); if (!String.IsNullOrEmpty(conversionError)) { retValue.Add(new PollerTestResult(false, type + "Conversion with word converter failed: " + conversionError)); } else { retValue.Add(new PollerTestResult(true, type + "Conversion with word ok.")); } } catch (Exception ex) { retValue.Add(new PollerTestResult(false, type + "Conversion with word converter failed: " + ex.Message)); } }
private void TestPowerPointFile( List <PollerTestResult> retValue, String fileName, String type, Byte[] fileContent) { try { var tempFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(tempFile)) { File.Delete(tempFile); } File.WriteAllBytes(tempFile, fileContent); var conversionError = PowerPointConverter.ConvertToPdf(tempFile, tempFile + ".pdf"); if (!String.IsNullOrEmpty(conversionError)) { retValue.Add(new PollerTestResult(false, type + "Conversion with powerpoint converter failed:" + conversionError)); } else { retValue.Add(new PollerTestResult(true, type + "Conversion with powerpoint ok.")); } } catch (Exception ex) { retValue.Add(new PollerTestResult(false, type + "Conversion with powerpoint converter failed: " + ex.Message)); } }
private static void TestFile( List <PollerTestResult> retValue, ITikaAnalyzer analyzer, String fileName, String type, String expected, Byte[] fileContent) { var tempFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(tempFile)) { File.Delete(tempFile); } File.WriteAllBytes(tempFile, fileContent); try { string content = analyzer.GetHtmlContent(tempFile, ""); if (content.Contains(expected)) { retValue.Add(new PollerTestResult(true, type + " conversion")); } else { retValue.Add(new PollerTestResult(false, type + " conversion: wrong content")); } } catch (Exception ex) { retValue.Add(new PollerTestResult(false, type + " conversion: " + ex.Message)); } }
private void TestFile( List <PollerTestResult> retValue, String fileName, String type, Byte[] fileContent) { String converter = Conversion.GetType().Name; try { var tempFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(tempFile)) { File.Delete(tempFile); } File.WriteAllBytes(tempFile, fileContent); string content = Conversion.Run(tempFile, "pdf"); if (!String.IsNullOrEmpty(content)) { retValue.Add(new PollerTestResult(true, type + " conversion with converter: " + converter)); } else { retValue.Add(new PollerTestResult(false, type + " conversion: wrong content with converter: " + converter)); } } catch (Exception ex) { retValue.Add(new PollerTestResult(false, type + " conversion with converter " + converter + ex.Message)); } }
public async Task can_upload_document_with_name_greater_than_250_char() { var handle = DocumentHandle.FromString("Pdf_3"); String longFileName = Path.Combine( Path.GetTempPath(), "_lfn" + new string('X', 240) + ".pdf"); if (!File.Exists(longFileName)) { File.Copy(TestConfig.PathToDocumentPdf, longFileName); } await _documentStoreClient.UploadAsync(longFileName, handle); // wait background projection polling await UpdateAndWaitAsync().ConfigureAwait(false); // check readmodel var tenantAccessor = ContainerAccessor.Instance.Resolve <ITenantAccessor>(); var tenant = tenantAccessor.GetTenant(new TenantId(TestConfig.Tenant)); var docReader = tenant.Container.Resolve <IMongoDbReader <DocumentDescriptorReadModel, DocumentDescriptorId> >(); var allDocuments = docReader.AllUnsorted.Count(); Assert.AreEqual(1, allDocuments); }
public FormatStoreMultipartStreamProvider( IBlobStore store, DocumentFormat format ) : base(Path.GetTempPath()) { _store = store; _format = format; }
public FileStoreMultipartStreamProvider( IBlobStore store, DocumentStoreConfiguration config ) : base(Path.GetTempPath()) { _store = store; _config = config; }
public void SetUp() { longFolderName = Path.Combine(Path.GetTempPath(), new String('a', 230)); _blobId = new BlobId(_originalFormat, 1); _pathToTask = Path.Combine(longFolderName, "File_1.dsimport"); _fileToImport = Path.Combine(longFolderName, "A Word Document.docx"); _fileUri = new Uri(Path.Combine(longFolderName, "A word document.docx")); ClearQueueTempFolder(); Directory.CreateDirectory(longFolderName); File.Copy(Path.Combine(TestConfig.DocumentsFolder, "Queue\\File_1.dsimport"), _pathToTask); File.Copy(TestConfig.PathToWordDocument, _fileToImport); var accessor = Substitute.For <ITenantAccessor>(); var tenant = Substitute.For <ITenant>(); tenant.Id.Returns(new TenantId("tests")); var container = Substitute.For <IWindsorContainer>(); _commandBus = Substitute.For <ICommandBus>(); var identityGenerator = Substitute.For <IIdentityGenerator>(); _blobstore = Substitute.For <IBlobStore>(); _blobstore.Upload(Arg.Is(_originalFormat), Arg.Any <string>()).Returns(_blobId); _blobstore.Upload(Arg.Is(_originalFormat), Arg.Any <FileNameWithExtension>(), Arg.Any <Stream>()).Returns(_blobId); accessor.GetTenant(_testTenant).Returns(tenant); accessor.Current.Returns(tenant); tenant.Container.Returns(container); container.Resolve <IBlobStore>().Returns(_blobstore); container.Resolve <IIdentityGenerator>().Returns(identityGenerator); container.Resolve <IMongoDatabase>().Returns(MongoDbTestConnectionProvider.ReadModelDb); var collection = MongoDbTestConnectionProvider.ReadModelDb.GetCollection <ImportFailure>("sys.importFailures"); collection.Drop(); DocumentStoreTestConfiguration config = new DocumentStoreTestConfiguration(tenantId: "tests"); config.SetFolderToMonitor(longFolderName); var sysDb = config.TenantSettings.Single(t => t.TenantId == "tests").Get <IMongoDatabase>("system.db"); sysDb.Drop(); _queue = new ImportFormatFromFileQueue(config, accessor, _commandBus) { Logger = new ConsoleLogger() }; _queue.DeleteTaskFileAfterImport = false; }
private static void TestFile( List <PollerTestResult> retValue, CreateImageFromPdfTask task, String fileName, Byte[] fileContent) { var tempFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(tempFile)) { File.Delete(tempFile); } File.WriteAllBytes(tempFile, fileContent); try { var convertParams = new CreatePdfImageTaskParams() { Dpi = 150, FromPage = 1, Pages = 1, Format = CreatePdfImageTaskParams.ImageFormat.Jpg, }; Boolean wasCalled = false; var result = task.Run( tempFile, convertParams, (i, s) => { wasCalled = true; return(Task.FromResult <Boolean>(true)); } ); result.Wait(); if (wasCalled) { retValue.Add(new PollerTestResult(true, "Pdf to Jpg")); } else { retValue.Add(new PollerTestResult(false, "Pdf to Jpg")); } } catch (Exception ex) { retValue.Add(new PollerTestResult(false, "Pdf to Jpg: " + ex.Message)); } }
public List <PollerTestResult> Execute() { List <PollerTestResult> retValue = new List <PollerTestResult>(); String format = "png"; Int32 secondsOffset = 4; String vlcExecutable = Helper.GetExecutableLocation(); if (vlcExecutable == null) { retValue.Add(new PollerTestResult(false, "Executable location, use app settings vlc_location")); return(retValue); } else { retValue.Add(new PollerTestResult(true, "Executable location, ")); } try { var worker = new VlcCommandLineThumbnailCreator(vlcExecutable, format, NullLogger.Instance); var tempFile = Path.Combine(Path.GetTempPath(), "video.mp4"); if (File.Exists(tempFile)) { File.Delete(tempFile); } File.WriteAllBytes(tempFile, TestFiles.video); var thumb = worker.CreateThumbnail(tempFile, Path.GetTempPath(), 4); retValue.Add(new PollerTestResult( !String.IsNullOrEmpty(tempFile), "video thumb extraction: ")); } catch (Exception ex) { retValue.Add(new PollerTestResult(false, "video thumb extraction: " + ex.Message)); } return(retValue); }
private static string GenerateQueueFolder() { return(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString(), "Queue")); }