public DigitalPersonaBiometricsForm(string Savefile, DPBiometricsState scanprocess, string userid, int timeout, BiometricDataManager biodatamanager) { InitializeComponent(); buttonScan.Text = LanguageTranslation.SCAN; buttonCancel.Text = LanguageTranslation.CANCEL; SaveFileName = Savefile; Cancelled = false; Success = false; UserID = userid; Timeout = timeout; BioDataManager = biodatamanager; IdentificationIDs = new List <string>(); AvailableReaders = ReaderCollection.GetReaders(); ScanProcess = scanprocess; if (AvailableReaders.Count > 0) { Reader = AvailableReaders[0]; } else { throw new Exception("No Biometric Readers\r\nAvailable"); } SetLabelText(labelMessage, LanguageTranslation.SCAN_FINGERPRINT + ScanProcess.ToString()); }
static void Main() { WINDOW_BACKGROUND_COLOR = "255,255,255"; //must be set temporarily so that loading form can be initialized WindowBackRed = 255; WindowBackGreen = 255; WindowBackBlue = 255; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorForm loading = ShowMessage(""); if (!Directory.Exists("Logs")) { Directory.CreateDirectory("Logs"); } if (!Directory.Exists("Transactions")) { Directory.CreateDirectory("Transactions"); } #region Program Initialization try { #region Config file values loading.SetLabelText("Loading Config\r\nFile Values..."); xml = new XmlConfig.XmlConfigDoc(CONFIGURATION_FILE_NAME); root = xml.GetNode("root"); globals = root.GetNode("globals"); portnode = root.GetNode("ports"); idscannode = root.GetNode("idscan"); emailnode = root.GetNode("email"); textnode = root.GetNode("textmsg"); rfidnode = root.GetNode("rfid"); sqlitenode = root.GetNode("sqlite"); biometricnode = root.GetNode("biometric"); usersnode = root.GetNode("users"); configadminpasswords = root.GetNode("configurableadminpasswords"); //globals KD_DEBUG = GetBoolValue("UseDebugLog", globals); DEV_STATION_SETUP = GetBoolValue("DevSetup", globals); PROGRAM_VERSION = GetStringValue("Version", globals); KIOSK_ID = GetStringValue("KioskID", globals); KIOSK_LOCATION = GetStringValue("KioskLocation", globals); EXIT_CODE = GetStringValue("ExitCode", globals); RELAY_CONTROL_BOARD_TYPE = GetStringValue("RelayControlBoardType", globals); MAINSCREEN_TITLE1 = GetStringValue("MainscreenTitle1", globals); MAINSCREEN_TITLE2 = GetStringValue("MainscreenTitle2", globals); WINDOW_BACKGROUND_COLOR = GetStringValue("WindowBackColor", globals); SERVICE_MANAGER_NUMBER = GetStringValue("serviceManagerPhone", globals); REMINDER_INTERVAL = GetIntValue("reminderTimer", globals); TIMEOUT_INTERVAL = GetIntValue("timeOutInterval", globals); GLOBAL_ACCESS_TYPE = (GlobalAccessType)GetIntValue("globalAccessType", globals); PASSWORD_SIZE = GetIntValue("passWordSize", globals); NUMBER_CREDIT_CARD_DIGITS = GetIntValue("cardNumberSize", globals); VEHICLE_NUMBER_LENGTH = GetIntValue("vehicleNumLength", globals); GENERIC_DATA_FIELD_LENGTH = GetIntValue("genericDataFieldLength", globals); MILEAGE_DIFFERENCE_ALLOWED = GetIntValue("mileageDifferenceAllowed", globals); NUMBER_RELAYS = GetIntValue("numberOfRelays", globals); RESERVATION_DATABASE_CONNECTION_STRING = GetStringValue("ReservationDatabaseConnection", globals); CUSTOMER_DATA_SERVER = GetStringValue("customerdataserver", globals); OPEN_DOOR_INTERVAL = GetIntValue("openDoorInterval", globals); //Window Background Color WindowBackRed = int.Parse(WINDOW_BACKGROUND_COLOR.Split(',')[0]); WindowBackGreen = int.Parse(WINDOW_BACKGROUND_COLOR.Split(',')[1]); WindowBackBlue = int.Parse(WINDOW_BACKGROUND_COLOR.Split(',')[2]); //ports string tempPort = GetStringValue("RCB_port", portnode); RCB_PORT = ValidPortName(tempPort); RFID_PORT = GetStringValue("RFID_port", portnode); //configurable admin passwords CONFIG_ADMIN_PWORD_1 = GetStringValue("adminpassword1", configadminpasswords); CONFIG_ADMIN_PWORD_2 = GetStringValue("adminpassword2", configadminpasswords); CONFIG_ADMIN_PWORD_3 = GetStringValue("adminpassword3", configadminpasswords); //idscan IMAGE_SCAN_RESOLUTION = GetIntValue("imagescanresolution", idscannode); IMAGE_SCAN_TYPE = GetStringValue("imagescantype", idscannode); //Text Msg ENABLE_TEXTMSG = GetBoolValue("textEnable", textnode); TEXTTO_ADDRESS = GetStringValue("textToAddress", textnode); //Email SMTP_SERVER = GetStringValue("smtpServer", emailnode); SMTP_USERNAME = GetStringValue("smtpUsername", emailnode); SMTP_PASSWORD = GetStringValue("smtpPassword", emailnode); SMTP_AUTHENTICATION = GetBoolValue("smtpAuthentication", emailnode); FROM_ADDRESS = GetStringValue("emailFromAddress", emailnode); TO_ADDRESS = GetStringValue("emailToAddress", emailnode); ENABLE_EMAIL = GetBoolValue("emailEnable", emailnode); //RFID ENABLE_RFID = GetBoolValue("RFID_Enable", rfidnode); RFID_READER_TYPE = GetStringValue("RFID_Reader", rfidnode); RFID_READ_ON_TIME = GetIntValue("RFID_ReadOnTime", rfidnode); RFID_READ_OFF_TIME = GetIntValue("RFID_ReadOffTime", rfidnode); RFID_TOTAL_READ_TIME = GetIntValue("RFID_TotalReadTime", rfidnode); RFID_READ_POWER = GetIntValue("RFID_ReadPower", rfidnode); RFID_INVENTORY_READ_TIME = GetIntValue("RFID_InventoryTime", rfidnode); IMPINJ_ANTENNA1_ENABLE = GetBoolValue("ImpinjAntenna1Enable", rfidnode); IMPINJ_ANTENNA1_POWER = GetIntValue("ImpinjAntenna1Power", rfidnode); IMPINJ_ANTENNA2_ENABLE = GetBoolValue("ImpinjAntenna2Enable", rfidnode); IMPINJ_ANTENNA2_POWER = GetIntValue("ImpinjAntenna2Power", rfidnode); IMPINJ_ANTENNA3_ENABLE = GetBoolValue("ImpinjAntenna3Enable", rfidnode); IMPINJ_ANTENNA3_POWER = GetIntValue("ImpinjAntenna3Power", rfidnode); IMPINJ_ANTENNA4_ENABLE = GetBoolValue("ImpinjAntenna4Enable", rfidnode); IMPINJ_ANTENNA4_POWER = GetIntValue("ImpinjAntenna4Power", rfidnode); //SQLite ENABLE_SQLITE = GetBoolValue("EnableSQLiteDatabase", sqlitenode); SQLITE_DATABASE_NAME = GetStringValue("SQLiteDatabaseName", sqlitenode); SQLITE_MAX_RECORDS = GetIntValue("MaxSQLiteRecords", sqlitenode); //Biometrics BIOMETRIC_ENABLE = GetBoolValue("BiometricEnable", biometricnode); BIOMETRIC_TIMEOUT = GetIntValue("BiometricTimeout", biometricnode); BIOMETRIC_FALSE_POSITIVE_RATIO = GetIntValue("BiometricFalsePositiveRatio", biometricnode); //Users USERS_ENABLE = GetBoolValue("Users_Enable", usersnode); USERS_ACCESS_RESTRICTIONS_OVERRIDE = GetBoolValue("Users_Access_Restrictions_Override", usersnode); USER_ID_LENGTH = GetIntValue("UsersIDLength", usersnode); #endregion #region Software Initialization if (NUMBER_RELAYS > 20) { SIXTY_KEY_DISPENSER = true; } loading.SetLabelText("Loading key data"); // read in the key location and password file passwordMgr = new KeyPasswordManager(PASSWORD_FILE_NAME); loading.SetLabelText("Loading email\r\nmanager"); //create the email manager emailMgr = new EmailerManager(SMTP_SERVER, FROM_ADDRESS, TO_ADDRESS, TEXTTO_ADDRESS); //create the user manager if (USERS_ENABLE) { loading.SetLabelText("Loading user data"); userMgr = new UserManager("Users.xml"); } //create the SQLcommandClass SqlManager = new SQLManager(); #endregion #region Hardware Initialization //create Biometric Reader connection if (BIOMETRIC_ENABLE) { loading.SetLabelText("Loading biometric\r\ndata"); biometricMgr = new BiometricDataManager("Fingerprints.xml"); } } catch (Exception e) { string message = LanguageTranslation.CONFIGURATION_FILE_ERROR + "\r\n" + e.Message; MessageBox.Show(message); Program.logError(message); //try to log error Program.programExit(); //exit program - unreliable program due to unknown configuration problem } try { //create RFID reader connection if (ENABLE_RFID) { if (RFID_READER_TYPE.ToUpper() == "IMPINJ") { loading.SetLabelText("Impinj Reader\r\nConnecting"); ImpinjRFIDreader = new ImpinjSpeedwayRFID(RFID_PORT); } else { loading.SetLabelText("M6e Micro Reader\r\nConnecting"); ThingMagicRFIDreader = new M6eMicroRFID(RFID_PORT, 115200, RFID_READ_ON_TIME, RFID_READ_OFF_TIME, RFID_READ_POWER, RFID_TOTAL_READ_TIME); } } } catch (Exception ex) { string message = LanguageTranslation.CONFIGURATION_RFID_ERROR_1 + "\r\n " + ex.Message + "\r\n" + LanguageTranslation.CONFIGURATION_RFID_ERROR_2; DialogResult result = MessageBox.Show(message, "RFID Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); Program.logError(message); //try to log error //if (result == DialogResult.No) //This ability to exit the program was removed 2/2/15 due to my concerns that if the impinj readers did not connect for some //{ //reason during a daily morning reboot, a user could exit the program, access the box opening software and steal keys. // Program.programExit(); //} } #endregion #endregion #region port initialization try { loading.SetLabelText("Initializing Serial\r\nPorts"); pm = PortManager.GetInstance(); pm.InitializePorts(RCB_PORT); } catch (Exception e) { string message = LanguageTranslation.CONFIGURATION_OPEN_PORT_ERROR + "\r\n" + e.Message; MessageBox.Show(message); Program.logError(message); //try to log error Program.programExit(); //exit program - unreliable program due to unknown configuration problem } #endregion try { //Set REMINDER_INTERVAL to 0 if there is no need for reminders. if (REMINDER_INTERVAL > 0) { loading.SetLabelText("Initializing Reminders"); System.Timers.Timer ReminderTimer = new System.Timers.Timer(REMINDER_INTERVAL); ReminderTimer.Elapsed += new System.Timers.ElapsedEventHandler(ReminderTimer_Elapsed); ReminderTimer.Start(); } loading.SetLabelText("Initializing Customer\r\nConfiguration"); if (KIOSK_LOCATION.ToUpper() == "ONTARIO") { locationdata = new OntarioLocationData(); } else if (KIOSK_LOCATION.ToUpper() == "NEBRASKA") { NebResMgr = new NebraskaReservationManager("NebraskaReservations.xml"); locationdata = new NebraskaLocationData(); InitIDScanner = new SnapShell_Driver_Lic.Snapshell(); } else if (KIOSK_LOCATION.ToUpper() == "OSU") { locationdata = new OregonStateULocationData(); } else if (KIOSK_LOCATION.ToUpper() == "MONTANA") { locationdata = new MontanaLocationData(); } else if (KIOSK_LOCATION.ToUpper() == "WAWATER") { locationdata = new WAWaterLocationData(); } else if (KIOSK_LOCATION.ToUpper() == "HUDSON") { locationdata = new HudsonLocationData(); } else if (KIOSK_LOCATION.ToUpper() == "DAIMLER") { locationdata = new DaimlerChinaLocationData(); LanguageTranslation.language = language.Chinese; } else if (Program.KIOSK_LOCATION.ToUpper() == "CHEVIN") //if ChevinLocationData is used WaWaterTransactionData will be used with it { locationdata = new ChevinLocationData(); } else { locationdata = new DefaultLocationData(); } main = new MainForm(); logEvent("Version: " + PROGRAM_VERSION); DeleteOldLogs(); loading.Dispose(); blank = new BlankForm(); Program.blank.Visible = false; Program.blank.SendToBack(); Program.logEvent("Program Started"); Application.Run(main); } catch (Exception e) { string message = LanguageTranslation.CONFIGURATION_APP_ERROR + "\r\n " + e.Message; MessageBox.Show(message); Program.logError(message); //try to log error Program.programExit(); //exit program - unreliable program due to unknown configuration problem } }
public bool EnrollFingerprints(string Userid, int Timeout, BiometricDataManager BioDataManager) { List <Fmd> PreenrollmentFmds = new List <Fmd>(); if (Reader.Open(Constants.CapturePriority.DP_PRIORITY_EXCLUSIVE) != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Failed\r\nto Open for\r\nEnrollment"); } GetStatus(); DataResult <Fmd> resultEnrollment; int enrollmentcount = 0; SetLabelText(labelMessage, LanguageTranslation.NEW_SCAN_FINGERPRINT); do { CaptureResult Result = Reader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, Timeout, Reader.Capabilities.Resolutions.First <int>()); if (!CheckCaptureResult(Result)) { Reader.Dispose(); return(false); } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(Result.Data, Constants.Formats.Fmd.ANSI); PreenrollmentFmds.Add(resultConversion.Data); resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, PreenrollmentFmds); enrollmentcount++; SetLabelText(labelMessage, LanguageTranslation.AGAIN_SCAN_FINGERPRINT + enrollmentcount); } while ((resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_NOT_READY) && (enrollmentcount <= 6)); if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET) { Reader.Dispose(); throw new Exception("Enrollment was unsuccessful.\r\nPlease try again."); } else if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_NOT_READY) { Reader.Dispose(); throw new Exception("Enrollment did not have\r\nsufficiently good scans."); } List <string> Prints = BioDataManager.FindIDByFingerprint(resultEnrollment.Data); if (Prints.Count > 0) { YesNoForm clearprints = new YesNoForm(LanguageTranslation.CLEAR_FINGERPRINT_QUESTION); clearprints.ShowDialog(); if (clearprints.YesResult) { foreach (string s in Prints) { BioDataManager.ClearFingerprint(s); } Program.ShowErrorMessage(LanguageTranslation.OLD_PRINTS_CLEARED, 3000); } } SetLabelText(labelMessage, LanguageTranslation.SAVING_FINGERPRINTS); BioDataManager.AddFingerprint(Userid, resultEnrollment.Data); BioDataManager.SaveFile(); PreenrollmentFmds.Clear(); Reader.Dispose(); Thread.Sleep(2000); return(true); }
/// <summary> /// /// </summary> /// <param name="Timeout"></param> /// <param name="biometricDataList">BiometricDataManager.Biometrics.biometricDataList</param> /// <returns>Number of matches. Returns -1 or throws an exception if there's an error</returns> public int IdentifyFingerprint(int Timeout, BiometricDataManager BioDataManager) { if (Reader.Open(Constants.CapturePriority.DP_PRIORITY_EXCLUSIVE) != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Failed\r\nto Open for Identification"); } try { GetStatus(); SetLabelText(labelMessage, LanguageTranslation.PLACE_ENROLLED_FINGER); CaptureResult Result = Reader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, Timeout, Reader.Capabilities.Resolutions.First <int>()); if (!CheckCaptureResult(Result)) { Reader.Dispose(); return(-1); } else if (Result.Quality == Constants.CaptureQuality.DP_QUALITY_TIMED_OUT) { Reader.Dispose(); return(-2); } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(Result.Data, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner \r\nIdentify ResultConversion Error:\r\n" + resultConversion.ResultCode.ToString()); } int NumberofMatches = 0; IdentifyResult identifyResult; foreach (BiometricData bd in BioDataManager.Biometrics.biometricDataList) { if (bd.FMDs.Count <= 0) //if there are no fingerprints for the current user. { continue; } identifyResult = Comparison.Identify(resultConversion.Data, 0, bd.FMDs, PROBABILITY_ONE / Program.BIOMETRIC_FALSE_POSITIVE_RATIO, 1000); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner\r\nIdentify ResultCode Error:\r\n" + identifyResult.ResultCode.ToString()); } NumberofMatches += identifyResult.Indexes.Length; if (identifyResult.Indexes.Length > 0) { IdentificationIDs.Add(bd.ID); } } Program.logEvent("Identification resulted in " + NumberofMatches + " matches"); Reader.Dispose(); return(NumberofMatches); } catch (Exception ex) { throw ex; } finally { if (Reader != null) { Reader.Dispose(); } } }
/// <summary> /// /// </summary> /// <param name="Userid"></param> /// <param name="Timeout"></param> /// <returns>Returns dissimilarity score. Higher numbers are less of a match. 0 is a perfect match. -1 is an error</returns> public int VerifyFingerprint(string Userid, int Timeout, BiometricDataManager BioDataManager) { if (Reader.Open(Constants.CapturePriority.DP_PRIORITY_EXCLUSIVE) != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Failed\r\nto Open for Verification"); } try { GetStatus(); SetLabelText(labelMessage, LanguageTranslation.SCAN_ENROLLED_FINGERPRINT); CaptureResult Result = Reader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, Timeout, Reader.Capabilities.Resolutions.First <int>()); if (!CheckCaptureResult(Result)) { Reader.Dispose(); return(-1); } else if (Result.Quality == Constants.CaptureQuality.DP_QUALITY_TIMED_OUT) { Reader.Dispose(); return(-2); } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(Result.Data, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Verify\r\nResultConversion Error: " + resultConversion.ResultCode.ToString()); } CompareResult compareResult; foreach (Fmd data in BioDataManager.FindFingerprint(Userid)) { compareResult = Comparison.Compare(resultConversion.Data, 0, data, 0); if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Verify\r\nResultCode Error: " + compareResult.ResultCode.ToString()); } //Analyze the score of the fingerprint to see if it is good enough to call a match if (AnalyzeFingerprintVerificationScore(compareResult.Score, Program.BIOMETRIC_FALSE_POSITIVE_RATIO)) { Reader.Dispose(); return(0); } } Reader.Dispose(); return(-3); } catch (Exception ex) { throw ex; } finally { if (Reader != null) { Reader.Dispose(); } } }