Пример #1
0
        public IActionResult GetNumPlayersOnServer(string platform, string guid, SlotResponseType type = SlotResponseType.Battlelog)
        {
            try
            {
                var cacheKey = guid;
                var gameId   = GetGameIdFromCache(cacheKey);
                ServerDetailsViewModel model = null;

fetchNewGameId:
                if (!string.IsNullOrEmpty(gameId))
                {
                    _logger?.LogInformation("GameId {gameId} fetched from cache for Guid {guid}", gameId, guid);

                    _logger?.LogInformation("Retrieving server slots for gameId {gameId}", gameId);
                    model = _companionService?.GetServerDetails(gameId);

                    // Check if guid matches (in other words whether the gameId was correct or not)
                    if (!guid.Equals(model?.Guid, StringComparison.OrdinalIgnoreCase))
                    {
                        gameId = null;
                        goto fetchNewGameId;
                    }
                }
                else
                {
                    var serverInfo = BattlelogClient.GetServerShow(guid, platform);
                    gameId = serverInfo.gameId;

                    _distributedCache.SetStringAsync(cacheKey, gameId).ConfigureAwait(false);
                    _logger?.LogInformation("GameId {gameId} added to cache for Guid {guid}", gameId, guid);

                    _logger?.LogInformation("Retrieving server slots for gameId {gameId}", gameId);
                    model = _companionService?.GetServerDetails(gameId);
                }

                if (model?.Slots == null)
                {
                    return(BadRequestBattlelogResponse <SlotTypesViewModel>(null, "Couldn't retrieve server slots"));
                }

                return(type switch {
                    SlotResponseType.Companion => SuccessBattlelogResponse(model.Slots),
                    _ => Ok(model.CompanionPlayerCountsToBattlelog()),
                });
            }
        public ActionResult GetLocationByRackName(ServerDetailsViewModel model)
        {
            Server s = new Server();

            s.ServerCode = model.ServerCode;
            s.Power      = model.Power;
            s.Customer   = model.Customer;
            var locations = LocationBLO.Current.GetChangeLocation(s);
            var data      = new ServerDetailsViewModel();

            if (!String.IsNullOrWhiteSpace(model.SelectedRack))
            {
                locations = locations.Where(r => r.RackName.Trim() == model.SelectedRack.Trim()).ToList();
            }
            data.Locations1 = locations;

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        // GET: Server/Details
        public ActionResult Detail(string code, string Message)
        {
            var data = new ServerDetailsViewModel();

            data.UserRole       = GetCurrentUserRole();
            data.SuccessMessage = Message;
            data.Server         = ServerBLO.Current.GetAllServerInfo(code);
            //var serverattributes = ServerBLO.Current.GetServerAttributes(serverCode);
            var ips = ServerIPBLO.Current.GetCurrentIP(code);

            if (ips != null)
            {
                data.CurrentIPs = ips;
            }
            //get customer
            data.CustomerInfo = AccountBLO.Current.GetAccountByCode(data.Server.Customer);
            return(View(data));
        }
Пример #4
0
 public static BattlelogPlayerCountsViewModel CompanionPlayerCountsToBattlelog(this ServerDetailsViewModel serverDetails)
 {
     return(new BattlelogPlayerCountsViewModel {
         Map = serverDetails.MapName,
         MapMode = (ulong)GenericHelpers.GameModeToEnum(serverDetails.MapMode),
         Players = 0,
         Queued = 0,
         Slots = new BattlelogSlotTypesViewModel {
             Queue = new BattlelogSlotsViewModel {
                 Current = serverDetails.Slots.Queue.Current,
                 Max = serverDetails.Slots.Queue.Max
             },
             Soldier = new BattlelogSlotsViewModel {
                 Current = serverDetails.Slots.Soldier.Current,
                 Max = serverDetails.Slots.Soldier.Max
             },
             Spectator = new BattlelogSlotsViewModel {
                 Current = serverDetails.Slots.Spectator.Current,
                 Max = serverDetails.Slots.Spectator.Max
             }
         }
     });
 }
 public ServerDetailsDialog()
 {
     InitializeComponent();
     DataContext = new ServerDetailsViewModel();
 }
Пример #6
0
 void OnTest()
 {
     var serverDetailsViewModel = new ServerDetailsViewModel();
     ServiceFactory.UserDialogs.ShowModalWindow(serverDetailsViewModel);
 }