Esempio n. 1
0
        public NormalizedMatch DownloadOnlyMatchMetadataForMatchId(string matchId, ref int counter, int matchesCount)
        {
            string mmOutputFileName = "mm-" + matchId + ".json";
            string mmOutputFilePath = Path.Combine(TelemetryApp.App.MatchDir, mmOutputFileName);

            string mtOutputFileName = "mt-" + matchId + ".json.gz";
            string mtOutputFilePath = Path.Combine(TelemetryApp.App.TelemetryDir, mtOutputFileName);

            string matchJsonStr;
            bool   metadataAlreadyDownloaded;

            if (!File.Exists(mmOutputFilePath))
            {
                DownloadProgressEvent?.Invoke(this, new DownloadProgressEventArgs
                {
                    Value = Interlocked.Increment(ref counter),
                    Max   = matchesCount,
                    Msg   = $"[{counter}/{matchesCount}] Downloading metadata for match: {matchId}"
                });
                matchJsonStr = TelemetryApp.App.ApiGetMatch(matchId);
                matchJsonStr = PrettyPrintJson(matchJsonStr);
                TelemetryApp.FileWriteAllTextAtomic(mmOutputFilePath, matchJsonStr);
                metadataAlreadyDownloaded = false;
            }
            else
            {
                DownloadProgressEvent?.Invoke(this, new DownloadProgressEventArgs
                {
                    Value = Interlocked.Increment(ref counter),
                    Max   = matchesCount,
                    Msg   = $"[{counter}/{matchesCount}] Loading cached metadata for match: {matchId}"
                });
                matchJsonStr = File.ReadAllText(mmOutputFilePath);
                metadataAlreadyDownloaded = true;
            }
            NormalizedMatch normedMatch = NormalizeMatch(matchId, matchJsonStr);

            normedMatch.JsonStr = matchJsonStr;
            normedMatch.MetadataAlreadyDownloaded  = metadataAlreadyDownloaded;
            normedMatch.TelemetryAlreadyDownloaded = File.Exists(mtOutputFilePath);
            return(normedMatch);
        }
 static TelemetryApp()
 {
     App = new TelemetryApp();
 }