private void InsertTestData(CSSDataContext db) { //Create test user CreateUser("Orion", "Test", "Test", 10); CreateUser("BackTrak", "Test", "Test", 20); CreateUser("TheBored", "Test", "Test", 30); for (int i = 0; i < 30; i++) { CreateUser("TestPilot" + i, "Test", "Test", i * 6); } //Create a tranform method db.TransformMethods.InsertOnSubmit(new TransformMethod() { Text = "int len = rand.Next(189, 350); for (int i = rand.Next(15, 35); i < len; i += 2) sb.Append((char)rand.Next(48, 122));" }); //Create session statuses db.SessionStatus.InsertOnSubmit(new SessionStatus() { Id = 1, Name = "Pending Verification" }); db.SessionStatus.InsertOnSubmit(new SessionStatus() { Id = 2, Name = "Active" }); db.SessionStatus.InsertOnSubmit(new SessionStatus() { Id = 3, Name = "Closed" }); //Create Roles db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.SuperAdministrator, Name = RoleType.SuperAdministrator.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.Administrator, Name = RoleType.Administrator.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.Moderator, Name = RoleType.Moderator.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.ZoneLeader, Name = RoleType.ZoneLeader.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.User, Name = RoleType.User.ToString() }); //Create lobby db.Lobbies.InsertOnSubmit(new Lobby() { Name = "Production", IsRestrictive = false, IsEnabled = true, BasePath = "test", Host = "test.alleg.net" }); // Create GroupRole db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '*', Name = "Squad Leader" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '^', Name = "Assistant Squad Leader" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '+', Name = "Zone Lead" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '$', Name = "Developer" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '?', Name = "Help Desk" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = null, Name = "Pilot" }); // Add localhost game servers using (CSSStatsDataContext statsDB = new CSSStatsDataContext()) { var gameServer = new DataAccess.GameServer() { GameServerName = "Test Server", GameServerOwnerName = "BackTrak" }; statsDB.GameServers.InsertOnSubmit(gameServer); //db.GameServerIPs.InsertOnSubmit(new GameServerIP() { GameServer = gameServer, GameServerID = gameServer.GameServerID, IPAddress = "127.0.0.1" }); statsDB.GameServerIPs.InsertOnSubmit(new GameServerIP() { GameServer = gameServer, IPAddress = "127.0.0.1" }); statsDB.SubmitChanges(); } //foreach(string name in Enum.GetNames(typeof(DataAccess.Enumerations.LinkedItemType))) //{ // db.LinkedItemTypes.InsertOnSubmit(new LinkedItemType() // { // Id = (int) Enum.Parse(typeof(DataAccess.Enumerations.LinkedItemType), name), // Name = name // }); //} LoadTestMachineRecords(); LoadTestMachineExclusions(); LoadTestVirtualMachineMarkers(); }
private int SaveGame(DataAccess.CSSDataContext db, DataAccess.CSSStatsDataContext statsDB, DataAccess.GameServer gameServer, Data.GameDataset.GameRow gameRow) { DataAccess.Game game = new Allegiance.CommunitySecuritySystem.DataAccess.Game() { GameDefections = gameRow.AllowDefections, GameDevelopments = gameRow.AllowDevelopments, GameShipyards = gameRow.AllowShipyards, GameConquest = gameRow.Conquest, GameCore = TrimString(gameRow.CoreFile, 50), GameDeathMatch = gameRow.DeathMatch, GameDeathmatchGoal = gameRow.DeathmatchGoal, GameEndTime = gameRow.EndTime, GameFriendlyFire = gameRow.FriendlyFire, GameName = TrimString(gameRow.GameName, 254), GameInvulStations = gameRow.InvulnerableStations, GameMap = TrimString(gameRow.MapName, 49), GameMaxImbalance = gameRow.MaxImbalance, GameResources = gameRow.Resources, GameRevealMap = gameRow.RevealMap, GameSquadGame = gameRow.SquadGame, GameStartingMoney = gameRow.StartingMoney, GameStartTime = gameRow.StartTime, GameStatsCount = gameRow.StatsCount, GameTotalMoney = gameRow.TotalMoney, GameID = gameRow.GameID, GameServer = gameServer.GameServerID }; statsDB.Games.InsertOnSubmit(game); try { statsDB.SubmitChanges(); } catch (Exception ex) { string dbLengthErrors = Utilities.LinqErrorDetector.AnalyzeDBChanges(statsDB); throw new Exception("CSSStats[games]: DB Error, Linq Length Analysis: " + dbLengthErrors + "\r\n", ex); } SaveGameEvents(db, statsDB, gameRow, game.GameIdentID); SaveTeams(db, statsDB, gameRow, game.GameIdentID); SaveChatLog(db, statsDB, gameRow, game.GameIdentID); try { statsDB.SubmitChanges(); } catch (Exception ex) { string dbLengthErrors = Utilities.LinqErrorDetector.AnalyzeDBChanges(statsDB); throw new Exception("CSSStats[game data]: DB Error, Linq Length Analysis: " + dbLengthErrors + "\r\n", ex); } try { db.SubmitChanges(); } catch (Exception ex) { string dbLengthErrors = Utilities.LinqErrorDetector.AnalyzeDBChanges(db); throw new Exception("CSS DB Error, Linq Length Analysis: " + dbLengthErrors + "\r\n", ex); } statsDB.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, game); UpdateLeaderboard(game.GameIdentID); UpdateFactionStats(game.GameIdentID); UpdateMetrics(game.GameIdentID); statsDB.SubmitChanges(); db.SubmitChanges(); return(game.GameIdentID); }
private void InsertTestData(CSSDataContext db) { //Create test user CreateUser("Orion", "Test", "Test", 10); CreateUser("BackTrak", "Test", "Test", 20); CreateUser("TheBored", "Test", "Test", 30); for (int i = 0; i < 30; i++) CreateUser("TestPilot" + i, "Test", "Test", i * 6); //Create a tranform method db.TransformMethods.InsertOnSubmit(new TransformMethod() { Text = "int len = rand.Next(189, 350); for (int i = rand.Next(15, 35); i < len; i += 2) sb.Append((char)rand.Next(48, 122));" }); //Create session statuses db.SessionStatus.InsertOnSubmit(new SessionStatus() { Id = 1, Name = "Pending Verification" }); db.SessionStatus.InsertOnSubmit(new SessionStatus() { Id = 2, Name = "Active" }); db.SessionStatus.InsertOnSubmit(new SessionStatus() { Id = 3, Name = "Closed" }); //Create Roles db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.SuperAdministrator, Name = RoleType.SuperAdministrator.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.Administrator, Name = RoleType.Administrator.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.Moderator, Name = RoleType.Moderator.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.ZoneLeader, Name = RoleType.ZoneLeader.ToString() }); db.Roles.InsertOnSubmit(new Role() { Id = (int)RoleType.User, Name = RoleType.User.ToString() }); //Create lobby db.Lobbies.InsertOnSubmit(new Lobby() { Name = "Production", IsRestrictive = false, IsEnabled = true, BasePath = "test", Host = "test.alleg.net" }); // Create GroupRole db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '*', Name="Squad Leader" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '^', Name="Assistant Squad Leader" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '+', Name="Zone Lead" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '$', Name="Developer" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = '?', Name = "Help Desk" }); db.GroupRoles.InsertOnSubmit(new GroupRole() { Token = null, Name="Pilot" }); // Add localhost game servers using (CSSStatsDataContext statsDB = new CSSStatsDataContext()) { var gameServer = new DataAccess.GameServer() { GameServerName = "Test Server", GameServerOwnerName = "BackTrak" }; statsDB.GameServers.InsertOnSubmit(gameServer); //db.GameServerIPs.InsertOnSubmit(new GameServerIP() { GameServer = gameServer, GameServerID = gameServer.GameServerID, IPAddress = "127.0.0.1" }); statsDB.GameServerIPs.InsertOnSubmit(new GameServerIP() { GameServer = gameServer, IPAddress = "127.0.0.1" }); statsDB.SubmitChanges(); } //foreach(string name in Enum.GetNames(typeof(DataAccess.Enumerations.LinkedItemType))) //{ // db.LinkedItemTypes.InsertOnSubmit(new LinkedItemType() // { // Id = (int) Enum.Parse(typeof(DataAccess.Enumerations.LinkedItemType), name), // Name = name // }); //} LoadTestMachineRecords(); LoadTestMachineExclusions(); LoadTestVirtualMachineMarkers(); }