コード例 #1
0
        static void Main(string[] args)
        {
            var airline = new Airline();

            airline.Name = "Air India";
            airline.Code = "AI";

            var flight1 = new Flight(airline);

            flight1.FlightID             = "AI 101";
            flight1.FlightStatus         = FlightStatus.OnTime;
            flight1.DepartureAirportCode = "CCU";
            flight1.ArrivalAirportCode   = "BLR";

            var flight2 = new Flight(airline);

            flight2.FlightID             = "AI 102";
            flight2.FlightStatus         = FlightStatus.OnTime;
            flight2.DepartureAirportCode = "BLR";
            flight2.ArrivalAirportCode   = "CCU";

            var flightCollection = new FlightCollection();

            flightCollection.Flights.Add(flight1);
            flightCollection.Flights.Add(flight2);

            var flightsdesc = flightCollection.Sort("DepartureAirportCode", true);
            var flightsasc  = flightCollection.Sort("DepartureAirportCode", false);

            var flightFilter1 = flightCollection.Filter(x => x.DepartureAirportCode == "CCU" && x.ArrivalAirportCode == "BLR");
            var flightFilter2 = flightCollection.Filter(x => x.DepartureAirportCode == "BLR" && x.ArrivalAirportCode == "CCU");
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            RenderRedFlagAlerts     = true;
            RenderFIRMS             = true;
            RenderWeatherConditions = false;

            CmdClose    = new ApplicationCommand((obj) => Close(), (obj) => true);
            CmdMinimize = new ApplicationCommand((obj) => WindowState = WindowState.Normal, (obj) => true);

            CmdEndPolygonDrawing  = new ApplicationCommand(CmdEndPolygonDrawing_Execute);
            CmdStartPolygon       = new ApplicationCommand(CmdStartPolygon_Execute);
            CmdCleanMap           = new ApplicationCommand(CmdCleanMap_Execute);
            CmdAnalizeNow         = new ApplicationCommand(CmdAnalizeNow_Execute);
            CmdMoveMap            = new ApplicationCommand(CmdMoveMap_Execute);
            CmdNotificationOpened = new ApplicationCommand(CmdNotificationOpened_Execute);
            CmdAlertGroups        = new ApplicationCommand(CmdAlertGroups_Execute);
            CmdConfig             = new ApplicationCommand(CmdConfig_Execute);
            CmdSave      = new ApplicationCommand(CmdSave_Execute);
            OpenSavedAOI = new ApplicationCommand(OpenSavedAOI_Execute);
            CmdDismissRedFlagNotifications = new ApplicationCommand(CmdDismissRedFlagNotifications_Execute);


            Flights = new FlightCollection();
            RedFlagsNotifications = new AreasOfInterestCollection();
            AreasOfInterest       = new AreasOfInterestCollection();
            SavedAreasOfInterest  = new AreasOfInterestCollection();

            UpdateRedFlagNotifications(Settings.RED_FLAGS_COUNTRY_CODE);
            CmdCleanMap_Execute(null);
        }
コード例 #3
0
ファイル: Race.cs プロジェクト: helios57/anrl
 public Race()
     : base()
 {
     competitors = new CompetitorCollection();
     competitorGroups = new CompetitorGroupCollection();
     flights = new FlightCollection();
 }
コード例 #4
0
 public FlightRowCallback(FlightCollection flights, IAircraftDao aircraftDao,
                          Airport origin, Airport destination, DateTime departureDate)
 {
     this.flights       = flights;
     this.aircraftDao   = aircraftDao;
     this.origin        = origin;
     this.destination   = destination;
     this.departureDate = departureDate;
 }
