Пример #1
0
        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);
            }
        }
Пример #2
0
 protected virtual void OnCardPermittedReporting(OfflineCardReadReport report)
 {
     if (this.CardPermittedReporting != null)
     {
         this.CardPermittedReporting(this, report);
     }
 }
Пример #3
0
        private ReportBase DeformatCardPermitedPacket(Packet packet)
        {
            //已经确认的事件
            //格式:事件序列号(4byte)+口地址(1byte)+上次地址(1byte)+事件状态(1byte)+停车状态(1byte)+事件参数(1byte)+发生卡内码(4byte)+
            //发生日期时间秒分时日月年(6byte)+操作员编号(1byte)+ 交易金额(2byte)+储值卡余额(4byte)+CRC
            OfflineCardReadReport report = new OfflineCardReadReport();

            report.Address       = packet.ReadByteFromParameter(4);
            report.CardID        = ((uint)SEBinaryConverter.BytesToInt(packet.ReadDataFromParameter(9, 4))).ToString();
            report.EventStatus   = CardEventStatus.Valid;
            report.EventDateTime = BytesToDateTime(packet.ReadDataFromParameter(13, 6));
            return(report);
        }
Пример #4
0
        private ReportBase DeformatCardWaitingPacket(Packet packet)
        {
            //正在等待处理的事件
            //口地址[1]+上次地址[1]+事件状态[1]+停车状态[1]+事件参数[1]+发生卡内码[4]+上次动作日期时间秒分时日月年[6]+发生日期时间秒分时日月年[6]+
            //操作员编号[1]+小数点位数[1]+交易金额[2]+储值卡余额[4]
            OfflineCardReadReport report = new OfflineCardReadReport();

            report.Address       = packet.ReadByteFromParameter(0);
            report.CardID        = ((uint)SEBinaryConverter.BytesToInt(packet.ReadDataFromParameter(5, 4))).ToString();
            report.EventStatus   = CardEventStatus.Pending;
            report.LastDateTime  = BytesToDateTime(packet.ReadDataFromParameter(9, 6));
            report.EventDateTime = BytesToDateTime(packet.ReadDataFromParameter(15, 6));
            return(report);
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
        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;
            }
        }
Пример #9
0
        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();
                    }
                }
            }
        }
Пример #10
0
 private void CardPermitedHandler(OfflineCardReadReport report)
 {
     OnCardPermittedReporting(report);
 }
Пример #11
0
 private void CardWaitingHandler(OfflineCardReadReport report)
 {
     OnCardWaitReporting(report);
 }
Пример #12
0
 private void ReportHandler(ReportBase report)
 {
     try
     {
         if (report is EntranceStatusReport)
         {
             OnStatusChangedReporting(report as EntranceStatusReport);
         }
         else if (report is DeviceResetReport)
         {
             OnDeviceResetReporting(report as DeviceResetReport);
         }
         else if (report is CarSenseReport)
         {
             CarSenseHandler(report as CarSenseReport);
         }
         else if (report is ButtonClickedReport)
         {
             CardButtonHandler(report as ButtonClickedReport);
         }
         else if (report is CardTakeoutReport)
         {
             OnTakeoutCardReporting(report as CardTakeoutReport);
         }
         else if (report is CardCaptureReport)
         {
             CardCaptureHandler(report as CardCaptureReport);
         }
         else if (report is CardReadReport)
         {
             CardReadReportHandler(report as CardReadReport);
         }
         else if (report is ParkVacantReport)
         {
             ParkVacantHandler(report as ParkVacantReport);
         }
         else if (report is CarplateRecReport)
         {
             CarplateRecHandler(report as CarplateRecReport);
         }
         else if (report is OfflineCardReadReport)
         {
             OfflineCardReadReport cer = report as OfflineCardReadReport;
             if (cer.EventStatus == CardEventStatus.CarPlateFail)
             {
                 CardWaitingHandler(cer);
             }
             else if (cer.EventStatus == CardEventStatus.Valid)
             {
                 CardPermitedHandler(cer);
             }
         }
         else if (report is CardInvalidEventReport)
         {
             CardInvalidHandler(report as CardInvalidEventReport);
         }
         else if (report is CommandEchoReport)
         {
             CommandEchoHandler(report as CommandEchoReport);
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
 }
Пример #13
0
        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);
                //}
            }
        }