Ejemplo n.º 1
0
        private IList <int> FindSplitterPages(BatchResult batch)
        {
            var pages = batch.recognitionResults
                        .Where(r => r.lines.Any(l => l.text.ToUpper().Contains("SEPARATOR") && l.text.ToUpper().Contains("INVOICE")))
                        .Distinct()
                        .Select(r => r.page)
                        .ToList();

            return(pages);
        }
Ejemplo n.º 2
0
        private IList <int> FindBlankPages(BatchResult batch)
        {
            var pages = batch.recognitionResults
                        .Where(r => r.lines.Length == 0)
                        .Distinct()
                        .Select(r => r.page)
                        .ToList();

            return(pages);
        }
Ejemplo n.º 3
0
        private async Task <BatchResult> RetrieveBatchReadResponseAsync(string resourceUrl)
        {
            BatchResult batchResult = null;

            using (var client = new HttpClient()) {
                // Request headers
                client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", COGSVC_API_KEY);

                do
                {
                    Thread.Sleep(TimeSpan.FromSeconds(2));

                    var response = await client.GetStringAsync(resourceUrl);

                    var result = JsonConvert.DeserializeObject <BatchResult>(response);

                    batchResult = result.status == "Succeeded" ? result : null;
                } while (batchResult == null);

                // Return the result
                return(batchResult);
            }
        }