示例#1
0
        private List <CardInfo> GetCardHasCarplate(string carplate, int maxCarPlateErrorChar)
        {
            List <CardInfo> cards = null;

            if (maxCarPlateErrorChar == 0)
            {
                CardSearchCondition con = new CardSearchCondition();
                con.CarPlate = carplate;
                cards        = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCards(con).QueryObjects;
            }
            else if (maxCarPlateErrorChar > 0)
            {
                List <CardInfo> temp = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetAllCards().QueryObjects;
                foreach (CardInfo card in temp)
                {
                    if (!string.IsNullOrEmpty(card.CarPlate))  //多个车牌号分开处理
                    {
                        //多个车牌号分开处理,车牌号可用中文或英文逗号分隔
                        string[] strs = card.CarPlate.Split(',', ',');
                        foreach (string str in strs)
                        {
                            if (CarPlateComparer.CarPlateComparison(carplate, str, maxCarPlateErrorChar))
                            {
                                if (cards == null)
                                {
                                    cards = new List <CardInfo>();
                                }
                                cards.Add(card);
                            }
                        }
                    }
                }
            }
            return(cards);
        }
示例#2
0
        public void CarPlateComparisonTest()
        {
            CardEventReport report = new CardEventReport();

            report.LastCarPlate = "粤A12345";
            report.CarPlate     = "粤A12345";
            for (int i = 0; i < 8; i++)
            {
                Assert.IsTrue(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, i));
            }

            report.CarPlate = "粤B12345";
            Assert.IsFalse(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, 0));
            for (int i = 1; i < 2; i++)
            {
                Assert.IsTrue(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, i));
            }

            report.CarPlate = "粤B22345";
            Assert.IsFalse(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, 0));
            Assert.IsFalse(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, 1));
            for (int i = 2; i < 8; i++)
            {
                Assert.IsTrue(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, i));
            }

            report.CarPlate = "粤B1234";
            Assert.IsFalse(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, 0));
            Assert.IsFalse(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, 1));

            report.CarPlate = string.Empty;
            for (int i = 0; i < 8; i++)
            {
                Assert.IsFalse(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, i));
            }

            report.LastCarPlate = null;
            for (int i = 0; i < 8; i++)
            {
                Assert.IsFalse(CarPlateComparer.CarPlateComparison(report.CarPlate, report.LastCarPlate, i));
            }
        }