public void OnlyMakeVelocityCalculations_FromTheTwoLatestRecords(int lat1, int lon1, int alt1,
                                                                         int lat2, int lon2, int alt2, int timeSec2,
                                                                         int lat3, int lon3, int alt3, int timeSec3,
                                                                         double expectedVelocity)
        {
            // ARRAGNE
            _uut = new FlightTrack("AAA123");
            var record1 = new FlightRecord()
            {
                Position = new Position(lat1, lon1, alt1), Timestamp = new DateTime(2018, 1, 1, 0, 0, 0)
            };
            var record2 = new FlightRecord()
            {
                Position = new Position(lat2, lon2, alt2), Timestamp = new DateTime(2018, 1, 1, 0, 0, 0).Add(new TimeSpan(0, 0, timeSec2))
            };

            _uut.Update(record1);
            _uut.Update(record2);

            // ACT
            var record3 = new FlightRecord()
            {
                Position = new Position(lat3, lon3, alt3), Timestamp = new DateTime(2018, 1, 1, 0, 0, 0).Add(new TimeSpan(0, 0, timeSec2 + timeSec3))
            };;

            _uut.Update(record3);

            //ASSERT
            Assert.That(_uut.Velocity, Is.EqualTo(expectedVelocity));
        }
        public void OnlyMakeVelocityCalculations_FromTheTwoLatestRecords2(string tag, int lat, int lon, int alt,
                                                                          double expectedCourse, double expectedVelocity,
                                                                          int hour, int minute)
        {
            // ARRANGE
            _uut = new FlightTrack(tag);
            var record1 = new FlightRecord()
            {
                Position  = new Position(lat, lon, alt),
                Timestamp = new DateTime(2018, 1, 1, hour, minute, 0)
            };

            _uut.Update(record1);

            var uutStr = _uut.ToString();

            //ASSERT
            Assert.That(uutStr, Does.Contain(tag));
            Assert.That(uutStr, Does.Contain(lat.ToString()));
            Assert.That(uutStr, Does.Contain(lon.ToString()));
            Assert.That(uutStr, Does.Contain(alt.ToString()));
            Assert.That(uutStr, Does.Contain(expectedCourse.ToString()));
            Assert.That(uutStr, Does.Contain(expectedVelocity.ToString()));
            Assert.That(uutStr, Does.Contain(hour.ToString()));
            Assert.That(uutStr, Does.Contain(minute.ToString()));
        }
Пример #3
0
        public void WhenRaisingTransponderDataReady_CreateRecordObject_ThatASubscriperCanReceive(string rawData, string expTag, int expLat, int expLong, int expAlt)
        {
            // ARRANGE
            var transponderData = new List <string>();

            transponderData.Add(rawData);

            FlightRecord persistedArgs = null;

            _sut.FlightRecordReceived += (sender, e) =>
            {
                persistedArgs = e.FlightRecord;
            };

            //ACT
            _fakeTransponder.TransponderDataReady += Raise.EventWith(_fakeTransponder, new RawTransponderDataEventArgs(transponderData));

            // ASSERT
            Assert.That(persistedArgs.Tag, Is.Not.Null);
            Assert.That(persistedArgs.Tag, Is.EqualTo(expTag));
            Assert.That(persistedArgs.Position.Altitude, Is.EqualTo(expAlt));
            Assert.That(persistedArgs.Position.Latitude, Is.EqualTo(expLat));
            Assert.That(persistedArgs.Position.Longitude, Is.EqualTo(expLong));
            Assert.That(persistedArgs.Timestamp, Is.Not.EqualTo(DateTime.MinValue));
        }
