public override bool EventValid(EventValidNotify notify) { EntranceBase entrance = GetEntrance(notify.EntranceID); if (entrance != null && entrance.ProcessingEvent != null) { entrance.Operator = notify.Operator.OperatorName; entrance.Station = notify.Station; if (entrance.ProcessingEvent.IsExitEvent && entrance.ProcessingCard.CardType.IsPrepayCard) //出口事件 { entrance.ProcessingEvent.Balance = entrance.ProcessingEvent.Balance >= notify.Paid ? entrance.ProcessingEvent.Balance - notify.Paid : entrance.ProcessingEvent.Balance; entrance.ProcessingCard.Balance = entrance.ProcessingEvent.Balance; } entrance.CardValid(); if (!entrance.EntranceInfo.CardValidNeedResponse) //设置成事件有效指令不需要硬件返回 { PermitCard(entrance, notify.Operator.OperatorName, notify.Station); //离线模式产生此事件 //if (AppSettings.CurrentSetting.ParkWorkMode == 0 && entrance.ProcessingCard != null) if (WorkMode == ParkWorkMode.OffLine && entrance.ProcessingCard != null) { SaveCard(entrance.ProcessingCard, ActionType.Upate); } } } return(true); }
protected override void OnCardWaiting(OfflineCardReadReport report) { //EntranceBase entrance = GetEntrance(report.EntranceID); //if (entrance == null) return; //CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID); //if (card != null) //{ // //离线模式下,如果硬件记录的时间大于系统记录的时间,表明卡片在软件退出时进出过停车场,所以此时以硬件时间为准 // if (report.LastDateTime != null && report.LastDateTime.Value.Ticks > card.LastDateTime.Ticks) card.LastDateTime = report.LastDateTime.Value; // ProcessCard(entrance, report.Reader, card, report.EventDateTime); //} //else //{ // DenyCard(report.CardID, Ralid.Park.BusinessModel.Enum.EventInvalidType.INV_UnRegister, entrance,null); //} EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } //收到卡片等待确认事件时,如果之前没有收到此卡的事件等待事件,则生成一个卡片事件 if (entrance.ProcessingEvent == null || entrance.ProcessingEvent.CardID != report.CardID) { CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID); if (card != null) { if (report.LastDateTime != null) { card.LastDateTime = report.LastDateTime.Value; } if (entrance.IsExitDevice) { CreateCardExitEvent(card, entrance, report.EventDateTime); } else { CreateCardEnterEvent(card, entrance, report.EventDateTime); } if (entrance.ProcessingEvent != null) { entrance.ProcessingEvent.CarPlate = report.CarPlate; entrance.ProcessingEvent.LastCarPlate = report.LastCarPlate; entrance.ProcessingEvent.ComparisonResult = report.CarPlateComparisonResult; entrance.ProcessingEvent.EventStatus = report.EventStatus; if (entrance.ProcessingEvent.CardPaymentInfo != null) { //这里要将费用设为0,因为收到卡片车牌对比确认事件时,控制板肯定会先判断是否已收费的,所以收到该事件时,费用应为0 entrance.ProcessingEvent.CardPaymentInfo.Accounts = 0; } } } } if (entrance.ProcessingEvent != null && entrance.ProcessingEvent.CardID == report.CardID) { RaiseCardEventReporting(entrance.ProcessingEvent); } }
protected override void UpdateVacant(EntranceBase entrance) { base.UpdateVacant(entrance); //if (AppSettings.CurrentSetting.ParkWorkMode == 0) //离线模式把车位数设置到控制板 if (WorkMode == ParkWorkMode.OffLine) //离线模式把车位数设置到控制板 { (Master as CANEntrance).SetVacant(Park.Vacant); } }
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 != null) { PermitCard(entrance, entrance.Operator, entrance.Station); } }
public override bool EventValid(EventValidNotify notify) { EntranceBase entrance = GetEntrance(notify.EntranceID); if (entrance != null && entrance.ProcessingEvent != null) { entrance.Operator = notify.Operator.OperatorName; entrance.Station = notify.Station; if (entrance.ProcessingEvent.IsExitEvent && entrance.ProcessingCard.CardType.IsPrepayCard) //出口事件 { entrance.ProcessingEvent.Balance = entrance.ProcessingEvent.Balance >= notify.Paid ? entrance.ProcessingEvent.Balance - notify.Paid : entrance.ProcessingEvent.Balance; } entrance.CardValid(); } return(true); }
protected override void OnCommandEchoReporting(CommandEchoReport report) { EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } if (entrance.ProcessingEvent != null) { base.OnCommandEchoReporting(report); //离线模式时,通过远程读卡处理读卡事件采用的是在线模式处理,所以处理完成后要把卡片的信息同步到硬件中 //if (AppSettings.CurrentSetting.ParkWorkMode == 0 && entrance.ProcessingCard != null) if (WorkMode == ParkWorkMode.OffLine && entrance.ProcessingCard != null) { SaveCard(entrance.ProcessingCard, ActionType.Upate); } } }
protected override void OnDeviceResetReporting(DeviceResetReport report) { //收到控制器复位事件后把车位数显示到屏上 EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance != null) { if (report.Address == CanAddress.HostEntrance) { foreach (EntranceBase en in _Entrances) { if (!en.IsExitDevice) { en.ShowVacant(); } } if (_SubParks != null && _SubParks.Count > 0) { foreach (ParkBase sub in _SubParks) { CANPark subPark = sub as CANPark; foreach (EntranceBase en in subPark._Entrances) { if (!en.IsExitDevice && en.EntranceInfo.EnableParkvacantLed) { en.ShowVacant(); } } } } } else if (!entrance.IsExitDevice) { if (entrance.EntranceInfo.EnableParkvacantLed) { entrance.ShowVacant(); } } } base.OnDeviceResetReporting(report); }
/// <summary> /// 更新停车场车位余数 /// </summary> /// <param name="entrance"></param> protected override void UpdateVacant(EntranceBase entrance) { //if (WorkMode == ParkWorkMode.OffLine)//离线模式从主控制板获取车位信息 //{ // if (_Master != null && _Master.Status == EntranceStatus.Ok) // { // ParkParams pp; // if (_Master.ParkDevice.GetParkLots(0, out pp)) // { // unchecked // { // Park.Vacant = (short)pp.ParkVacant; // } // } // } //} //else //{ base.UpdateVacant(entrance); //} }
protected override void OnCardPermitted(OfflineCardReadReport report) { EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } //收到卡片有效事件时,如果之前没有收到此卡的事件等待事件,则生成一个卡片事件 if (entrance.ProcessingEvent == null || entrance.ProcessingEvent.CardID != report.CardID) { CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID); if (card != null) { if (report.LastDateTime != null) { card.LastDateTime = report.LastDateTime.Value; } if (entrance.IsExitDevice) { CreateCardExitEvent(card, entrance, report.EventDateTime); } else { CreateCardEnterEvent(card, entrance, report.EventDateTime); } if (entrance.ProcessingEvent != null) { entrance.ProcessingEvent.CarPlate = report.CarPlate; entrance.ProcessingEvent.LastCarPlate = report.LastCarPlate; entrance.ProcessingEvent.ComparisonResult = report.CarPlateComparisonResult; } } } if (entrance.ProcessingEvent != null && entrance.ProcessingEvent.CardID == report.CardID) { PermitCard(entrance, entrance.Operator, entrance.Station); } }
protected override void OnCardWaiting(OfflineCardReadReport report) { EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID); if (card != null) { //离线模式下,如果硬件记录的时间大于系统记录的时间,表明卡片在软件退出时进出过停车场,所以此时以硬件时间为准 if (report.LastDateTime != null && report.LastDateTime.Value.Ticks > card.LastDateTime.Ticks) { card.LastDateTime = report.LastDateTime.Value; } if (entrance.IsExitDevice) { CreateCardExitEvent(card, entrance, report.EventDateTime); if (card.CardType.IsTempCard || card.CardType.IsPrepayCard) { entrance.CardWait(); //储值卡和临时卡重新播放费用 } } else { CreateCardEnterEvent(card, entrance, report.EventDateTime); } RaiseCardEventReporting(entrance.ProcessingEvent); } else { DenyCard(report.CardID, report.CarPlate, null, report.CardType, report.Reader, EventInvalidType.INV_UnRegister, entrance, null); } }
public override bool UpdateEntrance(EntranceInfo info) { if (info.ParkID == this.Park.ParkID) { EntranceBase entrance = GetEntrance(info.EntranceID); if (entrance != null) { entrance.EntranceInfo = info; (entrance as CANEntrance).SyncToHardware(); return(true); } } else { foreach (CANPark subPark in _SubParks) { if (info.ParkID == subPark.Park.ParkID) { return(subPark.UpdateEntrance(info)); } } } return(false); }
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; } }
protected override void OnCardCaptureReporting(CardCaptureReport report) { EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } RaiseCardCaptureReporting(report); if (entrance.ProcessingEvent != null && entrance.ProcessingEvent.CardType.IsTempCard) { if (UserSetting.Current.EnableCarPlateRecognize) { CarPlateHandler(entrance, entrance.ProcessingEvent, entrance.ProcessingCard); } //如果启用车牌识别,且出入口车牌对比失败, if (entrance.ProcessingEvent.EventStatus == CardEventStatus.CarPlateFail) { entrance.DisplayMsg(CardInvalidDescripition.GetDescription(Ralid.Park.BusinessModel.Enum.EventInvalidType.INV_CarPlateWrong), false); //(entrance as NetEntrance).ParkDevice.Speak(DeviceVoice.eAUDIO_CPBF); //(entrance as NetEntrance).ParkDevice.Speak(DeviceVoice.eAUDIO_ZZQRQSH); entrance.CardWait(); RaiseCardEventReporting(entrance.ProcessingEvent); return; } else { entrance.CardValid(); if (!entrance.EntranceInfo.CardValidNeedResponse) { PermitCard(entrance, entrance.Operator, entrance.Station); } } } }
protected override void OnCardWaiting(OfflineCardReadReport report) { //EntranceBase entrance = GetEntrance(report.EntranceID); //if (entrance == null) return; //CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID); //if (card != null) //{ // //离线模式下,如果硬件记录的时间大于系统记录的时间,表明卡片在软件退出时进出过停车场,所以此时以硬件时间为准 // if (report.LastDateTime != null && report.LastDateTime.Value.Ticks > card.LastDateTime.Ticks) card.LastDateTime = report.LastDateTime.Value; // ProcessCard(entrance, report.Reader, card, report.EventDateTime); //} //else //{ // DenyCard(report.CardID, Ralid.Park.BusinessModel.Enum.EventInvalidType.INV_UnRegister, entrance,null); //} EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } //收到卡片等待事件时,如果之前没有收到此卡的事件等待事件,则生成一个卡片事件 if (entrance.ProcessingEvent == null || entrance.ProcessingEvent.CardID != report.CardID) { CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID, AppSettings.CurrentSetting.CurrentStandbyConnect); if (card != null) { //卡片信息以硬件上传信息为准 if (report.LastDateTime != null) { card.LastDateTime = report.LastDateTime.Value; } card.RegCarPlate = report.CarPlate; card.LastCarPlate = report.LastCarPlate; if (entrance.IsExitDevice) { CreateCardExitEvent(card, entrance, report.EventDateTime); } else { CreateCardEnterEvent(card, entrance, report.EventDateTime); } } } if (entrance.ProcessingEvent != null && entrance.ProcessingEvent.CardID == report.CardID) { //如果正在处理的事件的读头与上传事件的读头不一致,将正在处理的事件的读头设置为上传事件的读头 if (entrance.ProcessingEvent.Reader != report.Reader) { entrance.ProcessingEvent.Reader = report.Reader; } //当事件车牌对比结果为车牌对比失败,而软件又启用了软件车牌识别的,使用软件识别重新进行车牌识别对比 //这是因为当控制板没有安装硬件车牌识别一体机时,默认返回对比结果为对比失败 if (report.EventStatus == CardEventStatus.CarPlateFail && UserSetting.Current.EnableCarPlateRecognize && UserSetting.Current.SoftWareCarPlateRecognize) { CarPlateHandler(entrance, entrance.ProcessingEvent, entrance.ProcessingCard); } else { entrance.ProcessingEvent.CarPlate = report.CarPlate; entrance.ProcessingEvent.ComparisonResult = report.CarPlateComparisonResult; entrance.ProcessingEvent.EventStatus = report.EventStatus; } entrance.ProcessingEvent.LastCarPlate = report.LastCarPlate; if (entrance.ProcessingEvent.CardPaymentInfo != null) { //这里要将费用设为0,因为收到卡片车牌对比确认事件或事件有效时,控制板肯定会先判断是否已收费的,所以收到该事件时,费用应为0 entrance.ProcessingEvent.CardPaymentInfo.Accounts = 0; } if (report.EventStatus == CardEventStatus.CarPlateFail) { //如果收到的刷卡事件状态为对比失败,需要确认或放行 if (entrance.ProcessingEvent.EventStatus == CardEventStatus.CarPlateFail) { //上位机确认 RaiseCardEventReporting(entrance.ProcessingEvent); } else { //如果处理的事件状态为非对比失败,而收到的刷卡事件状态为对比失败,说明了系统启用了软件识别,并且对比成功了,可放行卡片 entrance.CardValid(); } } } }
//private void SyncTime_Thread() //{ // while (true) // { // Thread.Sleep(5 * 60 * 1000); // try // { // foreach (EntranceBase entrance in _Entrances) // { // entrance.SyncTime(); // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // } // } //} private void ExecuteWaitingCommand_Thread() { try { ClearInvalidWaitingCommand();//清除已删除的控制器的等待命令 Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); while (true) { try { if (!_WaitingCommandPause && DataBaseConnectionsManager.Current.MasterConnected) { WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); List <WaitingCommandInfo> wcs = wb.GetAllCommands().QueryObjects; EntranceBase entrance = null; int entranceID = -1; foreach (var wc in wcs) { if (entranceID != wc.EntranceID) { entrance = GetEntrance(wc.EntranceID); entranceID = wc.EntranceID; } if (entrance != null) { bool ret = false; if (wc.Command == CommandType.DownloadAccesses) { ret = entrance.ApplyAccessSetting(AccessSetting.Current); } else if (wc.Command == CommandType.DownloadHolidays) { ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); } else if (wc.Command == CommandType.DownloadTariffs) { ret = entrance.ApplyTariffSetting(TariffSetting.Current); } else if (wc.Command == CommandType.ClearCard) { ret = entrance.ClearCard(); } else if (wc.Command == CommandType.DeleteCard) { CardInfo card = new CardInfo(); card.CardID = wc.CardID; ret = entrance.SaveCard(card, ActionType.Delete); } else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) { CardBll cb = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; if (card != null) { ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate, false); } else { ret = true; } } if (ret) { CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); if (DataBaseConnectionsManager.Current.MasterConnected) { dresult = wb.Delete(wc); } if (AppSettings.CurrentSetting.Debug) { if (dresult.Result == ResultCode.Successful) { string msg = string.Format("控制器{0}[{1}] 命令 {2} {3} 成功,删除命令 {4}", entrance.EntranceName, entrance.EntranceID, wc.Command, wc.CardID, dresult.Result == ResultCode.Successful ? "成功" : dresult.Result.ToString()); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", msg); } } } } } } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); } Thread.Sleep(60 * 1000); } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); } }
protected override void OnCardWaiting(OfflineCardReadReport report) { //EntranceBase entrance = GetEntrance(report.EntranceID); //if (entrance == null) return; //CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID); //if (card != null) //{ // //离线模式下,如果硬件记录的时间大于系统记录的时间,表明卡片在软件退出时进出过停车场,所以此时以硬件时间为准 // if (report.LastDateTime != null && report.LastDateTime.Value.Ticks > card.LastDateTime.Ticks) card.LastDateTime = report.LastDateTime.Value; // ProcessCard(entrance, report.Reader, card, report.EventDateTime); //} //else //{ // DenyCard(report.CardID, Ralid.Park.BusinessModel.Enum.EventInvalidType.INV_UnRegister, entrance,null); //} EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } //收到卡片等待事件时,如果之前没有收到此卡的事件等待事件,则生成一个卡片事件 if (entrance.ProcessingEvent == null || entrance.ProcessingEvent.CardID != report.CardID) { CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardDetail(report.CardID, AppSettings.CurrentSetting.CurrentStandbyConnect); if (card != null) { //卡片信息以硬件上传信息为准 //不是远距离读卡的,如果有上一次读卡时间,以硬件上传的上一次读卡时间为准 if (report.Reader != EntranceReader.Reader2 && report.LastDateTime != null) { card.LastDateTime = report.LastDateTime.Value; } //modify by Jan 2014-08-19 当启用硬件识别时,以硬件上传的为准 if (UserSetting.Current.EnableCarPlateRecognize && UserSetting.Current.HardWareCarPlateRecognize) { card.RegCarPlate = report.CarPlate; card.LastCarPlate = report.LastCarPlate; } if (entrance.IsExitDevice) { CreateCardExitEvent(card, entrance, report.EventDateTime); } else { CreateCardEnterEvent(card, entrance, report.EventDateTime); } } else { string description = string.Format("未找到脱机卡片{0}", report.CardID); //提示找不到脱机卡片 AlarmReport alarm = new AlarmReport( this.Park.ParkID, entrance.EntranceID, DateTime.Now, entrance.EntranceName, AlarmType.InvalidCard, description, string.Empty); RaiseAlarmReporting(alarm); } } if (entrance.ProcessingEvent != null && entrance.ProcessingEvent.CardID == report.CardID) { //如果正在处理的事件的读头与上传事件的读头不一致,将正在处理的事件的读头设置为上传事件的读头 if (entrance.ProcessingEvent.Reader != report.Reader) { entrance.ProcessingEvent.Reader = report.Reader; } entrance.ProcessingEvent.ComparisonResult = report.CarPlateComparisonResult; entrance.ProcessingEvent.EventStatus = report.EventStatus; ////当事件车牌对比结果为车牌对比失败,而软件又启用了软件车牌识别的,使用软件识别重新进行车牌识别对比 ////这是因为当控制板没有安装硬件车牌识别一体机时,默认返回对比结果为对比失败 //if (((report.EventStatus == CardEventStatus.CarPlateFail)||(report.CarPlateComparisonResult== BusinessModel.Enum.CarPlateComparisonResult.Noncontrastive)) // && UserSetting.Current.EnableCarPlateRecognize // && UserSetting.Current.SoftWareCarPlateRecognize) //modify by Jan 2014-08-19 当启用车牌识别时 if (UserSetting.Current.EnableCarPlateRecognize) { //当启用软件识别时,忽略控制板上传的识别结果,使用软件识别重新进行车牌识别对比 if (UserSetting.Current.SoftWareCarPlateRecognize) { //add by Jan 2014-09-01 如果当前状态为车牌对比失败,对比前需设置为等待处理状态和对比成功 if (entrance.ProcessingEvent.EventStatus == CardEventStatus.CarPlateFail) { entrance.ProcessingEvent.ComparisonResult = BusinessModel.Enum.CarPlateComparisonResult.Success; entrance.ProcessingEvent.EventStatus = CardEventStatus.Pending; } CarPlateHandler(entrance, entrance.ProcessingEvent, entrance.ProcessingCard); } else { //当启用硬件识别时,以控制板上传的结果为准 entrance.ProcessingEvent.CarPlate = report.CarPlate; entrance.ProcessingEvent.LastCarPlate = report.LastCarPlate; } } if (entrance.ProcessingEvent.CardPaymentInfo != null && !report.NeedPay) { //不需要收费时,将费用设为0,因为收到卡片车牌对比确认事件或事件有效时,控制板肯定会先判断是否已收费的,所以收到该事件时,费用应为0 entrance.ProcessingEvent.CardPaymentInfo.Accounts = 0; } if (report.EventStatus == CardEventStatus.CarPlateFail) { //如果收到的刷卡事件状态为对比失败,需要确认或放行 if (entrance.ProcessingEvent.EventStatus == CardEventStatus.CarPlateFail) { //上位机确认 RaiseCardEventReporting(entrance.ProcessingEvent); } else { //如果处理的事件状态为非对比失败,而收到的刷卡事件状态为对比失败,说明了系统启用了软件识别,并且对比成功了,可放行卡片 entrance.CardValid(); } } //这里不上传到上位机,是因为当需要收费时,上位机的收费窗口也可以进行收费处理,但收费窗口是没有卡片的,所以是写不了卡的 //else //{ // RaiseCardEventReporting(entrance.ProcessingEvent); //} } }
private void ExecuteWaitingCommand_Thread() { ClearInvalidWaitingCommand();//清除已删除的控制器的等待命令 WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); while (true) { List <WaitingCommandInfo> wcs = wb.GetAllCommands().QueryObjects; EntranceBase entrance = null; int entranceID = -1; foreach (var wc in wcs) { if (entranceID != wc.EntranceID) { entrance = GetEntrance(wc.EntranceID); entranceID = wc.EntranceID; } if (entrance != null) { bool ret = false; if (wc.Command == CommandType.DownloadAccesses) { ret = entrance.ApplyAccessSetting(AccessSetting.Current); } else if (wc.Command == CommandType.DownloadHolidays) { ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); } else if (wc.Command == CommandType.DownloadTariffs) { ret = entrance.ApplyTariffSetting(TariffSetting.Current); } else if (wc.Command == CommandType.ClearCard) { ret = entrance.ClearCard(); } else if (wc.Command == CommandType.DeleteCard) { CardInfo card = new CardInfo(); card.CardID = wc.CardID; ret = entrance.DeleteCard(card); } else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) { CardBll cb = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; if (card != null) { ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate); } else { ret = true; } } if (ret) { wb.Delete(wc); } } } Thread.Sleep(60 * 1000); } }
//private void SyncTime_Thread() //{ // while (true) // { // Thread.Sleep(5 * 60 * 1000); // try // { // foreach (EntranceBase entrance in _Entrances) // { // entrance.SyncTime(); // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // } // } //} //private void ExecuteWaitingCommand_Thread() //{ // try // { // ClearInvalidWaitingCommand();//清除已删除的控制器的等待命令 // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); // while (true) // { // try // { // if (!_WaitingCommandPause && DataBaseConnectionsManager.Current.MasterConnected) // { // WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); // List<WaitingCommandInfo> wcs = wb.GetAllCommands().QueryObjects; // EntranceBase entrance = null; // int entranceID = -1; // foreach (var wc in wcs) // { // if (entranceID != wc.EntranceID) // { // entrance = GetEntrance(wc.EntranceID); // entranceID = wc.EntranceID; // } // if (entrance != null) // { // bool ret = false; // if (wc.Command == CommandType.DownloadAccesses) // { // ret = entrance.ApplyAccessSetting(AccessSetting.Current); // } // else if (wc.Command == CommandType.DownloadHolidays) // { // ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); // } // else if (wc.Command == CommandType.DownloadTariffs) // { // ret = entrance.ApplyTariffSetting(TariffSetting.Current); // } // else if (wc.Command == CommandType.ClearCard) // { // ret = entrance.ClearCard(); // } // else if (wc.Command == CommandType.DeleteCard) // { // CardInfo card = new CardInfo(); // card.CardID = wc.CardID; // ret = entrance.SaveCard(card, ActionType.Delete); // } // else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) // { // CardBll cb = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); // CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; // if (card != null) // { // ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate, false); // } // else // { // ret = true; // } // } // if (ret) // { // CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); // if (DataBaseConnectionsManager.Current.MasterConnected) // { // dresult = wb.Delete(wc); // } // if (AppSettings.CurrentSetting.Debug) // { // if (dresult.Result == ResultCode.Successful) // { // string msg = string.Format("控制器{0}[{1}] 命令 {2} {3} 成功,删除命令 {4}", entrance.EntranceName, entrance.EntranceID, wc.Command, wc.CardID, dresult.Result == ResultCode.Successful ? "成功" : dresult.Result.ToString()); // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", msg); // } // } // } // } // } // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); // } // Thread.Sleep(60 * 1000); // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); // } //} private void ExecuteWaitingCommand_Thread() { try { //开始前先等待10分钟,用于等待硬件设备连接状态检测完成 Thread.Sleep(10 * 60 * 1000); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); while (true) { try { if (!_WaitingCommandPause && DataBaseConnectionsManager.Current.MasterConnected) { WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); List <WaitingCommandInfo> wcs = wb.GetWaitingCommands().QueryObjects; EntranceBase entrance = null; int entranceID = -1; foreach (var wc in wcs) { if (entranceID != wc.EntranceID) { entrance = GetEntrance(wc.EntranceID); entranceID = wc.EntranceID; } if (entrance != null && entrance.Status != EntranceStatus.OffLine) { bool ret = false; if (wc.Command == CommandType.DownloadAccesses) { ret = entrance.ApplyAccessSetting(AccessSetting.Current); } else if (wc.Command == CommandType.DownloadHolidays) { ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); } else if (wc.Command == CommandType.DownloadTariffs) { ret = entrance.ApplyTariffSetting(TariffSetting.Current); } else if (wc.Command == CommandType.DownloadKeySetting) { ret = entrance.ApplyKeySetting(KeySetting.Current); } else if (wc.Command == CommandType.ClearCard) { ret = entrance.ClearCard(); } else if (wc.Command == CommandType.DeleteCard) { //由于命令执行前已删除了卡片信息,所以如果是车牌名单时,cardid保存的是车牌名单的车牌号 CardInfo card = new CardInfo(); card.ListType = wc.CardIDType.HasValue && wc.CardIDType.Value == 1 ? CardListType.CarPlate : CardListType.Card; if (card.IsCardList) { card.CardID = wc.CardID; } else { card.CarPlate = wc.CardID; } ret = entrance.SaveCard(card, ActionType.Delete); } else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) { CardBll cb = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; if (card != null) { ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate); } else { ret = true; } } if (ret) { CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); if (DataBaseConnectionsManager.Current.MasterConnected) { dresult = wb.Delete(wc); } if (AppSettings.CurrentSetting.Debug) { if (dresult.Result == ResultCode.Successful) { string msg = string.Format("控制器{0}[{1}] 命令 {2} {3} 成功,删除命令 {4}", entrance.EntranceName, entrance.EntranceID, wc.Command, wc.CardID, dresult.Result == ResultCode.Successful ? "成功" : dresult.Result.ToString()); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", msg); } } } else { CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); if (DataBaseConnectionsManager.Current.MasterConnected) { wc.Status = WaitingCommandStatus.Fail; dresult = wb.Update(wc); } } } } } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } Thread.Sleep(5 * 60 * 1000); } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "WaitingCommand服务异常终止"); } }