コード例 #1
0
        /// <summary>
        /// Check if there are banned players and update their banned flags
        /// </summary>
        /// <param name="demo"></param>
        /// <returns></returns>
        public async Task <Demo> AnalyzeBannedPlayersAsync(Demo demo)
        {
            List <string>         ids      = demo.Players.Select(playerExtended => playerExtended.SteamId.ToString()).ToList();
            IEnumerable <Suspect> suspects = await _steamService.GetBanStatusForUserList(ids);

            var enumerableSuspects = suspects as IList <Suspect> ?? suspects.ToList();

            if (enumerableSuspects.Any())
            {
                List <string> whitelistIds = await _cacheService.GetPlayersWhitelist();

                // Update player's flag
                foreach (Suspect suspect in enumerableSuspects)
                {
                    PlayerExtended cheater = demo.Players.FirstOrDefault(p => p.SteamId.ToString() == suspect.SteamId);
                    if (cheater != null && !whitelistIds.Contains(cheater.SteamId.ToString()))
                    {
                        if (suspect.GameBanCount > 0)
                        {
                            demo.HasCheater           = true;
                            cheater.IsOverwatchBanned = true;
                        }
                        if (suspect.VacBanned)
                        {
                            demo.HasCheater     = true;
                            cheater.IsVacBanned = true;
                        }
                    }
                }
            }
            return(demo);
        }
コード例 #2
0
        private async Task LoadSuspects()
        {
            if (!AppSettings.IsInternetConnectionAvailable())
            {
                await _dialogService.ShowNoInternetConnectionAsync();

                return;
            }

            try
            {
                Suspects.Clear();
                SelectedSuspects.Clear();

                List <string> suspectsIdList = await _cacheService.GetSuspectsListFromCache();

                if (suspectsIdList.Any())
                {
                    // Split list to 100 elements as Steam API allow to request by 100 SteamID maximum
                    IEnumerable <IEnumerable <string> > ids = suspectsIdList.Batch(100);
                    foreach (IEnumerable <string> idList in ids)
                    {
                        List <Suspect> suspects = await _steamService.GetBanStatusForUserList(idList.ToList());

                        foreach (Suspect s in suspects)
                        {
                            Suspects.Add(s);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Instance.Log(e);
                await _dialogService.ShowErrorAsync("Error while trying to get suspects information.", MessageDialogStyle.Affirmative);
            }
        }
コード例 #3
0
        private async Task LoadPlayers()
        {
            if (!AppSettings.IsInternetConnectionAvailable())
            {
                await _dialogService.ShowNoInternetConnectionAsync();

                return;
            }

            Suspects.Clear();
            SelectedSuspects.Clear();

            List <string> suspectsIdList = await _cacheService.GetPlayersWhitelist();

            if (suspectsIdList.Any())
            {
                // Split list to 100 elements as Steam API allow to request by 100 SteamID maximum
                IEnumerable <IEnumerable <string> > ids = suspectsIdList.Batch(100);
                try
                {
                    foreach (IEnumerable <string> idList in ids)
                    {
                        IEnumerable <Suspect> suspects = await _steamService.GetBanStatusForUserList(idList.ToList());

                        foreach (Suspect suspect in suspects)
                        {
                            Suspects.Add(suspect);
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.Instance.Log(e);
                    await _dialogService.ShowErrorAsync(Properties.Resources.DialogErrorWhileRetrievingPlayersInformation, MessageDialogStyle.Affirmative);
                }
            }
        }