Пример #1
0
        protected async Task <Boolean> AddFormatToDocumentFromFile(
            string tenantId,
            String jobId,
            Client.Model.DocumentFormat format,
            string pathToFile,
            IDictionary <string, object> customData)
        {
            DocumentStoreServiceClient       client = GetDocumentStoreClient(tenantId);
            AddFormatFromFileToDocumentModel model  = new AddFormatFromFileToDocumentModel
            {
                CreatedById = this.PipelineId,
                JobId       = jobId,
                QueueName   = this.QueueName,
                Format      = format,
                PathToFile  = pathToFile
            };

            var response = await client.AddFormatToDocument(model, customData).ConfigureAwait(false);

            if (Logger.IsInfoEnabled)
            {
                Logger.Info($"Job {this.GetType()} Added format {format} to handle with job id {jobId}");
            }

            return(response != null);
        }
        public void Upload_doc_then_add_format_to_doc()
        {
            _docs.UploadAsync(TestConfig.PathToWordDocument, DocumentHandle.FromString("doc_2")).Wait();
            AddFormatFromFileToDocumentModel model = new AddFormatFromFileToDocumentModel();

            model.CreatedById    = "tika";
            model.DocumentHandle = DocumentHandle.FromString("doc_2");
            model.PathToFile     = TestConfig.PathToTextDocument;
            model.Format         = new DocumentFormat(DocumentFormats.Tika);
            _docs.AddFormatToDocument(model, null).Wait();
        }
Пример #3
0
        public async Task Can_add_new_format_with_api()
        {
            //Upload original
            var handle = new DocumentHandle("Add_Format_Test");
            await _documentStoreClient.UploadAsync(TestConfig.PathToOpenDocumentText, handle);

            // wait background projection polling
            await UpdateAndWaitAsync().ConfigureAwait(false);

            //now add format to document.
            AddFormatFromFileToDocumentModel model = new AddFormatFromFileToDocumentModel();

            model.DocumentHandle = handle;
            model.PathToFile     = TestConfig.PathToTextDocument;
            model.CreatedById    = "tika";
            model.Format         = new DocumentFormat("tika");
            await _documentStoreClient.AddFormatToDocument(model, new Dictionary <String, Object>());

            // wait background projection polling
            await UpdateAndWaitAsync().ConfigureAwait(false);

            var formats = await _documentStoreClient.GetFormatsAsync(handle);

            Assert.NotNull(formats);
            Assert.IsTrue(formats.HasFormat(new DocumentFormat("original")));
            Assert.IsTrue(formats.HasFormat(new DocumentFormat("tika")));
            Assert.That(formats, Has.Count.EqualTo(2));
        }
Пример #4
0
        protected async Task <Boolean> AddFormatToDocumentFromObject(string tenantId,
                                                                     String queueName,
                                                                     String jobId,
                                                                     Client.Model.DocumentFormat format,
                                                                     Object obj,
                                                                     String originalFileName,
                                                                     IDictionary <string, object> customData)
        {
            DocumentStoreServiceClient         client = GetDocumentStoreClient(tenantId);
            AddFormatFromObjectToDocumentModel model  = new AddFormatFromObjectToDocumentModel
            {
                CreatedById   = this.PipelineId,
                JobId         = jobId,
                QueueName     = queueName,
                Format        = format,
                FileName      = originalFileName,
                StringContent = JsonConvert.SerializeObject(obj),
            };
            var response = await client.AddFormatToDocument(model, customData).ConfigureAwait(false);

            return(response != null);
        }