Beispiel #1
0
        public async Task <OcrResult <OcrProcessDocumentResponse> > ProcessDocument(OcrRequest request)
        {
            string         url         = _url + _processDocumentMethod + "?" + zurl.BuildQuery(GetQueryValues(request));
            HttpRequest_v5 httpRequest = new HttpRequest_v5 {
                Url = url, Method = HttpRequestMethod.Post, Content = new FileContent(request.DocumentFile)
                {
                    ContentType = _contentType
                }
            };
            HttpResult_v5 <string> httpResult = await _httpManager.LoadText(httpRequest);

            OcrResult <OcrProcessDocumentResponse> result = new OcrResult <OcrProcessDocumentResponse> {
                Success = httpResult.Success, StatusCode = httpResult.StatusCode
            };

            if (httpResult.Success)
            {
                result.Data = BsonSerializer.Deserialize <OcrProcessDocumentResponse>(httpResult.Data);
            }
            return(result);
        }
Beispiel #2
0
 private IEnumerable <KeyValuePair <string, string> > GetQueryValues(OcrRequest request)
 {
     if (request.Language != null)
     {
         yield return(new KeyValuePair <string, string>("language", request.Language));
     }
     if (request.OutputFormat != null)
     {
         yield return(new KeyValuePair <string, string>("outputformat", request.OutputFormat));
     }
     if (request.GetText)
     {
         yield return(new KeyValuePair <string, string>("gettext", "true"));
     }
     if (request.GetWords)
     {
         yield return(new KeyValuePair <string, string>("getwords", "true"));
     }
     if (request.BlackAndWhite)
     {
         yield return(new KeyValuePair <string, string>("tobw", "true"));
     }
     if (request.NewLine)
     {
         yield return(new KeyValuePair <string, string>("newline", "true"));
     }
     if (request.PageRange != null)
     {
         yield return(new KeyValuePair <string, string>("pagerange", request.PageRange));
     }
     if (request.Zone != null)
     {
         yield return(new KeyValuePair <string, string>("zone", request.Zone));
     }
     if (request.Description != null)
     {
         yield return(new KeyValuePair <string, string>("description", request.Description));
     }
 }