コード例 #1
0
        protected override void Execute(CodeActivityContext context)
        {
            ExtractorDocumentType documentType   = ExtractorDocumentType.Get(context);
            ResultsDocumentBounds documentBounds = DocumentBounds.Get(context);
            string   text         = DocumentText.Get(context);
            Document document     = DocumentObjectModel.Get(context);
            string   documentPath = DocumentPath.Get(context);

            ExtractorResult.Set(context, ComputeResult(documentType, documentBounds, text, document, documentPath));
        }
コード例 #2
0
        protected override void Execute(CodeActivityContext context)
        {
            string   text         = DocumentText.Get(context);
            Document document     = DocumentObjectModel.Get(context);
            string   documentPath = DocumentPath.Get(context);

            ClassifierDocumentType[] documentTypes = DocumentTypes.Get(context);
            int evidencePage = EvidencePage.Get(context);

            ClassifierResult.Set(context, ComputeResult(text, document, documentPath, documentTypes, evidencePage));
        }
コード例 #3
0
        Task <HttpResponseMessage> ExecuteAsync(CodeActivityContext context)
        {
            MultipartFormDataContent formData = new MultipartFormDataContent();
            FileStream fs = null;

            var basePath = BasePath.Get(context);
            var request  = new HttpRequestMessage()
            {
                RequestUri = new Uri(basePath + "/parseDocument"),
                Method     = HttpMethod.Post,
            };

            var apiKey = APIKey.Get(context);

            request.Headers.Add("X-Auth-Key", apiKey);

            var documentURL = DocumentURL.Get(context);

            if (documentURL != null && !documentURL.Equals(""))
            {
                formData.Add(new StringContent(documentURL, Encoding.UTF8), "url");
            }

            var template = Template.Get(context);

            if (template != null && !template.Equals(""))
            {
                formData.Add(new StringContent(template, Encoding.UTF8), "template");
            }

            var pdfTextExtraction = PDFTextExtraction.Get(context);

            if (pdfTextExtraction == PDFTextExtractionType.Fast)
            {
                formData.Add(new StringContent("fast", Encoding.UTF8), "pdf_text_extraction");
            }
            else if (pdfTextExtraction == PDFTextExtractionType.Full)
            {
                formData.Add(new StringContent("full", Encoding.UTF8), "pdf_text_extraction");
            }

            var userData = UserData.Get(context);

            if (userData != null && !userData.Equals(""))
            {
                formData.Add(new StringContent(userData, Encoding.UTF8), "user_data");
            }

            var userDataSetExternalID = UserDataSetExternalID.Get(context);

            if (userDataSetExternalID != null && !userDataSetExternalID.Equals(""))
            {
                formData.Add(new StringContent(userDataSetExternalID, Encoding.UTF8), "user_data_set_external_id");
            }

            var documentFilename = DocumentFilename.Get(context);
            var documentBytes    = DocumentBytes.Get(context);
            var documentPath     = DocumentPath.Get(context);
            var documentStream   = DocumentStream.Get(context);

            if (documentBytes != null && documentBytes.Length > 0)
            {
                formData.Add(new ByteArrayContent(documentBytes), "document", documentFilename);
            }
            else if (documentPath != null && !documentPath.Equals(""))
            {
                fs = File.OpenRead(documentPath);
                formData.Add(new StreamContent(fs), "document", Path.GetFileName(documentPath));
            }
            else if (documentStream != null && documentStream.Length > 0)
            {
                formData.Add(new StreamContent(documentStream), "document", documentFilename);
            }

            request.Content = formData;
            request.Properties["RequestTimeout"] = TimeSpan.FromSeconds(600);

            return(httpClient.SendAsync(request));
        }