public void Refresh(Player player)
        {
            _logger.LogMessage($"Main window: refresh player {player.ID} cards clicked.");
            if (!string.IsNullOrEmpty(player.DeckId))
            {
                try {
                    _loadingStatusService.ReportPlayerStatus(player.ID, Status.LoadingDeck);
                    var originalName = player.Name;
                    _cardLoadService.LoadPlayer(player);

                    //if this is a new character, clear all cards from card zones
                    if (originalName != player.Name)
                    {
                        player.CardGroup.ClearCards();
                    }

                    var worker = new BackgroundWorker();
                    worker.DoWork += (x, y) => {
                        _loadingStatusService.ReportPlayerStatus(player.ID, Status.LoadingCards);
                        try {
                            _cardLoadService.LoadPlayerCards(player);
                            _loadingStatusService.ReportPlayerStatus(player.ID, Status.Finished);
                        }
                        catch {
                            _loadingStatusService.ReportPlayerStatus(player.ID, Status.Error);
                        }
                    };
                    worker.RunWorkerAsync();
                }
                catch (Exception ex) {
                    _logger.LogException(ex, $"Main window: error refreshing player {player.ID} cards.");
                    _loadingStatusService.ReportPlayerStatus(player.ID, Status.Error);
                }
            }
        }
Exemple #2
0
        public void Refresh(Player player)
        {
            _logger.LogMessage($"Main window: refresh player {player.ID} cards clicked.");
            if (!string.IsNullOrEmpty(player.DeckId))
            {
                try {
                    _loadingStatusService.ReportPlayerStatus(player.ID, Status.LoadingDeck);
                    _arkhamDbService.LoadPlayer(player);

                    var worker = new BackgroundWorker();
                    worker.DoWork += (x, y) => {
                        _loadingStatusService.ReportPlayerStatus(player.ID, Status.LoadingCards);
                        try {
                            _arkhamDbService.LoadPlayerCards(player);
                            _loadingStatusService.ReportPlayerStatus(player.ID, Status.Finished);
                        }
                        catch {
                            _loadingStatusService.ReportPlayerStatus(player.ID, Status.Error);
                        }
                    };
                    worker.RunWorkerAsync();
                }
                catch (Exception ex) {
                    _logger.LogException(ex, $"Main window: error refreshing player {player.ID} cards.");
                    _loadingStatusService.ReportPlayerStatus(player.ID, Status.Error);
                }
            }
        }