Example #1
0
        public void BuildTicketStorage()
        {
            TicketStorage storage;

            Assert.DoesNotThrow(() => {
                string path = @"C:\Users\everettr\Documents\Repositories\RisqueServer\server\RisqueServer\bin\Debug\Tickets";
                storage     = new TicketStorage(path);
            });
        }
Example #2
0
 public Scheduler(TicketStorage storage, Security.SecurityManager securityManager)
 {
     StartTime    = new DateTime(1, 1, 1, 8, 0, 0);
     EndTime      = new DateTime(1, 1, 1, 19, 0, 0);
     mainSchedule = new Thread(loop);
     this.storage = storage;
     this.storage.registerScheduler(this);
     this.securityManager = securityManager;
     loadTickets();
     mainSchedule.Start();
 }
Example #3
0
 public MethodMan(TicketStorage storage, Scheduler scheduler)
 {
     this.scheduler   = scheduler;
     this.storage     = storage;
     methodDictionary = new Dictionary <string, IRPCMethod>(4);
     methodDictionary.Add("addTicketInfo", new addTicketInfo(storage));
     methodDictionary.Add("checkTicket", new checkTicket(scheduler));
     methodDictionary.Add("doesTicketExist", new doesTicketExist(storage));
     methodDictionary.Add("getTicketInfo", new getTicketInfo(storage));
     methodDictionary.Add("getScheduledCount", new getScheduledCount(scheduler));
     methodDictionary.Add("getTicketStatus", new getTicketStatus(storage));
     methodDictionary.Add("removeTicket", new removeTicket(storage));
     MethodMan.getActiveManager = this;
 }
        public string Get(Guid id)
        {
            Ticket t = TicketStorage.getInstance().getPassengerTicket(id);

            if (t == null)
            {
                return("0"); //passenger with this id didn't buy ticket
            }
            else
            {
                string json = JsonConvert.SerializeObject(t);
                return(json);
            }
        }
Example #5
0
        public string Get(int id, string ps, string fl)
        {
            Flight          f            = JsonConvert.DeserializeObject <Flight>(fl);
            FlightPassenger p            = JsonConvert.DeserializeObject <FlightPassenger>(ps);
            int             passnumber   = 0; //number of passengers in the plain
            int             flightID     = f.reisNumber;
            string          ticketJson   = null;
            string          scheduleData = ScheduleHttpClient.ScheduleRequest(flightID);
            int             scheduleInt  = Convert.ToInt32(scheduleData);

            if (scheduleInt >= 0)
            {
                passnumber = scheduleInt;
                if (TicketStorage.getInstance().fingPassenger(p.Passport.Guid))
                {
                    return("2"); //passenger with this id has already buy a ticket
                }
                else
                {
                    if (TicketStorage.getInstance().flightCount(flightID) < passnumber)
                    {
                        Ticket t = new Ticket(p.Passport.Guid, flightID, f.to, p.Passport.Surname, p.Passport.GivenNames, p.Passport.Sex);
                        TicketStorage.getInstance().Add(t);
                        ticketJson = JsonConvert.SerializeObject(t);
                        return(ticketJson);
                    }
                    else
                    {
                        return("3"); //there are no more tickets for this flight
                    }
                }
            }
            else
            {
                if (scheduleInt == -3)
                {
                    return("4"); //flight registration
                }
                else if (scheduleInt == -4 || scheduleInt == -2 || scheduleInt == -1)
                {
                    return("1"); //flight to this city doesn't exist or plain has already landed or there is no plain for this flight - can not buy a ticket
                }
                else
                {
                    return("1");
                }
            }
        }
Example #6
0
 public getTicketInfo(TicketStorage storage)
 {
     this.storage = storage;
 }
Example #7
0
 public doesTicketExist(TicketStorage storage)
 {
     this.storage = storage;
 }
Example #8
0
 public addTicketInfo(TicketStorage storage)
 {
     this.storage = storage;
 }
Example #9
0
 public getTicketStatus(TicketStorage storage)
 {
     this.storage = storage;
 }