예제 #1
0
        public async override Task Execute()
        {
            if (CanExecute())
            {
                _timer.Start();
                var lastmodekey = await DetermineLastModeKey();

                HtmlDocument responsedoc = await ExecuteRequest(lastmodekey);

                if (responsedoc != null)
                {
                    var players = new List <ExpandoObject>();
                    foreach (var pl in ParsePlayersFromResponse(responsedoc))
                    {
                        players.Add(CreateSquadPlayer(pl));
                    }
                    ;
                    await HttpRequestFactory.Post(players, _playersapiroot, _registrationsApiPath);

                    _logger.LogDebug(string.Format("Stored new player data to database for club key '{0}' and season key '{1}'", ClubKey, SeasonKey));
                }
                else
                {
                    _logger.LogDebug(string.Format("Failed to store & commit player squad registration for season '{0}' in data store.", SeasonKey));
                }
                HarvestHelper.FinaliseTimer(_timer);
            }
            ;
        }
        public async override Task Execute()
        {
            if (CanExecute())
            {
                _timer.Start();
                JObject      jsondata    = null;
                HtmlDocument responsedoc = await ExecuteRequest();

                if (responsedoc != null)
                {
                    var playerapps = new List <ExpandoObject>();
                    jsondata = CleanJsonData(responsedoc);
                    playerapps.AddRange(CreatePlayerAppearances(jsondata, true));
                    playerapps.AddRange(CreatePlayerAppearances(jsondata, false));
                    if (playerapps.Count > 0)
                    {
                        await HttpRequestFactory.Post(playerapps, _fixturesapiroot, _registrationsApiPath);

                        _logger.LogDebug(string.Format("Stored & comitted fixture player appearances for fixture '{0}' in data store.", FixtureKey));
                    }
                }
                else
                {
                    _logger.LogDebug(string.Format("Failed to store & commit player appearances for fixture '{0}'", FixtureKey));
                }
                HarvestHelper.FinaliseTimer(_timer);
            }
        }
예제 #3
0
        public async override Task Execute()
        {
            if (CanExecute())
            {
                _timer.Start();
                IHarvestRequestResult responsedoc = await ExecuteRequest();

                if (responsedoc != null)
                {
                    var clubs = new List <ExpandoObject>();
                    foreach (var cr in ParseClubsFromResponse(responsedoc))
                    {
                        clubs.Add(CreateSeasonParticipant(cr));
                    }
                    await _httpmanager.Post(clubs, $"{_participantsapiroot}/api/{_registrationsApiPath}"); // TODO: handle success/fail

                    _logger.LogDebug(string.Format("Stored club season registrations data to database for season '{0}'", SeasonKey));
                }
                else
                {
                    _logger.LogDebug(string.Format("Failed to store & commit club registations for season as no response was recieved from endpoint: '{0}'", SeasonKey));
                }
                HarvestHelper.FinaliseTimer(_timer);
            }
        }
예제 #4
0
        public async override Task Execute()
        {
            if (CanExecute())
            {
                _timer.Start();
                var lastmodekey = await DetermineLastModeKey();

                var          pdate       = RequestPeriod;
                HtmlDocument responsedoc = await ExecuteRequest(pdate.Year, GetIso8601WeekOfYear(pdate), lastmodekey);

                if (responsedoc != null)
                {
                    var fixtures = new List <ExpandoObject>();
                    foreach (var fx in ParseFixturesFromResponse(responsedoc))
                    {
                        var fixture = CreateFixture(fx);
                        fixtures.Add(fixture);
                    }
                    if (fixtures.Count > 0)
                    {
                        await HttpRequestFactory.Post(fixtures, _fixturesapiroot, _registrationsApiPath);

                        _logger.LogDebug(string.Format("Stored season fixtures to database for season and period '{0}' - '{1}", SeasonKey, pdate.ToShortDateString()));
                    }
                    else
                    {
                        _logger.LogDebug(string.Format("No seasons identified for storage for season and period '{0}' - '{1}", SeasonKey, pdate.ToShortDateString()));
                    }
                }
                else
                {
                    _logger.LogDebug(string.Format("Failed to store & commit fixtures for period '{0}' in data store.", pdate.ToShortDateString()));
                }
            }
            ;
            HarvestHelper.FinaliseTimer(_timer);
        }