예제 #1
0
        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();
            }
        }
        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();
            }
        }