コード例 #5
0
ファイル: Race.cs プロジェクト: helios57/anrl
 public Race(string filename)
     : base()
 {
     competitors = new CompetitorCollection();
     competitorGroups = new CompetitorGroupCollection();
     flights = new FlightCollection();
     map = new Map();
     this.loadRace(filename);
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: northos/CodingExercise
        private static void Execute()
        {
            // Load the input data
            AirportCollection   airports = AirportCollection.LoadFromFile(AirportsFilePath);
            AdsbEventCollection events   = AdsbEventCollection.LoadFromFile(AdsbEventsFilePath);

            // Create collection of identifiable flights
            FlightCollection flights = CalculateFlights(airports, events);

            // Write the output data
            flights.WriteToFile(OutputFilePath);
        }
コード例 #7
0
        private FlightCollection GetFlightsToBook()
        {
            FlightCollection flightsToBook  = new FlightCollection();
            Flight           outboundFlight = this.flights.GetOutboundFlight(outboundFlightIndex);

            flightsToBook.Add(outboundFlight);
            if (HasReturnFlight)
            {
                Flight returnFlight = this.flights.GetReturnFlight(returnFlightIndex);
                flightsToBook.Add(returnFlight);
            }
            return(flightsToBook);
        }
コード例 #8
0
        public FlightSuggestions SuggestFlights([Validated("tripValidator")] Trip trip)
        {
            #region Sanity Check

            if (trip == null)
            {
                throw new ArgumentNullException("trip", "The 'trip' argument is required.");
            }

            #endregion

            Aircraft outboundAircraft, returnAircraft;
            bool     transAtlantic = trip.StartingFrom.AirportCode == "LHR" || trip.ReturningFrom.AirportCode == "LHR";
            if (transAtlantic)
            {
                outboundAircraft = aircraftDao.GetAircraft(2);
                returnAircraft   = aircraftDao.GetAircraft(2);
            }
            else
            {
                outboundAircraft = aircraftDao.GetAircraft(1);
                returnAircraft   = aircraftDao.GetAircraft(3);
            }
            Airport from = airportDao.GetAirport(trip.StartingFrom.AirportCode);
            Airport to   = airportDao.GetAirport(trip.ReturningFrom.AirportCode);

            FlightCollection outboundFlights = new FlightCollection();
            outboundFlights.Add(new Flight("UA 0123", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(6.5)));
            outboundFlights.Add(new Flight("AA 2367", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(10)));
            outboundFlights.Add(new Flight("SW 6534", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(15.75)));
            outboundFlights.Add(new Flight("CO 0054", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(19.25)));

            FlightCollection returnFlights = new FlightCollection();
            returnFlights.Add(new Flight("CO 0112", to, from, returnAircraft, trip.ReturningFrom.Date.AddHours(9)));
            returnFlights.Add(new Flight("UA 0230", to, from, returnAircraft, trip.ReturningFrom.Date.AddHours(12.3)));
            returnFlights.Add(new Flight("AA 2234", to, from, returnAircraft, trip.ReturningFrom.Date.AddHours(21.5)));

            if (trip.Mode == TripMode.RoundTrip)
            {
                return(new FlightSuggestions(outboundFlights, returnFlights));
            }
            else
            {
                return(new FlightSuggestions(outboundFlights, NoSuggestions));
            }
        }
コード例 #9
0
        private void BookFlights(object sender, EventArgs e)
        {
//			if(Validate(this, flightsValidator))
//			{
            FlightCollection flightsToBook = GetFlightsToBook();
            Itinerary        itinerary     = new Itinerary(flightsToBook);
            // TODO: forward to next logical page and get user details...
            ReservationConfirmation confirmation = bookingAgent.Book(
                new Reservation(new Passenger(1, "Aleksandar", "Seovic"), itinerary));

            Session[Constants.ReservationConfirmationKey] = confirmation;
            SetResult(ReservationConfirmed);
//			}
//			else
//			{
//				this.outboundFlightIndex = NoFlightSelected;
//				this.returnFlightIndex = NoFlightSelected;
//			}
        }
コード例 #10
0
        public void FlightCollectionFilterTest()
        {
            var airline = new Airline()
            {
                Name = "Air India", Code = "AI"
            };
            var flight1 = new Flight(airline)
            {
                FlightID             = "AI 102",
                ArrivalAirportCode   = "CCU",
                DepartureAirportCode = "BLR",
                DepartureDateUtc     = DateTime.UtcNow,
                ArrivalDateTimeUtc   = DateTime.UtcNow.AddMinutes(60),
            };

            var flight2 = new Flight(airline)
            {
                FlightID             = "AI 103",
                ArrivalAirportCode   = "BLR",
                DepartureAirportCode = "CCU",
                DepartureDateUtc     = DateTime.UtcNow,
                ArrivalDateTimeUtc   = DateTime.UtcNow.AddMinutes(70),
            };

            var flightCollection = new FlightCollection();

            flightCollection.Flights.Add(flight1);
            flightCollection.Flights.Add(flight2);

            var flights0 = flightCollection.Filter(t => t.FlightID == "AI 102");

            Assert.AreEqual(flights0[0].FlightID, "AI 102");


            var flights1 = flightCollection.Filter(t => t.DepartureAirportCode == "CCU");

            Assert.AreEqual(flights1[0].DepartureAirportCode, "CCU");

            var flights2 = flightCollection.Filter(t => t.ArrivalAirportCode == "BLR");

            Assert.AreEqual(flights1[0].ArrivalAirportCode, "BLR");
        }
コード例 #11
0
        public void FlightCollectionSortTest()
        {
            var airline = new Airline()
            {
                Name = "Air India", Code = "AI"
            };
            var flight1 = new Flight(airline)
            {
                FlightID             = "AI 102",
                ArrivalAirportCode   = "CCU",
                DepartureAirportCode = "BLR",
                DepartureDateUtc     = DateTime.UtcNow,
                ArrivalDateTimeUtc   = DateTime.UtcNow.AddMinutes(60),
            };

            var flight2 = new Flight(airline)
            {
                FlightID             = "AI 103",
                ArrivalAirportCode   = "BLR",
                DepartureAirportCode = "CCU",
                DepartureDateUtc     = DateTime.UtcNow,
                ArrivalDateTimeUtc   = DateTime.UtcNow.AddMinutes(70),
            };

            var flightCollection = new FlightCollection();

            flightCollection.Flights.Add(flight1);
            flightCollection.Flights.Add(flight2);

            //Sort1
            var flights1 = flightCollection.Sort("DepartureAirportCode", true);

            Assert.AreEqual(flights1[0].DepartureAirportCode, "CCU");
            //Sort2
            var flights2 = flightCollection.Sort("ArrivalAirportCode", true);

            Assert.AreEqual(flights2[0].ArrivalAirportCode, "CCU");
            //Sort3
            var flights3 = flightCollection.Sort("FlightDurationInMinutes", false);

            Assert.AreEqual(flights3[0].FlightID, "AI 102");
        }
コード例 #12
0
 protected void BookFlights(object sender, EventArgs e)
 {
     if ((flights.HasOutboundFlights && !HasOutboundFlight))
     {
         this.ValidationErrors.AddError("summary", new ErrorMessage("error.outboundFlight.required"));
     }
     if ((flights.HasReturnFlights && !HasReturnFlight))
     {
         this.ValidationErrors.AddError("summary", new ErrorMessage("error.returnFlight.required"));
     }
     if (this.ValidationErrors.IsEmpty)
     {
         FlightCollection flightsToBook = GetFlightsToBook();
         Itinerary        itinerary     = new Itinerary(flightsToBook);
         // TODO: forward to next logical page and get user details...
         ReservationConfirmation confirmation = bookingAgent.Book(
             new Reservation(new Passenger(1, "Aleksandar", "Seovic"), itinerary));
         Session[Constants.ReservationConfirmationKey] = confirmation;
         SetResult(ReservationConfirmed);
     }
 }
コード例 #13
0
        /// <summary>
        /// Gets those <see cref="SpringAir.Domain.FlightSuggestions"/>
        /// that are applicable for the supplied <see cref="SpringAir.Domain.Trip"/>.
        /// </summary>
        /// <param name="trip">
        /// The <see cref="SpringAir.Domain.Trip"/> that contains the criteria
        /// that are to be used to select the flight suggestions.
        /// </param>
        /// <returns>
        /// A <see cref="SpringAir.Domain.FlightSuggestions"/> comprised of all
        /// those <see cref="SpringAir.Domain.Flight"/> instances that
        /// are applicable for the supplied <see cref="SpringAir.Domain.Trip"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="trip"/> is <cref lang="null"/>.
        /// </exception>
        public FlightSuggestions SuggestFlights(Trip trip)
        {
            #region Sanity Check

            if (trip == null)
            {
                throw new ArgumentNullException("trip", "The 'trip' argument is required.");
            }

            #endregion

            Airport origin      = this.airportDao.GetAirport(trip.StartingFrom.AirportCode);
            Airport destination = this.airportDao.GetAirport(trip.ReturningFrom.AirportCode);

            FlightCollection outboundLegs = GetFlights(origin, destination, trip.StartingFrom.Date);
            FlightCollection returnLegs   = null;
            if (trip.Mode == TripMode.RoundTrip)
            {
                // swap 'em round, and get the legs for the way back...
                returnLegs = GetFlights(destination, origin, trip.ReturningFrom.Date);
            }
            return(new FlightSuggestions(outboundLegs, returnLegs));
        }
コード例 #14
0
        public FlightCollection GetFlights(Airport origin, Airport destination, DateTime departureDate)
        {
            #region Sanity Checks
            AssertUtils.ArgumentNotNull(origin, "origin");
            AssertUtils.ArgumentNotNull(destination, "destination");
            #endregion

            FlightCollection flights = new FlightCollection();


            IDbParametersBuilder builder = new DbParametersBuilder(DbProvider);
            builder.Create().Name("departureDate").Type(DbType.Date).Value(departureDate);
            builder.Create().Name("departureAirport").Type(DbType.Int32).Value(origin.Id);
            builder.Create().Name("destinationAirport").Type(DbType.Int32).Value(destination.Id);

#if NET_2_0
            AdoTemplate.QueryWithRowCallbackDelegate(CommandType.Text, FlightsQuery,
                                                     delegate(IDataReader dataReader)
            {
                int flightId        = dataReader.GetInt32(0);
                string flightNumber = dataReader.GetString(1);
                Aircraft aircraft   = aircraftDao.GetAircraft(dataReader.GetInt32(2));

                //TODO: Load cabins from the database
                Cabin[] cabins = aircraft.Cabins;

                Flight flight = new Flight(flightId, flightNumber, origin, destination, aircraft, departureDate, cabins);
                flights.Add(flight);
            },


                                                     builder.GetParameters());
#else
            AdoTemplate.QueryWithRowCallback(CommandType.Text, FlightsQuery,
                                             new FlightRowCallback(flights, aircraftDao, origin, destination, departureDate),
                                             builder.GetParameters());
#endif


            /*
             * IDbCommand command = GetCommand(FlightsQuery);
             * using(new ConnectionManager(command.Connection))
             * {
             *  SetFlightQueryParameters(command, departureDate, origin.Id, destination.Id);
             *  using (SqlDataReader reader = (SqlDataReader) command.ExecuteReader())
             *  {
             *      while(reader.Read())
             *      {
             *          int flightId = reader.GetInt32(0);
             *          string flightNumber = reader.GetString(1);
             *          Aircraft aircraft = aircraftDao.GetAircraft(reader.GetInt32(2));
             *
             *          //TODO: Load cabins from the database
             *          Cabin[] cabins = aircraft.Cabins;
             *
             *          Flight flight = new Flight(flightId, flightNumber, origin, destination, aircraft, departureDate, cabins);
             *          flights.Add(flight);
             *      }
             *  }
             * }
             */
            return(flights);
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: northos/CodingExercise
        private static FlightCollection CalculateFlights(AirportCollection airports, AdsbEventCollection events)
        {
            // Organize all ADS-B events by aircraft ID
            FlightCollection flights = new FlightCollection();
            Dictionary <string, List <AdsbEvent> > eventsByID = new Dictionary <string, List <AdsbEvent> >();

            foreach (AdsbEvent adsbEvent in events.Events)
            {
                if (!eventsByID.ContainsKey(adsbEvent.Identifier))
                {
                    eventsByID.Add(adsbEvent.Identifier, new List <AdsbEvent>());
                    eventsByID[adsbEvent.Identifier].Add(adsbEvent);
                }
                else
                {
                    // Remove events that are soon after the previous one to improve performance
                    int       eventCount = eventsByID[adsbEvent.Identifier].Count;
                    AdsbEvent lastEvent  = eventsByID[adsbEvent.Identifier][eventCount - 1];
                    TimeSpan  timeDiff   = adsbEvent.Timestamp - lastEvent.Timestamp;
                    if (timeDiff.TotalSeconds >= TimeThreshold)
                    {
                        eventsByID[adsbEvent.Identifier].Add(adsbEvent);
                    }
                }
            }

            // For each aircraft identifier, step through the logged events in sequence to identify flights
            foreach (string identifier in eventsByID.Keys)
            {
                List <AdsbEvent> eventLog       = eventsByID[identifier];
                FlightStatus     flightStatus   = FlightStatus.Unknown;
                Airport          lastAirport    = new Airport();
                DateTime         lastGroundTime = DateTime.MinValue;
                foreach (AdsbEvent adsbEvent in eventLog)
                {
                    // Find closest airport to the logged coordinates, as long as the event has coordinate values
                    GeoCoordinate eventLoc = new GeoCoordinate(adsbEvent.Latitude ?? double.NaN, adsbEvent.Longitude ?? double.NaN);
                    if (eventLoc.HasLocation())
                    {
                        Airport       closestAirport  = airports.GetClosestAirport(eventLoc);
                        GeoCoordinate airportLoc      = new GeoCoordinate(closestAirport.Latitude, closestAirport.Longitude);
                        double        airportDistance = eventLoc.GetDistanceTo(airportLoc);
                        double        altitudeDiff    = adsbEvent.Altitude.HasValue ? Math.Abs(adsbEvent.Altitude.Value - closestAirport.Elevation) : 0f;
                        double        speed           = adsbEvent.Speed ?? 0f;

                        // If the event was logged close to an airport, assume the aircraft has landed at that airport
                        if (airportDistance <= DistanceThreshold && altitudeDiff <= AltitudeThreshold && speed <= SpeedThreshold)
                        {
                            // If this is not the first event (status unknown) and the new closest airport is different, create a new completed flight record
                            if (flightStatus != FlightStatus.Unknown && closestAirport.Identifier != lastAirport.Identifier)
                            {
                                flights.Flights.Add(new Flight
                                {
                                    AircraftIdentifier = identifier,
                                    DepartureTime      = lastGroundTime,
                                    DepartureAirport   = lastAirport.Identifier,
                                    ArrivalTime        = adsbEvent.Timestamp,
                                    ArrivalAirport     = closestAirport.Identifier
                                });
                            }
                            // In any case, update the status for the new airport
                            flightStatus   = FlightStatus.Ground;
                            lastAirport    = closestAirport;
                            lastGroundTime = adsbEvent.Timestamp;
                        }
                        // If the aircraft is not close to an airport and was not previously flying, set the status to airborne
                        else if ((airportDistance > DistanceThreshold || altitudeDiff > AltitudeThreshold) && flightStatus != FlightStatus.Air)
                        {
                            flightStatus = FlightStatus.Air;
                        }
                        // Otherwise, assume no status change
                    }
                }

                // If all events have been read and the aircraft was last known to be flying, record a final flight with no arrival
                if (flightStatus == FlightStatus.Air)
                {
                    flights.Flights.Add(new Flight
                    {
                        AircraftIdentifier = identifier,
                        DepartureTime      = lastGroundTime,
                        DepartureAirport   = lastAirport.Identifier,
                        ArrivalTime        = DateTime.MaxValue,
                        ArrivalAirport     = null
                    });
                }
            }

            return(flights);
        }
コード例 #16
0
ファイル: Race.cs プロジェクト: helios57/anrl
 public void loadRace(string filename)
 {
     BinaryFormatter binaryFormatter = new BinaryFormatter();
     Stream fStream = File.OpenRead(filename);
     Race r = (Race)binaryFormatter.Deserialize(fStream);
     this.competitors = r.Competitors;
     this.competitorGroups = r.CompetitorGroups;
     this.flights = r.Flights;
     this.map = r.map;
 }