Esempio n. 1
0
 private void s_OnPaidFail(object sender, OpenCardEventArgs e)
 {
     if (string.IsNullOrEmpty(e.CardID))
     {
         return;
     }
     if (e.Entrance != null)
     {
         IParkingAdapter pad = ParkingAdapterManager.Instance[e.Entrance.RootParkID];
         if (pad != null)
         {
             if (!e.LastError.Contains("余额不足"))
             {
                 pad.LedDisplay(new SetLedDisplayNotify(e.Entrance.EntranceID, CanAddress.TicketBoxLed, string.IsNullOrEmpty(e.LastError) ? "扣款失败" : e.LastError, false, 0));
             }
             else
             {
                 string temp   = AppSettings.CurrentSetting.GetConfigContent("RemoteReader");
                 int    reader = 0;
                 if (!int.TryParse(temp, out reader))
                 {
                     reader = 0;
                 }
                 var ce = new CardEventReport()
                 {
                     EntranceID = e.Entrance.EntranceID,
                     CardID     = e.Payment.CardID,
                     CardType   = e.Payment.CardType,
                     Reader     = (EntranceReader)reader,
                 };
                 var notify = new EventInvalidNotify()
                 {
                     CardEvent   = ce,
                     Balance     = e.Balance,
                     OperatorNum = OperatorInfo.CurrentOperator.OperatorNum,
                     InvalidType = EventInvalidType.INV_Balance
                 };
                 pad.EventInvalid(notify);
                 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.Payment.GetPaying(), e.Balance), false, 0));
                     });
                     ThreadPool.QueueUserWorkItem(wc);
                 }
             }
         }
     }
     if (this.OnPaidFail != null)
     {
         this.OnPaidFail(sender, e);
     }
 }
Esempio n. 2
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;
     }
 }
Esempio n. 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);
            }
        }
Esempio n. 4
0
 private void s_OnError(object sender, OpenCardEventArgs e)
 {
     if (e.Entrance != null)
     {
         IParkingAdapter pad = ParkingAdapterManager.Instance[e.Entrance.RootParkID];
         if (pad != null)
         {
             if (e.LastError.Contains("黑名单"))
             {
                 string temp   = AppSettings.CurrentSetting.GetConfigContent("RemoteReader");
                 int    reader = 0;
                 if (!int.TryParse(temp, out reader))
                 {
                     reader = 0;
                 }
                 var f**k = new CardEventReport()
                 {
                     EntranceID = e.Entrance.EntranceID,
                     CardID     = e.CardID,
                     CardType   = CustomCardTypeSetting.Current.GetCardType(e.CardType),
                     Reader     = (EntranceReader)reader,
                 };
                 var notify = new EventInvalidNotify()
                 {
                     CardEvent   = f**k,
                     Balance     = e.Balance,
                     OperatorNum = OperatorInfo.CurrentOperator.OperatorNum,
                     InvalidType = EventInvalidType.INV_Invalid,
                 };
                 pad.EventInvalid(notify);
             }
             else
             {
                 pad.LedDisplay(new SetLedDisplayNotify(e.Entrance.EntranceID, CanAddress.TicketBoxLed, e.LastError, false, 0));
             }
         }
     }
     if (this.OnError != null)
     {
         this.OnError(this, e);
     }
 }
Esempio n. 5
0
 public void LedDisplay(SetLedDisplayNotify notify)
 {
     try
     {
         if (_Channel != null)
         {
             _Channel.LedDisplay(notify);
         }
     }
     catch (CommunicationException)
     {
         if (ParkAdapterConnectFail != null)
         {
             ParkAdapterConnectFail(this, EventArgs.Empty);
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
 }
Esempio n. 6
0
        public void ProcessReport(BusinessModel.Report.ReportBase report)
        {
            EntranceInfo entrance = ParkBuffer.Current.GetEntrance(report.EntranceID);

            if (entrance == null)
            {
                return;
            }
            if (entrance.IsExitDevice)  //处理出口
            {
                if (report is CardEventReport)
                {
                    CardEventReport cer = report as CardEventReport;
                    if (cer.EventStatus == CardEventStatus.Pending)
                    {
                        ZSTHandlerInfo zst = GetZSTHandlerInstance(cer.EntranceID);
                        if (zst != null && !string.IsNullOrEmpty(zst.CardID) && zst.CardID == cer.CardID)
                        {
                            if (zst.Balance >= cer.CardPaymentInfo.Accounts)
                            {
                                zst.ProcessingEvent = cer;
                                _Reader.Consumption(zst.ReaderIP, cer.CardPaymentInfo.Accounts);  //余额足够的话就直接扣款
                                IParkingAdapter pad = ParkingAdapterManager.Instance[cer.ParkID];
                                if (pad != null)
                                {
                                    SetLedDisplayNotify notify = new SetLedDisplayNotify(entrance.ParkID, CanAddress.TicketBoxLed,
                                                                                         string.Format("扣款{0}元", cer.CardPaymentInfo.Accounts), false, 0);
                                    pad.LedDisplay(notify);
                                }
                            }
                            else
                            {
                                _Reader.MessageConfirm(zst.ReaderIP); //发送中山通读卡确认消息
                                zst.ClearCardInfo();                  //清空读卡器内的卡片信息
                                IParkingAdapter pad = ParkingAdapterManager.Instance[cer.ParkID];
                                if (pad != null)
                                {
                                    EventInvalidNotify n = new EventInvalidNotify()
                                    {
                                        InvalidType = EventInvalidType.INV_Balance,
                                        Balance     = zst.Balance,
                                        CardEvent   = cer
                                    };
                                    pad.EventInvalid(n);
                                }
                            }
                        }
                    }
                    else
                    {
                        ZSTHandlerInfo zst = GetZSTHandlerInstance(cer.EntranceID);
                        if (zst != null && !string.IsNullOrEmpty(zst.CardID) && zst.CardID == cer.CardID)
                        {
                            _Reader.MessageConfirm(zst.ReaderIP); //发送中山通读卡确认消息
                            zst.ClearCardInfo();                  //清空读卡器内的卡片信息
                        }
                    }
                }
                else if (report is CardInvalidEventReport)
                {
                    CardInvalidEventReport cier = report as CardInvalidEventReport;
                    ZSTHandlerInfo         zst  = GetZSTHandlerInstance(report.EntranceID);
                    if (zst != null && !string.IsNullOrEmpty(zst.CardID) && zst.CardID == cier.CardID)
                    {
                        _Reader.MessageConfirm(zst.ReaderIP); //发送中山通读卡确认消息
                        zst.ClearCardInfo();                  //清空读卡器内的卡片信息
                    }
                }
            }
        }