Пример #4
0
        private async void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary
            };

            picker.FileTypeFilter.Add(".txt");
            picker.FileTypeFilter.Add(".dat");

            var file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                //var data = await FileIO.ReadTextAsync(file);

                var buffer = await FileIO.ReadBufferAsync(file);

                using (var dataReader = DataReader.FromBuffer(buffer))
                {
                    var data = new byte[buffer.Length];
                    dataReader.ReadBytes(data);

                    var fr = new FlightRecord(data);
                }
            }
        }
        public BaseResponse CreateFlightRecord(FlightRecord request)
        {
            var flightRecord = AutoMapper.Mapper.Map <FlightRecord>(request);

            flightRecordRepository.Create(flightRecord);
            this.unitOfWork.Commit();
            return(this.BuildSuccessResponse());
        }
Пример #6
0
        private static IEnumerable <Flight> processFlights(FlightRecord flightRecord)
        {
            if (flightRecord == null || string.IsNullOrWhiteSpace(flightRecord.Content))
            {
                return new Flight[] { }
            }
            ;
            var commandFlights = Command.Domain.Utility.Parser.GetFlights(flightRecord.Content);
            var flights        = commandFlights.FilterShareFlight().FilterAirport(flightRecord.Departure, flightRecord.Arrival).FilterRepeatFlight();

            return(FlightProcessor.ExecuteWithoutBunk(flights, flightRecord.FlightDate).FilterExpiredFlight().ToList());
        }
    }
Пример #7
0
        private string[,] LoadArray(Airline airline, int day)
        {
            IOrderedEnumerable <FlightRecord> flightRecords = airline == null
                ? Game.current.flightRecords.GetForDay(day - 1).OrderBy(x => x.arrivalTime).ThenBy(x => x.airline)
                : Game.current.flightRecords.GetForDay(day - 1).Where(x => x.airline == airline.name).OrderBy(x => x.arrivalTime).ThenBy(x => x.airline);

            int numFlights = flightRecords.Count();

            string[,] arr = new string[numFlights + 1, arrayCols];
            for (int i = 0; i < arrayCols; i++)
            {
                arr[0, i] = i18n.Get($"TBFlash.AirportStats.AirlineDailyStats.stats{i}");
            }
            for (int i = 1; i <= numFlights; i++)
            {
                FlightRecord fr = flightRecords.ElementAt(i - 1);
                arr[i, 0]  = fr.airline;
                arr[i, 1]  = fr.aircraft;
                arr[i, 2]  = AirportStatUtils.FormatTime(fr.arrivalTime * 60, true);
                arr[i, 3]  = fr.actual_arrivalTime > 0 ? AirportStatUtils.FormatTime(fr.actual_arrivalTime * 60, true) : string.Empty;
                arr[i, 4]  = AirportStatUtils.FormatTime(fr.departureTime * 60, true);
                arr[i, 5]  = fr.actual_departureTime > 0 ? AirportStatUtils.FormatTime(fr.actual_departureTime * 60, true) : string.Empty;
                arr[i, 6]  = fr.nArriving.ToString("#");
                arr[i, 7]  = fr.actual_arrivalTime > 0 ? AirportStatUtils.FormatTime(fr.time_deplaning * 60) : string.Empty;
                arr[i, 8]  = fr.nDeparting.ToString("#");
                arr[i, 9]  = fr.nCheckedIn.ToString("#");
                arr[i, 10] = fr.nBoarded.ToString("#");
                arr[i, 11] = fr.nBoarded > 0 ? AirportStatUtils.FormatTime(fr.time_boarding * 60) : string.Empty;
                arr[i, 12] = fr.nArrivalBags.ToString("#");
                arr[i, 13] = fr.nBagsUnloaded.ToString("#");
                arr[i, 14] = fr.nBagsUnloaded > 0 ? AirportStatUtils.FormatTime(fr.time_bag_unload * 60, true) : string.Empty;
                arr[i, 15] = fr.nDepartingBags.ToString("#");
                arr[i, 16] = fr.nBagsLoaded.ToString("#");
                arr[i, 17] = fr.nBagsLoaded > 0 ? AirportStatUtils.FormatTime(fr.time_bag_load * 60) : string.Empty;
                arr[i, 18] = (fr.nFuelRequested / 1000).ToString("#,###");
                arr[i, 19] = (fr.nFuelRefueled / 1000).ToString("#,###");
                string st = string.Empty;
                foreach (Flight.Status stat in Enum.GetValues(typeof(Flight.Status)))
                {
                    if (AirportStatUtils.HasStatus(fr.status, stat))
                    {
                        st += i18n.Get("TBFlash.AirportStats.flightstatus." + Enum.GetName(typeof(Flight.Status), stat)) + "<br/>";
                    }
                }
                arr[i, 20] = st;
                arr[i, 21] = i18n.Get("UI.strings.flightstatusreason.") + fr.reason.ToString();
            }
            return(arr);
        }
