Example #1
0
        public void SaveETCTagBinding(string EPCID, string CarId, int PropseId)
        {
            try
            {
                string tmpCarId;
                int    carpid;
                if (!IsETCExists(EPCID, out tmpCarId, out carpid))
                {
                    etcbinding.Add(new ETCBinding()
                    {
                        CarID = CarId, CarPurposeTypeID = PropseId, ETCID = EPCID, CreateTime = DateTime.Now
                    });
                }
                else
                {
                    ETCBinding existdata = etcbinding.First(w => w.ETCID.Equals(EPCID, StringComparison.InvariantCultureIgnoreCase));

                    existdata.LastUpdateTiem   = DateTime.Now;
                    existdata.LastUploadTime   = null;
                    existdata.CarID            = CarId;
                    existdata.CarPurposeTypeID = PropseId;

                    etcbinding.Remove(existdata);
                    etcbinding.Add(existdata);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
                throw;
            }
        }
Example #2
0
        public bool IsETCExists(string EPCID, out string OCarId, out int OPropseId)
        {
            try
            {
                OCarId    = string.Empty;
                OPropseId = 0;

                if (etcbinding != null & etcbinding.Count > 0)
                {
                    ETCBinding data = etcbinding.FirstOrDefault(w => w.ETCID.Equals(EPCID, StringComparison.InvariantCultureIgnoreCase));

                    if (data != null)
                    {
                        OCarId    = data.CarID;
                        OPropseId = data.CarPurposeTypeID ?? 0;
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
                throw ex;
            }
        }