Exemplo n.º 1
0
        static EResult DownloadLeaderboardRange(uint appid, int lbid, int first, int last, int totalCount, StreamWriter outputWriter)
        {
            Console.WriteLine($"Downloading entries {first} to {last}... [{(first * 100) / totalCount}%]");

            var queryLeaderboardEntriesJob = steamUserStats.GetLeaderboardEntries(appid, lbid, first, last, ELeaderboardDataRequest.Global);

            while (queryLeaderboardEntriesJob.GetAwaiter().IsCompleted)
            {
                manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
                if (!isRunning)
                {
                    return(EResult.Fail);
                }
            }

            var result = queryLeaderboardEntriesJob.GetAwaiter().GetResult();

            if (result.Result == EResult.OK)
            {
                foreach (var entry in result.Entries)
                {
                    var line = new StringBuilder();
                    line.Append(entry.SteamID.ConvertToUInt64());
                    line.Append(',');
                    line.Append(entry.GlobalRank);
                    line.Append(',');
                    line.Append(entry.Score);
                    line.Append(',');
                    line.Append(entry.UGCId.Value);
                    foreach (var detail in entry.Details)
                    {
                        line.Append(',');
                        line.Append(detail);
                    }
                    outputWriter.WriteLine(line);
                }
            }
            else
            {
                Console.Error.WriteLine($"Failed to download leaderboard section! Error code: {result.Result.ToString()}");
            }

            return(result.Result);
        }