public void DisplayResults(DocumentReaderResults results) { if (results != null) { var name = results.GetTextFieldValueByType(EVisualFieldType.FtSurnameAndGivenNames); if (!String.IsNullOrEmpty(name)) { nameTv.Text = 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); Log.Debug("MainActivity", value + "\n"); } } var portrait = results.GetGraphicFieldImageByType(EGraphicFieldType.GfPortrait); if (portrait != null) { portraitIv.SetImageBitmap(portrait); } var documentImage = results.GetGraphicFieldImageByType(EGraphicFieldType.GtDocumentFront); if (documentImage != null) { docImageIv.SetImageBitmap(documentImage); } } }
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); }
public void OnCompleted(int action, DocumentReaderResults results, DocumentReaderException error) { if (action == DocReaderAction.Complete) { if (loadingDialog != null && loadingDialog.IsShowing) { loadingDialog.Dismiss(); } //Checking, if nfc chip reading should be performed if (!isStartRfid && doRfid && results != null && results.ChipPage != 0) { //setting the chip's access key - mrz on car access number string accessKey = null; if ((accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStringsIcaoRfid)) != null && !String.IsNullOrEmpty(accessKey)) { accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStringsIcaoRfid).Replace("^", "").Replace("\n", ""); DocumentReader.Instance().RfidScenario().Mrz = accessKey; DocumentReader.Instance().RfidScenario().PacePasswordType = ERFID_Password_Type.PptMrz; } else if ((accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStrings)) != null && !String.IsNullOrEmpty(accessKey)) { accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtMrzStrings).Replace("^", "").Replace("\n", ""); DocumentReader.Instance().RfidScenario().Mrz = accessKey; DocumentReader.Instance().RfidScenario().PacePasswordType = ERFID_Password_Type.PptMrz; } else if ((accessKey = results.GetTextFieldValueByType(EVisualFieldType.FtCardAccessNumber)) != null && !String.IsNullOrEmpty(accessKey)) { DocumentReader.Instance().RfidScenario().Password = accessKey; DocumentReader.Instance().RfidScenario().PacePasswordType = ERFID_Password_Type.PptCan; } //starting chip reading DocumentReader.Instance().StartRFIDReader(this, this); isStartRfid = true; } else { DisplayResults(results); isStartRfid = false; } } else { //something happened before all results were ready if (action == DocReaderAction.Cancel) { Toast.MakeText(this, "Scanning was cancelled", ToastLength.Long).Show(); isStartRfid = false; } else if (action == DocReaderAction.Error) { Toast.MakeText(this, "Error:" + error, ToastLength.Long).Show(); isStartRfid = false; } } }