Example #1
0
        // Gets the result of a PDF analysis request.
        private async Task <GetDocumentAnalysisResponse> GetDocAnalysisResponse(StartDocumentAnalysisResponse response)
        {
            // Get jobID from start analysis response
            var x = new GetDocumentAnalysisRequest();

            x.JobId = response.JobId;

            // Poll for analysis to finish. Can take over 15sec. to
            // get results, thus the somewhat long delay.
            GetDocumentAnalysisResponse res = await this.textractClient.GetDocumentAnalysisAsync(x);

            int c = 0;

            while (res.JobStatus != "SUCCEEDED")
            {
                await Task.Delay(200);

                res = await this.textractClient.GetDocumentAnalysisAsync(x);

                c++;
                System.Diagnostics.Debug.WriteLine("Trying again.... " + res.JobStatus + " Attempt " + c);
            }

            return(res);
        }
Example #2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            StartDocumentAnalysisResponse response = new StartDocumentAnalysisResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("JobId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.JobId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }