当前位置: 首页>>代码示例>>C#>>正文


C# DataAccess.SubmitChanges方法代码示例

本文整理汇总了C#中DataAccess.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DataAccess.SubmitChanges方法的具体用法?C# DataAccess.SubmitChanges怎么用?C# DataAccess.SubmitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataAccess的用法示例。


在下文中一共展示了DataAccess.SubmitChanges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveGameEvents

        private void SaveGameEvents(Allegiance.CommunitySecuritySystem.DataAccess.CSSDataContext db, DataAccess.CSSStatsDataContext statsDB, Allegiance.CommunitySecuritySystem.Server.Data.GameDataset.GameRow gameRow, int gameIdentID)
        {
            foreach (Data.GameDataset.GameEventRow gameEventRow in gameRow.GetGameEventRows())
            {
                int performerLoginID = 0;
                int targetLoginID = 0;

                try
                {
                    var performerAlias = DataAccess.Alias.GetAliasByCallsign(db, gameEventRow.PerformerName);

                    if (performerAlias != null)
                        performerLoginID = performerAlias.Login.Id;

                    var targetAlias = DataAccess.Alias.GetAliasByCallsign(db, gameEventRow.TargetName);

                    if (targetAlias != null)
                        targetLoginID = targetAlias.Login.Id;

                    DataAccess.GameEvent gameEvent = new DataAccess.GameEvent()
                    {
                        GameEventTime = gameEventRow.EventTime,
                        GameID = gameIdentID,
                        GameEventIndirectID = gameEventRow.IndirectID,
                        GameEventIndirectName = TrimString(DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.IndirectName), 254),
                        GameEventPerformerID = gameEventRow.PerformerID,
                        GameEventPerformerName = TrimString(DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.PerformerName), 254),
                        GameEventPerformerLoginID = performerLoginID,
                        GameEventTargetID = gameEventRow.TargetID,
                        GameEventTargetName = TrimString(DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.TargetName), 254),
                        GameEventTargetLoginID = targetLoginID,
                        EventID = gameEventRow.EventID
                    };

                    statsDB.GameEvents.InsertOnSubmit(gameEvent);

                    statsDB.SubmitChanges();
                }
                catch(Exception ex)
                {

                    string errorDetails = String.Format(@"SaveGameEvents(): Insert error!
            gameIdentID = {0},
            gameEventRow.EventID = {1},
            gameEventRow.EventTime = {2},
            gameEventRow.GameID = {3},
            gameEventRow.IndirectID = {4},
            gameEventRow.IndirectName = {5},
            gameEventRow.PerformerID = {6},
            gameEventRow.PerformerName = {7},
            gameEventRow.TargetID = {8},
            gameEventRow.TargetName = {9},
            performerLoginID = {10},
            targetLoginID = {11},
            DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.IndirectName) = {12},
            DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.PerformerName) = {13},
            DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.TargetName) = {14}
            ===================================================
            {15}
            ",
            gameIdentID,
            gameEventRow.EventID,
            gameEventRow.EventTime,
            gameEventRow.GameID,
            gameEventRow.IndirectID,
            gameEventRow.IndirectName,
            gameEventRow.PerformerID,
            gameEventRow.PerformerName,
            gameEventRow.TargetID,
            gameEventRow.TargetName,
            performerLoginID,
            targetLoginID,
            DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.IndirectName),
            DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.PerformerName),
            DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, gameEventRow.TargetName),
            ex.ToString());

                    if (String.IsNullOrEmpty(Settings.Default.TagExceptionLogFileName) == false)
                        File.AppendAllText(Settings.Default.TagExceptionLogFileName, DateTime.Now.ToString() + ": " + errorDetails + "\n\n\n");

                }
            }
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:83,代码来源:Tag.cs

示例2: SaveTeams

        private void SaveTeams(Allegiance.CommunitySecuritySystem.DataAccess.CSSDataContext db, DataAccess.CSSStatsDataContext statsDB, Allegiance.CommunitySecuritySystem.Server.Data.GameDataset.GameRow gameRow, int gameIdentID)
        {
            foreach (Data.GameDataset.TeamRow teamRow in gameRow.GetTeamRows())
            {
                var commanderAlias = DataAccess.Alias.GetAliasByCallsign(db, teamRow.Commander);
                int commanderLoginID = 0;

                if (commanderAlias != null)
                    commanderLoginID = commanderAlias.Login.Id;

                DataAccess.GameTeam team = new Allegiance.CommunitySecuritySystem.DataAccess.GameTeam()
                {
                    GameID = gameIdentID,
                    GameTeamCommander = TrimString(teamRow.Commander, 49),
                    GameTeamCommanderLoginID = commanderLoginID,
                    GameTeamExpansion = teamRow.ResearchedExpansion,
                    GameTeamFaction = teamRow.Faction,
                    GameTeamID = teamRow.TeamID,
                    GameTeamName = TrimString(teamRow.TeamName, 49),
                    GameTeamNumber = teamRow.TeamNumber,
                    GameTeamShipyard = teamRow.ResearchedShipyard,
                    GameTeamStarbase = teamRow.ResearchedStarbase,
                    GameTeamSupremacy = teamRow.ResearchedSupremacy,
                    GameTeamTactical = teamRow.ResearchedTactical,
                    GameTeamWinner = teamRow.Won
                };

                statsDB.GameTeams.InsertOnSubmit(team);
                statsDB.SubmitChanges();

                foreach (Data.GameDataset.TeamMemberRow teamMemberRow in teamRow.GetTeamMemberRows())
                {
                    var teamMemberAlias = DataAccess.Alias.GetAliasByCallsign(db, teamMemberRow.Callsign);
                    int loginID = 0;
                    if (teamMemberAlias != null)
                        loginID = teamMemberAlias.Login.Id;

                    DataAccess.GameTeamMember teamMember = new Allegiance.CommunitySecuritySystem.DataAccess.GameTeamMember()
                    {
                        GameTeamID = team.GameTeamIdentID,
                        GameTeamMemberCallsign = TrimString(DataAccess.Alias.GetCallsignFromStringWithTokensAndTags(db, teamMemberRow.Callsign), 49),
                        GameTeamMemberDuration = teamMemberRow.Duration,
                        GameTeamMemberLoginID = loginID
                    };

                    statsDB.GameTeamMembers.InsertOnSubmit(teamMember);
                }

                statsDB.SubmitChanges();
            }
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:51,代码来源:Tag.cs

示例3: SaveGame

        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;
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:79,代码来源:Tag.cs


注:本文中的DataAccess.SubmitChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。