public async void OnValidTransfert() { try { await SqlContext.TransfertRackTo(TransfertRackValidation.IdRackPartant, TransfertRackValidation.IdRackArrivant); // Recharger les racks. Racks = await SqlContext.GetRackEmpty(); RacksFull = await SqlContext.GetRackFull(); AllHangar.RemoveAll(x => x.IdRack == TransfertRackValidation.IdRackPartant); HangarView hangar = await SqlContext.GetHangar(ClientTransfert.IdCommande, TransfertRackValidation.IdRackArrivant); AllHangar.Add(hangar); await HangarGrid.Reload(); Notification.Notify(NotificationSeverity.Success, "Transfert OK", "Transfert effectué"); // Remise à zéro TransfertRackValidation = new TransfertRackValidation(); ClientTransfert = new CommandeView(); StateChange.Invoke(); } catch (Exception ex) { Log.Error(ex, "HangarViewModel - OnValidTransfert"); Notification.Notify(NotificationSeverity.Success, "Error", "Erreur sur le transfert"); } }
public static async Task <ValidatedView> UpdateHangar(int accountId, HangarView hangarView) { if (!hangarView.IsValid(out string message)) { return(ValidatedView.Invalid(message)); } try { HangarModel hangarModel = Mapper <HangarView> .Map(hangarView, new HangarModel { AccountID = accountId }); hangarModel.Configuration_1 = Mapper <ConfigurationView> .Map <Configuration>(hangarView.Configuration_1); hangarModel.Configuration_2 = Mapper <ConfigurationView> .Map <Configuration>(hangarView.Configuration_2); ReplaceOneResult result = await Model <HangarModel> .AsCollection() .ReplaceOneAsync(x => x.AccountID == accountId && x.ShipID == hangarView.ShipID, hangarModel); if (result.IsModifiedCountAvailable && result.ModifiedCount == 1) { return(ValidatedView.Valid()); } } catch (Exception e) { GameContext.Logger.LogError(e); } return(ValidatedView.Invalid(ErrorCode.OPERATION_FAILED)); }
public async Task <HangarView> GetInfoRack(int idRack) { HangarView result = new HangarView(); if (!IsServerAdressOk) { return(result); } using (var content = new StringContent(JsonConvert.SerializeObject(idRack), Encoding.UTF8, "application/json")) { HttpResponseMessage reponse = await ClientHttp.PostAsync("api/Hangar/rackinfo/", content); if (reponse.StatusCode == System.Net.HttpStatusCode.OK) { string jsonHangarView = await reponse.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <HangarView>(jsonHangarView)); } else { throw new Exception(); } } }
public void CreateHangarView(OSTData.Hangar h) { HangarView newObj = Instantiate <HangarView>(hangarViewPrefab); Window window = winSystem.NewWindow("HangarView", newObj.gameObject); window.Title = "Hangar " + h.Station.Name; newObj.SetHangar(h); }
public static async Task <ValidatedView> UpdateHangar(int accountId, HangarDetailView hangarDetailView) { if (!hangarDetailView.IsValid(out string message)) { return(ValidatedView.Invalid(message)); } try { if (GameManager.Get(accountId, out PlayerController controller) && !controller.ZoneAssembly.CanEquip) { return(ValidatedView.Invalid(ErrorCode.EQUIPMENT_NOT_POSSIBLE)); } HangarModel hangarModel = await Model <HangarModel> .AsQueryable() .FirstOrDefault(x => x.AccountID == accountId && x.ShipID == hangarDetailView.ShipID); if (hangarModel == null) { return(ValidatedView <HangarView> .Invalid(ErrorCode.NO_HANGAR_FOUND)); } if (controller != null && controller.HangarAssembly.Ship.ID == hangarDetailView.ShipID) { HangarView hangarView = Mapper <HangarModel> .Map <HangarView>(hangarModel); hangarView.Configuration_1 = hangarDetailView.Configuration_1; hangarView.Configuration_2 = hangarDetailView.Configuration_2; UpdateHangarIngame(accountId, hangarView); } else { hangarModel.Configuration_1 = Mapper <ConfigurationView> .Map <Configuration>(hangarDetailView.Configuration_1); hangarModel.Configuration_2 = Mapper <ConfigurationView> .Map <Configuration>(hangarDetailView.Configuration_2); ReplaceOneResult result = await Model <HangarModel> .AsCollection() .ReplaceOneAsync(x => x.AccountID == accountId && x.ShipID == hangarDetailView.ShipID, hangarModel); } return(ValidatedView.Valid()); } catch (Exception e) { GameContext.Logger.LogError(e); } return(ValidatedView.Invalid(ErrorCode.OPERATION_FAILED)); }
public static async Task <ValidatedView> ActivateHangar(int accountId, int shipId) { try { if (GameManager.Get(accountId, out PlayerController controller) && !controller.ZoneAssembly.CanEquip) { return(ValidatedView.Invalid(ErrorCode.EQUIPMENT_NOT_POSSIBLE)); } HangarModel hangarModel = await Model <HangarModel> .AsQueryable() .FirstOrDefault(x => x.AccountID == accountId && x.ShipID == shipId); if (hangarModel == null) { return(ValidatedView <HangarView> .Invalid(ErrorCode.NO_HANGAR_FOUND)); } if (await Model <AccountModel> .AsQueryable() .Any(x => x.ID == accountId && x.ActiveShipID == shipId)) { return(ValidatedView.Invalid(ErrorCode.HANGAR_ALREADY_ACTIVE)); } if (controller != null) { HangarView hangarView = Mapper <HangarModel> .Map <HangarView>(hangarModel); hangarView.Configuration_1 = Mapper <Configuration> .Map <ConfigurationView>(hangarModel.Configuration_1); hangarView.Configuration_2 = Mapper <Configuration> .Map <ConfigurationView>(hangarModel.Configuration_2); UpdateHangarIngame(accountId, hangarView); } await Model <AccountModel> .AsCollection() .UpdateOneAsync(x => x.ID == accountId, new UpdateDefinitionBuilder <AccountModel>() .Set(x => x.ActiveShipID, shipId)); return(ValidatedView.Valid()); } catch (Exception e) { GameContext.Logger.LogError(e); } return(ValidatedView.Invalid(ErrorCode.OPERATION_FAILED)); }
public async void OnValidSubmit() { try { if (EntreHangarValidation.IdRack == 0) { Notification.Notify(NotificationSeverity.Warning, "Attention", "Le Rack choisi n'est pas bon."); return; } // Sauvegarde de la commande SuiviCommande cmd = EntreHangarValidation.ToSuiviCommande(); await SqlContext.AddCommande(cmd); // Sauvegarde dans le hangar GeoCommande nouvelleEntreHangar = EntreHangarValidation.ToGeoCommande(); await SqlContext.AddToHangar(nouvelleEntreHangar); HangarView newEntry = await SqlContext.GetHangar(nouvelleEntreHangar.CommandeId, nouvelleEntreHangar.RackId); Notification.Notify(NotificationSeverity.Success, "Sauvegarde OK", "Sauvegarde OK"); Log.Information("HANGAR ENTREE - {date} : commande- {commande} - Gisement-{rack}", nouvelleEntreHangar.DateEntree.ToString("d"), cmd.IdCommande, EntreHangarValidation.GisementRack); // remise à zéro EntreHangarValidation = new EntreHangarValidation(); AllHangar.Add(newEntry); await HangarGrid.Reload(); // Recharger les racks vides. Racks = await SqlContext.GetRackEmpty(); StateChange.Invoke(); } catch (Exception ex) { Log.Error(ex, "HangarViewModel - OnValidSubmit"); Notification.Notify(NotificationSeverity.Success, "Error", "Erreur sur la sauvegarde"); } }
private IEnumerator OnHangarClicWait() { Hangar h = LocalDataManager.instance.GetHangarInfo(_station.ID, LocalDataManager.instance.LocalCharacter.Corp); while (!h.Loaded) { yield return(null); } WindowSystem ws = FindObjectOfType <WindowSystem>(); PrefabManager pf = FindObjectOfType <PrefabManager>(); HangarView view = Instantiate(pf.prefabHangarView); Window w = ws.NewWindow("HangarView", view.gameObject); Station s = LocalDataManager.instance.GetStations()[h.Station - 1]; view.SetHangar(h); w.Title = s.Name; w.Show(); yield break; }
public static async Task <ValidatedView <HangarView> > RetrieveHangar(int accountId, int shipId) { try { HangarModel hangarModel = await Model <HangarModel> .AsQueryable() .FirstOrDefault(x => x.AccountID == accountId && x.ShipID == shipId); if (hangarModel == null) { return(ValidatedView <HangarView> .Invalid(ErrorCode.NO_HANGAR_FOUND)); } HangarView hangarView = Mapper <HangarModel> .Map <HangarView>(hangarModel); hangarView.Configuration_1 = Mapper <Configuration> .Map <ConfigurationView>(hangarModel.Configuration_1); hangarView.Configuration_2 = Mapper <Configuration> .Map <ConfigurationView>(hangarModel.Configuration_2); return(ValidatedView <HangarView> .Valid(hangarView)); } catch (Exception e) { GameContext.Logger.LogError(e); } return(ValidatedView <HangarView> .Invalid(ErrorCode.OPERATION_FAILED)); }
private static void UpdateHangarIngame(int accountId, HangarView hangar) { if (GameManager.Get(accountId, out PlayerController controller)) { controller.BoosterAssembly.Divide(BoosterType.SHIELD_REGNERATION, Math.Max(0.0000001, controller.Account.CurrentHangar.CurrentConfiguration.Regeneration)); controller.BoosterAssembly.Divide(BoosterType.SHIELD_ABSORBATION, Math.Max(0.0000001, controller.Account.CurrentHangar.CurrentConfiguration.Absorption)); if (hangar.ShipID == controller.Account.CurrentHangar.ShipID) { controller.Account.CurrentHangar.Configuration_1 = hangar.Configuration_1; controller.Account.CurrentHangar.Configuration_2 = hangar.Configuration_2; } else { controller.UpdateState(); controller.PlayerAbilityAssembly.CheckOrStopAfterburner(true); controller.PlayerAbilityAssembly.CheckOrStopFortress(true); controller.PlayerAbilityAssembly.CheckOrStopPrismaticShield(true); controller.PlayerAbilityAssembly.CheckOrStopSingularity(true); controller.PlayerAbilityAssembly.CheckOrStopWeakenShields(true); controller.Account.CurrentHangar = hangar; } controller.Account.CurrentHangar.Check(GameContext.Logger, controller.Account.ID, controller.Account.Vault); controller.Account.CurrentHangar.Calculate(); // Wtf denkt mein kopf ((Action)(async() => await UpdateHangar(accountId, controller.Account.CurrentHangar)))(); controller.HangarAssembly.BroadcastHealth(); controller.HangarAssembly.BroadcastShield(); controller.BoosterAssembly.Multiply(BoosterType.SHIELD_REGNERATION, Math.Max(0.0000001, controller.Account.CurrentHangar.CurrentConfiguration.Regeneration)); controller.BoosterAssembly.Multiply(BoosterType.SHIELD_ABSORBATION, Math.Max(0.0000001, controller.Account.CurrentHangar.CurrentConfiguration.Absorption)); controller.AttackTraceAssembly.Trace.Clear(); controller.Refresh(); // refresh all entities controller.EntitesInRange(x => { bool wasLocked = false; if (x.Locked != null && x.Locked.ID == accountId) { wasLocked = true; x.Lock(null); } x.Send(PacketBuilder.ShipRemoveCommand(accountId)); x.EntityAddedToMap(controller); if (wasLocked) { x.Lock(controller); } }); if (controller.Locked != null) { controller.Lock(controller.Locked); } } }
internal async Task LoadInfoRack() { RackInfo = await RackService.GetInfoRack(RackSelected.IdRack); }