Пример #8
0
        public void TrackAllreadyExists_AddToRenderWithColor()
        {
            _fakeMonitoredAirspace.HasPositionWithinBoundaries(Arg.Any <Position>()).Returns(true);

            var record = new FlightRecord()
            {
                Tag       = "AA123",
                Position  = new Position(20000, 20000, 19000),
                Timestamp = DateTime.MinValue
            };

            _fakeFlight.FlightRecordReceived += Raise.EventWith(_fakeFlight, new FlightRecordEventArgs(record));
            _fakeFlight.FlightRecordReceived += Raise.EventWith(_fakeFlight, new FlightRecordEventArgs(record));

            _fakeView.Received().AddToRenderWithColor(Arg.Any <string>(), Arg.Any <ConsoleColor>());
        }
        public void GivenTwoPositionRecords_CalculateVelocity(int lon1, int lat1, int alt1, int lon2, int lat2, int alt2, int time, double expectedVelocity)
        {
            _uut = new FlightTrack("AAA123");
            var record1 = new FlightRecord()
            {
                Position = new Position(lat1, lon1, alt1), Timestamp = new DateTime(2018, 1, 1, 0, 0, 0)
            };
            var record2 = new FlightRecord()
            {
                Position = new Position(lat2, lon2, alt2), Timestamp = new DateTime(2018, 1, 1, 0, 0, 0 + time)
            };

            _uut.Update(record1);
            _uut.Update(record2);

            Assert.That(_uut.Velocity, Is.EqualTo(expectedVelocity));
        }
        [TestCase(-1, -1, 1, 1, 45)]         // North East
        public void GivenTwoPositionRecords_CalculateNavigationCourse(int lat1, int lon1, int lat2, int lon2, double expectedCourse)
        {
            _uut = new FlightTrack("AAA123");
            var record1 = new FlightRecord()
            {
                Position = new Position(lat1, lon1, 0)
            };
            var record2 = new FlightRecord()
            {
                Position = new Position(lat2, lon2, 0)
            };

            _uut.Update(record1);
            _uut.Update(record2);

            Assert.That(_uut.NavigationCourse, Is.EqualTo(expectedCourse).Within(0.001));
        }
Пример #11
0
        public void Call_DetectCollision()
        {
            // Arrange
            _fakeMonitoredAirspace.HasPositionWithinBoundaries(Arg.Any <Position>()).Returns(true);

            // Act
            var record = new FlightRecord()
            {
                Tag       = "test flight",
                Position  = new Position(20000, 20000, 19000),
                Timestamp = DateTime.MinValue
            };

            _fakeFlight.FlightRecordReceived += Raise.EventWith(_fakeFlight, new FlightRecordEventArgs(record));

            // Assert
            _fakeSeperation.Received().DetectCollision(Arg.Any <ICollection <IFlightTrack> >());
        }
