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(); 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); } }
public List <SanitizedFieldInfo> GetFields(Type type) { var fields = new HarvestHelper().GetFieldsAndProperties(type); return(fields.Where(x => x.FieldInfo.CustomAttributes.FirstOrDefault(o => o.AttributeType == typeof(PrintableAttribute)) != null) .ToList()); }
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); } }
private async Task <HtmlDocument> ExecuteRequest() { var url = CreateUrl(); var refer = CreateRefererUrl(); var ctx = HarvestHelper.ConstructRequestContext(null, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", refer, CookieString, "en-GB,en;q=0.9,en-US;q=0.8,th;q=0.7", false, true, true); var p = await _requestmanager.MakeRequest(url, ctx); CookieString = ctx.Cookies["Cookie"]; return(p); }
private async Task <HtmlDocument> ExecuteRequest(string lastmodekey) { var url = CreateRequestUrl(); var referer = CreateRefererUrl(); var ctx = HarvestHelper.ConstructRequestContext(lastmodekey, "application/json,text/javascript,*/*; q=0.01", referer, CookieString, "en-GB", true, false, false); var p = await _requestmanager.MakeRequest(url, ctx); CookieString = ctx.Cookies["Cookie"]; return(p); }
private async Task <HtmlDocument> ExecuteRequest(int year, int week, string lastmodekey) { var url = CreateRequestUrl(year, week); var referer = CreateRefererUrl(); var ctx = HarvestHelper.ConstructRequestContext(lastmodekey, "en -GB,en;q=0.9,en-US;q=0.8,th;q=0.7", referer, CookieString, null, true, false, false); var p = await _requestmanager.MakeRequest(url, ctx); CookieString = ctx.Cookies["Cookie"]; return(p); }
private async Task <string> DetermineLastModeKey() { var referer = CreateRefererUrl(); var ctx = HarvestHelper.ConstructRequestContext(null, "text/html,application/xhtml+xml,image/jxr,*/*", null, CookieString, null, false, false, false); var p = await _requestmanager.MakeRequest(referer, ctx); if (p != null) { return(GetLastModeKey(p.DocumentNode.InnerHtml)); } return(null); }
private async Task <string> DetermineLastModeKey() { var referer = CreateRefererUrl(); var ctx = HarvestHelper.ConstructRequestContext(null, "text/html, application/xhtml+xml, image/jxr, */*", WhoScoredConstants.RootUrl, CookieString, "en-GB,en;q=0.9,en-US;q=0.8,th;q=0.7", false, false, true); var parentresponse = await _requestmanager.MakeRequest(referer, ctx); if (parentresponse != null) { var r = GetLastModeKey(parentresponse.DocumentNode.InnerHtml); return(r); } return(null); }
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); }