コード例 #1
0
        public byte CheckCard(byte[] RecivedUID)
        {
            cardID = arrayToInt(getAreaId(RecivedUID));
            dbr    = getCardData();

            //Console.WriteLine("DB CARDID: " + dbr.CardUID + " Input: " + cardID);

            if (dbr.CardUID != cardID)
            {
                //the card is worng, reject it
                return(0);
            }

            if (dbr.CardIsCheckedIn)
            {
                //the card gets checked out
                return(2);
            }

            if (dbr.TooManyInArea)
            {
                //the area is full, reject it
                return(3);
            }

            //the card gets checked in
            return(1);
        }
コード例 #2
0
        //DatabaseResult Factory
        public static DatabaseResult GetDatabaseResult(int cardUID, int currentNmberInArea, int maxNumberInArea, bool isCheckedIn)
        {
            DatabaseResult newDbr = new DatabaseResult(cardUID, currentNmberInArea, maxNumberInArea, isCheckedIn);

            //is there room in the area?
            if (currentNmberInArea <= maxNumberInArea && currentNmberInArea != maxNumberInArea)
            {
                //Yes
                newDbr.TooManyInArea = false;
            }
            else
            {
                //No
                newDbr.TooManyInArea = true;
            }

            return(newDbr);
        }