private async void BtnUpdate_OnClick(object sender, RoutedEventArgs e) { if (!isCreate) { var pilotInput = ReadTextBoxesData(); if (pilotInput != null && _selectedAircraft != null) { try { await Service.Update(pilotInput, _selectedAircraft.Id); } catch { Info.Text = "Server error!"; } var itemIndex = Aircrafts.ToList().FindIndex(x => x.Id == _selectedAircraft.Id); var item = Aircrafts.ToList().ElementAt(itemIndex); Aircrafts.RemoveAt(itemIndex); item = pilotInput; item.Id = _selectedAircraft.Id; Aircrafts.Insert(itemIndex, item); TbId.Text = "Aircraft Id :" + item.Id; TbName.Text = "Name : " + item.Name; TbType.Text = "Type Id : " + item.TypeId; TbRelease.Text = "Release date : " + item.ReleseDate; TbLifetime.Text = "Lifetime : " + item.Lifetime; } } }
internal void RemoveAircraft(Aircraft aircraft) { var squadron = aircraft.Squadron; if (squadron != null) { squadron.RemoveAircraft(aircraft); if (squadron.Leader == null) { RemoveSquadron(squadron); } } Aircrafts.Remove(aircraft); ActiveAircrafts.Remove(aircraft); aircraft.VertexZ = 0f; // reset vertexZ if (PlayerAircrafts.Contains(aircraft)) { PlayerAircrafts.Remove(aircraft); // check if the player now has lost all his aircrafts if (!PlayerAircrafts.Any()) { // and if true stop the PlayLayer and enter the WreckageLayer EnterWreckageLayer(); } } RemoveChild(aircraft); }
private void SendRequestForRelease() { _Client = new Clients(_FuelOrder.AdminClientID); _Customer.Contacts = new ContactsCollection(); _Customer.Contacts.LoadByCustClientID(_Customer.CustClientID); try { if (_Customer.Contacts.Count > 0) { if (!string.IsNullOrEmpty(_Customer.Email) && !_Customer.Email.EndsWith(";")) { _Customer.Email += ";"; } foreach (Contacts contact in _Customer.Contacts) { if (!contact.Distribute || string.IsNullOrEmpty(contact.Email)) { continue; } _Customer.Email += contact.Email + ";"; } } _FuelOrder.Aircraft = Aircrafts.GetAircraft(_FuelOrder.AircraftID); _FuelOrder.Aircraft.MakeAndModel = AircraftData.GetAircraftData(_FuelOrder.Aircraft.MakeModelID); CreateAndSendEmail(); } catch (Exception e) { ErrorLog EL = new ErrorLog(e); EL.UserID = _FuelOrder.CustClientID; EL.URL = "SendFuelOrderVendorDispatchRequestForRelease, ID: " + _FuelOrder.Id.ToString(); EL.LogError(); } }
private void Aircrafts_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (DataContext is IAircraftListViewModel vm && vm.SelectedAircraft != null) { Aircrafts.ScrollIntoView(vm.SelectedAircraft); } }
public void DeleteAircraft() { if (SelectedAircraft != null) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = $"delete flights where aircraft = @aircraft"; sqlCommand.Connection = DBConnection.DBConnection.SqlConnection; SqlParameter aircraftParam = new SqlParameter("@aircraft", SelectedAircraft.name_aircraft); sqlCommand.Parameters.Add(aircraftParam); sqlCommand.ExecuteNonQuery(); sqlCommand.CommandText = $"delete aircrafts where name_aircraft = @nameAircraft"; SqlParameter nameParam = new SqlParameter("@nameAircraft", SelectedAircraft.name_aircraft); sqlCommand.Parameters.Add(nameParam); sqlCommand.ExecuteNonQuery(); Aircrafts.Remove(SelectedAircraft); MessageBox.Show("Самолет успешно удален"); } else { MessageBox.Show("Выберите самолет!"); } }
private async void BtnCreate_OnClick(object sender, RoutedEventArgs e) { Canvas.Visibility = Visibility.Collapsed; if (isCreate) { var pilot = ReadTextBoxesData(); if (pilot != null) { try { await Service.Create(pilot); } catch { Info.Text = "Server error!"; } lastId++; pilot.Id = lastId; Aircrafts.Add(pilot); isCreate = false; CreateInfo(); Info.Text = "Choose new action!"; } } else { CreateInfo(); isCreate = true; Info.Text = "Info : Input data and press 'Create' "; } }
public void SendFuelRequestConfirmation(int fuelOrderId) { _FuelOrder = new FuelOrders(fuelOrderId); _Customer = new CustomerDetails(_FuelOrder.CustClientID); try { _Customer.Contacts = new ContactsCollection(); _Customer.Contacts.LoadByCustClientID(_Customer.CustClientID); _Customer.Email = ""; foreach (Contacts contact in _Customer.Contacts) { if (contact.Distribute) { _Customer.Email += contact.Email + ";"; } } _FuelOrder.Aircraft = Aircrafts.GetAircraft(_FuelOrder.AircraftID); _FuelOrder.Aircraft.MakeAndModel = AircraftData.GetAircraftData(_FuelOrder.Aircraft.MakeModelID); CreateAndSendEmail(); _FuelOrder.AdminStatus = AdminStatuses.Confirmed; _FuelOrder.Update(); } catch (Exception e) { ErrorLog EL = new ErrorLog(e); EL.UserID = _FuelOrder.CustClientID; EL.URL = "SendFuelRequestConfirmation, ID: " + _FuelOrder.Id.ToString(); EL.LogError(); } }
private void OnRoutePointRemoved(RoutePointRemovedEvent obj) { RoutePoint routePoint = RoutePoints.FirstOrDefault(x => x.Id == obj.RoutePointId); if (routePoint != null) { RoutePoints.Remove(routePoint); } AircraftRouteViewModel routeViewModel = Routes.FirstOrDefault(x => x.AircraftId == obj.AircraftId); if (routeViewModel != null) { Routes.Remove(routeViewModel); } Aircraft aircraft = Aircrafts.FirstOrDefault(x => x.Id == obj.AircraftId); if (aircraft != null) { AircraftRouteViewModel route = _routeService.GetRouteLine(aircraft); route.IsSelected = true; Routes.Add(route); } }
private string StatMostValuableTrophy(string statData) { string[] aircraftsData = statData.Split(','); string trophy = "не было"; double trophyPrice = 0; foreach (string aircraftData in aircraftsData) { Aircraft aircraft = Aircrafts.FindEnemyAircraft(aircraftData.Split('=')[0]); if (aircraft == null) { continue; } if (trophyPrice < aircraft.price) { trophy = aircraft.aircraftName; trophyPrice = aircraft.price; } } return(trophy); }
public static int UpdateAircraft(object aircraftOBJ) { Aircrafts aircraft = new Aircrafts(); aircraft.Clone(aircraftOBJ); aircraft.Update(); return(aircraft.Id); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { var result = await Service.GetAll(); result.ForEach(x => Aircrafts.Add(x)); lastId = Aircrafts.LastOrDefault().Id; LoadTypes(); }
public void AddAircraft(Aircraft aircraft) { if (!Aircrafts.Any(i => i.Id == aircraft.Id)) { Aircrafts.Add(aircraft); } return; }
private void StatBoxValues(DataGrid StatBox, string statData, int percentBaseCount, double percentBasePrice, bool inaccurate = false) { StatBox.Items.Clear(); StatBox.Columns.Clear(); if (String.IsNullOrWhiteSpace(statData)) { return; } StatBox.AutoGenerateColumns = false; StatBox.Columns.Add(new DataGridTextColumn { Header = "тип", Binding = new Binding("aircraft") }); StatBox.Columns.Add(new DataGridTextColumn { Header = "количество", Binding = new Binding("count"), Width = new DataGridLength(100) }); StatBox.Columns.Add(new DataGridTextColumn { Header = "от общего кол-ва", Binding = new Binding("percent"), Width = new DataGridLength(120) }); StatBox.Columns.Add(new DataGridTextColumn { Header = String.Format("от ущерба {0}", (inaccurate ? " (примерно)" : String.Empty)), Binding = new Binding("pricePercent"), Width = new DataGridLength(120) }); string[] aircraftsData = statData.Split(','); string inacc = (inaccurate ? "до " : String.Empty); foreach (string aircraftData in aircraftsData) { dynamic newRow = new ExpandoObject(); string[] data = aircraftData.Split('='); int count = Int32.Parse(data[1]); int percentCount = (count * 100) / percentBaseCount; Aircraft aircraft = Aircrafts.FindEnemyAircraft(data[0]); double price = aircraft.price * count; int percentPrice = (int)((price * 100) / percentBasePrice); ((IDictionary <string, object>)newRow)["aircraft"] = data[0]; ((IDictionary <string, object>)newRow)["count"] = data[1]; ((IDictionary <string, object>)newRow)["percent"] = String.Format("{0}%", percentCount); ((IDictionary <string, object>)newRow)["pricePercent"] = String.Format("{0}{1}%", inacc, percentPrice); StatBox.Items.Add(newRow); } }
private void CenterOnSelectedAircaft() { Aircraft selected = Aircrafts.FirstOrDefault(x => x.IsSelected); if (selected != null && selected.Location != null) { MapCenter = new Location(selected.Location.Latitude, selected.Location.Longitude); } }
public async Task Search() { Aircrafts.Clear(); List <Aircraft> tempAircrafts = await AircraftService.GetAll(); foreach (var item in tempAircrafts) { Aircrafts.Add(item); } }
public void TakeAllRouts() { Classes.Clear(); Classes.Add(new FlightsModel { clas = "Бизнес" }); Classes.Add(new FlightsModel { clas = "Эконом" }); Routs.Clear(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = @"select id_route,s1.town,s2.town,length_of_route from route inner join airport s1 on s1.nameAirport = route.id_airport_from inner join airport s2 on s2.nameAirport = route.id_airport_to"; sqlCommand.Connection = DBConnection.DBConnection.SqlConnection; SqlDataReader reader = sqlCommand.ExecuteReader(); foreach (var i in reader) { Routs.Add(new RouteModel { IdRoute = reader.GetInt32(0), airport_From_To = $"{reader.GetString(1)} - {reader.GetString(2)}", length_of_route = Convert.ToString(reader.GetInt32(3)) }); } reader.Close(); Aircrafts.Clear(); sqlCommand.CommandText = @"select * from aircrafts"; sqlCommand.Connection = DBConnection.DBConnection.SqlConnection; SqlDataReader reader2 = sqlCommand.ExecuteReader(); foreach (var i in reader2) { Aircrafts.Add(new AircraftModel { name_aircraft = reader2.GetString(0), count_of_seats = reader2.GetInt32(1).ToString(), speed = reader2.GetInt32(2).ToString() }); } reader2.Close(); Company.Clear(); sqlCommand.CommandText = @"select * from company"; sqlCommand.Connection = DBConnection.DBConnection.SqlConnection; SqlDataReader reader3 = sqlCommand.ExecuteReader(); foreach (var i in reader3) { Company.Add(new CompanyModel { company_name = reader3.GetString(0), cost_of_1km = reader3.GetFloat(1).ToString(), cost_of_business = reader3.GetFloat(2).ToString(), cost_of_econom = reader3.GetFloat(3).ToString() }); } reader3.Close(); }
private async void BtnDelete_OnClick(object sender, RoutedEventArgs e) { Canvas.Visibility = Visibility.Visible; try { await Service.Delete(_selectedAircraft.Id); } catch { Info.Text = "Server error!"; } Aircrafts.Remove(_selectedAircraft); }
public async Task Seed() { if (!_context.Aircrafts.Any()) { Aircrafts.ForEach(i => _context.Aircrafts.Add(i)); await _context.SaveChangesAsync(); } if (!_context.AircraftTypes.Any()) { AircraftTypes.ForEach(i => _context.AircraftTypes.Add(i)); await _context.SaveChangesAsync(); } if (!_context.Pilots.Any()) { Pilots.ForEach(i => _context.Pilots.Add(i)); await _context.SaveChangesAsync(); } if (!_context.Crews.Any()) { Crews.ForEach(i => _context.Crews.Add(i)); await _context.SaveChangesAsync(); } if (!_context.Stewardesses.Any()) { Stewardesses.ForEach(i => _context.Stewardesses.Add(i)); await _context.SaveChangesAsync(); } if (!_context.Tickets.Any()) { Tickets.ForEach(i => _context.Tickets.Add(i)); await _context.SaveChangesAsync(); } if (!_context.Flights.Any()) { Flights.ForEach(i => _context.Flights.Add(i)); await _context.SaveChangesAsync(); } if (!_context.Departures.Any()) { Departureses.ForEach(i => _context.Departures.Add(i)); await _context.SaveChangesAsync(); } }
public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e) { if (managerType == typeof(CollectionChangedEventManager)) { Parallel.ForEach( Aircrafts, aircraft => { PropertyChangedEventManager.AddListener(aircraft, this, nameof(aircraft.IsSelected)); }); } else if (!_isMarkingSelectedAfterSelectedInList) { _isSelectingAircraftAfterSelectionChangedInModel = true; SelectedAircraft = Aircrafts.FirstOrDefault(x => x.IsSelected); _isSelectingAircraftAfterSelectionChangedInModel = false; } return(true); }
private void HighlightSelectedAircraftRoute() { foreach (AircraftRouteViewModel aircraftRouteViewModel in Routes) { aircraftRouteViewModel.IsSelected = false; } Aircraft selectedCraft = Aircrafts.FirstOrDefault(x => x.IsSelected); if (selectedCraft != null) { AircraftRouteViewModel aircraftRouteViewModel = Routes.FirstOrDefault(x => x.AircraftId == selectedCraft.Id); if (aircraftRouteViewModel != null) { aircraftRouteViewModel.IsSelected = true; } } }
/// <summary> /// Initialisiert eine neue Instanz der <see cref="T:System.Object" />-Klasse. /// </summary> public AircraftListDesignViewModel() { Aircraft aircraft = new Aircraft(new AircraftInformation() { AircraftFile = "test.acf", Livery = "my/test/livery", }, new AircraftLauncherInformation()); aircraft.Update(new Situation(true, new FileInfo("temp.tmp"))); Aircraft aircraft2 = new Aircraft(new AircraftInformation() { AircraftFile = "test.acf", Livery = "my/test/livery" }, new AircraftLauncherInformation()); aircraft2.Update(new Situation(false, null)); aircraft2.Update(100.42356, 42.456789); Aircrafts.Add(aircraft); Aircrafts.Add(aircraft2); SelectedAircraft = aircraft; SelectedAircraft.IsSelected = true; }
private static Aircraft NewAircraftForTraining() { if (!suspendedTargetDowned) { return(Aircrafts.Cloud()); } else if (rand.Next(Constants.TRAINING_LAUNCH_PROBABILITTY) != 1) { return(Aircrafts.Cloud()); } else if (allAircraftsInGame < Constants.TRAINING_IL28_AT_THE_START) { return(Aircrafts.targetTugs[Constants.TRAINING_IL28_INDEX]); } else if (allAircraftsInGame < Constants.TRAINING_M16K_AT_THE_START) { return(Aircrafts.targetPlane[Constants.TRAINING_M16K_INDEX]); } else { return(Aircrafts.targetDrones[rand.Next(Aircrafts.targetDrones.Count)]); } }
public HttpResponseMessage CreateFuelOrder(PartnerServiceIntegrationAddFuelOrderRequest model) { if (!CheckAccount(model)) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, badResponse)); } AircraftsCollection aircrafts = new AircraftsCollection(); aircrafts.LoadByAdminAndCustClientID(model.AdminClientID, model.CustClientID); Aircrafts aircraft = aircrafts.GetTailNumber(model.TailNumber); if (aircraft != null) { model.AircraftID = aircraft.Id; } model.IsFromFuelerLinx = true; ItemResponse <int> response = new ItemResponse <int>(); response.Item = FuelOrdersService.UpdateFuelOrder(model); return(Request.CreateResponse(response)); }
public static Aircrafts GetAircraft(int id) { return(Aircrafts.GetAircraft(id)); }
public static void Start(object obj, ElapsedEventArgs e) { int aircraftCategory = rand.Next(1, 17); if (Shilka.school) { aircraftCategory = AircraftCategoryForSchool(aircraftCategory, allAircraftsInGame); } int dice; Aircraft newAircraft; if (Shilka.training) { newAircraft = NewAircraftForTraining(); } else { switch (aircraftCategory) { case 1: case 2: case 3: case 4: default: if (Shilka.currentScript == Scripts.ScriptsNames.Vietnam) { goto case 5; } newAircraft = Aircrafts.Cloud(); break; case 5: case 6: case 7: case 8: case 9: if ((Scripts.scriptAircraft != null) && (Scripts.scriptAircraft.Length == 0)) { goto case 1; } do { dice = rand.Next(Aircrafts.aircraft.Count); }while (!InList(Scripts.scriptAircraft, dice)); string aircraftType = Aircrafts.aircraft[dice].aircraftType; if ((Shilka.currentScript == Scripts.ScriptsNames.F117Hunt) && (aircraftType != "f117")) { goto case 1; } if (Weather.currentWeather != Weather.WeatherTypes.good && Aircrafts.aircraft[dice].doesNotFlyInBadWeather) { goto case 9; } if (Shilka.currentScript == Scripts.ScriptsNames.Khmeimim) { goto case 10; } if ((Shilka.currentScript != Scripts.ScriptsNames.Rust) && (aircraftType == "cessna")) { goto case 5; } if ((Shilka.currentScript == Scripts.ScriptsNames.Rust) && (aircraftType != "cessna")) { goto case 15; } newAircraft = Aircrafts.aircraft[dice]; break; case 10: case 11: case 12: if ((Scripts.scriptHelicopters != null) && (Scripts.scriptHelicopters.Length == 0)) { goto case 5; } if (Shilka.currentScript != Scripts.ScriptsNames.Khmeimim) { do { dice = rand.Next(Aircrafts.helicopters.Count); }while (!InList(Scripts.scriptHelicopters, dice)); newAircraft = Aircrafts.helicopters[dice]; break; } else { SwarmLaunch(); return; } case 13: if ((Scripts.scriptAircraftFriend != null) && (Scripts.scriptAircraftFriend.Length == 0)) { goto case 1; } do { dice = rand.Next(Aircrafts.aircraftFriend.Count); }while (!InList(Scripts.scriptAircraftFriend, dice)); newAircraft = Aircrafts.aircraftFriend[dice]; break; case 14: if ((Scripts.scriptHelicoptersFriend != null) && (Scripts.scriptHelicoptersFriend.Length == 0)) { goto case 13; } do { dice = rand.Next(Aircrafts.helicoptersFriend.Count); }while (!InList(Scripts.scriptHelicoptersFriend, dice)); newAircraft = Aircrafts.helicoptersFriend[dice]; break; case 15: if (Shilka.currentScript == Scripts.ScriptsNames.Vietnam) { goto case 5; } if ((Scripts.scriptAirliners != null) && (Scripts.scriptAirliners.Length == 0)) { goto case 1; } do { dice = rand.Next(Aircrafts.airliners.Count); }while (!InList(Scripts.scriptAirliners, dice)); newAircraft = Aircrafts.airliners[dice]; break; case 16: if ( Shilka.currentScript != Scripts.ScriptsNames.noScript && Shilka.currentScript != Scripts.ScriptsNames.KoreanBoeing ) { goto case 10; } dice = rand.Next(Aircrafts.aerostat.Count); newAircraft = Aircrafts.aerostat[dice]; break; } } newAircraft.Launch(); }
void Start() { RB2DAlliedAircraft = AlliedAircraft.gameObject.GetComponent <Rigidbody2D>(); Aircraft = AlliedAircraft.gameObject.GetComponent <Aircrafts>(); }
public static List <Aircrafts> GetListOfAircrafts() { return(Aircrafts.LoadList()); }
public static List <Aircrafts> GetAircraftsByCustClientID(int id) { return(Aircrafts.LoadAircraftsByCustClient(id)); }
public static void DeleteAircraft(int id) { Aircrafts.DeleteAircraft(id); }
public static List <Aircrafts> GetAircraftsByAdminAndClientID(int adminId, int clientId) { return(Aircrafts.LoadAircraftsByAdminAndClient(adminId, clientId)); }