private void buttonOpenDoors_Click(object sender, EventArgs e) { Program.logEvent("Admin is opening all doors from " + Startbox + " to " + Endbox); BlankForm blank = new BlankForm(); blank.Visible = true; for (int i = Startbox; i <= Endbox; i++) { Program.ShowErrorMessage(LanguageTranslation.OPENING_BOX + i, DoorDelay); if (i < Program.passwordMgr.AllBoxLocations.Length) { Program.pm.OpenAndCloseRelay(i); Program.logEvent("Box# " + i.ToString() + " Opened"); } } Program.locationdata.makeHTTPPost(HTTPPostType.KeyLoaded, "", "", ""); blank.Close(); Program.logEvent("All doors open process complete"); }
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 } }