コード例 #1
0
        public async Task <List <GetDocumentTextDetectionResponse> > GetJobResult(string jobId)
        {
            List <GetDocumentTextDetectionResponse> result = new List <GetDocumentTextDetectionResponse>();

            // Wait for response of Amazon Textract
            GetDocumentTextDetectionResponse response = await this.amazonTextract.GetDocumentTextDetectionAsync(new GetDocumentTextDetectionRequest
            {
                JobId = jobId
            });

            // Add response to the result
            result.Add(response);

            // If there is a next token in the result, we need to check the data again
            string nextToken = response.NextToken;

            while (nextToken != null)
            {
                this.Wait();
                response = await this.amazonTextract.GetDocumentTextDetectionAsync(new GetDocumentTextDetectionRequest
                {
                    JobId     = jobId,
                    NextToken = response.NextToken
                });

                // Add next result to the response
                result.Add(response);

                // If there is a next token in the result, we need to check the data again
                nextToken = response.NextToken;
            }

            return(result);
        }
コード例 #2
0
        public async Task <bool> IsJobComplete(string jobId)
        {
            GetDocumentTextDetectionResponse response = await this.amazonTextract.GetDocumentTextDetectionAsync(new GetDocumentTextDetectionRequest
            {
                JobId = jobId
            });

            return(!response.JobStatus.Equals("IN_PROGRESS"));
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetDocumentTextDetectionResponse response = new GetDocumentTextDetectionResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Blocks", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Block, BlockUnmarshaller>(BlockUnmarshaller.Instance);
                    response.Blocks = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("DetectDocumentTextModelVersion", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.DetectDocumentTextModelVersion = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("DocumentMetadata", targetDepth))
                {
                    var unmarshaller = DocumentMetadataUnmarshaller.Instance;
                    response.DocumentMetadata = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("JobStatus", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.JobStatus = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("StatusMessage", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.StatusMessage = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Warnings", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Warning, WarningUnmarshaller>(WarningUnmarshaller.Instance);
                    response.Warnings = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }