Example #1
0
        public bool ExtAuth(string extPsd)
        {
            bool bRet = false;

            try
            {
                Log.Debug("购电外部认证" + extPsd);
                byte[] bOut     = new byte[2048];
                int    nOut     = 0;
                string info     = "";
                byte[] bExt     = PubFunc.HexStringToByteArray(extPsd);
                byte[] bCommand = new byte[EXT_AUTH.Length + bExt.Length];
                Array.Copy(EXT_AUTH, bCommand, EXT_AUTH.Length);
                Array.Copy(bExt, 0, bCommand, EXT_AUTH.Length, bExt.Length);
                Log.Debug("购电外部命令:" + PubFunc.ByteArrayToHexString(bCommand, bCommand.Length));
                CardReader.Status sRet = CardReader.CardChipIO(bCommand, bCommand.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    Log.Debug("购电外部:" + info);
                    if (info == RET_STRING)
                    {
                        bRet = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("ExtAuth:" + ex.ToString());
            }
            return(bRet);
        }
Example #2
0
        public static void Task1()
        {
            Console.WriteLine("AOC2020_Day22_1");

            List <byte> Player1 = null;
            List <byte> Player2 = null;

            CardReader.ReadCards(out Player1, out Player2);

            while (Player1.Count > 0 && Player2.Count > 0)
            {
                var p1c = Player1[0]; Player1.RemoveAt(0);
                var p2c = Player2[0]; Player2.RemoveAt(0);

                if (p1c > p2c)
                {
                    Player1.Add(p1c); Player1.Add(p2c);
                }
                else if (p2c > p1c)
                {
                    Player2.Add(p2c); Player2.Add(p1c);
                }
                else
                {
                    throw new Exception();
                }
            }

            List <byte> winner = Player1.Count > 0 ? Player1 : Player2;

            Console.WriteLine("Score = {0}", Score(winner));
        }
Example #3
0
 public void getstartD()
 {
     cardReaderList = new CardReader();
     cardReaderList.CardInserted += new CardReader.CardInsertedEventHandler(cardReader_CardInserted);
     cardReaderList.CardRemoved  += new CardReader.CardRemovedEventHandler(cardReader_CardRemoved);
     startProc();
 }
Example #4
0
 public void Dispose()
 {
     foreach (SCPCardReader CardReader in this.Readers)
     {
         CardReader.Dispose();
     }
 }
Example #5
0
        public static int GetLogicalDevices([MarshalAs(UnmanagedType.LPWStr)] ref string itemsBuf, ref int bufLen,
                                            IntPtr obj)
        {
            string text =
                $"!!! GetLogicalDevices !!!\tobj:{obj}\tItemsBuf:{itemsBuf}\tbufLen:{bufLen}\t";

            WriteToLog(text);
            try
            {
                var    readers = CardReader.GetReaderNames().ToArray();
                string res     = "";
                Array.ForEach(readers, t => res += (string.IsNullOrWhiteSpace(res) ? "" : "#0") + t);
                res   += '\0';
                bufLen = readers.Length;
                text   = $"!!! GetLogicalDevices !!!\tLogicalDevices:{res}";
                WriteToLog(text);

                //UnMemory<char>.SaveInMemArr(res.ToCharArray(), ref itemsBuf);
                itemsBuf = res;

                return((int)ErrorCodes.E_SUCCESS);
            }
            catch (Exception e)
            {
                WriteToLog($"GetLogicalDevices ERROR !!! {text}\r\n {e}");
                return((int)ErrorCodes.E_GENERIC);
            }
        }
Example #6
0
        protected Result DefaultRead()
        {
            string trk1 = "", trk2 = "", trk3 = "";

            CardReader.Status ret = CardReader.InsertCard(ref trk1, ref trk2, ref trk3);
            if (ret == CardReader.Status.CARD_SUCC)
            {
                if (CardReader.IsUse)
                {
                    CommonData.BIsCardIn = true;//有卡进入
                }
                if (trk1.Trim() == "")
                {
                    Log.Debug("Track1 : NULL");
                }
                else
                {
                    Log.Debug("Track1 : IN");
                }
                if (trk2.Trim() == "")
                {
                    Log.Debug("Track2 : NULL");
                }
                else
                {
                    Log.Debug("Track2 : IN");
                }
                if (trk3.Trim() == "")
                {
                    Log.Debug("Track3 : NULL");
                }
                else
                {
                    Log.Debug("Track3 : IN");
                }

                Track1 = trk1;
                Track2 = trk2;
                Track3 = trk3;
                string CardNumber = Utility.GetCardNumber(trk2, trk3);
                BankCardNum = CardNumber;
                if (CardNumber.Trim().Length > 0)
                {
                    return(Result.Success);
                }
                else
                {
                    return(Result.Fail);
                }
            }
            else if (ret == CardReader.Status.CARD_WAIT)
            {
                return(Result.Again);
            }
            else
            {
                Log.Error("ReaderOnce:" + ret.ToString());
                return(Result.HardwareError);
            }
        }
Example #7
0
 public frmIntegralQuery()
 {
     wsm = new WSMemeber();
     InitializeComponent();
     crInstance = new CardReader();
     crInstance.OnReadFini += readCallBack;
 }
Example #8
0
 protected override void OnLeave()
 {
     if (!CommonData.BIsCardIn)
     {
         CardReader.CancelCommand();
     }
 }
Example #9
0
 protected override void OnLeave()
 {
     base.OnLeave();
     CardReader.CancelCommand();
     CardReader.CardOut();
     CommonData.BIsCardIn = false;
 }
        /// <summary>
        ///
        /// </summary>
        public string CardOperations()
        {
            CardTransactionResult cardTransactionResult = CardReader.RunCard(Total);

            switch (cardTransactionResult)
            {
            case CardTransactionResult.Approved:
                DateTime orderDate = DateTime.Now;
                UpdateCashDrawer.UpdateCashDrawerValues(this, paymentType, orderDate);
                return("Approved");

            case CardTransactionResult.Declined:
                return("Declnined");

            case CardTransactionResult.IncorrectPin:
                return("Incorrect Pin");

            case CardTransactionResult.InsufficientFunds:
                return("Insufficient Funds");

            case CardTransactionResult.ReadError:
                return("Read Error");

            default:
                throw new NotImplementedException("Card Operation Not Recognized");
            }
        }
Example #11
0
        /// <summary>
        /// 判断电卡类型
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool GetCardType(ref string info)
        {
            bool bRet = false;

            try
            {
                byte[]            bOut = new byte[2048];
                int               nOut = 0;
                CardReader.Status sRet = CardReader.CardChipIO(GET_CARD_TYPE, GET_CARD_TYPE.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    Log.Debug("GetCardType:" + info);
                    if (info == RET_CARDTYPE_2)
                    {
                        bRet = true;
                    }
                    else
                    {
                        Log.Warn("GetCardType:" + info);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetCardType:" + ex);
            }
            return(bRet);
        }
        protected override void HandleResult(Result result)
        {
            switch (result)
            {
            case Result.Success:
            {
                CommonData.BankCardNum     = BankCardNum;
                CommonData.BankCardSeqNum  = CardSeqNum;
                CommonData.BankCardExpDate = ExpDate;
                CommonData.Track1          = Track1;
                CommonData.Track2          = Track2;
                CommonData.Track3          = Track3;
                CommonData.UserCardType    = BankCardType;
                StartActivity("ÊÖ»ú³äÖµÊäÈëÃÜÂë");
            }
            break;

            case Result.HardwareError:
                ShowMessageAndGotoMain("¶Á¿¨Æ÷¹ÊÕÏ");
                break;

            case Result.Fail:
                CardReader.CardOut();
                StartActivity("ÊÖ»ú³äÖµ¶Á¿¨´íÎó");
                break;

            case Result.Cancel:
            case Result.TimeOut:
                StartActivity("Ö÷½çÃæ");
                break;
            }
        }
Example #13
0
        /// <summary>
        /// EMV卡片交互
        /// </summary>
        /// <param name="field55"></param>
        /// <param name="AuthNo"></param>
        /// <returns></returns>
        public int EMVTransEnd(byte[] field55, string AuthNo)
        {
            int ret = 0;

            try
            {
                string temp = PubFunc.ByteArrayToHexString(field55, field55.Length);
                ret = pboc.App_EMVOnlineDataProcess(0, Encoding.Default.GetBytes(temp), temp.Length,
                                                    PubFunc.HexStringToByteArray(AuthNo), AuthNo.Length);
                if (ret == 0)
                {
                    byte[] field551   = new byte[1024];
                    int    field55Len = 0;
                    pboc.App_EMVGetField55(field551, ref field55Len);
                    EMVInfo.EndField55 = new byte[field55Len];
                    Array.Copy(field551, EMVInfo.EndField55, field55Len);
                }
            }
            catch (System.Exception ex)
            {
                Log.Error("App_EMVOnlineDataProcess Error!", ex);
                ret = -1;
            }
            finally
            {
                CardReader.CardPowerDown();
            }
            return(ret);
        }
Example #14
0
        /// <summary>
        /// Handles credit card payment when the Credit/Debit button is pressed
        /// </summary>
        /// <param name="sender">The Credit/Debit button</param>
        /// <param name="e">Click event arguments</param>
        private void HandleCreditPayment(object sender, RoutedEventArgs e)
        {
            var orderComponent = this.FindAncestor <OrderComponent>();
            var result         = CardReader.RunCard(orderComponent.Order.Total);

            switch (result)
            {
            case CardTransactionResult.Declined:
                MessageBox.Show("Card declined.");
                break;

            case CardTransactionResult.IncorrectPin:
                MessageBox.Show("Incorrect PIN entered.");
                break;

            case CardTransactionResult.InsufficientFunds:
                MessageBox.Show("Insufficient funds on card.");
                break;

            case CardTransactionResult.ReadError:
                MessageBox.Show("Error reading card.");
                break;

            case CardTransactionResult.Approved:
                orderComponent.FinishPayment();
                break;
            }
        }
        /// <summary>
        /// Uses the RoundRegister dll to process a card payment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CardPayment_Click(object sender, RoutedEventArgs e)
        {
            var order = (Order)DataContext;
            var c     = CardReader.RunCard(order.Total);

            if (c == CardTransactionResult.Approved)
            {
                var v      = this.FindAncestor <MainWindow>();
                var receit = new Receit();
                v.ChangeScreen(receit);
            }
            else if (c == CardTransactionResult.Declined)
            {
                MessageBox.Show("Card Declined");
            }
            else if (c == CardTransactionResult.IncorrectPin)
            {
                MessageBox.Show("Incorrect Pin");
            }
            else if (c == CardTransactionResult.InsufficientFunds)
            {
                MessageBox.Show("InsufficientFunds");
            }
            else
            {
                MessageBox.Show("Read Error");
            }

            Order o = new Order();

            DataContext = o;
            OrderComponent orderC = new OrderComponent();

            orderC.orderListView.DataContext = o;
        }
        public DistributedSearch(string configFilename)
        {
            // Grab the configuration info
            _configFilename = configFilename;
            var config = Toml.ReadFile <Configuration>(_configFilename);

            // Console.WriteLine("NumFeatures: " + config.Map.Features.Length);
            // foreach (var p in config.Map.Features)
            // {
            //     Console.WriteLine(p.Name);
            // }

            // Configuration for the search space
            _heroClass = CardReader.GetClassFromName(config.Deckspace.HeroClass);
            CardSet[] sets = CardReader.GetSetsFromNames(config.Deckspace.CardSets);
            _cardSet = CardReader.GetCards(_heroClass, sets);

            // Setup the logs to record the data on individuals
            InitLogs();

            // Set up search algorithm
            Console.WriteLine("Algo: " + config.Search.Type);
            if (config.Search.Type.Equals("MAP-Elites"))
            {
                var searchConfig = Toml.ReadFile <MapElitesParams>(config.Search.ConfigFilename);
                _searchAlgo = new MapElitesAlgorithm(searchConfig);
            }

            else if (config.Search.Type.Equals("EvolutionStrategy"))
            {
                var searchConfig = Toml.ReadFile <EvolutionStrategyParams>(config.Search.ConfigFilename);
                _searchAlgo = new EvolutionStrategyAlgorithm(searchConfig);
            }
        }
Example #17
0
 void CreditOrDebitClick(object sender, RoutedEventArgs e)
 {
     if (DataContext is Order order)
     {
         var result = CardReader.RunCard(order.Total);
         if (result == CardTransactionResult.Approved)
         {
             PrintReciept();
             order.Clear();
             menu.orderBorder.Child = new ButtonControlComponent(menu);
             DependencyObject parent = menu;
             do
             {
                 parent = LogicalTreeHelper.GetParent(parent);
             }while (parent != null && !(parent is MainWindow));
             ((MainWindow)parent).DataContext = new Order();
         }
         else if (result == CardTransactionResult.Declined)
         {
             MessageBox.Show("Card Declined");
         }
         else if (result == CardTransactionResult.ReadError)
         {
             MessageBox.Show("Card Read Error, Try Again");
         }
         else if (result == CardTransactionResult.InsufficientFunds)
         {
             MessageBox.Show("Insufficient Funds, Try Another Card Or Pay With Cash");
         }
         else if (result == CardTransactionResult.IncorrectPin)
         {
             MessageBox.Show("Incorrect Pin, Please Try Again");
         }
     }
 }
Example #18
0
        /// <summary>
        /// 上电获取卡片序列号
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool GetCardNo(ref string info)
        {
            bool bRet = false;

            if (!CardReader.IsUse)
            {
                info = "10110800000F82CA";
                return(true);
            }

            try
            {
                byte[]            bAnswer = new byte[512];
                int               nLen    = 0;
                int               nChip   = 0;
                CardReader.Status status  = CardReader.CardPowerUp(bAnswer, ref nLen, ref nChip);
                Log.Error("GetCardResult:" + Enum.GetName(typeof(CardReader.Status), status));
                if (status == CardReader.Status.CARD_SUCC)
                {
                    bRet = true;
                    info = PubFunc.ByteArrayToHexString(bAnswer, nLen);
                    Log.Debug("GetCardNO:" + info);
                    info = info.Substring(info.Length - 16);
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetCardNo:" + ex);
            }
            return(bRet);
        }
Example #19
0
 protected override void OnEnter()
 {
     mUserTakeCard = false;
     CardReader.CardOut();
     CommonData.BIsCardIn = false;
     PostAsync(OnResult);
 }
Example #20
0
        /// <summary>
        /// 读钱包文件
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool GetEF2(ref string info)
        {
            bool bRet = false;

            if (!CardReader.IsUse)
            {
                info = "0000283C000000019000";
                return(true);
            }
            try
            {
                byte[]            bOut = new byte[2048];
                int               nOut = 0;
                CardReader.Status sRet = CardReader.CardChipIO(GET_EF2, GET_EF2.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    Log.Debug("GetEF2:" + info);
                    if (info.Substring(info.Length - 4) == RET_STRING)
                    {
                        bRet = true;
                        info = info.Substring(0, info.Length - 4);
                    }
                    else
                    {
                        Log.Warn("GetEF2:" + info);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetEF2:" + ex);
            }
            return(bRet);
        }
Example #21
0
        /// <summary>
        /// Handles Credit/Debit click event
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">Event args</param>
        public void CreditDebitClick(object sender, EventArgs e)
        {
            CardTransactionResult k = CardReader.RunCard(Convert.ToDouble(price.Total));

            switch (k)
            {
            case CardTransactionResult.Approved:
                PrintOrder("Card", price.Total, price.Total);
                Win.NewOrder();
                break;

            case CardTransactionResult.Declined:
                MessageBox.Show("Card was declined. Please try new card");
                break;

            case CardTransactionResult.ReadError:
                MessageBox.Show("Error reading card. Please try again");
                break;

            case CardTransactionResult.InsufficientFunds:
                MessageBox.Show("Card Has insufficient Funds");
                break;

            case CardTransactionResult.IncorrectPin:
                MessageBox.Show("Transaction Failed. Incorrect pin");
                break;
            }
        }
Example #22
0
        /// <summary>
        /// 8.	读返写区文件
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool GetEF5(ref string info)
        {
            bool bRet = false;

            if (!CardReader.IsUse)
            {
                info = "6811002B02000001000001000000629276002013007233000017E80000001700000000010004010000001510051026FE169000";
                return(true);
            }
            try
            {
                byte[]            bOut = new byte[2048];
                int               nOut = 0;
                CardReader.Status sRet = CardReader.CardChipIO(GET_EF5, GET_EF5.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    Log.Debug("GetEF5:" + info);
                    if (info.Substring(info.Length - 4) == RET_STRING)
                    {
                        bRet = true;
                        info = info.Substring(0, info.Length - 4);
                    }
                    else
                    {
                        Log.Warn("GetEF5:" + info);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetEF5:" + ex);
            }
            return(bRet);
        }
Example #23
0
        /// <summary>
        /// Click event for CREDIT/DEBIT button for payment type
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PayByCard_Click(object sender, RoutedEventArgs e)
        {
            switch (CardReader.RunCard(ancestor.newOrder.Total))
            {
            case CardTransactionResult.Approved:
                //print receipt
                //OrderListView.Items.Clear();
                Order order = new Order();
                DataContext = order;
                break;

            case CardTransactionResult.Declined:
                PayByCard.IsEnabled = false;
                MessageBox.Show("Error: Card Declined, please select another payment method.");
                break;

            case CardTransactionResult.ReadError:
                MessageBox.Show("Error: Card Read Error! \n\t Please try swiping card again!");
                break;

            case CardTransactionResult.InsufficientFunds:
                PayByCard.IsEnabled = false;
                MessageBox.Show("Error: Insufficient funds on card. \n\t Please select another payment method.");
                break;

            case CardTransactionResult.IncorrectPin:
                MessageBox.Show("Error: Incorrect Pin. \n\t Please try entering again.");
                break;

            default:
                throw new NotImplementedException("Should never be reached");
            }
        }
Example #24
0
        /// <summary>
        /// 8.	写返写区文件
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool SetEF5(string ef5)
        {
            bool bRet = false;

            try
            {
                byte[]            bOut     = new byte[2048];
                string            sCommand = "04D6850035";
                int               nOut     = 0;
                string            info     = "";
                byte[]            bCommand = PubFunc.HexStringToByteArray(sCommand + ef5);
                CardReader.Status sRet     = CardReader.CardChipIO(bCommand, bCommand.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    if (info == RET_STRING)
                    {
                        bRet = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("SetEF5:" + ex);
            }
            return(bRet);
        }
Example #25
0
        /// <summary>
        /// 插入带芯片卡
        /// </summary>
        /// <returns></returns>
        protected Result InsertICCard()
        {
            CardReader.Status ret = CardReader.Insert_ICcard();
            if (ret != CardReader.Status.CARD_WAIT)
            {
                CommonData.BIsCardIn = true;
            }

            switch (ret)
            {
            case CardReader.Status.CARD_WAIT:
            {
                return(Result.Again);
            }

            case CardReader.Status.CARD_SUCC:
            {
                ReportSync("none");
                return(Result.Success);
            }

            default:
                return(Result.HardwareError);
            }
        }
Example #26
0
        private byte[] EXT_AUTH   = { 0x00, 0x82, 0x00, 0x04, 0x08 }; //外部认证 + 密钥


        /// <summary>
        /// 获取电卡信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool GetCardInfo(ref string info)
        {
            bool bRet = false;

            if (!CardReader.IsUse)
            {
                info = "5DDC19FC1287506465BE2C70D5080817C28C009B181DA1C46ADC7285F5D1FCCD7CD2E7CAE3EA664F5754B8AC2C6DF4189B14A56696A950B915BE6794C7F49E41849C8756619EA31922FE5D04326128B03A32FB122697F077F932274EF10E320790EAF47E1304D7BF33DC2176D9FFE4E2F29069BF5C8E3D47ED9CAC426C38ADC69000";
                return(true);
            }
            try
            {
                byte[]            bOut = new byte[2048];
                int               nOut = 0;
                CardReader.Status sRet = CardReader.CardChipIO(GET_CARD_INFO, GET_CARD_INFO.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    Log.Debug("GetCardInfo:" + info);
                    if (info.Substring(info.Length - 4) == RET_STRING)
                    {
                        bRet = true;
                        info = info.Substring(0, info.Length - 4);
                    }
                    else
                    {
                        Log.Warn("GetCardInfo:" + info);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetCardInfo:" + ex);
            }
            return(bRet);
        }
        protected override void HandleResult(Result result)
        {
            switch (result)
            {
            case Result.Success:
            {
                CommonData.BankCardNum     = BankCardNum;
                CommonData.BankCardSeqNum  = CardSeqNum;
                CommonData.BankCardExpDate = ExpDate;
                CommonData.Track1          = Track1;
                CommonData.Track2          = Track2;
                CommonData.Track3          = Track3;
                CommonData.UserCardType    = BankCardType;
                StartActivity("信用卡还款输入密码");
            }
            break;

            case Result.HardwareError:
                ShowMessageAndGotoMain("读卡器故障");
                break;

            case Result.Fail:
                CardReader.CardOut();
                StartActivity("信用卡还款读卡错误");
                break;

            case Result.Cancel:
                StartActivity("信用卡还款输入还款金额");
                break;

            case Result.TimeOut:
                StartActivity("主界面");
                break;
            }
        }
Example #28
0
        public bool LimitAuth(string limitPsd)
        {
            bool bRet = false;

            try
            {
                Log.Debug("写权限认证:" + limitPsd);
                byte[] bOut     = new byte[2048];
                int    nOut     = 0;
                string info     = "";
                byte[] bLimit   = PubFunc.HexStringToByteArray(limitPsd);
                byte[] bCommand = new byte[LIMIT_AUTH.Length + bLimit.Length];
                Array.Copy(LIMIT_AUTH, bCommand, LIMIT_AUTH.Length);
                Array.Copy(bLimit, 0, bCommand, LIMIT_AUTH.Length, bLimit.Length);
                //bCommand[bCommand.Length - 1] = 0x00;
                Log.Debug("写权限命令:" + PubFunc.ByteArrayToHexString(bCommand, bCommand.Length));
                CardReader.Status sRet = CardReader.CardChipIO(bCommand, bCommand.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    Log.Debug("写权限:" + info);
                    if (info == RET_STRING)
                    {
                        bRet = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("LimitAuth:" + ex.ToString());
            }
            return(bRet);
        }
        private void CreditCardPayment(object sender, RoutedEventArgs e)
        {
            CardTransactionResult cardStatusResult = CardReader.RunCard(GetOrder.Total);

            switch (cardStatusResult)
            {
            case CardTransactionResult.Approved:
                cardStatus.Text = "Approved";
                ReceiptPrinterFunc(e);
                return;

            case CardTransactionResult.Declined:
                cardStatus.Text = "Your Card has been Declined";
                return;

            case CardTransactionResult.IncorrectPin:
                cardStatus.Text = "The PIN entered is incorrect";
                return;

            case CardTransactionResult.InsufficientFunds:
                cardStatus.Text = "Insufficient Funds";
                return;

            case CardTransactionResult.ReadError:
                cardStatus.Text = "Error Reading Card";
                return;
            }
        }
Example #30
0
 public frmVipConsumption()
 {
     InitializeComponent();
     wsm = new WSMemeber();
     crInstance = new CardReader();
     crInstance.OnReadFini += readCallBack;
 }
        /// <summary>
        /// Handles when a user clicks on the card button option.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The RoutedEventArgs of the event.</param>
        private void CreditDebitButton_Click(object sender, RoutedEventArgs e)
        {
            CardTransactionResult res = CardReader.RunCard((DataContext as Order).Total);

            switch (res)
            {
            case CardTransactionResult.Approved:
                ((Order)this.DataContext).PrintReciept(PaymentType.Card, 0.00);
                NewOrderEvent?.Invoke(this, new NewOrderEventArgs(new Order()));
                break;

            case CardTransactionResult.Declined:
                MessageBox.Show("Your card was declined, contact your bank.");
                break;

            case CardTransactionResult.ReadError:
                MessageBox.Show("Error reading your card, try again.");
                break;

            case CardTransactionResult.InsufficientFunds:
                MessageBox.Show("Your card was rejected due to a lack of funds.");
                break;

            case CardTransactionResult.IncorrectPin:
                MessageBox.Show("Your pin was incorrect, try re-enterring");
                break;
            }
        }
Example #32
0
        public bool UpdateKey(string key)
        {
            bool bRet = false;

            try
            {
                byte[]            bOut     = new byte[2048];
                string            sKey     = "84D401FF20";
                int               nOut     = 0;
                string            info     = "";
                byte[]            bCommand = PubFunc.HexStringToByteArray(sKey + key);
                CardReader.Status sRet     = CardReader.CardChipIO(bCommand, bCommand.Length, bOut, ref nOut);
                if (sRet == CardReader.Status.CARD_SUCC)
                {
                    info = PubFunc.ByteArrayToHexString(bOut, nOut);
                    if (info == RET_STRING)
                    {
                        bRet = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("UpdateKey:" + ex);
            }
            return(bRet);
        }
Example #33
0
 public frmAddNewVip()
 {
     InitializeComponent();
     wsm = new WSMemeber();
     wsp = new WSPotentialMember();
     cbCardKind.SelectedIndex = 0;
     cbSex.SelectedIndex = 0;
     crInstance = new CardReader();
 }
Example #34
0
 public frmVipEnter()
 {
     InitializeComponent();
     wsm = new WSMemeber();
     wsr = new WSRack();
     wsi = new WSImport();
     crInstance = new CardReader();
     crInstance.OnReadFini += readCallBack;
 }
Example #35
0
		public static void Init(string path = ".", string scripts = "script", string cards = "cards.cdb")
		{
			PathManager.Init(path, scripts, cards);
			CardsManager.Init(cards);

			m_buffer = Marshal.AllocHGlobal(65536);

			m_creader = MyCardReader;
			m_sreader = MyScriptReader;
			m_msghandler = MyMessageHandler;

			set_card_reader(m_creader);
			set_script_reader(m_sreader);
			set_message_handler(m_msghandler);
		}
Example #36
0
        public static void Init(string rootPath = ".", string scriptDirectory = "script", string databaseFile = "cards.cdb")
        {
            _rootPath = rootPath;
            _scriptDirectory = scriptDirectory;

            CardsManager.Init(Path.Combine(Path.GetFullPath(rootPath), databaseFile));

            Duel.Duels = new Dictionary<IntPtr, Duel>();

            _buffer = Marshal.AllocHGlobal(65536);

            _cardCallback = OnCardReader;
            _scriptCallback = OnScriptReader;
            _messageCallback = OnMessageHandler;

            set_card_reader(_cardCallback);
            set_script_reader(_scriptCallback);
            set_message_handler(_messageCallback);
        }
Example #37
0
 /*
  * Private constructor; use factory objects below
  */
 private EFCIA_DS(byte[] AID, CardReader cardReader, byte[] FileID)
     : base(AID, cardReader, FileID)
 {
 }
Example #38
0
 /*
  * Create a DocumentSigner object for the Registration B
  */
 public static EFCIA_DS Create_DS_B(byte[] AID, CardReader cardReader)
 {
     return new EFCIA_DS(AID, cardReader, new byte[] { 0xC0, 0x11 });
 }
Example #39
0
 public static extern void set_card_reader(CardReader f);