Beispiel #1
0
        public async Task EveryFiveMinutesTick(CancellationToken token)
        {
            var fetched = await _eventStatusClient.GetEventStatus();

            // init/ app-startup
            if (_storedCurrent == null)
            {
                _logger.LogDebug("Executing initial fetch");
                _storedCurrent = fetched;
                return;
            }

            _logger.LogInformation("Checking status");
            var bonusAdded = GetBonusAdded(fetched, _storedCurrent);

            if (bonusAdded != null)
            {
                _logger.LogInformation("Bonus added!");
                await _mediator.Publish(bonusAdded, token);
            }

            var pointsReady = GetPointsReady(fetched, _storedCurrent);

            if (pointsReady != null)
            {
                _logger.LogInformation("Points ready!");
                await _mediator.Publish(pointsReady, token);
            }

            _storedCurrent = fetched;
        }
Beispiel #2
0
    public async Task EveryFiveMinutesTick(CancellationToken token)
    {
        EventStatusResponse fetched;

        try
        {
            fetched = await _eventStatusClient.GetEventStatus();
        }
        catch (Exception e) when(LogError(e))
        {
            return;
        }

        // init/ app-startup
        if (_storedCurrent == null)
        {
            _logger.LogDebug("Executing initial fetch");
            _storedCurrent = fetched;
            return;
        }

        _logger.LogInformation("Checking status");
        var bonusAdded = GetBonusAdded(fetched, _storedCurrent);

        if (bonusAdded != null)
        {
            _logger.LogInformation("Bonus added!");
            await _session.Publish(bonusAdded);
        }

        var pointsReady = GetPointsReady(fetched, _storedCurrent);

        if (pointsReady != null)
        {
            _logger.LogInformation("Points ready!");
            await _session.Publish(pointsReady);
        }

        var leaguesStatusChanged = fetched.Leagues != _storedCurrent.Leagues;

        if (leaguesStatusChanged && fetched.Leagues == EventStatusConstants.LeaguesStatus.Updated)
        {
            _logger.LogInformation($"League status changed from ${_storedCurrent.Leagues} to ${fetched.Leagues}");
            await _session.Publish(new MatchdayLeaguesUpdated());
        }

        _storedCurrent = fetched;
    }