示例#1
0
        /// <summary>
        /// 磁条卡优先,兼容IC卡
        /// </summary>
        /// <returns></returns>
        protected Result DefaultRead3()
        {
            Result ret = DefaultRead();

            if ((ret == Result.Fail) && GlobalAppData.GetInstance().UseICCard)
            {
                //读卡失败,如果有启动IC,则进入IC卡读卡模式
                ReportSync("none");
                CardReader.CardType(0, 0);
                EMVTransProcess emv   = new EMVTransProcess();
                int             state = emv.EMVTransInit(0, EMVTransProcess.PbocTransType.PURCHASE);
                CardReader.CardPowerDown();
                if (state == 0)
                {
                    SaveBoolean("UseICCard", true);//交易变量
                    BankCardNum = emv.EMVInfo.CardNum;
                    Track2      = emv.EMVInfo.Track2;
                    Log.Debug("IC Card In");
                    return(Result.Success);
                }
            }

            return(ret);
        }
示例#2
0
        private void monitorTimer_TimeTick(object sender, TimerWrapperEventArgs e)
        {
            int nCurrentCount = mMonitorTimer.CurrentCount;

            mMonitorTimer.Stop();
            try
            {
                #region 清空管理界面计数器
                if (nCurrentCount % mClearClickNumInterval == 0)
                {
                    clearClickNum();
                }
                #endregion

                long calcInterval = GlobalAppData.GetInstance().MonitorTimeInterval;
                if (nCurrentCount % calcInterval == 0)
                {
                    if (SystemStatus == AppStatus.Idle ||
                        SystemStatus == AppStatus.OnAd ||
                        SystemStatus == AppStatus.OnStopServer)
                    {
                        #region 自动开关机时间检测
                        if (GlobalAppData.GetInstance().CloseAcmSwitch)
                        {
                            Log.Info("自动开关机时间检测...");
                            DateTime shutTime    = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + GlobalAppData.GetInstance().CloseAcmTime);
                            DateTime shutTimeEnd = shutTime.AddMinutes(2); //2分钟内关机
                            if (DateTime.Now >= shutTime && DateTime.Now <= shutTimeEnd)
                            {
                                switch (GlobalAppData.GetInstance().CloseAcmType)
                                {
                                case GlobalAppData.ECloseAcmType.Close:
                                    WindowsController.ExitWindows(RestartOptions.PowerOff, true);
                                    System.Threading.Thread.Sleep(5000);
                                    break;

                                case GlobalAppData.ECloseAcmType.Restart:
                                    WindowsController.ExitWindows(RestartOptions.Reboot, true);
                                    System.Threading.Thread.Sleep(5000);
                                    break;
                                }
                                return;
                            }
                        }
                        #endregion

                        #region 发送tms状态监控报文
                        if (GlobalAppData.GetInstance().TMSSwitch)
                        {
                            #region 设备自检,判断当前设备是否正常,暂停服务或者恢复服务
                            Log.Info("设备自检开始...");

                            bool isHdError = HardwareManager.CheckAll();
                            if (!isHdError && SystemStatus != AppStatus.OnStopServer)
                            {
                                bool isNetError = !HardwareManager.CheckOne("GPRS");
                                HideAd();
                                string errMsg = isNetError ? "网络故障" : "设备故障";
                                Intent stop   = new Intent(mApplicationInfo.StopServerActivity);
                                stop.PutExtra("Message", errMsg);
                                SendMessage(ActivityManagerHandler.LAUNCH_ACTIVITY, stop);
                            }
                            #endregion

                            Log.Info("发送TMS终端监控报文...");
                        }
                        #endregion
                    }

                    nCurrentCount = 0;
                }
            }
            catch (System.Exception ex)
            {
                Log.Error(this, ex);
            }
            finally
            {
                mMonitorTimer.CurrentCount = nCurrentCount;
                mMonitorTimer.Start();
            }
        }
示例#3
0
        /// <summary>
        /// IC卡优先,兼容磁条卡,不降级处理
        /// </summary>
        /// <returns></returns>
        protected Result DefaultRead4()
        {
            bool   isIcCard = true;
            int    nCardType = 0;
            string trk1 = "", trk2 = "", trk3 = "";

            CardReader.Status ret = CardReader.InsertCard(ref trk1, ref trk2, ref trk3);
            if (ret == CardReader.Status.CARD_SUCC)
            {
                CommonData.BIsCardIn = true;//有卡进入
                //读卡模式隐藏按钮
                ReportSync("none");
                Log.Debug("Track1:" + trk1);
                Log.Debug("Track2 : " + trk2);
                Log.Debug("Track3 : " + trk3);
                string CardNumber = Utility.GetCardNumber(trk2, trk3);
                if (CardNumber.Trim().Length > 0)
                {
                    Log.Info("MS Card Deal");
                    Track1      = trk1;
                    Track2      = trk2;
                    Track3      = trk3;
                    BankCardNum = CardNumber;
                    ExpDate     = Utility.GetExpDate(trk2, trk3);
                    isIcCard    = Utility.CheckIcCardFlag(trk2);
                    nCardType   = 1;
                }

                if (isIcCard && GlobalAppData.GetInstance().UseICCard)
                {
                    Log.Info("IC Card Deal");
                    CardReader.CardType(0, 0);//防止读卡器问题类型问题
                    EMVTransProcess emv   = new EMVTransProcess();
                    int             state = emv.EMVTransInit(0, EMVTransProcess.PbocTransType.PURCHASE);
                    CardReader.CardPowerDown();
                    if (state == 0)
                    {
                        BankCardNum = emv.EMVInfo.CardNum;
                        Track2      = emv.EMVInfo.Track2;
                        ExpDate     = emv.EMVInfo.CardExpDate;
                        CardSeqNum  = emv.EMVInfo.CardSeqNum;
                        nCardType  += 2;
                    }
                }

                BankCardType = (UserBankCardType)nCardType;

                if (isIcCard && nCardType < 2)//不降级处理
                {
                    return(Result.Fail);
                }

                if (BankCardType == UserBankCardType.None)
                {
                    return(Result.Fail);
                }
            }
            else if (ret == CardReader.Status.CARD_WAIT)
            {
                return(Result.Again);
            }
            else
            {
                Log.Error("ReaderOnce:" + ret.ToString());
                return(Result.HardwareError);
            }

            return(Result.Success);
        }