Esempio n. 1
0
        private void HandlePayingRequst(LJHSocket socket, YiTingPacket packet)
        {
            if (Setting == null)
            {
                return;
            }
            byte[] data = packet.Data;
            if (data == null || data.Length < 26)
            {
                return;
            }
            OpenCardEventArgs args = new OpenCardEventArgs()
            {
                CardID   = YiTingPacket.GetCardID(data.Take(19).ToArray()),
                CardType = data[19] == 0x01 ? YiTingShanFuSetting.CardType : string.Empty,
            };
            string    device = YiTingPacket.ConvertToAsc(new byte[] { data[20], data[21], data[22], data[23], data[24], data[25] });
            YiTingPOS pos    = Setting.GetReader(device);

            if (pos != null && pos.EntranceID.HasValue)
            {
                args.Entrance = ParkBuffer.Current.GetEntrance(pos.EntranceID.Value);
            }
            if (this.OnPaying != null)
            {
                this.OnPaying(this, args);
            }

            if (args.Payment != null)
            {
                if (args.Payment.GetPaying() == 0)
                {
                    args.Payment.PaymentCode = Park.BusinessModel.Enum.PaymentCode.Computer;
                    args.Payment.PaymentMode = Park.BusinessModel.Enum.PaymentMode.Pos;
                    if (this.OnPaidOk != null)
                    {
                        this.OnPaidOk(this, args);
                    }
                }
                else
                {
                    lock (_WaitingPayingCardsLocker)
                    {
                        _WaitingPayingCards[args.CardID] = args; //保存某个读卡器目前正在处理的收费记录
                    }
                    List <byte> temp = new List <byte>();
                    temp.AddRange(data.Take(26));                                               //取包的前26字节
                    temp.AddRange(new byte[5]);                                                 //车位号
                    temp.AddRange(YiTingPacket.GetDateBytes(args.Payment.EnterDateTime.Value)); //入场时间
                    temp.AddRange(YiTingPacket.GetIntervalBytes(args.Payment.EnterDateTime.Value, args.Payment.ChargeDateTime));
                    temp.AddRange(YiTingPacket.GetMoneyBytes(args.Payment.GetPaying()));        //金额
                    temp.Add(0x00);                                                             //未出场
                    YiTingPacket response = packet.CreateResponse(temp.ToArray());
                    byte[]       r        = response.ToBytes();
                    socket.SendData(r);
                    Ralid.GeneralLibrary.LOG.FileLog.Log("驿停闪付", "回复扣款 " + Ralid.GeneralLibrary.HexStringConverter.HexToString(r, " "));
                }
            }
        }
Esempio n. 2
0
        private void HandleEnterRead(LJHSocket socket, YiTingPacket packet)
        {
            if (Setting == null)
            {
                return;
            }
            byte[] data = packet.Data;
            if (data == null || data.Length < 26)
            {
                return;
            }
            OpenCardEventArgs args = new OpenCardEventArgs()
            {
                CardID   = YiTingPacket.GetCardID(data.Take(19).ToArray()),
                CardType = data[19] == 0x01 ? YiTingShanFuSetting.CardType : string.Empty,
            };
            string    device = YiTingPacket.ConvertToAsc(new byte[] { data[20], data[21], data[22], data[23], data[24], data[25] });
            YiTingPOS pos    = Setting.GetReader(device);

            if (pos != null && pos.EntranceID.HasValue)
            {
                args.Entrance = ParkBuffer.Current.GetEntrance(pos.EntranceID.Value);
            }
            if (this.OnReadCard != null)
            {
                this.OnReadCard(this, args);
            }

            List <byte> temp = new List <byte>();

            temp.AddRange(data);
            byte[] carPlate = UnicodeEncoding.Unicode.GetBytes("粤A24M55");
            byte[] t        = new byte[27];
            Array.Copy(carPlate, t, carPlate.Length);
            temp.AddRange(t);
            temp.AddRange(new byte[2]);
            temp.AddRange(YiTingPacket.GetDateBytes(DateTime.Now));
            temp.Add(_OK);
            YiTingPacket response = packet.CreateResponse(temp.ToArray());

            byte[] r = response.ToBytes();
            socket.SendData(r);
            Ralid.GeneralLibrary.LOG.FileLog.Log("驿停闪付", "回复读卡 " + Ralid.GeneralLibrary.HexStringConverter.HexToString(r, " "));
        }