Пример #1
0
        private IList<BoardJob> GenerateBoardJobs(string departure)
        {
            IList<BoardJob> listBoardJobs = new List<BoardJob>();

            try
            {
                var dep = AirportDatabaseFile.FindAirportInfo(departure);

                var depCoord = new GeoCoordinate(dep.Latitude, dep.Longitude);
                var randomPob = new Random();
                var randomCargo = new Random();

                var plane = new Plane() { Country = dep.Country };
                var planes = plane.GetPlanesByCountry();

                foreach (var arrival in new Base().GetAll())
                {
                    var arrCoord = new GeoCoordinate(arrival.Latitude, arrival.Longitude);
                    var distMeters = depCoord.GetDistanceTo(arrCoord);
                    var distMiles = (int)DataConversion.ConvertMetersToMiles(distMeters);
                    int pob = randomPob.Next(95, 135);  // TODO:
                    int cargo = randomCargo.Next(500, 3500); // TODO:

                    long profit = (pob + cargo) * distMiles;

                    string planeName = "A320";
                    if (planes.Count > 0)
                    {
                        planeName = planes.First().ModelName + " " + planes.First().Companny;
                    }

                    listBoardJobs.Add(new BoardJob()
                    {
                        Plane = planeName,
                        Departure = departure,
                        Arrival = arrival.ICAO,
                        Dist = distMiles,
                        Eobt = 127, // TODO:
                        Pob = pob,
                        Cargo = cargo,
                        Profit = profit
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return listBoardJobs;
        }