protected override void OnCardPermitted(OfflineCardReadReport report) { EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } if (entrance.ProcessingEvent != null && entrance.ProcessingEvent.CardID == report.CardID) { if (entrance.ProcessingEvent.CardType.IsPrepayCard && entrance.ProcessingEvent.CardPaymentInfo != null && entrance.ProcessingEvent.CardPaymentInfo.Accounts > 0 && entrance.ProcessingCard.Balance >= entrance.ProcessingEvent.CardPaymentInfo.Accounts ) //储值卡扣除余额 { entrance.ProcessingEvent.CardPaymentInfo.Paid = entrance.ProcessingEvent.CardPaymentInfo.Accounts; entrance.ProcessingEvent.CardPaymentInfo.OperatorID = string.Empty; entrance.ProcessingEvent.CardPaymentInfo.StationID = string.Empty; entrance.ProcessingEvent.CardPaymentInfo.PaymentMode = PaymentMode.Prepay; CardBll cpb = new CardBll(AppSettings.CurrentSetting.ParkConnect); cpb.PayParkFee(entrance.ProcessingEvent.CardPaymentInfo); entrance.ProcessingEvent.Balance = entrance.ProcessingEvent.Balance - entrance.ProcessingEvent.CardPaymentInfo.Accounts; entrance.ProcessingCard.Balance = entrance.ProcessingEvent.Balance; } CardEventReport cardEvent = entrance.ProcessingEvent.Clone(); cardEvent.EventStatus = CardEventStatus.Valid; cardEvent.OperatorID = string.Empty; cardEvent.StationID = string.Empty; CardBll cbll = new CardBll(AppSettings.CurrentSetting.ParkConnect); cbll.SaveCardAndEvent(entrance.ProcessingCard, cardEvent); RaiseCardEventReporting(cardEvent); entrance.ProcessingEvent = null; } }
private string CardOut(CardBll bll, CardInfo card) { ParkInfo park = this.ucEntrance1.SelectedPark; EntranceInfo entrance = this.ucEntrance1.SelectedEntrance; //手动生成出场事件 CardEventReport report = CardEventReport.CreateExitEvent(card, entrance.ParkID, entrance.EntranceID, entrance.EntranceName, park.WorkMode, card.CarType, TariffSetting.Current, DateTime.Now); report.EventStatus = CardEventStatus.Valid; report.OperatorID = OperatorInfo.CurrentOperator.OperatorName; report.StationID = WorkStationInfo.CurrentStation.StationName; report.UpdateFlag = true;//先标识为已上传 CardInfo origal = card.Clone(); ////卡片出场 //card.ParkingStatus = ParkingStatus.Out; //card.LastDateTime = DateTime.Now; bool offlineHandleCard = AppSettings.CurrentSetting.EnableWriteCard && card != null && !card.OnlineHandleWhenOfflineMode; //CommandResult result = bll.UpdateCardAll(card); CommandResult result = bll.SaveCardAndEvent(card, report); //写卡模式需要将收费信息写入卡片扇区 if (result.Result == ResultCode.Successful && offlineHandleCard) { if (CardOperationManager.Instance.WriteCardLoop(card) != CardOperationResultCode.Success) { //写入失败时,需将数据库卡片状态还原及删除出场事件 bll.UpdateCardAll(origal); (new CardEventBll(AppSettings.CurrentSetting.ParkConnect)).Delete(new CardEventRecord(report)); result = new CommandResult(ResultCode.Fail); } } if (result.Result == ResultCode.Successful) { if (string.IsNullOrEmpty(AppSettings.CurrentSetting.CurrentStandbyConnect)) { //更新到备用数据库 CardBll standbybll = new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect); //standbybll.UpdateCardAll(card); standbybll.SaveCardAndEvent(card, report); } string msg = string.Format("{0}:[{1}] {2}:[{3}]", Resource1.FrmCardOut_CardID, card.CardID, Resource1.FrmCardOut_InDateTime, origal.LastDateTime.ToString("yyyy-MM-dd HH:mm:ss")); //插入卡片直接出场报警记录 AlarmInfo alarm = new AlarmInfo(); alarm.AlarmDateTime = card.LastDateTime; alarm.AlarmType = AlarmType.CardOutAnomaly; alarm.OperatorID = OperatorInfo.CurrentOperator.OperatorName; alarm.AlarmDescr = msg + string.Format(" {0}:[{1}]", Resource1.FrmCardOut_OutReason, this.txtMemo.Text.Trim()); new AlarmBll(AppSettings.CurrentSetting.ParkConnect).Insert(alarm); if (!_OutCardsWitPark.ContainsKey(park)) { _OutCardsWitPark.Add(park, 0); } //该停车场出场卡片数加1 _OutCardsWitPark[park] += 1; this.txtCount.Text = _OutCardsWitPark[park].ToString(); return(msg); } return(result.Message); }