public override bool Parse() { try { var l1 = Mrz.Substring(0, 44); var l2 = Mrz.Substring(44); array = new string[] { l1, l2 }; AddComponent(MrzComponentCode.DocumentCode, l1.Substring(0, 2)); AddComponent(MrzComponentCode.IssuingState, l1.Substring(2, 3)); AddComponent(MrzComponentCode.Name, l1.Substring(5, 39)); AddComponent(MrzComponentCode.DocumentNumber, l2.Substring(0, 9)); AddComponent(MrzComponentCode.DocumentNumberCheckDigit, l2.Substring(9, 1)); AddComponent(MrzComponentCode.Nationality, l2.Substring(10, 3)); AddComponent(MrzComponentCode.DateOfBirth, l2.Substring(13, 6)); AddComponent(MrzComponentCode.DateOfBirthCheckDigit, l2.Substring(19, 1)); AddComponent(MrzComponentCode.Sex, l2.Substring(20, 1)); AddComponent(MrzComponentCode.DateOfExpiry, l2.Substring(21, 6)); AddComponent(MrzComponentCode.DateOfExpiryCheckDigit, l2.Substring(27, 1)); AddComponent(MrzComponentCode.OptionalData, l2.Substring(28, 14)); AddComponent(MrzComponentCode.OptionalDataCheckDigit, l2.Substring(42, 1)); AddComponent(MrzComponentCode.CompositeCheckDigit, l2.Substring(43, 1)); } catch (Exception ex) { var debugException = ex; return(false); } return(true); }
public override bool Parse() { try { var l1 = Mrz.Substring(0, 30); var l2 = Mrz.Substring(30, 30); var l3 = Mrz.Substring(60); array = new string[] { l1, l2, l3 }; AddComponent(MrzComponentCode.DocumentCode, l1.Substring(0, 2)); AddComponent(MrzComponentCode.IssuingState, l1.Substring(2, 3)); AddComponent(MrzComponentCode.DocumentNumber, l1.Substring(5, 9)); AddComponent(MrzComponentCode.DocumentNumberCheckDigit, l1.Substring(14, 1)); AddComponent(MrzComponentCode.DateOfBirth, l2.Substring(0, 6)); AddComponent(MrzComponentCode.DateOfBirthCheckDigit, l2.Substring(6, 1)); AddComponent(MrzComponentCode.Sex, l2.Substring(7, 1)); AddComponent(MrzComponentCode.DateOfExpiry, l2.Substring(8, 6)); AddComponent(MrzComponentCode.DateOfExpiryCheckDigit, l2.Substring(14, 1)); AddComponent(MrzComponentCode.Nationality, l2.Substring(15, 3)); AddComponent(MrzComponentCode.Name, l3); } catch (Exception ex) { var debugException = ex; return(false); } return(true); }
public override bool Parse() { try { var l1 = Mrz.Substring(0, 36); var l2 = Mrz.Substring(36); array = new string[] { l1, l2 }; } catch (Exception ex) { var debugException = ex; return(false); } // TODO: parsing is not complete. return(false); }
public async override Task RaiseMrzDetected(object sender, MrzRecognizedEventArgs e) { try { var lines = e.MrzCode.Split(new[] { Environment.NewLine, @"\\n", @"\n" }, StringSplitOptions.None); if (lines.Length != 2 || lines[0].Length != 42 || lines[1].Length != 44) { return; } var fio = lines[0].Remove(0, 5).Split(new[] { "<" }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (fio.Count < 2) { fio.Add(" "); } var firstNameOld = fio[0].Replace(e.SurNames, ""); var lastNameOld = e.SurNames; var patronymicOld = fio[1]; var givenNames = e.GivenNames.Split(' '); var firstName = string.Join(" ", givenNames.Take(givenNames.Length - 1)); var lastName = e.SurNames; var patronymic = givenNames.Last(); var mrzParsed = new Mrz(lastName, firstName, patronymic, lines[1]); foreach (var @event in OnMrzDetectedAsync?.GetInvocationList()) { await(@event as Func <object, MrzProcessedEventArgs, Task>)?.Invoke(sender, new MrzProcessedEventArgs(mrzParsed)); } } catch (Exception ex) { if (ex is FormatException) { return; } await DisplayAlert("Внимание", ex.ToString(), "Окей"); } }
public MrzProcessedEventArgs(Mrz result) { Result = result; }