/// <summary> /// cardReaderTask_ScanDataRecieved - if the card has been scanned /// CreditCardReadEventArgs - will have the card name /// if read is bad will start a new scan /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void cardReaderTask_ScanDataRecieved(object sender, CreditCardReadEventArgs e) { base.resetTimer(); Program.logDebug("ScanCardForm - card data read"); keyCabinetCardData data = (keyCabinetCardData)e.CardData; if ((e.GoodRead == false) || (data.isValid() == false)) { GoodData = false; Program.logDebug("ScanCardForm : bad credit card read"); //Program.ShowErrorMessage("Scan error\r\ntry again", 2000); this.label1.Text = LanguageTranslation.CARD_SWIPE_ERROR; this.label2.Visible = true; ScanAttempts++; this.label2.Text = LanguageTranslation.SCAN_ATTEMPTS + ScanAttempts.ToString(); cardRead.StartScan(); // start a new scan } else { GoodData = true; CardName = data.getCardName(); CardNumber = data.getCardNumber(); this.Close(); } }
} //nothing here /// <summary> /// CreditCardControl_cardInserted - event handler for card reader - event have track data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CreditCardControl_cardInserted(object sender, AxotCreditCard.__creditCardControl_cardInsertedEvent e) { try { //stop looking for card insertions //cardscan.stopScan(); string Track1 = e.track1; string Track2 = e.track2; string Track3 = e.track3; CreditCardReadEventArgs args = null; cardData CardData = null; //Test for errors in the card read if ((Track1 == "" && Track2 == "" && Track3 == "") || (Track1 == "Error" || Track2 == "Error" || Track3 == "Error")) { Program.logEvent("Bad Card Read:"); //Program.logEvent(" Track1: " + Track1); uncomment for debug only -do not keep customer info in logs //Program.logEvent(" Track2: " + Track2); //Program.logEvent(" Track3: " + Track3); //send message about bad read and then do a retry from customForm CardData = new keyCabinetCardData("", "", ""); args = new CreditCardReadEventArgs(CardData); args.GoodRead = false; } else { Program.logEvent("Good ID Card Read:"); //Program.logEvent(" Track1: " + Track1); uncomment for debug only -do not keep customer info in logs //Program.logEvent(" Track2: " + Track2); //Program.logEvent(" Track3: " + Track3); ////pull the card number and name out of the card tracks CardData = new keyCabinetCardData(Track1, Track2, Track3); //or substitute for specialized client args = new CreditCardReadEventArgs(CardData); args.GoodRead = true; } ScanDataRecieved.Invoke(this, args); } catch (Exception ex) { Program.logEvent("cardReaderTask - exception - " + ex.Message); CreditCardReadEventArgs args = null; cardData CardData = null; CardData = new keyCabinetCardData("", "", ""); args = new CreditCardReadEventArgs(CardData); args.GoodRead = false; ScanDataRecieved.Invoke(this, args); //throw new Exception("cardReaderTask - exception - " + ex.Message); } }