コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }