Beispiel #1
0
        /// <summary>
        /// Function for creating packet of booking to card reader
        /// </summary>
        /// <param name="reservation"></param>
        /// <returns></returns>
        public bool CreateBooking(Reservation reservation)
        {
            if (reservation.Person.CardNumber.Length == 8)
            {
                if (!CrName.findCrGroup(reservation.CardReader.Name))
                {
                    //while (!SetDate(reservation.CardReader.CrAddress)) ;
                    //while (!SetTime(reservation.CardReader.CrAddress)) ;

                    //while (!ClearPm(reservation.CardReader.CrAddress)) ;
                    while (!ClearZm(reservation.CardReader.CrAddress))
                    {
                        ;
                    }
                    while (!ClearAg(reservation.CardReader.CrAddress))
                    {
                        ;
                    }

                    while (!EnablePm(reservation.CardReader.CrAddress))
                    {
                        ;
                    }
                    while (!EnableZm(reservation.CardReader.CrAddress))
                    {
                        ;
                    }

                    CrName.addCrGroup(new CrGroup()
                    {
                        Name = reservation.CardReader.Name, Addr = reservation.CardReader.CrAddress, IP = reservation.CardReader.IP, Port = reservation.CardReader.Port
                    });
                }

                if (!CrName.getCrGroupName(reservation.CardReader.Name).People.Exists(x => x.Campus_ID == reservation.Person.Campus_ID))
                {
                    CrName.getCrGroupName(reservation.CardReader.Name).People.Add(reservation.Person);

                    int groupNum = CrName.findIndexPerson(reservation.CardReader.Name, reservation.Person.CardNumber) + 1;

                    while (!AddNewPerson(reservation.CardReader.CrAddress, reservation.Person.CardNumber, groupNum))
                    {
                        ;
                    }

                    while (!AddNewTimeZone(reservation.CardReader.CrAddress, reservation.StartTime, reservation.EndTime, groupNum))
                    {
                        ;
                    }
                    while (!AddNewAccessGroup(reservation.CardReader.CrAddress, groupNum, groupNum))
                    {
                        ;
                    }
                    return(true);
                }
            }
            return(false);
        }