public static Stream Load(AIGamesCompetition competition, AIGameResult game) { if (competition == null) { throw new ArgumentNullException("competition"); } if (game == null) { throw new ArgumentNullException("game"); } var location = GetLocation(competition, game); return new FileStream(location.FullName , FileMode.Open, FileAccess.Read); }
/// <summary>Saves the game dump for a specified game.</summary> public bool SaveGameDump(AIGamesCompetition competition, AIGameResult game) { if (competition == null) { throw new ArgumentNullException("competition"); } if (game == null) { throw new ArgumentNullException("game"); } var dir = competition.GetGameDumpDirectory(); if (!dir.Exists) { dir.Create(); } var dump = AIGameDump.GetLocation(competition, game); if (dump.Exists) { return false; } Driver.Url = competition.GetGameDumpUrl(game.Id).ToString(); var html = new HtmlDocument(); html.LoadHtml(Driver.PageSource); var code = html.DocumentNode.SelectNodes("//code").ElementAt(1).InnerHtml; if (String.IsNullOrEmpty(code)) { return false; } using (var stream = dump.OpenWrite()) { AIGameDump.Save(stream, code); } return true; }
public static FileInfo GetLocation(AIGamesCompetition competition, AIGameResult game) { return new FileInfo(Path.Combine(AppConfig.Games_RootDir_Dump.FullName, competition.UrlKey, string.Format("{0}.log", game.Id))); }