예제 #1
0
 string HtmlResponse(string rawUrl, string lastPart, Holder holder)
 {
     if (lastPart == "now.html")
     {
         return(NowPage());
     }
     else if (holder == null)
     {
         return(string.Format(CultureInfo.InvariantCulture, "<html><body>Couldn't find a league key in \"<br>{0}\". Try <a href=\"now.html\">Now Playing</a> instead.</body></html>", rawUrl));
     }
     else if (lastPart == "index.html")
     {
         return(ReportPages.OverviewPage(holder, false, ReportPages.GameHyper, OutputFormat.Svg));
     }
     else if (lastPart.StartsWith("game", StringComparison.OrdinalIgnoreCase))
     {
         DateTime dt   = DateTime.ParseExact(lastPart.Substring(4, 12), "yyyyMMddHHmm", CultureInfo.InvariantCulture);
         Game     game = holder.League.AllGames.Find(x => x.Time.Subtract(dt).TotalSeconds < 60);
         if (game == null)
         {
             return(string.Format(CultureInfo.InvariantCulture, "<html><body>Invalid game: <br>{0}</body></html>", rawUrl));
         }
         else
         {
             return(ReportPages.GamePage(holder.League, game));
         }
     }
     else if (lastPart.StartsWith("team", StringComparison.OrdinalIgnoreCase))
     {
         if (int.TryParse(lastPart.Substring(4, 2), out int teamId))
         {
             LeagueTeam leagueTeam = holder.League.Teams.Find(x => x.TeamId == teamId);
             if (leagueTeam == null)
             {
                 return(string.Format(CultureInfo.InvariantCulture, "<html><body>Invalid team number: <br>{0}</body></html>", rawUrl));
             }
             else
             {
                 return(ReportPages.TeamPage(holder.League, false, leagueTeam, ReportPages.GameHyper, OutputFormat.Svg));
             }
         }
         else
         {
             return(string.Format(CultureInfo.InvariantCulture, "<html><body>Invalid team: <br>{0}</body></html>", rawUrl));
         }
     }
     else if (lastPart.StartsWith("fixture", StringComparison.OrdinalIgnoreCase))
     {
         return(ReportPages.FixturePage(holder.Fixture, holder.League));
     }
     else if (lastPart == "scoreboard.html")
     {
         return(ScoreboardPage(holder.League));
     }
     else
     {
         return(string.Format(CultureInfo.InvariantCulture, "<html><body>Invalid path: <br>{0}</body></html>", rawUrl));
     }
 }
예제 #2
0
        /// <summary>Write out fixtures for the selected leagues.</summary>
        public static void ExportFixtures(string path, List <Holder> leagues)
        {
            if (path != null)
            {
                foreach (Holder holder in leagues)
                {
                    Directory.CreateDirectory(Path.Combine(path, holder.Key));

                    using (StreamWriter sw = File.CreateText(Path.Combine(path, holder.Key, "fixture." + holder.ReportTemplates.OutputFormat.ToExtension())))
                        sw.Write(ReportPages.FixturePage(holder.Fixture, holder.League));
                }
            }
        }