public FileDownloadModule(GameSL gameSl) { Get["/download/replay/{gameId}"] = param => { GameReplayData replayData = gameSl.GetReplayData(param.gameId); if (replayData == null || !File.Exists(replayData.ReplayPath)) { _logger.Info($"Replay file not found. GameId: {param.gameId}, path: {replayData.ReplayPath}"); return(Response.AsError(HttpStatusCode.NotFound, "Replay file cannot be found from the server")); } var file = new FileStream(replayData.ReplayPath, FileMode.Open); string fileName = "Fate Another Replay " + replayData.PlayedDateTime.ToString(CultureInfo.InvariantCulture) + ".w3g"; var response = new StreamResponse(() => file, MimeTypes.GetMimeType(fileName)); return(response.AsAttachment(fileName)); }; Get["/download/{fileName}"] = param => SendAttachmentResponse(param.fileName); Get["/download/map"] = param => SendAttachmentResponse(ConfigHandler.MapName); }
public MainModule(IResourceLinker linker, GameSL gameSl, PlayerStatSL playerStatsSl, GhostCommSL ghostCommSl, StatisticsSL statisticsSl, GameDetailSL gameDetailSl, BanListSL banListSl) { Get["/"] = _ => { Context.EnableOutputCache(15); MainPageViewModel mpVm = new MainPageViewModel { CurrentBotTime = DateTime.Now, RecentGameDataList = gameSl.GetRecentGames(10) }; return(View["Views/MainPage.sshtml", mpVm]); }; Post["/Search"] = param => Response.AsRedirect($"/PlayerStats/USEast/{Request.Form.searchPlayerName}"); Get["/GameList"] = param => { Context.EnableOutputCache(10); return(View["Views/GameList.sshtml", ghostCommSl.GetGameList()]); }; Get["/About"] = Param => View["Views/About.sshtml"]; Get["/ServantStatistics"] = Param => { Context.EnableOutputCache(30); return(View["Views/ServantStatistics.sshtml", statisticsSl.GetServantStatistics()]); }; Get["/LeaderBoards"] = Param => { Context.EnableOutputCache(30); return(View["Views/LeaderBoards.sshtml"]); }; Get["/Downloads"] = Param => View["Views/Downloads.sshtml", ConfigHandler.MapName]; Get["/PlayerGameBuildDetail/{GameID}/{PlayerName}"] = param => { PlayerGameBuildViewModel vm = gameDetailSl.GetPlayerGameBuild(param.GameID, param.PlayerName); return(View["Views/PlayerGameBuildDetail.sshtml", vm]); }; Get["/Log"] = x => { string gameLog = gameSl.GetGameLog(Request.Query.gameId); return(View["Views/Log.sshtml", gameLog]); }; Get["/PlayerStats/{server}/{playerName}"] = param => { PlayerStatsPageViewModel summaryData = playerStatsSl.GetPlayerStatSummary(param.playerName, param.server, int.MaxValue); return(View["Views/PlayerStatsPage.sshtml", summaryData]); }; Get["/Maintenance"] = param => View["Views/Maintenance.sshtml"]; Get["/Login"] = param => View["Views/Login.sshtml", new LoginViewModel()]; Get["/BanList"] = param => { Context.EnableOutputCache(60); return(View["Views/BanList.sshtml", banListSl.GetBannedPlayers()]); }; }