public ActionResult Leaderboard() { var service = new iRacingScraperService(); var csvFilename = HostingEnvironment.MapPath("~/driverStats.csv"); service.RebuildStatsFileIfOld(csvFilename, 6.0, false); // Get Info from cache only. var drivers = service.GetDriverStats(csvFilename); var rankedDrivers = drivers .OrderByDescending(d => d.iRating) .ThenByDescending(d => d.AvgPointsPerRace) .ToList(); foreach (var driver in rankedDrivers) { driver.Driver = AsrDriverNames.Names.ContainsKey($"{driver.CustId}") ? AsrDriverNames.Names[$"{driver.CustId}"] : driver.Driver; } var leaderboardService = new LeaderboardImageCreator(Server); var leaderboard = leaderboardService.CreateLeaderboad(rankedDrivers); return(new ImageResult(leaderboard)); }
public ActionResult Badge(string type, int customerId) { if (!Authorised(customerId)) { return(new EmptyResult()); } var service = new iRacingScraperService(); var csvFilename = HostingEnvironment.MapPath("~/driverStats.csv"); service.RebuildStatsFileIfOld(csvFilename, 6.0, false); var signatureCreator = new SignatureImageCreator(Server); var driverInfo = service.GetDriverStats(csvFilename).First(d => d.CustId == customerId); Image signature = null; //if (type == "road") signature = signatureCreator.GetRoadBadge(driverInfo); //else if (type == "oval") // signature = signatureCreator.GetOvalBadge(driverInfo); //else if (type == "dirtoval") // signature = signatureCreator.GetDirtOvalBadge(driverInfo); //else if (type == "dirtroad") // signature = signatureCreator.GetDirtRoadBadge(driverInfo); return(new ImageResult(signature)); }
public ActionResult TimeTrials(int id) { var service = new iRacingScraperService(); var jsonFilename = HostingEnvironment.MapPath($"~/{id}-tt.json"); service.RebuildTTLeaderboardIfOld(jsonFilename, id, 6.0, true); var timeTrials = service.GetTimeTrialLeaderboard(jsonFilename); var ledaerboardService = new LeaderboardImageCreator(Server); var leaderboard = ledaerboardService.CreateTimeTrialLeaderboad(timeTrials); return(new ImageResult(leaderboard)); }
//[AsrIRacingCustomerIdAuthorize] public ActionResult Mini(int id) { if (!Authorised(id)) { return(new EmptyResult()); } var service = new iRacingScraperService(); var csvFilename = HostingEnvironment.MapPath("~/driverStats.csv"); service.RebuildStatsFileIfOld(csvFilename, 6.0, false); var signatureCreator = new SignatureImageCreator(Server); var driverInfo = service.GetDriverStats(csvFilename).First(d => d.CustId == id); var signature = signatureCreator.GetRoadMiniSignature(driverInfo); return(new ImageResult(signature)); }
public ActionResult Season(int id, string f = null) { bool forceRefresh = !string.IsNullOrWhiteSpace(f); var csvFilename = HostingEnvironment.MapPath($"~/season-{id}.csv"); var service = new iRacingScraperService(); if (service.IsFileOld(csvFilename, 6.0) || forceRefresh) { var cookies = service.LoginAndGetCookies(); service.RebuildSeriesStandingFile(cookies, id, csvFilename); } var standings = service.GetSeasonStandings(csvFilename); var leaderboardService = new LeaderboardImageCreator(Server); var standingsTable = leaderboardService.CreateSeasonTable(standings); return(new ImageResult(standingsTable)); }
public ActionResult Stats() { var service = new iRacingScraperService(); var csvFilename = HostingEnvironment.MapPath("~/driverStats.csv"); service.RebuildStatsFileIfOld(csvFilename, 6.0, false); var drivers = service.GetDriverStats(csvFilename); foreach (var driver in drivers) { driver.Driver = AsrDriverNames.Names.ContainsKey($"{driver.CustId}") ? AsrDriverNames.Names[$"{driver.CustId}"] : driver.Driver; } var leaderboardService = new LeaderboardImageCreator(Server); var statsTable = leaderboardService.CreateStatsTable(drivers); return(new ImageResult(statsTable)); }
//[AsrIRacingCustomerIdAuthorize] public ActionResult Srr(int id) { if (!Authorised(id)) { return(new EmptyResult()); } if (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.Contains("atomicracingracing.net/forum/")) { return(Badge("road", id)); } var service = new iRacingScraperService(); var csvFilename = HostingEnvironment.MapPath("~/driverStats.csv"); service.RebuildStatsFileIfOld(csvFilename, 6.0, false); var signatureCreator = new SignatureImageCreator(Server); var driverInfo = service.GetDriverStats(csvFilename).First(d => d.CustId == id); var signature = signatureCreator.GetRoadMiniSrrSignature(driverInfo); return(new ImageResult(signature)); }