Пример #1
0
 private void s_OnPaidOk(object sender, OpenCardEventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(e.CardID))
         {
             return;
         }
         CardPaymentInfo pay = e.Payment;
         if (pay != null && (pay.Accounts > 0 || pay.Discount > 0)) //只有要收费的记录才保存
         {
             pay.Paid           = e.Paid;
             pay.IsCenterCharge = true;
             pay.OperatorID     = OperatorInfo.CurrentOperator.OperatorName;
             pay.StationID      = WorkStationInfo.CurrentStation.StationName;
             CommandResult ret = (new CardBll(AppSettings.CurrentSetting.MasterParkConnect)).PayParkFee(pay);
         }
         if (e.Entrance != null)
         {
             IParkingAdapter pad = ParkingAdapterManager.Instance[e.Entrance.RootParkID];
             if (pad != null)
             {
                 var notify = new RemoteReadCardNotify(e.Entrance.RootParkID, e.Entrance.EntranceID, e.CardID, string.Empty,
                                                       OperatorInfo.CurrentOperator.OperatorID, WorkStationInfo.CurrentStation.StationID);
                 string temp   = AppSettings.CurrentSetting.GetConfigContent("RemoteReader");
                 int    reader = 0;
                 if (!int.TryParse(temp, out reader))
                 {
                     reader = 0;
                 }
                 notify.Reader = (EntranceReader)reader;
                 if (!pad.RemoteReadCard(notify))
                 {
                     if (Debug)
                     {
                         Ralid.GeneralLibrary.LOG.FileLog.Log(e.Entrance.EntranceName, string.Format("【{0}】 缴费事件 远程读卡失败", e.CardID));
                     }
                 }
                 if (!string.IsNullOrEmpty(e.CardType)) //只有开放卡片才显示余额
                 {
                     WaitCallback wc = (WaitCallback)((object state) =>
                     {
                         System.Threading.Thread.Sleep(AppSettings.CurrentSetting.GetShowBalanceInterval() * 1000);
                         pad.LedDisplay(new SetLedDisplayNotify(e.Entrance.EntranceID, CanAddress.TicketBoxLed, string.Format("车费{0}元 余额{1}元", e.Paid, e.Balance), false, 0));
                     });
                     ThreadPool.QueueUserWorkItem(wc);
                 }
             }
         }
         if (this.OnPaidOk != null)
         {
             this.OnPaidOk(sender, e);
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
         throw ex;
     }
 }
Пример #2
0
 private void CardReadHandler(object sender, CardReadEventArgs e)
 {
     if (AppSettings.CurrentSetting.EnableWriteCard)
     {
         //当前读到的卡片
         _cardInfo = CardDateResolver.Instance.GetCardInfoFromData(e.CardID, e[GlobalVariables.ParkingSection]);
     }
     foreach (int enID in WorkStationInfo.CurrentStation.EntranceList)
     {
         EntranceInfo entrance = ParkBuffer.Current.GetEntrance(enID);
         if (entrance != null && entrance.IsExitDevice)
         {
             RemoteReadCardNotify notify = new RemoteReadCardNotify(entrance.ParkID, entrance.EntranceID, e.CardID, e[GlobalVariables.ParkingSection]);
             if (_cardInfo != null)
             {
                 notify.LastCarPlate = _cardInfo.LastCarPlate;
             }
             IParkingAdapter pad = ParkingAdapterManager.Instance[entrance.ParkID];
             if (pad != null)
             {
                 pad.RemoteReadCard(notify);
                 break;
             }
         }
     }
 }
