public static async Task <bool> ShowReplay(GameStats game, bool showToast)
        {
            if (game == null)
            {
                return(false);
            }
            if (Config.Instance.ForceLocalReplayViewer)
            {
                ReplayReader.LaunchReplayViewer(game.ReplayFile, false);
                return(true);
            }
            Action <ReplayProgress> setToastStatus = null;

            if (game.HasReplayFile && !game.HsReplay.Uploaded)
            {
                if (showToast)
                {
                    setToastStatus = ToastManager.ShowReplayProgressToast();
                }
                var log = GetLogFromHdtReplay(game.ReplayFile).ToArray();
                var validationResult = LogValidator.Validate(log);
                if (validationResult.IsValid)
                {
                    await LogUploader.Upload(log, null, game);
                }
                else
                {
                    Log.Error("Invalid log: " + validationResult.Reason);
                    game.HsReplay.Unsupported = true;
                }
                if (DefaultDeckStats.Instance.DeckStats.Any(x => x.DeckId == game.DeckId))
                {
                    DefaultDeckStats.Save();
                }
                else
                {
                    DeckStatsList.Save();
                }
            }
            if (game.HsReplay?.Uploaded ?? false)
            {
                setToastStatus?.Invoke(ReplayProgress.Complete);
                Helper.TryOpenUrl(game.HsReplay?.Url);
            }
            else if (game.HasReplayFile)
            {
                setToastStatus?.Invoke(ReplayProgress.Error);
                ReplayReader.LaunchReplayViewer(game.ReplayFile, true);
            }
            else
            {
                setToastStatus?.Invoke(ReplayProgress.Error);
                return(false);
            }
            return(true);
        }
        public static async Task <bool> ShowReplay(GameStats game, bool showToast)
        {
            if (game == null)
            {
                return(false);
            }
            Action <ReplayProgress> setToastStatus = null;

            if (game.HasReplayFile && !game.HsReplay.Uploaded)
            {
                if (showToast)
                {
                    setToastStatus = ToastManager.ShowReplayProgressToast();
                }
                var log = GetLogFromHdtReplay(game.ReplayFile).ToArray();
                var validationResult = LogValidator.Validate(log);
                if (validationResult.IsValid)
                {
                    await LogUploader.Upload(log, null, game);
                }
                else
                {
                    Log.Error("Invalid log: " + validationResult.Reason);
                    game.HsReplay.Unsupported = true;
                }
                if (DefaultDeckStats.Instance.DeckStats.Any(x => x.DeckId == game.DeckId))
                {
                    DefaultDeckStats.Save();
                }
                else
                {
                    DeckStatsList.Save();
                }
            }
            if (game.HsReplay?.Uploaded ?? false)
            {
                setToastStatus?.Invoke(ReplayProgress.Complete);
                Helper.TryOpenUrl(game.HsReplay?.Url);
            }
            else
            {
                setToastStatus?.Invoke(ReplayProgress.Error);
                if (game.HsReplay?.Unsupported ?? false)
                {
                    ErrorManager.AddError("Can not load replay", "Game has no valid replay.");
                }
                else
                {
                    ErrorManager.AddError("Error uploading replay", "Please try again later.");
                }
                return(false);
            }
            return(true);
        }
        public static async Task ShowReplay(string fileName, bool showToast)
        {
            if (Config.Instance.ForceLocalReplayViewer)
            {
                ReplayReader.LaunchReplayViewer(fileName, false);
                return;
            }
            Action <ReplayProgress> setToastStatus = null;
            var log = GetLogFromHdtReplay(fileName).ToArray();
            var validationResult = LogValidator.Validate(log);

            if (validationResult.IsValid)
            {
                if (showToast)
                {
                    setToastStatus = ToastManager.ShowReplayProgressToast();
                }
                setToastStatus?.Invoke(ReplayProgress.Uploading);
                var file     = new FileInfo(fileName);
                var hsBuild  = BuildDates.GetByDate(file.LastWriteTime);
                var metaData = hsBuild != null ? new GameMetaData()
                {
                    HearthstoneBuild = hsBuild
                } : null;
                var gameStats = hsBuild != null ? new GameStats()
                {
                    StartTime = file.LastWriteTime
                } : null;
                var success = await LogUploader.Upload(log.ToArray(), metaData, gameStats);

                if (success)
                {
                    Helper.TryOpenUrl(gameStats?.HsReplay?.Url);
                }
                else
                {
                    ReplayReader.LaunchReplayViewer(fileName, true);
                }
            }
            else
            {
                Log.Error("Invalid log: " + validationResult.Reason);
                ReplayReader.LaunchReplayViewer(fileName, true);
            }
            setToastStatus?.Invoke(ReplayProgress.Complete);
        }
        public static async Task ShowReplay(string fileName, bool showToast)
        {
            Action <ReplayProgress> setToastStatus = null;
            var log = GetLogFromHdtReplay(fileName).ToArray();
            var validationResult = LogValidator.Validate(log);

            if (validationResult.IsValid)
            {
                if (showToast)
                {
                    setToastStatus = ToastManager.ShowReplayProgressToast();
                }
                setToastStatus?.Invoke(ReplayProgress.Uploading);
                var file     = new FileInfo(fileName);
                var hsBuild  = BuildDates.GetByDate(file.LastWriteTime);
                var metaData = hsBuild != null ? new GameMetaData()
                {
                    HearthstoneBuild = hsBuild
                } : null;
                var gameStats = hsBuild != null ? new GameStats()
                {
                    StartTime = file.LastWriteTime
                } : null;
                var success = await LogUploader.Upload(log.ToArray(), metaData, gameStats);

                if (success)
                {
                    Helper.TryOpenUrl(gameStats?.HsReplay?.Url);
                    setToastStatus?.Invoke(ReplayProgress.Complete);
                }
                else
                {
                    ErrorManager.AddError("Error uploading replay", "Please try again later.");
                    setToastStatus?.Invoke(ReplayProgress.Error);
                }
            }
            else
            {
                Log.Error("Invalid log: " + validationResult.Reason);
                ErrorManager.AddError("Can not load replay", $"{fileName} does not contain a valid replay.");
            }
        }