public Aircraft(AircraftType type, bool maintenanceStatus, int range) { ScheduleList = new List<Schedule>(); AircraftType = type; this.MaintenanceStatus = maintenanceStatus; PassengerCapacity = (int)AircraftType; this.Range = range; }
public ActionResult Add(AircraftType aircraftType) { if(ModelState.IsValid) { db.AircraftTypes.Add(aircraftType); db.SaveChanges(); return RedirectToAction("Index", "Home"); } return View(); }
public AddAircraftTypeResponse AddAircraftTypeResponse(AircraftType entity) { return(new AddAircraftTypeResponse(entity.Id)); }
/// <summary> /// See interface docs. /// </summary> /// <param name="type"></param> /// <returns></returns> public AircraftType FindAircraftType(string type) { AircraftType result = null; if (_FakeGroundVehicleCodes != null && _FakeGroundVehicleCodes.Length > 0 && _FakeGroundVehicleCodes.Contains(type)) { result = CreateGroundVehicleRecord(type); } else if (_FakeTowerCodes != null && _FakeTowerCodes.Length > 0 && _FakeTowerCodes.Contains(type)) { result = CreateTowerRecord(type); } if (result == null) { lock (Lock) { if (_FilesValid) { using (var connection = CreateOpenConnection()) { Sql.RunSql(connection, null, "SELECT [Icao]" + " ,[WakeTurbulenceId]" + " ,[SpeciesId]" + " ,[EngineTypeId]" + " ,[Engines]" + " ,[Model]" + " ,[Manufacturer]" + (_DatabaseVersion >= 5 ? ",[EnginePlacementId]" : "") + " FROM [AircraftTypeNoEnumsView]" + " WHERE [Icao] = @icao", new Dictionary <string, object>() { { "@icao", type }, }, (reader) => { if (result == null) { result = new AircraftType() { Type = Sql.GetString(reader, 0), WakeTurbulenceCategory = (WakeTurbulenceCategory)Sql.GetInt32(reader, 1), Species = (Species)Sql.GetInt32(reader, 2), EngineType = (EngineType)Sql.GetInt32(reader, 3), Engines = Sql.GetString(reader, 4), }; } result.Models.Add(Sql.GetString(reader, 5)); var manufacturer = Sql.GetString(reader, 6); if (!String.IsNullOrEmpty(manufacturer)) { result.Manufacturers.Add(manufacturer); } if (_DatabaseVersion >= 5) { result.EnginePlacement = (EnginePlacement)Sql.GetInt32(reader, 7); } return(true); }, false, null); } } } } return(result); }
/// <summary> /// Create random flights /// </summary> private static Random Init_FlightSet() { Console.WriteLine("Create Flights..."); WWWingsContext ctx = new WWWingsContext(); ctx.ChangeTracker.AutoDetectChangesEnabled = false; var act1 = new AircraftType(); act1.TypeID = 1; act1.Manufacturer = "Airbus"; act1.Name = "A380-800"; // max 853 Passengers ctx.AircraftTypeSet.Add(act1); var act2 = new AircraftType(); act2.TypeID = 2; act2.Manufacturer = "Boeing"; act2.Name = "737-500"; // max 140 Passengers ctx.AircraftTypeSet.Add(act2); ctx.SaveChanges(); var flightSet = from f in ctx.FlightSet select f; int Start = 100; Pilot[] PilotArray = ctx.PilotSet.ToArray(); var sw = new Stopwatch(); sw.Start(); for (int i = Start; i < (Start + NO_OF_FLIGHTS); i++) { if (i % 100 == 0) { Console.WriteLine("Flight #" + i + " / Duration of creation of last 100:" + sw.ElapsedMilliseconds + "ms"); sw.Restart(); try { ctx.SaveChanges(); ctx = new WWWingsContext(); } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message.ToString()); } } Flight flightNew = new Flight(); flightNew.FlightNo = i; flightNew.Departure = Airports[rnd.Next(0, Airports.Length - 1)]; flightNew.Destination = Airports[rnd.Next(0, Airports.Length - 1)]; if (flightNew.Departure == flightNew.Destination) // no roundtrip flights :-) { i--; continue; } flightNew.FreeSeats = Convert.ToInt16(new Random(i).Next(250)); int randdomAircrafttype = (DateTime.Now.Millisecond % 2) + 1; flightNew.AircraftTypeID = (byte)randdomAircrafttype; if (randdomAircrafttype == 1) { flightNew.Seats = 853; } else { flightNew.Seats = 140; } flightNew.Date = DateTime.Now.AddDays((double)flightNew.FreeSeats).AddMinutes((double)flightNew.FreeSeats * 7); flightNew.PilotId = PilotArray[rnd.Next(PilotArray.Count() - 1)].PersonID; flightNew.CopilotId = PilotArray[rnd.Next(PilotArray.Count() - 1)].PersonID; ctx.FlightSet.Add(flightNew); } ctx.SaveChanges(); CUI.PrintSuccess("Number of Flights: " + ctx.FlightSet.Count()); var f101 = ctx.FlightSet.Find(101); f101.Departure = "Berlin"; f101.Destination = "Seattle"; ctx.SaveChanges(); return(rnd); }
public FlightWaiting CreateWaitingFlight(Airport origin, Airport destination, AircraftType type, string time) { int id = NextAvailiableId(); string name = type.ToString() + id; Aircraft a = new Aircraft(name, origin.Coordinates, type, id); WaitingFlight f = new WaitingFlight(a, origin, destination, Canv, DateTime.UtcNow); return(new FlightWaiting() { DateTime = time, Flight = f }); }
public void TestInitialise() { _OriginalFactory = Factory.TakeSnapshot(); _RuntimeEnvironment = TestUtilities.CreateMockSingleton <IRuntimeEnvironment>(); _RuntimeEnvironment.Setup(r => r.IsTest).Returns(true); _Clock = new ClockMock(); Factory.RegisterInstance <IClock>(_Clock.Object); _Fetcher = Factory.ResolveNewInstance <IAircraftDetailFetcher>(); _FetchedHandler = new EventRecorder <EventArgs <AircraftDetail> >(); _Fetcher.Fetched += _FetchedHandler.Handler; _Aircraft = TestUtilities.CreateMockInstance <IAircraft>(); _Aircraft.Setup(r => r.Icao24).Returns("ABC123"); // The fetcher uses a private heartbeat service to avoid slowing the GUI down. Unfortunately // the TestUtilities don't support creating non-singleton instances of ISingletons, do we // have to do it manually. _Heartbeat = TestUtilities.CreateMockInstance <IHeartbeatService>(); Factory.RegisterInstance <IHeartbeatService>(_Heartbeat.Object); _AutoConfigDatabase = TestUtilities.CreateMockSingleton <IAutoConfigBaseStationDatabase>(); _Database = TestUtilities.CreateMockInstance <IBaseStationDatabase>(); _AutoConfigDatabase.Setup(r => r.Database).Returns(_Database.Object); _DatabaseAircraftAndFlights = null; _GetManyAircraftAndFlightsByCodes = new List <string>(); _GetManyAircraftByCodes = new List <string>(); _Database.Setup(r => r.GetManyAircraftByCode(It.IsAny <IEnumerable <string> >())).Returns((IEnumerable <string> icaos) => { var result = new Dictionary <string, BaseStationAircraft>(); if (icaos != null && icaos.Count() == 1 && icaos.First() == "ABC123" && _DatabaseAircraft != null) { result.Add("ABC123", _DatabaseAircraft); } if (icaos != null) { _GetManyAircraftByCodes.AddRange(icaos); } return(result); }); _Database.Setup(r => r.GetManyAircraftAndFlightsCountByCode(It.IsAny <IEnumerable <string> >())).Returns((IEnumerable <string> icaos) => { var result = new Dictionary <string, BaseStationAircraftAndFlightsCount>(); if (icaos != null && icaos.Count() == 1 && icaos.First() == "ABC123" && _DatabaseAircraftAndFlights != null) { result.Add("ABC123", _DatabaseAircraftAndFlights); } if (icaos != null) { _GetManyAircraftAndFlightsByCodes.AddRange(icaos); } return(result); }); _AutoConfigPictureFolderCache = TestUtilities.CreateMockSingleton <IAutoConfigPictureFolderCache>(); _PictureFolderCache = TestUtilities.CreateMockInstance <IDirectoryCache>(); _AutoConfigPictureFolderCache.Setup(r => r.DirectoryCache).Returns(() => _PictureFolderCache.Object); _AircraftPictureManager = TestUtilities.CreateMockSingleton <IAircraftPictureManager>(); _PictureManagerCache = _PictureFolderCache.Object; _PictureManagerIcao24 = "INVALID"; _PictureManagerReg = null; _PictureManagerThrowException = false; _PictureDetail = new PictureDetail(); _AircraftPictureManager.Setup(r => r.FindPicture(It.IsAny <IDirectoryCache>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <PictureDetail>())).Returns((IDirectoryCache cache, string icao24, string reg, PictureDetail existingPictureDetail) => { if (_PictureManagerThrowException) { throw new InvalidOperationException(); } return(cache == _PictureManagerCache && icao24 == _PictureManagerIcao24 && reg == _PictureManagerReg ? _PictureDetail : null); }); _StandingDataManager = TestUtilities.CreateMockSingleton <IStandingDataManager>(); _AircraftType = new AircraftType(); _StandingDataManager.Setup(r => r.FindAircraftType(It.IsAny <string>())).Returns((string type) => { return(type == _FindAircraftType ? _AircraftType : null); }); _Log = TestUtilities.CreateMockSingleton <ILog>(); _Log.Setup(r => r.WriteLine(It.IsAny <string>())).Callback((string x) => { throw new InvalidOperationException(x); }); _Log.Setup(r => r.WriteLine(It.IsAny <string>(), It.IsAny <object[]>())).Callback((string x, object[] args) => { throw new InvalidOperationException(String.Format(x, args)); }); _AircraftOnlineLookupManager = TestUtilities.CreateMockSingleton <IAircraftOnlineLookupManager>(); }
//Get all aircraft types from Flight Radar data file public static List <AircraftType> GetAllAircraftTypes() { List <AircraftType> allAircraftTypes = new List <AircraftType>(); using (var reader = new StreamReader("AircraftTypes.csv")) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { var records = csv.GetRecords <AircraftTypeCSV>(); foreach (var aircraftType in records) { if (string.IsNullOrEmpty(aircraftType.MaxSpeed)) { aircraftType.MaxSpeed = "0"; } if (string.IsNullOrEmpty(aircraftType.MaxRange)) { aircraftType.MaxRange = "0"; } if (string.IsNullOrEmpty(aircraftType.MaxPassengers)) { aircraftType.MaxPassengers = "0"; } if (string.IsNullOrEmpty(aircraftType.MLW)) { aircraftType.MLW = "0"; } if (string.IsNullOrEmpty(aircraftType.MTOW)) { aircraftType.MTOW = "0"; } if (string.IsNullOrEmpty(aircraftType.MZFW)) { aircraftType.MZFW = "0"; } if (string.IsNullOrEmpty(aircraftType.FuelCapacity)) { aircraftType.FuelCapacity = "0"; } if (string.IsNullOrEmpty(aircraftType.MaxSpeed)) { aircraftType.OEW = "0"; } if (string.IsNullOrEmpty(aircraftType.MaxCeiling)) { aircraftType.MaxCeiling = "0"; } AircraftType newAircraftType = new AircraftType { Name = aircraftType.Name, ICAO = aircraftType.ICAO, IATA = aircraftType.IATA, Size = (AircraftSize)Enum.Parse(typeof(AircraftSize), aircraftType.WeightCategory), Manufacturer = aircraftType.Manufacturer, MaxCeiling = Convert.ToInt32(aircraftType.MaxCeiling), MaxSpeed = Convert.ToInt32(aircraftType.MaxSpeed), MaxRange = Convert.ToInt32(aircraftType.MaxRange), MaxPassengers = Convert.ToInt32(aircraftType.MaxPassengers), MaxLandingWeight = Convert.ToInt32(aircraftType.MLW), MaxTakeoffWeight = Convert.ToInt32(aircraftType.MTOW), MaxZeroFuelWeight = Convert.ToInt32(aircraftType.MZFW), FuelCapacity = Convert.ToInt32(aircraftType.FuelCapacity), Engines = aircraftType.Engines, OperatingEmptyWeight = Convert.ToInt32(aircraftType.OEW), }; allAircraftTypes.Add(newAircraftType); } } return(allAircraftTypes); }
public async Task UpdateAsync(AircraftType type) { await _aircraftTypeService.UpdateAsync(type); await UpdateListAsync(); }
public async Task AddAsync(AircraftType ob) { await _aircraftTypeService.PostAsync(ob); await UpdateListAsync(); }
public static void Run(bool delete = false) { CUI.Print("Data Generator", ConsoleColor.Blue, ConsoleColor.White); WWWingsContext ctx = new WWWingsContext(); Console.WriteLine("Number of Flights: " + ctx.FlightSet.Count()); Console.WriteLine("Number of Pilots: " + ctx.PilotSet.Count()); Console.WriteLine("Number of Passengers: " + ctx.PassengerSet.Count()); Console.WriteLine("Number of Bookings: " + ctx.BookingSet.Count()); // TODO: this does not work yet :-( //ctx.Database.ExecuteSqlCommand(File.ReadAllText(@"H:\TFS\Demos\EFC\EFC_Samples\SQL\WWWings70_CreateSP.sql").Replace("GO","")); //ctx.Database.ExecuteSqlCommand(File.ReadAllText(@"H:\TFS\Demos\EFC\EFC_Samples\SQL\WWWings70_CreateTVF.sql").Replace("GO", "")); //ctx.Database.ExecuteSqlCommand(File.ReadAllText(@"H:\TFS\Demos\EFC\EFC_Samples\SQL\WWWings70_CreateView.sql").Replace("GO", "")); if (ctx.FlightSet.Any() || ctx.PilotSet.Any() || ctx.PassengerSet.Any() || ctx.BookingSet.Any()) { if (!delete) { return; } CUI.PrintWarning( "Database is not empty. Delete all data and create new records? y = yes, other key = no and exit program"); var key = Console.ReadKey(); if (key.Key != ConsoleKey.Y) { Environment.Exit(1); } } if (delete) { CUI.PrintSuccess("Deleting..."); ctx.Database.ExecuteSqlCommand("Delete from Airline"); ctx.Database.ExecuteSqlCommand("Delete from Booking"); ctx.Database.ExecuteSqlCommand("Delete from Flight"); ctx.Database.ExecuteSqlCommand("Delete from Passenger"); ctx.Database.ExecuteSqlCommand("Delete from Employee"); ctx.Database.ExecuteSqlCommand("Delete from Persondetail"); ctx.Database.ExecuteSqlCommand("Delete from AircraftType"); ctx.Database.ExecuteSqlCommand("Delete from AircraftTypeDetail"); } Console.WriteLine("Number of Flights: " + ctx.FlightSet.Count()); Console.WriteLine("Number of Pilots: " + ctx.PilotSet.Count()); Console.WriteLine("Number of Passengers: " + ctx.PassengerSet.Count()); Console.WriteLine("Number of Bookings: " + ctx.BookingSet.Count()); var act = new AircraftType(); act.TypeID = 1; act.Manufacturer = "Airbus"; act.Name = "A380-800"; ctx.AircraftTypeSet.Add(act); Init_AirlineSet(ctx); Init_PilotSet(ctx); Init_FlightSet(ctx); Init_PassengerSet(ctx); Init_BookingSet(); CUI.PrintSuccess("=== End of data generation!"); }
public Airplane Airplane(AddAirplane request, AircraftType aircraftType) { return(new Airplane(request.Registration, aircraftType)); }
public void GenerateDemoData() { if (Repository.Query <AircraftType>().Count() > 0) { return; // Mach nix } AircraftType at1 = new AircraftType(); at1.Code = "C100"; at1.Model = "Cessna"; at1.Manufacturer = "Cessna"; at1.WTC = WTC.L; AircraftType at2 = new AircraftType(); at2.Code = "B735"; at2.Model = "Boeing 737-500"; at2.Manufacturer = "Boeing"; at2.WTC = WTC.H; AircraftType at3 = new AircraftType(); at3.Code = "A380"; at3.Model = "Airbus 380"; at3.Manufacturer = "Airbus"; at3.WTC = WTC.X; Airport a1 = new Airport(); a1.LocInt = "LOWW"; a1.Decode = "Vienna"; a1.Iata = "VIE"; a1.Latitude = 48.110298156738; a1.Longitude = 16.569700241089; a1.Elevation = 600; a1.SupportedWTC = WTC.L | WTC.M | WTC.H | WTC.X; Airport a2 = new Airport(); a2.LocInt = "EGLL"; a2.Decode = "London Heathrow Airport"; a2.Iata = "LHR"; a2.Latitude = 51.4706; a2.Longitude = -0.461941; a2.Elevation = 83; a2.SupportedWTC = WTC.L | WTC.M | WTC.H | WTC.X; Airport a3 = new Airport(); a3.LocInt = "LIMF"; a3.Decode = "Turin Airport"; a3.Iata = "TRN"; a3.Latitude = 45.200802; a3.Longitude = 7.46963; a3.Elevation = 989; a3.SupportedWTC = WTC.L | WTC.M | WTC.H; Flight f1 = new Flight(); f1.Departure = a1; f1.Destination = a2; f1.Duration = TimeSpan.FromMinutes(150); f1.AircraftID = "DLH123"; f1.AircraftType = at2; Flight f2 = new Flight(); f2.Departure = a3; f2.Destination = a1; f2.Duration = TimeSpan.FromMinutes(240); // Mit Rückenwind f2.AircraftID = "OEADS"; f2.AircraftType = at1; Flight f3 = new Flight(); f3.Departure = a2; f3.Destination = a3; f3.Duration = TimeSpan.FromMinutes(240); f3.AircraftID = "BAW987"; f3.AircraftType = at3; Repository.Add(f1); Repository.Add(f2); Repository.Add(f3); Repository.Save(); }
public Airport[] GetAllAirportsFor(AircraftType aircraft) { return(Repository.Query <Airport>().Where(x => x.SupportedWTC.HasFlag(aircraft.WTC)) .ToArray()); }
public GetAircraftTypeByIdResponse GetAircraftTypeByIdResponse(AircraftType entity) { return(new GetAircraftTypeByIdResponse(entity.Id, entity.Manufacturer, entity.Model)); }
public static void EinfachesUpdate() { // Set up demo: Create 1 flight type and 3 flights using (WWWingsContext ctx = new WWWingsContext()) { if (!ctx.AircraftTypeSet.Any()) { var ft = new AircraftType(); ft.TypeID = 1; ft.Manufacturer = "Airbus"; ft.Name = "A320"; ctx.AircraftTypeSet.Add(ft); var anz1 = ctx.SaveChanges(); Console.WriteLine("New aircrafttypes: " + anz1); } var ft2 = ctx.AircraftTypeSet.FirstOrDefault(); ctx.Log(); if (!ctx.FlightSet.Any(f => f.Departure == "Amsterdam")) { var p = new Pilot(); p.GivenName = "Holger"; p.Surname = "Schwichtenberg"; p.HireDate = DateTime.Now; p.LicenseDate = DateTime.Now; var pd = new Persondetail(); //pd.Planet = "Erde"; p.Detail = pd; var maxflightNo = ctx.FlightSet.Max(x => x.FlightNo); for (int i = 0; i < 3; i++) { var f = new Flight(); f.Pilot = p; f.FlightNo = maxflightNo + i; f.Departure = "Amsterdam"; f.Destination = "Bucharest"; f.Seats = 100; f.FreeSeats = 100; f.Date = DateTime.Now.AddDays(i); f.AircraftType = ft2; ctx.FlightSet.Add(f); var anz2 = ctx.SaveChanges(); Console.WriteLine("New flights: " + anz2); } } foreach (var f in ctx.FlightSet.Where(f => f.Departure == "Amsterdam").ToList()) { f.AircraftType = ft2; var anz3 = ctx.SaveChanges(); Console.WriteLine("Neu aircraft type assigment: " + anz3); } } CUI.Headline("Delete with dependent objects of the N-side in RAM"); using (WWWingsContext ctx = new WWWingsContext()) { ctx.Log(); Console.WriteLine("Total number of flights: " + ctx.FlightSet.Count()); var ft = ctx.AircraftTypeSet.FirstOrDefault(); //var ft = ctx.AircraftTypeSet.Include(x=>x.FlightSet).FirstOrDefault(); ctx.FlightSet.Where(f => f.AircraftTypeID == ft.TypeID).ToList(); ctx.ChangeTracker.DetectChanges(); Console.WriteLine("Flights with this aircraft type: " + ft.FlightSet.Count); CUI.Print("Remove aircraft type now...", ConsoleColor.Red); ctx.AircraftTypeSet.Remove(ft); var anz1 = ctx.SaveChanges(); Console.WriteLine("Number of saved changes: " + anz1); Console.WriteLine("Total number of flights: " + ctx.FlightSet.Count()); } }
/// <summary> /// Создает элемент управления для отображения коллекции ссылок для ВС и его отчетов /// </summary> public AircraftReferencesControl(AircraftType aircraftType) { this.aircraftType = aircraftType; InitializeComponent(); }
private static string GetNavPointsLabelText(AircraftType type, int number) { return(string.Format(type == AircraftType.Plane ? "SS{0:000}" : "UM{0:000}", number)); }
public AircraftTypeDTO GetAircraftType(int id) { AircraftType aircraftType = unitOfWork.AircraftTypes.GetById(id); return(mapper.Map <AircraftType, AircraftTypeDTO>(aircraftType)); }
public Aircraft(Point location, AircraftType aircraftType = AircraftType.FighterJet, int score = 20) : base(location, Aircraft.AircraftSize) { this.AircraftType = aircraftType; this.Score = score; }
private async void Page_Loaded(object sender, RoutedEventArgs e) { var window = this.window as NewEditAircraftConfigurationWindow; window.Top = SystemParameters.PrimaryScreenHeight / 2 - window.ActualHeight / 2; var aircraftTypeDataList = await dbCon.GetDataList("AircraftTypeReference", null, "WHERE StatusCode = 'A' ORDER BY AircraftTypeCode"); if (aircraftTypeDataList.HasData && aircraftTypeDataList.Error == ERROR.NoError) { foreach (DataRow row in aircraftTypeDataList) { aircraftTypeComboBox.Items.Add(new CustomComboBoxItem { Text = string.Format("{0} - {1}", row.Get("AircraftTypeCode"), row.Get("AircraftTypeName")), Value = row.Get("AircraftTypeCode").ToString() }); } } else { var result = MessageBox.Show(Messages.ERROR_AIRCRAFT_TYPE_NOTFOUND, Captions.NO_AIRCRAFT_TYPE_FOUND, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { this.window.Hide(); var aircraftTypeWindow = new AircraftTypeWindow(); aircraftTypeWindow.ShowDialog(); this.window.Close(); } else { this.window.Close(); } } statusComboBox.Items.Add(new CustomComboBoxItem { Text = "Active", Value = "A" }); statusComboBox.Items.Add(new CustomComboBoxItem { Text = "Inactive", Value = "I" }); if (Status == STATUS.NEW) { commitByStackPanel.Visibility = Visibility.Collapsed; commitTimeStackPanel.Visibility = Visibility.Collapsed; } else { try { var acData = await dbCon.GetDataRow("AircraftConfiguration", new DataRow("AircraftConfigurationId", AircraftConfigId)); if (acData.HasData && acData.Error == ERROR.NoError) { AircraftConfiguration = new AircraftConfiguration(); var properties = AircraftConfiguration.GetType().GetProperties(); foreach (var property in properties) { if (acData.ContainKey(property.Name)) { if (property.CanWrite) { property.SetValue(AircraftConfiguration, acData.Get(property.Name), null); } } } var aircraftTypeData = await dbCon.GetDataRow("AircraftTypeReference", new DataRow("AircraftTypeCode", acData.Get("AircraftTypeCode"))); if (aircraftTypeData.HasData && aircraftTypeData.Error == ERROR.NoError) { var aircraftType = new AircraftType(); var atProps = aircraftType.GetType().GetProperties(); foreach (var atProp in atProps) { if (atProp.CanWrite) { atProp.SetValue(aircraftType, aircraftTypeData.Get(atProp.Name), null); } } AircraftConfiguration.AircraftType = aircraftType; aircraftConfigCodeTextBox.Text = AircraftConfiguration.AircraftConfigurationCode; aircraftConfigNameTextBox.Text = AircraftConfiguration.AircraftConfigurationName; aircraftTypeComboBox.SelectedValue = AircraftConfiguration.AircraftType.AircraftTypeCode; statusComboBox.SelectedValue = AircraftConfiguration.StatusCode; commitByTextBlockValue.Text = await dbCon.GetFullNameFromUid(acData.Get("CommitBy").ToString()); commitTimeTextBlockValue.Text = acData.Get("CommitDateTime").ToString(); } else { MessageBox.Show(Messages.ERROR_GET_AIRCRAFT_CONFIG, Captions.ERROR); window.DialogResult = false; window.Close(); } } else { MessageBox.Show(Messages.ERROR_GET_AIRCRAFT_CONFIG, Captions.ERROR); window.DialogResult = false; window.Close(); } } catch (Exception ex) { Debug.WriteLine(ex.Message); MessageBox.Show(Messages.ERROR_GET_AIRCRAFT_CONFIG, Captions.ERROR); window.DialogResult = false; window.Close(); } } aircraftConfigCodeTextBox.Focus(); }
/// <summary> /// See interface docs. /// </summary> /// <param name="type"></param> /// <returns></returns> public AircraftType FindAircraftType(string type) { AircraftType result = null; if (_FakeGroundVehicleCodes != null && _FakeGroundVehicleCodes.Length > 0 && _FakeGroundVehicleCodes.Contains(type)) { result = CreateGroundVehicleRecord(type); } else if (_FakeTowerCodes != null && _FakeTowerCodes.Length > 0 && _FakeTowerCodes.Contains(type)) { result = CreateTowerRecord(type); } if (result == null) { lock (Lock) { if (_FilesValid) { using (var connection = CreateOpenConnection()) { foreach (var aircraftType in connection.Query <AircraftType, string, string, AircraftType>(@" SELECT [Icao] AS [Type] ,[WakeTurbulenceId] AS [WakeTurbulenceCategory] ,[SpeciesId] AS [Species] ,[EngineTypeId] AS [EngineType] ,[Engines]" + (_DatabaseVersion >= 5 ? ",[EnginePlacementId] AS [EnginePlacement]" : "") + @" ,[Manufacturer] ,[Model] FROM [AircraftTypeNoEnumsView] WHERE [Icao] = @icao ", map: (acType, manufacturer, model) => { if (!String.IsNullOrEmpty(manufacturer)) { acType.Manufacturers.Add(manufacturer); } if (!String.IsNullOrEmpty(model)) { acType.Models.Add(model); } return(acType); }, splitOn: $"Manufacturer,Model", param: new { icao = type })) { if (result == null) { result = aircraftType; } else { if (aircraftType.Manufacturers.Count > 0) { result.Manufacturers.Add(aircraftType.Manufacturers[0]); } if (aircraftType.Models.Count > 0) { result.Models.Add(aircraftType.Models[0]); } } } ; } } } } return(result); }
private async Task LoadSeatMapImage() { DataRow aircraftConfigData = await dbCon.GetDataRow("AircraftConfiguration", new DataRow("AircraftConfigurationId", AircraftConfigurationId)); if (aircraftConfigData.HasData && aircraftConfigData.Error == ERROR.NoError) { AircraftConfiguration = new AircraftConfiguration(); PropertyInfo[] properties = typeof(AircraftConfiguration).GetProperties(); foreach (PropertyInfo property in properties) { if (aircraftConfigData.ContainKey(property.Name)) { property.SetValue(AircraftConfiguration, aircraftConfigData.Get(property.Name)); } } DataRow aircraftTypeData = await dbCon.GetDataRow("AircraftTypeReference", new DataRow("AircraftTypeCode", aircraftConfigData.Get("AircraftTypeCode"))); if (aircraftTypeData.HasData && aircraftTypeData.Error == ERROR.NoError) { AircraftType aircraftType = new AircraftType(); properties = typeof(AircraftType).GetProperties(); foreach (PropertyInfo property in properties) { if (aircraftTypeData.ContainKey(property.Name)) { property.SetValue(aircraftType, aircraftTypeData.Get(property.Name)); } } AircraftConfiguration.AircraftType = aircraftType; } double AisleX = AdjustRatio(AircraftConfiguration.AisleX); double FrontDoorX = AdjustRatio(AircraftConfiguration.FrontDoorX); double FrontDoorY = AdjustRatio(AircraftConfiguration.FrontDoorY, false); double FrontDoorWidth = AdjustRatio(AircraftConfiguration.FrontDoorWidth, false); double RearDoorX = AdjustRatio(AircraftConfiguration.RearDoorX); double RearDoorY = AdjustRatio(AircraftConfiguration.RearDoorY, false); double RearDoorWidth = AdjustRatio(AircraftConfiguration.RearDoorWidth, false); AircraftConfiguration.AisleX = AisleX; AircraftConfiguration.FrontDoorX = FrontDoorX; AircraftConfiguration.FrontDoorY = FrontDoorY; AircraftConfiguration.FrontDoorWidth = FrontDoorWidth; AircraftConfiguration.RearDoorX = RearDoorX; AircraftConfiguration.RearDoorY = RearDoorY; AircraftConfiguration.RearDoorWidth = RearDoorWidth; seatMapImg.Source = aircraftConfigData.Get("SeatMapImage").BlobToSource(); if (selectedSeat != null && FrontDoorUsingFlag && RearDoorUsingFlag) { int selectedRow = int.Parse(selectedSeat.Split('_')[1]); if (selectedRow < AircraftConfiguration.MiddleRow) { imageCanvas.LayoutTransform = new RotateTransform(180); } } else if (FrontDoorUsingFlag) { imageCanvas.LayoutTransform = new RotateTransform(180); } } }