Esempio n. 1
0
        private GetCardInfoResponse GetCardInfoFromReader(CardSearchResponse r)
        {
            int           n        = -1;
            StringBuilder response = new StringBuilder(3000);

            if (UseInGD)
            {
                n = ETCInterop.GetCardInfo_GD(int.Parse(LaneNo), JsonConvert.SerializeObject(new { UserName = UserName, CardNo = r.CardNo, ReaderID = EcReaderID }), response);
            }
            else
            {
                n = ETCInterop.GetCardInfo(int.Parse(LaneNo), JsonConvert.SerializeObject(new { UserName = UserName, CardNo = r.CardNo, ReaderID = EcReaderID }), response);
            }
            if (n != 0)
            {
                return new GetCardInfoResponse()
                       {
                           ErrorCode = n
                       }
            }
            ;
            var ret = JsonConvert.DeserializeObject <GetCardInfoResponse>(response.ToString());

            ret.Content = response.ToString();
            ret.CardNo  = r.CardNo; //由于返回的串中没有这个属性,所以这里设置进去
            return(ret);
        }
Esempio n. 2
0
 public bool Init()
 {
     try
     {
         ETCDevices = null;
         StringBuilder pRet  = new StringBuilder(100 * 1000);
         StringBuilder err   = new StringBuilder(1000);
         int           count = 0;
         var           n     = ETCInterop.Initialize(pRet, ref count, err);
         if (n != 0)
         {
             return(false);
         }
         if (n == 0 && count > 0)
         {
             var str = pRet.ToString().Trim();
             ETCDevices = JsonConvert.DeserializeObject <ETCDevice[]>(str);
             if (ETCDevices != null && ETCDevices.Length > 0)
             {
                 foreach (var device in ETCDevices)
                 {
                     //device.IsExit = true;
                     device.Init();
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     return(false);
 }
Esempio n. 3
0
        private ETCResponse ListUpLoad(ETCPaymentRecord record)
        {
            StringBuilder response = new StringBuilder(100);
            var           request  = new
            {
                UserName      = UserName,
                ProvinceNo    = ProvinceNo,
                CityNo        = CityNo,
                ListType      = record.ListType.ToString(),
                ListNo        = record.ListNo,
                KeyServiceNo  = record.KeyServiceNo,
                TradeType     = record.TradeType.ToString(),
                TermCode      = record.TermCode,
                TermTradeNo   = record.TermTradeNo,
                CardTradeNo   = record.CardTradeNo,
                Tac           = record.Tac,
                OBUID         = record.OBUID == null ? string.Empty : record.OBUID,
                OBUNO         = record.OBUNO == null ? string.Empty : record.OBUNO,
                CardNo        = record.CardNo,
                CashMoney     = record.CashMoney.ToString(),
                Balance       = record.Balance.ToString(),
                TradeDevice   = record.TradeDevice.ToString(),
                VehPicture    = record.VehPicture,
                VehPictureLen = record.VehPictureLen.ToString(),
                SquadDate     = record.SquadDate,
                ShiftID       = record.ShiftID,
                ExTime        = record.ExTime,
                ExAreaNo      = record.ExAreaNo,
                ExGateNo      = record.ExGateNo,
                ExLaneNo      = record.ExLaneNo,
                ExOperatorNo  = record.ExOperatorNo,
                ExVehPlate    = record.ExVehPlate,
                ExVehType     = record.ExVehType,
                ExVehClass    = record.ExVehClass,
                EnTime        = record.EnTime,
                EnOperatorNo  = record.EnOperatorNo,
                EnAreaNo      = record.EnAreaNo,
                EnGateNo      = record.EnGateNo,
                EnLaneNo      = record.EnLaneNo,
                EnVehPlate    = record.EnVehPlate,
                EnVehType     = record.EnVehType,
                EnVehClass    = record.EnVehClass,
            };
            var n = ETCInterop.ListUpLoad(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);

            if (n != 0)
            {
                return new ETCResponse()
                       {
                           ErrorCode = n
                       }
            }
            ;
            var ret = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());

            ret.Content = response.ToString();
            return(ret);
        }
Esempio n. 4
0
        /// <summary>
        /// 上传扣费流水
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        public ETCResponse ListUpLoad(ETCPaymentList record)
        {
            int           plen     = 1000;
            StringBuilder response = new StringBuilder(plen);
            var           request  = new
            {
                ListType      = record.ListType.ToString(),
                ListNo        = record.ListNo,
                KeyServiceNo  = record.KeyServiceNo,
                TradeType     = record.TradeType.ToString(),
                TermCode      = record.TermCode,
                TermTradeNo   = record.TermTradeNo,
                CardTradeNo   = record.CardTradeNo,
                Tac           = record.Tac,
                OBUID         = record.OBUID == null ? string.Empty : record.OBUID,
                OBUNO         = record.OBUNO == null ? string.Empty : record.OBUNO,
                CardNo        = record.CardNo,
                CashMoney     = record.CashMoney.ToString(),
                Balance       = record.Balance.ToString(),
                TradeDevice   = record.TradeDevice.ToString(),
                VehPicture    = record.VehPicture,
                VehPictureLen = record.VehPictureLen.ToString(),
                SquadDate     = record.SquadDate,
                ShiftID       = record.ShiftID,
                ExTime        = record.ExTime,
                ExAreaNo      = record.ExAreaNo,
                ExGateNo      = record.ExGateNo,
                ExLaneNo      = record.ExLaneNo,
                ExOperatorNo  = record.ExOperatorNo,
                ExVehPlate    = record.ExVehPlate,
                ExVehType     = record.ExVehType,
                ExVehClass    = record.ExVehClass,
                EnTime        = record.EnTime,
                EnOperatorNo  = record.EnOperatorNo,
                EnAreaNo      = record.EnAreaNo,
                EnGateNo      = record.EnGateNo,
                EnLaneNo      = record.EnLaneNo,
                EnVehPlate    = record.EnVehPlate,
                EnVehType     = record.EnVehType,
                EnVehClass    = record.EnVehClass,
            };
            var strReq = JsonConvert.SerializeObject(request);
            var n      = ETCInterop.ListUpLoad(int.Parse(LaneNo), strReq, response, ref plen);

            if (n != 0)
            {
                Ralid.GeneralLibrary.LOG.FileLog.Log("未成功上传流水" + LaneNo.ToString(), strReq);
                return(new ETCResponse()
                {
                    ErrorCode = n
                });
            }
            var ret = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());

            ret.Content = response.ToString();
            return(ret);
        }
Esempio n. 5
0
        /// <summary>
        /// 进行天线扣款操作
        /// </summary>
        /// <param name="money"></param>
        /// <returns></returns>
        public WriteCardResponse RSUWrite(GetOBUInfoResponse r, int money, bool isExit, out ETCPaymentList record)
        {
            int n = -1;

            record = null;
            WriteCardResponse ret  = null;
            int           plen     = 3000;
            StringBuilder response = new StringBuilder(plen);
            var           request  = new
            {
                OBUID           = r.OBUID,
                OBUNO           = r.OBUNO,
                CardNo          = r.CardNo,
                CashMoney       = money.ToString(), //如果不改成字符串格式,会报错
                CardAreaNo      = AreaNo,
                CardGateNo      = GateNo.PadLeft(4, '0'),
                CardLaneNo      = LaneNo.PadLeft(4, '0'),
                PassTime        = DateTime.Now.ToString("yyyyMMddHHmmss"),
                VehPlate        = r.CardPlate,
                VehType         = r.CardVehClass,
                VehClass        = r.CardVehUserType,
                OutFlag         = isExit ? "1" : "0",
                OperatorNo      = "ffff",
                LittleGateNo    = r.LittleGateNo,
                LittleLaneNo    = r.LittleLaneNo,
                LittlePassTime  = r.LittlePassTime,
                LittleCashMoney = r.LittleCashMoney,
                LittleTime      = r.LittleTime,
                OfferType       = r.OfferType,
                OfferTime       = r.OfferTime,
                BackUp          = r.BackUp == null ? string.Empty : r.BackUp, //不能传NULL,
                CheckCode       = r.CheckCode,
            };

            n = ETCInterop.RSUWrite(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response, ref plen);
            if (n != 0)
            {
                return new WriteCardResponse()
                       {
                           ErrorCode = n
                       }
            }
            ;
            ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
            ret.Content = response.ToString();
            if (ret.ErrorCode == 0)
            {
                ret.CashMoney = money; //这两个属性返回串中没有,人为加上去,后面有用!

                ret.Balance = r.Balance - money;
                record      = CreateRecord(r, ret, isExit);
            }
            return(ret);
        }
Esempio n. 6
0
        private void Disconnect()
        {
            StringBuilder response = new StringBuilder(3000);
            var           request  = new
            {
                UserName   = UserName,
                ProvinceNo = ProvinceNo,
                CityNo     = CityNo,
                AreaNo     = AreaNo,
                GateNo     = GateNo,
                LaneNo     = LaneNo
            };

            ETCInterop.LaneQuit(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
            ETCInterop.quitserver(int.Parse(LaneNo));
        }
Esempio n. 7
0
 public void Dispose()
 {
     if (_UploadList != null)
     {
         _UploadList.Abort();
         _UploadList = null;
     }
     if (_Devices != null && _Devices.Count > 0)
     {
         foreach (var device in _Devices)
         {
             device.Dispose();
         }
     }
     ETCInterop.Uninit();
 }
Esempio n. 8
0
        private OBUSearchResponse OBUSearch()
        {
            StringBuilder response = new StringBuilder(100);
            var           n        = ETCInterop.OBUSearch(int.Parse(LaneNo), JsonConvert.SerializeObject(new { UserName = UserName, RSUID = EcRSUID, TimeOut = "2000" }), response);

            if (n != 0)
            {
                return new OBUSearchResponse {
                           ErrorCode = n
                }
            }
            ;
            var ret = JsonConvert.DeserializeObject <OBUSearchResponse>(response.ToString());

            ret.Content = response.ToString();
            return(ret);
        }
Esempio n. 9
0
        private ETCResponse CardReaderOpenClose()
        {
            StringBuilder response = new StringBuilder(100);
            var           n        = ETCInterop.CardReaderClose(int.Parse(LaneNo), JsonConvert.SerializeObject(new { UserName = UserName, ReaderID = EcReaderID }), response);

            if (n != 0)
            {
                return new ETCResponse()
                       {
                           ErrorCode = n
                       }
            }
            ;
            var ret = JsonConvert.DeserializeObject <ETCResponse>(response.ToString());

            ret.Content = response.ToString();
            return(ret);
        }
Esempio n. 10
0
 /// <summary>
 /// 获取所有的ETC设备
 /// </summary>
 /// <returns></returns>
 public static ETCDeviceInfo[] GetAllDevices()
 {
     try
     {
         int           plen = 100 * 1000;
         StringBuilder pRet = new StringBuilder(plen);
         var           n    = ETCInterop.Init(pRet, ref plen);
         if (n == 5)
         {
             var n1 = ETCInterop.GetResponse(ref n, pRet, ref plen);
         }
         var str = pRet.ToString();
         return(JsonConvert.DeserializeObject <ETCDeviceInfo[]>(pRet.ToString().Trim()));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 11
0
        private GetCardInfoResponse ReaderRead()
        {
            int           n        = -1;
            int           plen     = 3000;
            StringBuilder response = new StringBuilder(plen);

            n = ETCInterop.ReaderRead(int.Parse(LaneNo), JsonConvert.SerializeObject(new { TimeOut = "2000" }), response, ref plen);
            if (n != 0)
            {
                System.Threading.Thread.Sleep(1000);
                return(new GetCardInfoResponse()
                {
                    ErrorCode = n
                });
            }
            var ret = JsonConvert.DeserializeObject <GetCardInfoResponse>(response.ToString());

            ret.Content = response.ToString();
            return(ret);
        }
Esempio n. 12
0
        private GetOBUInfoResponse GetOBUInfo(OBUSearchResponse r)
        {
            StringBuilder response = new StringBuilder(3000);
            var           request  = new
            {
                UserName   = UserName,
                ProvinceNo = ProvinceNo,
                CityNo     = CityNo,
                AreaNo     = AreaNo,
                GateNo     = GateNo,
                LaneNo     = LaneNo,
                RSUID      = EcRSUID,
                OBUID      = r.OBUID,
                OBUNO      = r.OBUNO
            };
            int n = -1;

            if (UseInGD)
            {
                n = ETCInterop.GetOBUInfo_GD(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);          //广东接口
            }
            else
            {
                n = ETCInterop.GetOBUInfo(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
            }
            if (n != 0)
            {
                return new GetOBUInfoResponse()
                       {
                           ErrorCode = n
                       }
            }
            ;
            var ret = JsonConvert.DeserializeObject <GetOBUInfoResponse>(response.ToString());

            ret.Content = response.ToString();
            ret.OBUID   = r.OBUID; //这两个属性返回串中没有,是手动设置上去的,后面用得到,一定需要
            ret.OBUNO   = r.OBUNO;
            return(ret);
        }
Esempio n. 13
0
        private int Connect()
        {
            var r = ETCInterop.connectserver(int.Parse(LaneNo), IPAddr, int.Parse(Port));

            if (r == 0)
            {
                StringBuilder response = new StringBuilder(100);
                var           request  = new
                {
                    UserName   = UserName,
                    PassWord   = Password,
                    ProvinceNo = ProvinceNo,
                    CityNo     = CityNo,
                    AreaNo     = AreaNo,
                    GateNo     = GateNo,
                    LaneNo     = LaneNo
                };
                ETCInterop.LaneLogin(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
                var ret = JsonConvert.DeserializeObject <ETCResponse>(response.ToString());
                ret.Content = response.ToString();
                r           = ret.ErrorCode;
            }
            return(r);
        }
Esempio n. 14
0
        private WriteCardResponse CardReaderWriteCard(GetCardInfoResponse r, int money, out ETCPaymentRecord record)
        {
            int n = -1;

            record = null;
            WriteCardResponse ret      = null;
            StringBuilder     response = new StringBuilder(3000);

            if (UseInGD)
            {
                var request = new
                {
                    UserName        = UserName,
                    PassWord        = Password,
                    ProvinceNo      = ProvinceNo,
                    CityNo          = CityNo,
                    AreaNo          = AreaNo,
                    GateNo          = GateNo,
                    LaneNo          = LaneNo,
                    CardNo          = r.CardNo,
                    CashMoney       = money.ToString(),
                    CardAreaNo      = AreaNo,
                    CardGateNo      = GateNo.PadLeft(4, '0'),
                    CardLaneNo      = LaneNo.PadLeft(4, '0'),
                    PassTime        = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    VehPlate        = r.CardPlate,
                    VehType         = r.CardVehClass,
                    VehClass        = r.CardVehUserType,
                    OutFlag         = IsExit ? "1" : "0",
                    OperatorNo      = "ffff",
                    LittleGateNo    = r.LittleGateNo,
                    LittleLaneNo    = r.LittleLaneNo,
                    LittlePassTime  = r.LittlePassTime,
                    LittleCashMoney = r.LittleCashMoney,
                    LittleTime      = r.LittleTime,
                    OfferType       = r.OfferType,
                    OfferTime       = r.OfferTime,
                    BackUp          = r.BackUp == null ? string.Empty : r.BackUp, //不能传NULL
                    CheckCode       = r.CheckCode,
                    ReaderID        = EcReaderID
                };

                n = ETCInterop.CardReaderWriteCard_GD(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
                if (n != 0)
                {
                    return new WriteCardResponse()
                           {
                               ErrorCode = n
                           }
                }
                ;
                ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
                ret.Content = response.ToString();
            }
            else
            {
                var request = new
                {
                    UserName   = UserName,
                    PassWord   = Password,
                    ProvinceNo = ProvinceNo,
                    CityNo     = CityNo,
                    AreaNo     = AreaNo,
                    GateNo     = GateNo,
                    LaneNo     = LaneNo,
                    CardNo     = r.CardNo,
                    CashMoney  = money,
                    CardAreaNo = AreaNo,
                    CardGateNo = GateNo.PadLeft(4, '0'),
                    CardLaneNo = LaneNo.PadLeft(4, '0'),
                    PassTime   = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    VehPlate   = r.CardPlate,
                    VehType    = r.CardVehClass,
                    VehClass   = r.CardVehUserType,
                    OutFlag    = IsExit ? "1" : "0",
                    OperatorNo = "ffff",
                    ReaderID   = EcReaderID
                };
                n = ETCInterop.CardReaderWriteCard(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
                if (n != 0)
                {
                    return new WriteCardResponse()
                           {
                               ErrorCode = n
                           }
                }
                ;
                ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
                ret.Content = response.ToString();
            }
            if (ret.ErrorCode == -2320) //半条记录的情况,需要验证
            {
                response = new StringBuilder(1000);
                var request = new
                {
                    UserName      = UserName,
                    ProvinceNo    = ProvinceNo,
                    CityNo        = CityNo,
                    AreaNo        = AreaNo,
                    GateNo        = GateNo,
                    LaneNo        = LaneNo,
                    CardNo        = r.CardNo,
                    RelyServiceNo = ret.KeyServiceNo,
                    ReaderID      = EcReaderID
                };
                n = ETCInterop.CardReaderTransActionProve(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
                if (n != 0)
                {
                    return new WriteCardResponse {
                               ErrorCode = n
                    }
                }
                ;
                ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
                ret.Content = response.ToString();
            }
            if (ret.ErrorCode == 0)
            {
                ret.CashMoney = money; //这两个属性返回串中没有,人为加上去,后面有用!
                ret.Balance   = r.Balance - money;
                record        = CreateRecord(r, ret);
            }
            return(ret);
        }
Esempio n. 15
0
 public void UnInit()
 {
     ETCDevices = null;
     ETCInterop.Uninstall();
 }
Esempio n. 16
0
 public int HeartBeatEx(string laneNo)
 {
     return(ETCInterop.HeartBeat(int.Parse(laneNo)));
 }