private void CheckHash(string currentId, string hash) { if (TotalPlayers?.ContainsKey(hash) == true) { PlayersFound.Add(new Tuple <string, string>(hash, currentId)); } }
private async Task SaveAsync() { var found = PlayersFound?.Where(x => _totalPlayers.ContainsKey(x.Item1)) .Select(x => new { Id = _totalPlayers[x.Item1], steamId = x.Item2 }) .ToDictionary(x => x.Id, x => x.steamId); if ((found != null) && (found.Count > 0)) { await _playerRepository.SaveSteamIdAsync(found); } InProcess = false; }
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); } }