示例#1
0
 private void CheckHash(string currentId, string hash)
 {
     if (TotalPlayers?.ContainsKey(hash) == true)
     {
         PlayersFound.Add(new Tuple <string, string>(hash, currentId));
     }
 }
示例#2
0
        private async Task StartAsync()
        {
            InProcess = true;

            var found = PlayersFound;

            found.Clear();

            if (TotalPlayers == null)
            {
                TotalPlayers = (await _playerRepository.GetAllPlayersWithoutSteamAsync())
                               .Where(x => string.IsNullOrEmpty(x.GUID) == false)
                               .GroupBy(x => x.GUID)
                               .ToDictionary(x => x.Key, x => x.First().Id);
            }

            _cancelatioTokenSource?.Cancel();
            _cancelatioTokenSource = new CancellationTokenSource();

            if (_steamService.IsReady())
            {
                var res = await Task.Run(() => _steamService.GetSteamIds(TotalPlayers?.Keys.ToArray() ?? new string[0], _cancelatioTokenSource.Token));

                foreach (var item in res)
                {
                    PlayersFound.Add(Tuple.Create(item.Key, item.Value.ToString()));
                }

                await SaveAsync();
            }
            else
            {
                Task.Factory.StartNew(() => GenerateStart(_cancelatioTokenSource.Token),
                                      TaskCreationOptions.LongRunning);
            }
        }