Пример #12
0
 internal void AddFlights(int day)
 {
     flights.Remove(day);
     // current day flightrecords are not accurate; not until the flight has departed and flight record is archived. Need to load the flights for today.
     //game.current.flightScheduler.Today
     //question: do I go through Today and create flightRecords and add the enumeration to this.flights? Makes it easier to deal with later. Makes sense.
     if (day == GameTimer.Day && Game.current.flightScheduler.Today.Count > 0)
     {
         List <FlightRecord> frs = new List <FlightRecord>();
         foreach (Flight flt in Game.current.flightScheduler.Today)
         {
             FlightRecord fr = new FlightRecord(flt)
             {
                 actual_arrivalTime   = flt.record.actual_arrivalTime,
                 actual_departureTime = flt.record.actual_departureTime,
                 nCheckedIn           = flt.nDepartingCheckedIn,
                 nBoarded             = flt.record.nBoarded,
                 nArrivalBags         = flt.nArrivalBags,
                 nDepartingBags       = flt.nDepartingBags,
                 nBagsUnloaded        = flt.record.nBagsUnloaded,
                 nBagsLoaded          = flt.record.nBagsLoaded,
                 time_boarding        = flt.record.time_boarding,
                 time_deplaning       = flt.record.time_deplaning,
                 time_bag_unload      = flt.record.time_bag_unload,
                 time_bag_load        = flt.record.time_bag_load,
                 nFuelRequested       = flt.record.nFuelRequested,
                 nFuelRefueled        = flt.record.nFuelRefueled,
                 status = flt.status,
                 reason = flt.reason
             };
             if (flt.gate != flt.flightSchema.gate)
             {
                 fr.alternateGate = flt.gate.Name;
             }
             frs.Add(fr);
         }
         flights.Add(day, frs.AsEnumerable <FlightRecord>());
     }
     else
     {
         flights.Add(day, Game.current.flightRecords.GetForDay(day));
     }
 }
        public void WhenRaisingTransponderDataReady_CallCreateRecord(string rawData)
        {
            // ARRANGE
            var transponderData = new List <string>();

            transponderData.Add(rawData);

            FlightRecord persistedArgs        = null;
            var          expectedFlightRecord = new FlightRecord();

            _sut.FlightRecordReceived += (sender, e) =>
            {
                persistedArgs = e.FlightRecord;
            };

            //ACT
            _fakeTransponder.TransponderDataReady += Raise.EventWith(_fakeTransponder, new RawTransponderDataEventArgs(transponderData));

            // ASSERT
            _fakeFlightRecordFactory.Received().CreateRecord(Arg.Any <string>());
        }
        public FlightRecord CreateRecord(string rawRecordData)
        {
            var flightDataSplitArr = rawRecordData.Split(';');
            var provider           = CultureInfo.InvariantCulture;
            var latitude           = Int32.Parse(flightDataSplitArr[1], provider);
            var longitude          = Int32.Parse(flightDataSplitArr[2], provider);
            var altitude           = Int32.Parse(flightDataSplitArr[3], provider);

            var format = "yyyyMMddHHmmssfff";

            DateTime.TryParseExact(flightDataSplitArr[4], format, provider,
                                   DateTimeStyles.None, out var time);

            var record = new FlightRecord()
            {
                Tag       = flightDataSplitArr[0],
                Position  = new Position(latitude, longitude, altitude),
                Timestamp = time
            };

            return(record);
        }
Пример #15
0
        public void Not_RenderAnyTracksOutsideTheMonitoredAirSpace()
        {
            _fakeMonitoredAirspace.HasPositionWithinBoundaries(Arg.Any <Position>()).Returns(true);

            var record = new FlightRecord()
            {
                Tag       = "test flight",
                Position  = new Position(0, 0, 0),
                Timestamp = DateTime.MinValue
            };

            _fakeFlight.FlightRecordReceived += Raise.EventWith(_fakeFlight, new FlightRecordEventArgs(record));


            IFlightTrack persistedArg = null;

            _uut.LeftAirspace += (sender, e) => { persistedArg = e.FlightTrack; };

            _fakeMonitoredAirspace.HasPositionWithinBoundaries(Arg.Any <Position>()).Returns(false);
            _fakeFlight.FlightRecordReceived += Raise.EventWith(_fakeFlight, new FlightRecordEventArgs(record));

            Assert.That(persistedArg, Is.Not.Null);
        }
