Esempio n. 1
0
 /// <summary>
 /// 通过查询条件获取卡片
 /// </summary>
 /// <param name="con"></param>
 /// <returns></returns>
 public QueryResultList <CardInfo> GetCards(CardSearchCondition con)
 {
     return(_Provider.GetItems(con));
 }
Esempio n. 2
0
        /// <summary>
        /// 获取车牌号码所在停车场
        /// </summary>
        /// <param name="carPlate"></param>
        /// <returns></returns>
        public QueryResult <ParkInfo> GetParkInfoCarPlate(string carPlate)
        {
            QueryResult <ParkInfo> result = new QueryResult <ParkInfo>(ResultCode.Fail, null);

            //先根据车牌查找卡片
            ICardProvider       cardProvider  = ProviderFactory.Create <ICardProvider>(this._repoUri);
            CardSearchCondition cardCondition = new CardSearchCondition();

            cardCondition.CarPlateOrLast = carPlate;

            QueryResultList <CardInfo> cardResult = cardProvider.GetItems(cardCondition);

            if (cardResult.Result == ResultCode.Successful)
            {
                CardInfo card = null;

                if (cardResult.QueryObjects != null && cardResult.QueryObjects.Count > 0)
                {
                    //查找第一个符合条件的已入场卡片
                    card = cardResult.QueryObjects.FirstOrDefault(c => c.IsInPark);
                }

                if (card == null)
                {
                    result = new QueryResult <ParkInfo>(ResultCode.NoRecord, null);
                }
                else
                {
                    //根据卡号和入场时间查找入场事件
                    ICardEventProvider       eventProvider  = ProviderFactory.Create <ICardEventProvider>(this._repoUri);
                    CardEventSearchCondition eventCondition = new CardEventSearchCondition();
                    eventCondition.RecordDateTimeRange = new DateTimeRange(card.LastDateTime, card.LastDateTime);
                    eventCondition.CardID         = card.CardID;
                    eventCondition.OnlyEnterEvent = true;

                    QueryResultList <CardEventRecord> eventResult = eventProvider.GetItems(eventCondition);
                    if (eventResult.Result == ResultCode.Successful)
                    {
                        CardEventRecord eventRecord = null;
                        if (eventResult.QueryObjects != null && eventResult.QueryObjects.Count > 0)
                        {
                            //查找到多条记录时,取第一条记录
                            eventRecord = eventResult.QueryObjects[0];
                        }
                        if (eventRecord == null)
                        {
                            result = new QueryResult <ParkInfo>(ResultCode.NoRecord, null);
                        }
                        else
                        {
                            ParkInfo park = provider.GetByID(eventRecord.ParkID).QueryObject;
                            if (park == null)
                            {
                                result = new QueryResult <ParkInfo>(ResultCode.NoRecord, null);
                            }
                            else
                            {
                                result = new QueryResult <ParkInfo>(ResultCode.Successful, park);
                            }
                        }
                    }
                }
            }
            return(result);
        }