////////////////////////////////////////////////////////////////////////////////// // // Define callback functions // ////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // Function name : MRZCallback // Description : This functions is registered as a callback. It is run by the // videoOCR dll when MRZ data is available. // // : // Return type : void // Argument : ref UInt32 - paramter registered by user. // : DLL_MRZDATA - MRZ data from the DLL //////////////////////////////////////////////////////////////////////// private void MRZCallback(ref UInt32 Parameter, ref DLL_MRZDATA Data) { // Make sure the text box update is running in the same thread as the form ; frontend.textBoxMRZ.Invoke(new updateMrzTextBox(updateTextBox), Data.RawMRZ); // sdocumentno = "A11111111"; sdocumentno = Data.DocumentNumber.Trim(); sfname = Data.FirstNames.Trim(); slname = Data.LastNames.Trim(); snationality = Data.Nationality.Trim(); sgender = Data.Gender.Trim(); sDOB = Data.DOB.Trim(); sexpiry = Data.Expiry.Trim(); sissueer = Data.Issuer.Trim(); stype = Data.Type.Trim(); nationalIDNo = Data.Discretionary1.Trim(); if (Data.RawMRZ != string.Empty) { frontend.passportNoTextBox.Invoke(new UpdatePassportNoTextBox(updateTextBoxPassportNo), Data.DocumentNumber); frontend.firstNameTextBox.Invoke(new UpdateFirstNameTextBox(updateTextBoxFirstName), Data.FirstNames); frontend.lastNameTextBox.Invoke(new UpdateLastNameTextBox(updateTextBoxLastName), Data.LastNames); string fullname = sfname + slname; if (Regex.IsMatch(fullname, @"^[a-xA-Z ]*$")) { firstName = sfname; lastName = slname; } else { frontend.firstNameTextBox.BackColor = Color.Red; frontend.lastNameTextBox.BackColor = Color.Red; firstName = string.Empty; lastName = string.Empty; } if (sdocumentno != string.Empty) { string ppSubFirst = sdocumentno.Substring(0, 2); string ppSubLast = sdocumentno.Substring(2, (sdocumentno.Length - 2)); if (Regex.IsMatch(ppSubFirst, @"^[A-Z]*$") && Regex.IsMatch(ppSubLast, @"^[0-9]*$")) { newPassportNo = sdocumentno; string folder = @"Storage\"; // Directory.CreateDirectory(dstLoc + folder); System.IO.File.WriteAllText(dstLoc + folder + @"Data.csv", newPassportNo + "," + firstName + "," + lastName + "," + snationality + "," + sgender + "," + sDOB + "," + sexpiry + "," + sissueer + "," + stype + "," + nationalIDNo + "\r\n"); } else { frontend.passportNoTextBox.BackColor = Color.Red; newPassportNo = string.Empty; } } } }
////////////////////////////////////////////////////////////////////////////////// // // Define callback functions // ////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // Function name : MRZCallback // Description : This functions is registered as a callback. It is run by the // videoOCR dll when MRZ data is available. // // : // Return type : void // Argument : ref UInt32 - paramter registered by user. // : DLL_MRZDATA - MRZ data from the DLL //////////////////////////////////////////////////////////////////////// private void MRZCallback(ref UInt32 Parameter, ref DLL_MRZDATA Data) { // Make sure the text box update is running in the same thread as the form ; frontend.textBoxMRZ.Invoke(new updateMrzTextBox(updateTextBox), Data.RawMRZ); // sdocumentno = "A11111111"; sdocumentno = Data.DocumentNumber.Trim(); sfname = Data.FirstNames.Trim(); slname = Data.LastNames.Trim(); snationality = Data.Nationality.Trim(); sgender = Data.Gender.Trim(); sDOB = Data.DOB.Trim(); sexpiry = Data.Expiry.Trim(); sissueer = Data.Issuer.Trim(); stype = Data.Type.Trim(); nationalIDNo = Data.Discretionary1.Trim(); if (Data.RawMRZ!=string.Empty) { frontend.passportNoTextBox.Invoke(new UpdatePassportNoTextBox(updateTextBoxPassportNo), Data.DocumentNumber); frontend.firstNameTextBox.Invoke(new UpdateFirstNameTextBox(updateTextBoxFirstName), Data.FirstNames); frontend.lastNameTextBox.Invoke(new UpdateLastNameTextBox(updateTextBoxLastName), Data.LastNames); string fullname = sfname + slname; if (Regex.IsMatch(fullname, @"^[a-xA-Z ]*$")) { firstName = sfname; lastName = slname; } else { frontend.firstNameTextBox.BackColor = Color.Red; frontend.lastNameTextBox.BackColor = Color.Red; firstName = string.Empty; lastName = string.Empty; } if (sdocumentno!=string.Empty) { string ppSubFirst = sdocumentno.Substring(0, 2); string ppSubLast = sdocumentno.Substring(2, (sdocumentno.Length - 2)); if (Regex.IsMatch(ppSubFirst, @"^[A-Z]*$") && Regex.IsMatch(ppSubLast, @"^[0-9]*$")) { newPassportNo = sdocumentno; string folder = @"Storage\"; // Directory.CreateDirectory(dstLoc + folder); System.IO.File.WriteAllText(dstLoc + folder + @"Data.csv", newPassportNo + "," + firstName + "," + lastName + "," + snationality + "," + sgender + "," + sDOB + "," + sexpiry + "," + sissueer + "," + stype + "," + nationalIDNo + "\r\n"); } else { frontend.passportNoTextBox.BackColor = Color.Red; newPassportNo = string.Empty; } } } }