Пример #16
0
 public FlightRecordEventArgs(FlightRecord record)
 {
     FlightRecord = record;
 }
        public static IFlightTrack SortRecordByTag(this ICollection <IFlightTrack> tracks, FlightRecord update)
        {
            if (tracks == null)
            {
                throw new ArgumentNullException(nameof(tracks));
            }

            if (!tracks.Any(track => track.Tag == update.Tag))
            {
                IFlightTrack newTrack = new FlightTrack(update.Tag);
                newTrack.Update(update);
                tracks.Add(newTrack);
                return(newTrack);
            }
            else
            {
                var updatedTrack = tracks.First(track => track.Tag == update.Tag);
                updatedTrack.Update(update);
                return(updatedTrack);
            }
        }
 public ActionResult BookFlight(SearchFlightModel model)
 {
     try
     {
         using (var ctx = new UIA_Entities())
         {
             FlightRecord flight_record = new FlightRecord();
             flight_record.Name           = model.Name;
             flight_record.PassportNumber = model.PassportNumber;
             flight_record.SeatNo         = model.SeatNo;
             flight_record.Time           = model.Time;
             flight_record.Origin         = model.Origin;
             flight_record.Destination    = model.Destination;
             flight_record.SeatClass      = model.Seat_Class;
             flight_record.Price          = model.Price;
             flight_record.SeatNo         = model.SeatNo;
             flight_record.UserId         = model.UserId;
             flight_record.DateOfBirth    = model.DateOfBirth;
             flight_record.Email          = model.Email;
             flight_record.Id             = Guid.NewGuid().ToString("N");
             flight_record.FlightID       = (from table in ctx.Flights where table.fromAirport == model.OriginAirport where table.toAirport == model.DestinationAirport select table.Id).Single();
             ctx.FlightRecords.Add(flight_record);
             ctx.SaveChanges();
         }
         using (var ctx = new UIA_Entities())
         {
             if (model.hasReturn)
             {
                 FlightRecord flight_record_return = new FlightRecord();
                 flight_record_return.Name           = model.Name;
                 flight_record_return.PassportNumber = model.PassportNumber;
                 flight_record_return.SeatNo         = model.SeatNo;
                 flight_record_return.Time           = model.TimeReturn;
                 flight_record_return.Origin         = model.OriginReturn;
                 flight_record_return.Destination    = model.DestinationReturn;
                 flight_record_return.SeatClass      = model.Seat_Class;
                 flight_record_return.Price          = model.PriceReturn;
                 flight_record_return.SeatNo         = model.SeatNo;
                 flight_record_return.UserId         = model.UserId;
                 flight_record_return.DateOfBirth    = model.DateOfBirth;
                 flight_record_return.Email          = model.Email;
                 flight_record_return.Id             = Guid.NewGuid().ToString("N");
                 flight_record_return.FlightID       = (from table in ctx.Flights where table.fromAirport == model.OriginAirportReturn where table.toAirport == model.DestinationAirportReturn select table.Id).Single();
                 ctx.FlightRecords.Add(flight_record_return);
                 ctx.SaveChanges();
             }
         }
         using (var ctx = new UIA_Entities())
         {
             PaymentRecord payment = new PaymentRecord();
             payment.UserId         = model.UserId;
             payment.CCV            = model.CCV;
             payment.PurchaseDate   = DateTime.Now;
             payment.CardHolderName = model.CardHolderName;
             payment.CardType       = model.CardType;
             payment.CardNumber     = model.CardNumber;
             payment.TotalPrice     = model.TotalPrice;
             payment.PurchaseId     = Guid.NewGuid().ToString("N");
             payment.ExpiryDate     = model.ExpiryDate;
             ctx.PaymentRecords.Add(payment);
             ctx.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     return(RedirectToAction("BookingConfirmed"));
 }