Ejemplo n.º 1
0
		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);
		}
Ejemplo n.º 2
0
		/// <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;
		}
Ejemplo n.º 3
0
		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)));
		}