public Games GamesEntryToGames(GamesEntry gameEntry) { Games game = new Games() { GameControls = gameEntry.GameControls, GameCreatorName = gameEntry.GameCreatorName, GameDescription = gameEntry.GameDescription, GameGenreSurvival = gameEntry.GameGenreSurvival, GameGenreStrategy = gameEntry.GameGenreStrategy, GameGenreSports = gameEntry.GameGenreSports, GameGenreAction = gameEntry.GameGenreAction, GameGenreAdventure = gameEntry.GameGenreAdventure, GameGenreFighting = gameEntry.GameGenreFighting, GameGenrePuzzle = gameEntry.GameGenrePuzzle, GameGenreRacing = gameEntry.GameGenreRacing, GameGenreRpg = gameEntry.GameGenreRpg, GameGenreRhythm = gameEntry.GameGenreRhythm, GameGenreShooter = gameEntry.GameGenreShooter, GameGenrePlatformer = gameEntry.GameGenrePlatformer, GameId = gameEntry.GameId, GameName = gameEntry.GameName, GameOnArcade = gameEntry.GameOnArcade, GamePath = gameEntry.GamePath, GameReviewDateUtc = gameEntry.GameReviewDateUtc, GameStatus = gameEntry.GameStatus, GameSubmissionDateUtc = gameEntry.GameSubmissionDateUtc, GameVideoLink = gameEntry.GameVideoLink, GameAvailableToDownload = gameEntry.GameAvailableToDownload, }; game = InsertArrayToColumn(game, gameEntry); return(game); }
public void PutGamesEntry(GamesEntry gameEntry) { Games game = GamesEntryToGames(gameEntry); _rdsData.PutGames(game); return; }
///Helper functions/// public GamesEntry GamesToGamesEntry(Games game) { GamesEntry gameEntry = new GamesEntry() { GameControls = game.GameControls, GameCreatorName = game.GameCreatorName, GameDescription = game.GameDescription, GameGenreSurvival = game.GameGenreSurvival, GameGenreStrategy = game.GameGenreStrategy, GameGenreSports = game.GameGenreSports, GameGenreAction = game.GameGenreAction, GameGenreAdventure = game.GameGenreAdventure, GameGenreFighting = game.GameGenreFighting, GameGenrePuzzle = game.GameGenrePuzzle, GameGenreRacing = game.GameGenreRacing, GameGenreRpg = game.GameGenreRpg, GameGenreRhythm = game.GameGenreRhythm, GameGenreShooter = game.GameGenreShooter, GameGenrePlatformer = game.GameGenrePlatformer, GameId = game.GameId, GameName = game.GameName, GameOnArcade = game.GameOnArcade, GamePath = game.GamePath, GameReviewDateUtc = game.GameReviewDateUtc, GameStatus = game.GameStatus, GameSubmissionDateUtc = game.GameSubmissionDateUtc, GameVideoLink = game.GameVideoLink, GameImg = ValidGameImageURLs(game), GameAvailableToDownload = game.GameAvailableToDownload }; return(gameEntry); }
public GamesEntry GetGamesEntry(string gameName) { Games game = _rdsData.GetGames(gameName); GamesEntry gameEntry = GamesToGamesEntry(game); return(gameEntry); }
public void PutGamesEntry(GamesEntry gameEntry) { Games game = GamesEntryToGames(gameEntry); _rdsData.PutGames(game); Submissions submission = new Submissions(); submission.GameId = game.GameId; if (game.GameImage0 != null) { submission.SubmissionImage0 = game.GameImage0; } if (game.GameReviewDateUtc != null) { submission.SubmissionReviewDateUtc = game.GameReviewDateUtc; } if (game.GameStatus != null) { submission.SubmissionStatus = game.GameStatus; } _rdsData.PutSubmissions(submission); return; }
/////// //// Games Table /////// public GamesEntry GetGamesEntry(int gameId) { Games game = _rdsData.GetGames(gameId); GamesEntry gameEntry = GamesToGamesEntry(game); return(gameEntry); }
public IActionResult PutGames(GamesEntry game) { try { StringValues accessToken = new StringValues(); Request.Headers.TryGetValue("Authorization", out accessToken); if (accessToken.Count() == 0) { return(StatusCode(401, "Empty or no authorization header.")); } if (accessToken.FirstOrDefault().ToString() == null || accessToken.FirstOrDefault().ToString() == "") { return(StatusCode(401, "Empty or no authorization header.")); } if (_validation.CheckValidation(accessToken.ToString())) { _rdsLogic.PutGamesEntry(game); return(Ok()); } return(StatusCode(403, "This is an invalid access token.")); } catch (Exception e) { _logger.LogError(e.Message, e); return(StatusCode(500, e.Message)); } }
public IActionResult PostNewEntry([FromBody] GamesEntry newEntry) { try { StringValues accessToken = new StringValues(); Request.Headers.TryGetValue("Authorization", out accessToken); if (accessToken.Count() == 0) { return(StatusCode(401, "Empty or no authorization header.")); } if (accessToken.FirstOrDefault().ToString() == null || accessToken.FirstOrDefault().ToString() == "") { return(StatusCode(401, "Empty or no authorization header.")); } if (_validation.CheckValidation(accessToken.ToString())) { Tuple <Games, int> tuple = _rdsLogic.PostNewEntry(newEntry); if (tuple.Item2 == 1) { return(StatusCode(409, "That game name already exists.")); } _ec2Logic.StartAutomatedTestingEC2(); return(StatusCode(201, tuple.Item1)); } return(StatusCode(403, "This is an invalid access token.")); } catch (Exception e) { _logger.LogError(e.Message, e); return(StatusCode(500, e.Message)); } }
public bool PutGames(GamesEntry myGame, HttpClient client) { try { string json = JsonConvert.SerializeObject(myGame); var buffer = System.Text.Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PutAsync(new Uri("http://" + _host + "/api/v1/Restricted/rds/games/game"), byteContent).Result; if (response.StatusCode.ToString() == "OK") { return(true); } return(false); } catch (Exception e) { _logger.LogError(e.Message, e); return(false); } }
public Games InsertArrayToColumn(Games game, GamesEntry newEntry) { try { int size = newEntry.GameImg.Count(); switch (size) { case 1: game.GameImage0 = newEntry.GameImg[0]; break; case 2: game.GameImage0 = newEntry.GameImg[0]; game.GameImage1 = newEntry.GameImg[1]; break; case 3: game.GameImage0 = newEntry.GameImg[0]; game.GameImage1 = newEntry.GameImg[1]; game.GameImage2 = newEntry.GameImg[2]; break; case 4: game.GameImage0 = newEntry.GameImg[0]; game.GameImage1 = newEntry.GameImg[1]; game.GameImage2 = newEntry.GameImg[2]; game.GameImage3 = newEntry.GameImg[3]; break; case 5: game.GameImage0 = newEntry.GameImg[0]; game.GameImage1 = newEntry.GameImg[1]; game.GameImage2 = newEntry.GameImg[2]; game.GameImage3 = newEntry.GameImg[3]; game.GameImage4 = newEntry.GameImg[4]; break; default: break; } } catch (Exception e) { _logger.LogCritical(e.Message, e); } return(game); }
public GamesEntry GetGamesByID(int?gameID, HttpClient client) { try { HttpResponseMessage response = client.GetAsync("http://" + _host + "/api/v1/Public/rds/games/gamesbyid?gameId=" + gameID).Result; string json = response.Content.ReadAsStringAsync().Result; GamesEntry games = JsonConvert.DeserializeObject <GamesEntry>(json); return(games); } catch (Exception e) { _logger.LogError(e.Message, e); return(null); } }
public void PutNewEntry(GamesEntry updateEntry) { Games postedGame = _rdsData.GetGames((int)updateEntry.GameId); GamesEntry oldEntry = GamesToGamesEntry(postedGame); GamesEntry newEntry = UpdateEntry(oldEntry, updateEntry); Games newGamesUpdate = GamesEntryToGames(newEntry); _rdsData.PutGames(newGamesUpdate); try { TestsQueue newTestQueue = new TestsQueue() { GameId = newGamesUpdate.GameId, RetryCount = 0 }; try { _rdsData.DeleteTestsQueue((int)newGamesUpdate.GameId); } catch (Exception e) { _logger.LogCritical(e.Message, e); } _rdsData.PostTestsQueue(newTestQueue); Tests newTest = new Tests() { GameId = newGamesUpdate.GameId, Test10min = false, TestCloses = false, TestOpens = false, TestAttempts = 0, TestAverageRam = null, TestCloseOn3 = null, TestCloseOnEscape = null, TestFolderFileNames = null, TestNumExeFiles = null, TestPeakRam = null }; try { _rdsData.DeleteTests((int)newGamesUpdate.GameId); } catch (Exception e) { _logger.LogCritical(e.Message, e); } _rdsData.PostTests(newTest); return; } catch (Exception e) { _logger.LogError(e.Message, e); throw new Exception(e.Message); } }
public GamesEntry UpdateEntry(GamesEntry old, GamesEntry newInfo) { if (newInfo.GameAvailableToDownload != null) { old.GameAvailableToDownload = newInfo.GameAvailableToDownload; } if (newInfo.GameControls != null) { old.GameControls = newInfo.GameControls; } if (newInfo.GameCreatorEmail != null) { old.GameCreatorEmail = newInfo.GameCreatorEmail; } if (newInfo.GameCreatorName != null) { old.GameCreatorName = newInfo.GameCreatorName; } if (newInfo.GameDescription != null) { old.GameDescription = newInfo.GameDescription; } if (newInfo.GameGenreAction != null) { old.GameGenreAction = newInfo.GameGenreAction; } if (newInfo.GameGenreAdventure != null) { old.GameGenreAdventure = newInfo.GameGenreAdventure; } if (newInfo.GameGenreFighting != null) { old.GameGenreFighting = newInfo.GameGenreFighting; } if (newInfo.GameGenrePlatformer != null) { old.GameGenrePlatformer = newInfo.GameGenrePlatformer; } if (newInfo.GameGenrePuzzle != null) { old.GameGenrePuzzle = newInfo.GameGenrePuzzle; } if (newInfo.GameGenreRacing != null) { old.GameGenreRacing = newInfo.GameGenreRacing; } if (newInfo.GameGenreRhythm != null) { old.GameGenreRhythm = newInfo.GameGenreRhythm; } if (newInfo.GameGenreRpg != null) { old.GameGenreRpg = newInfo.GameGenreRpg; } if (newInfo.GameGenreShooter != null) { old.GameGenreShooter = newInfo.GameGenreShooter; } if (newInfo.GameGenreSports != null) { old.GameGenreSports = newInfo.GameGenreSports; } if (newInfo.GameGenreStrategy != null) { old.GameGenreStrategy = newInfo.GameGenreStrategy; } if (newInfo.GameGenreSurvival != null) { old.GameGenreSurvival = newInfo.GameGenreSurvival; } if (newInfo.GameImg != null) { old.GameImg = newInfo.GameImg; } if (newInfo.GameName != null) { old.GameName = newInfo.GameName; } if (newInfo.GameOnArcade != null) { old.GameOnArcade = newInfo.GameOnArcade; } if (newInfo.GamePath != null) { old.GamePath = newInfo.GamePath; } if (newInfo.GameReviewComments != null) { old.GameReviewComments = newInfo.GameReviewComments; } if (newInfo.GameReviewDateUtc != null) { old.GameReviewDateUtc = newInfo.GameReviewDateUtc; } if (newInfo.GameStatus != null) { old.GameStatus = newInfo.GameStatus; } if (newInfo.GameSubmissionDateUtc != null) { old.GameSubmissionDateUtc = newInfo.GameSubmissionDateUtc; } if (newInfo.GameVideoLink != null) { old.GameVideoLink = newInfo.GameVideoLink; } return(old); }
public Tuple <Games, int> PostNewEntry(GamesEntry newEntry) { Games newGame = new Games() { GameControls = newEntry.GameControls, GameCreatorName = newEntry.GameCreatorName, GameCreatorEmail = newEntry.GameCreatorEmail, GameDescription = newEntry.GameDescription, GameGenreAction = newEntry.GameGenreAction, GameGenreAdventure = newEntry.GameGenreAdventure, GameGenreFighting = newEntry.GameGenreFighting, GameGenrePuzzle = newEntry.GameGenrePuzzle, GameGenreRacing = newEntry.GameGenreRacing, GameGenreRhythm = newEntry.GameGenreRhythm, GameGenreRpg = newEntry.GameGenreRpg, GameGenreShooter = newEntry.GameGenreShooter, GameGenreSports = newEntry.GameGenreSports, GameGenreStrategy = newEntry.GameGenreStrategy, GameGenreSurvival = newEntry.GameGenreSurvival, GameGenrePlatformer = newEntry.GameGenrePlatformer, GameName = newEntry.GameName, GamePath = newEntry.GamePath, GameVideoLink = newEntry.GameVideoLink, GameOnArcade = false, GameStatus = "t", GameSubmissionDateUtc = DateTime.UtcNow, GameAvailableToDownload = newEntry.GameAvailableToDownload, }; char[] s = new char[5]; newGame = InsertArrayToColumn(newGame, newEntry); if (_rdsData.GetGames(newGame.GameName) != null) { return(Tuple.Create <Games, int>(null, 1)); } try { _rdsData.PostGames(newGame); Games postedGame = _rdsData.GetGames(newGame.GameName); TestsQueue newTestQueue = new TestsQueue() { GameId = postedGame.GameId, RetryCount = 0 }; _rdsData.PostTestsQueue(newTestQueue); Tests newTest = new Tests() { GameId = postedGame.GameId, Test10min = false, TestCloses = false, TestOpens = false, TestAttempts = 0, TestAverageRam = null, TestCloseOn3 = null, TestCloseOnEscape = null, TestFolderFileNames = null, TestNumExeFiles = null, TestPeakRam = null }; _rdsData.PostTests(newTest); return(Tuple.Create(newGame, 0)); } catch (Exception e) { _logger.LogError(e.Message, e); CleanUpOnCrash((int)newGame.GameId); throw new Exception(e.Message); } }
public void RunSingleEntryTest(TestsQueue testsQueue, Tests testProcess) { try { while (testsQueue.RetryCount < 3) { testProcess.Test10min = false; testProcess.TestAttempts = testsQueue.RetryCount; testProcess.TestCloseOn3 = false; testProcess.TestCloseOnEscape = false; testProcess.TestCloses = false; testProcess.TestOpens = false; testProcess.TestNumExeFiles = 0; testProcess.TestAverageRam = null; testProcess.TestFolderFileNames = null; testProcess.TestPeakRam = null; TestingLog testLog = new TestingLog(); _webData.PutTestsQueue(testsQueue, _client); testLog.TestlogAttempt = (int)testsQueue.RetryCount; testLog.GameId = (int)testsQueue.GameId; GamesEntry myGame = _webData.GetGamesByID(testsQueue.GameId, _client); //Retry to pull game if it failed the first time if (myGame == null) { testLog.TestlogLog = "No valid game found with this ID."; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } string debugKey = "public/" + myGame.GamePath; fileLocation = _s3Data.ReadObjectDataAsync(debugKey).Result; //Point variable to folder which contains .exe file string subFileLocation = FindSubDir(fileLocation); //Store list of names of files within game folder testProcess.TestFolderFileNames = FolderFileNames(subFileLocation); //Find .exe file path string[] exeFiles = FindExe(subFileLocation); //Store number of exe files within game folder testProcess.TestNumExeFiles = exeFiles.Length; gameProcess = new Process(); //start .exe, check to see if it started testProcess.TestOpens = StartFile(exeFiles[0]); //Retry tests if process does not start if (!(bool)testProcess.TestOpens) { testLog.TestlogLog = "Game Failed Start Test"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } //Check to see if game still running after 5 min testProcess.Test10min = SleepFile(exeFiles[0]); //Retry tests if process does not stay open for 5 min if ((bool)!testProcess.Test10min) { testLog.TestlogLog = "Game Failed Sleep Test"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } //Store memory usage by game process testProcess.TestAverageRam = RamFile(); //Retry tests if the program is unable to record the game's RAM usage if (testProcess.TestAverageRam == null) { testLog.TestlogLog = "Game Average RAM Test Failed"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } //Store memory usage by game process testProcess.TestPeakRam = RamFile(); //Retry tests if the program is unable to record the game's RAM usage if (testProcess.TestPeakRam == null) { testLog.TestlogLog = "Game Peak RAM Test Failed"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } //Test whether game will close on "3" key press int i = CloseOn3(exeFiles[0]); if (i == 0) { testProcess.TestCloseOn3 = true; testLog.TestlogLog = "Game shut down on 3 press."; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); } else if (i == 1) { testLog.TestlogLog = "Game did not shut down on 3 press."; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); } //Retry tests if the program is unable to restart after passing "3" test else if (i == 2) { testLog.TestlogLog = "Game passed 'close on 3' test but failed to restart"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } //Test whether game will close on "Escape" key press i = EscapeFile(exeFiles[0]); //Log if game did not shut down after "Escape" press if (i == 0) { testProcess.TestCloseOnEscape = true; testLog.TestlogLog = "Game shut down after Escape press"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); } else if (i == 1) { testProcess.TestCloseOnEscape = false; testLog.TestlogLog = "Game did not down after Escape press"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); } //Retry tests if the program is unable to restart after passing "3" test else if (i == 2) { testLog.TestlogLog = "Game passed 'close on Escape' test but failed to restart"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } //Log if game did not shut down after "3" press if ((bool)!testProcess.TestCloseOnEscape) { testLog.TestlogLog = "Game failed 'close on Escape' test"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); } //stop .exe, check to see if it stopped testProcess.TestCloses = StopFile(exeFiles[0]); if ((bool)!testProcess.TestCloses) { testLog.TestlogLog = "Game Failed Stop Test"; testLog.TestlogDatetimeUtc = DateTime.UtcNow; _webData.PostTestingLog(testLog, _client); continue; } //If all tests passed, update game object and stop rechecking if ((bool)testProcess.TestOpens && (bool)testProcess.Test10min && (bool)testProcess.TestCloses) { myGame.GameReviewDateUtc = DateTime.UtcNow; myGame.GameStatus = "p"; if ((testsQueue.RetryCount - 1) == 0) { testLog.TestlogLog = "Game Passed all essential tests on first try"; } else if ((testsQueue.RetryCount - 1) == 1) { testLog.TestlogLog = "Game Passed all essential tests after 1 retry"; } else if ((testsQueue.RetryCount - 1) == 2) { testLog.TestlogLog = "Game Passed all essential tests after 2 retries"; } _webData.PostTestingLog(testLog, _client); _webData.PutGames(myGame, _client); break; } } //Delete game from test queue and push the test results to database _webData.DeleteTestQueue(testsQueue.GameId, _client); _webData.PutTests(testProcess, _client); } catch (Exception e) { _webData.PostTestingLog(new TestingLog() { GameId = testsQueue.GameId, TestlogAttempt = (int)testsQueue.RetryCount, TestlogDatetimeUtc = DateTime.UtcNow, TestlogLog = "There was an error with the testing process, and it has crashed during this test. The error: " + e.Message }, _client); _webData.PutGames(new GamesEntry() { GameId = testsQueue.GameId, GameStatus = "p" }, _client); _webData.DeleteTestQueue(testsQueue.GameId, _client); _webData.PutTests(testProcess, _client); _logger.LogError(e.Message, e); } }