private void OnResultsObtained(RGLDocReaderAction action, RGLDocumentReaderResults result, NSError error)
        {
            DocReaderScannerEvent readerScannerEvent = null;

            if (action == RGLDocReaderAction.Complete)
            {
                if (result == null)
                {
                    readerScannerEvent = new DocReaderScannerEvent()
                    {
                        IsSuccess = false, Error = "Document Reader results is empty"
                    };
                }
                else
                {
                    if (IsReadRfid)
                    {
                        ReadRfid();
                    }
                    else
                    {
                        readerScannerEvent = GenerateDocReaderScannerEvent(result);
                    }
                }
            }

            if (readerScannerEvent != null)
            {
                ResultsObtained(this, readerScannerEvent);
            }
        }
예제 #2
0
        private DocReaderScannerEvent GenerateDocReaderScannerEvent(DocumentReaderResults results)
        {
            DocReaderScannerEvent readerScannerEvent = new DocReaderScannerEvent()
            {
                IsSuccess = true
            };
            var name = results.GetTextFieldValueByType(EVisualFieldType.FtSurnameAndGivenNames);

            if (!System.String.IsNullOrEmpty(name))
            {
                readerScannerEvent.SurnameAndGivenNames = name;
            }

            // through all text fields
            if (results.TextResult != null && results.TextResult.Fields != null)
            {
                foreach (DocumentReaderTextField textField in results.TextResult.Fields)
                {
                    var value = results.GetTextFieldValueByType(textField.FieldType, textField.Lcid);
                    Console.WriteLine(value);
                }
            }

            using var portraitImage          = results.GetGraphicFieldImageByType(EGraphicFieldType.GfPortrait);
            readerScannerEvent.PortraitField = ConvertBitmap(portraitImage);

            using var documentImage          = results.GetGraphicFieldImageByType(EGraphicFieldType.GfDocumentImage);
            readerScannerEvent.DocumentField = ConvertBitmap(documentImage);

            return(readerScannerEvent);
        }
예제 #3
0
        public void OnCompleted([IntDef(Type = "Com.Regula.Documentreader.Api.Enums.DocReaderAction", Fields = new[] { "Complete", "Process", "Cancel", "Error", "Notification", "ProcessWhiteUvImages", "MorePagesAvailable" })] int action, DocumentReaderResults results, DocumentReaderException error)
        {
            DocReaderScannerEvent readerScannerEvent = null;

            if (action == DocReaderAction.Complete)
            {
                if (results == null)
                {
                    readerScannerEvent = new DocReaderScannerEvent()
                    {
                        IsSuccess = false, Error = "Document Reader results is empty"
                    };
                }
                else
                {
                    if (IsReadRfid)
                    {
                        ReadRfid();
                    }
                    else
                    {
                        readerScannerEvent = GenerateDocReaderScannerEvent(results);
                    }
                }
            }
            else if (action == DocReaderAction.Error)
            {
                readerScannerEvent = new DocReaderScannerEvent()
                {
                    IsSuccess = false, Error = error.Message
                };
            }
            else if (action == DocReaderAction.Cancel)
            {
                readerScannerEvent = new DocReaderScannerEvent()
                {
                    IsSuccess = false, Error = "Cancelled by user"
                };
            }

            if (readerScannerEvent != null)
            {
                ResultsObtained(this, readerScannerEvent);
            }
        }
        private DocReaderScannerEvent GenerateDocReaderScannerEvent(RGLDocumentReaderResults result)
        {
            DocReaderScannerEvent readerScannerEvent = new DocReaderScannerEvent()
            {
                IsSuccess = true
            };
            var name = result.GetTextFieldValueByType(RGLFieldType.Surname_And_Given_Names);

            if (!System.String.IsNullOrEmpty(name))
            {
                readerScannerEvent.SurnameAndGivenNames = name;
            }

            // through all available text fields
            foreach (var textField in result.TextResult.Fields)
            {
                var value = result.GetTextFieldValueByType(textField.FieldType, textField.Lcid);
                if (value != null)
                {
                    Console.WriteLine("Field type name: {0}, value: {1}", textField.FieldName, value);
                }
            }

            using (var portraitImage = result.GetGraphicFieldImageByType(RGLGraphicFieldType.Portrait))
            {
                if (portraitImage != null)
                {
                    readerScannerEvent.PortraitField = ConvertImage(portraitImage);
                }
            }

            using (var documentImage = result.GetGraphicFieldImageByType(RGLGraphicFieldType.DocumentImage, RGLResultType.RawImage))
            {
                if (documentImage != null)
                {
                    readerScannerEvent.DocumentField = ConvertImage(documentImage);
                }
            }

            return(readerScannerEvent);
        }