Пример #3
0
        private void s_OnReadCard(object sender, OpenCardEventArgs e)
        {
            if (string.IsNullOrEmpty(e.CardID))
            {
                return;
            }
            if (e.Entrance == null)
            {
                return;                   //没有指定通道的读卡事件丢掉不处理
            }
            if (!e.Entrance.IsExitDevice) //入口刷卡时,如果卡片类型为开放卡片类型,则在系统中增加此卡片信息
            {
                CardType ct = string.IsNullOrEmpty(e.CardType) ? null : CustomCardTypeSetting.Current.GetCardType(e.CardType);
                if (ct != null)
                {
                    CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardByID(e.CardID).QueryObject;
                    if (card == null)
                    {
                        SaveOpenCard(e.CardID, ct, e.Balance);
                    }
                }
            }

            //通过远程读卡方式
            IParkingAdapter pad = ParkingAdapterManager.Instance[e.Entrance.RootParkID];

            if (pad != null)
            {
                var notify = new RemoteReadCardNotify(e.Entrance.RootParkID, e.Entrance.EntranceID, e.CardID, string.Empty,
                                                      OperatorInfo.CurrentOperator.OperatorID, WorkStationInfo.CurrentStation.StationID);
                string temp   = AppSettings.CurrentSetting.GetConfigContent("RemoteReader");
                int    reader = 0;
                if (!int.TryParse(temp, out reader))
                {
                    reader = 0;
                }
                notify.Reader = (EntranceReader)reader;
                if (!pad.RemoteReadCard(notify))
                {
                    if (Debug)
                    {
                        Ralid.GeneralLibrary.LOG.FileLog.Log(e.Entrance.EntranceName, string.Format("【{0}】 读卡事件 远程读卡失败", e.CardID));
                    }
                }
                if (!string.IsNullOrEmpty(e.CardType)) //只有开放卡片才显示余额
                {
                    WaitCallback wc = (WaitCallback)((object state) =>
                    {
                        System.Threading.Thread.Sleep(AppSettings.CurrentSetting.GetShowBalanceInterval() * 1000);
                        pad.LedDisplay(new SetLedDisplayNotify(e.Entrance.EntranceID, CanAddress.TicketBoxLed, string.Format("余额{0}元", e.Balance), false, 0));
                    });
                    ThreadPool.QueueUserWorkItem(wc);
                }
            }
            if (this.OnReadCard != null)
            {
                this.OnReadCard(sender, e);
            }
        }
Пример #4
0
        private void reader_CardReadHandler(object sender, ZSTReaderEventArgs e)
        {
            if (_ZSTSetting == null || _ZSTSetting.Items == null || !_ZSTSetting.HasReader(e.ReaderIP))
            {
                _Reader.MessageConfirm(e.ReaderIP);
                return;
            }
            EntranceInfo entrance = ParkBuffer.Current.GetEntrance(_ZSTSetting.GetReader(e.ReaderIP).EntranceID);

            if (entrance == null)
            {
                _Reader.MessageConfirm(e.ReaderIP);
                return;
            }

            CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardByID(e.CardID).QueryObject;

            if (!entrance.IsExitDevice)
            {
                _Reader.MessageConfirm(e.ReaderIP);
                if (card == null) //入口,如果卡片不在系统中,则先在系统中增加此中山通卡片
                {
                    //寻找系统中是否存在名称为"中山通"的自定义卡片类型
                    CardType ct = null;
                    if (CustomCardTypeSetting.Current != null)
                    {
                        ct = CustomCardTypeSetting.Current.GetCardType("中山通");
                    }
                    if (ct == null)
                    {
                        return;
                    }
                    if (!SaveZSTCard(e.CardID, ct, e.Balance))
                    {
                        return;
                    }
                }
            }

            ZSTHandlerInfo zst = GetZSTHandlerInstance(e.ReaderIP);

            zst.CardID  = e.CardID;
            zst.Balance = e.Balance;

            //通过远程读卡方式
            IParkingAdapter pad = ParkingAdapterManager.Instance[entrance.RootParkID];

            if (pad != null)
            {
                pad.RemoteReadCard(new RemoteReadCardNotify(entrance.RootParkID, entrance.EntranceID, e.CardID));
            }
        }
Пример #5
0
 private void TicketReader_BarCodeRead(object sender, BarCodeReadEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.BarCode))
     {
         foreach (int enID in WorkStationInfo.CurrentStation.EntranceList)
         {
             EntranceInfo entrance = ParkBuffer.Current.GetEntrance(enID);
             if (entrance != null && entrance.IsExitDevice)
             {
                 RemoteReadCardNotify notify = new RemoteReadCardNotify(entrance.ParkID, entrance.EntranceID, e.BarCode);
                 IParkingAdapter      pad    = ParkingAdapterManager.Instance[entrance.ParkID];
                 if (pad != null)
                 {
                     pad.RemoteReadCard(notify);
                     break;
                 }
             }
         }
     }
 }
Пример #6
0
 public bool RemoteReadCard(RemoteReadCardNotify notify)
 {
     try
     {
         if (_Channel != null)
         {
             return(_Channel.RemoteReadCard(notify));
         }
     }
     catch (CommunicationException)
     {
         if (ParkAdapterConnectFail != null)
         {
             ParkAdapterConnectFail(this, EventArgs.Empty);
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     return(false);
 }