コード例 #1
0
ファイル: TaskController.cs プロジェクト: mpnieland/NPGGFFL2
        public bool UpdateGameDataAll(string gamedataall)
        {
            GameCenterController gController = new GameCenterController();

            foreach (var gd in context.Games)
            {
                gd.GameData = new ASCIIEncoding().GetBytes(gController.GetGameCenterJson(gd.GameId));
            }

            context.SubmitChanges();

            return true;
        }
コード例 #2
0
ファイル: TaskController.cs プロジェクト: mpnieland/NPGGFFL2
        public bool UpdateGameData(string gamedata)
        {
            GameCenterController gController = new GameCenterController();
            var currentWeek = context.SeasonWeeks.Where(sw => sw.StartDtm <= DateTime.Now && sw.EndDtm >= DateTime.Now).FirstOrDefault();
            if (currentWeek == null)
            {
                currentWeek = context.SeasonWeeks.Where(sw => sw.SeasonYear == 2015 && sw.SeasonType == "REG" && sw.SeasonWeekNum == 17).FirstOrDefault();
            }

            foreach (var gd in currentWeek.Games)
            {
                gd.GameData = new ASCIIEncoding().GetBytes(gController.GetGameCenterJson(gd.GameId));
            }

            context.SubmitChanges();

            return true;
        }
コード例 #3
0
ファイル: TaskController.cs プロジェクト: mpnieland/NPGGFFL2
        private bool UpdatePlayerStats(Stats playerStats, int gameTimeRemaining)
        {
            GameCenterController gController = new GameCenterController();
            var scDictionary = gController.BuildScoringConfigDictionary();

            var PassingYards = playerStats.Statistic.Where(s => s.StatType.Equals("Passing") && s.StatName.Equals("Yds")).FirstOrDefault();
            var PassingTDs = playerStats.Statistic.Where(s => s.StatType.Equals("Passing") && s.StatName.Equals("TDs")).FirstOrDefault();
            var RushingYards = playerStats.Statistic.Where(s => s.StatType.Equals("Rushing") && s.StatName.Equals("Yds")).FirstOrDefault();
            var RushingTDs = playerStats.Statistic.Where(s => s.StatType.Equals("Rushing") && s.StatName.Equals("TDs")).FirstOrDefault();
            var ReceivingReceptions = playerStats.Statistic.Where(s => s.StatType.Equals("Receiving") && s.StatName.Equals("Rec")).FirstOrDefault();
            var ReceivingYards = playerStats.Statistic.Where(s => s.StatType.Equals("Receiving") && s.StatName.Equals("Yds")).FirstOrDefault();
            var ReceivingTDs = playerStats.Statistic.Where(s => s.StatType.Equals("Receiving") && s.StatName.Equals("TDs")).FirstOrDefault();
            var TwoPointConversionsPassing = playerStats.Statistic.Where(s => s.StatType.Equals("Passing") && s.StatName.Equals("2PCs")).FirstOrDefault();
            var TwoPointConversionsRushing = playerStats.Statistic.Where(s => s.StatType.Equals("Rushing") && s.StatName.Equals("2PCs")).FirstOrDefault();
            var TwoPointConversionsReceiving = playerStats.Statistic.Where(s => s.StatType.Equals("Receiving") && s.StatName.Equals("2PCs")).FirstOrDefault();
            var DefensiveTDs = playerStats.Statistic.Where(s => s.StatType.Equals("Team Defense") && s.StatName.Equals("Defensive TDs")).FirstOrDefault();
            var KickReturnTDs = playerStats.Statistic.Where(s => s.StatType.Equals("Kick Return") && s.StatName.Equals("Kick Ret TDs")).FirstOrDefault();
            var PuntReturnTDs = playerStats.Statistic.Where(s => s.StatType.Equals("Punt Return") && s.StatName.Equals("Punt Ret TDs")).FirstOrDefault();
            var FieldGoalsMade = playerStats.Statistic.Where(s => s.StatType.Equals("Kicking") && s.StatName.Equals("FGs")).FirstOrDefault();
            var ExtraPointsMade = playerStats.Statistic.Where(s => s.StatType.Equals("Kicking") && s.StatName.Equals("XPs")).FirstOrDefault();
            var Safeties = playerStats.Statistic.Where(s => s.StatType.Equals("Team Defense") && s.StatName.Equals("Safeties")).FirstOrDefault();
            var PointsAllowed = playerStats.Statistic.Where(s => s.StatType.Equals("Team Defense") && s.StatName.Equals("Pts Allowed")).FirstOrDefault();
            var Points = playerStats.TotalPoints;
            var playerGame = context.Games.Where(g => g.GameId == playerStats.PlayerGameId).FirstOrDefault();

            var statsExist = context.PlayerStats.Where(ps => ps.PlayerId == playerStats.PlayerProfileId && ps.GameId == playerStats.PlayerGameId).FirstOrDefault();
            if (statsExist == null)
            {
                statsExist = new PlayerStat();
                statsExist.PlayerId = playerStats.PlayerProfileId;
                statsExist.PlayerName = playerStats.PlayerName;
                statsExist.GameId = playerStats.PlayerGameId;
                statsExist.GameDesc = string.Format("{0} vs. {1}", playerGame.AwayTeamId.ToUpper(), playerGame.HomeTeamId.ToUpper());
                statsExist.GameTimeRemaining = gameTimeRemaining;
                statsExist.PassingYards = (PassingYards == null ? 0 : Convert.ToInt32(PassingYards.StatValue));
                statsExist.PassingTDs = (PassingTDs == null ? 0 : Convert.ToInt32(PassingTDs.StatValue));
                statsExist.RushingYards = (RushingYards == null ? 0 : Convert.ToInt32(RushingYards.StatValue));
                statsExist.RushingTDs = (RushingTDs == null ? 0 : Convert.ToInt32(RushingTDs.StatValue));
                statsExist.ReceivingReceptions = (ReceivingReceptions == null ? 0 : Convert.ToInt32(ReceivingReceptions.StatValue));
                statsExist.ReceivingYards = (ReceivingYards == null ? 0 : Convert.ToInt32(ReceivingYards.StatValue));
                statsExist.ReceivingTDs = (ReceivingTDs == null ? 0 : Convert.ToInt32(ReceivingTDs.StatValue));
                statsExist.TwoPointConversions = (TwoPointConversionsPassing == null ? 0 : Convert.ToInt32(TwoPointConversionsPassing.StatValue)) + (TwoPointConversionsRushing == null ? 0 : Convert.ToInt32(TwoPointConversionsRushing.StatValue)) + (TwoPointConversionsReceiving == null ? 0 : Convert.ToInt32(TwoPointConversionsReceiving.StatValue));
                statsExist.DefensiveTDs = (DefensiveTDs == null ? 0 : Convert.ToInt32(DefensiveTDs.StatValue));
                statsExist.KickReturnTDs = (KickReturnTDs == null ? 0 : Convert.ToInt32(KickReturnTDs.StatValue));
                statsExist.PuntReturnTDs = (PuntReturnTDs == null ? 0 : Convert.ToInt32(PuntReturnTDs.StatValue));
                statsExist.FumbleRecoveryTDs = 0;
                statsExist.FieldGoalsMade = (FieldGoalsMade == null ? 0 : Convert.ToInt32(FieldGoalsMade.StatValue));
                statsExist.ExtraPointsMade = (ExtraPointsMade == null ? 0 : Convert.ToInt32(ExtraPointsMade.StatValue));
                statsExist.Safeties = (Safeties == null ? 0 : Convert.ToInt32(Safeties.StatValue));
                statsExist.PointsAllowed = (PointsAllowed == null ? 0 : Convert.ToInt32(PointsAllowed.StatValue));
                statsExist.Points = Points;

                context.PlayerStats.InsertOnSubmit(statsExist);
            }
            else
            {
                statsExist.GameTimeRemaining = gameTimeRemaining;
                statsExist.PassingYards = (PassingYards == null ? 0 : Convert.ToInt32(PassingYards.StatValue));
                statsExist.PassingTDs = (PassingTDs == null ? 0 : Convert.ToInt32(PassingTDs.StatValue));
                statsExist.RushingYards = (RushingYards == null ? 0 : Convert.ToInt32(RushingYards.StatValue));
                statsExist.RushingTDs = (RushingTDs == null ? 0 : Convert.ToInt32(RushingTDs.StatValue));
                statsExist.ReceivingReceptions = (ReceivingReceptions == null ? 0 : Convert.ToInt32(ReceivingReceptions.StatValue));
                statsExist.ReceivingYards = (ReceivingYards == null ? 0 : Convert.ToInt32(ReceivingYards.StatValue));
                statsExist.ReceivingTDs = (ReceivingTDs == null ? 0 : Convert.ToInt32(ReceivingTDs.StatValue));
                statsExist.TwoPointConversions = (TwoPointConversionsPassing == null ? 0 : Convert.ToInt32(TwoPointConversionsPassing.StatValue)) + (TwoPointConversionsRushing == null ? 0 : Convert.ToInt32(TwoPointConversionsRushing.StatValue)) + (TwoPointConversionsReceiving == null ? 0 : Convert.ToInt32(TwoPointConversionsReceiving.StatValue));
                statsExist.DefensiveTDs = (DefensiveTDs == null ? 0 : Convert.ToInt32(DefensiveTDs.StatValue));
                statsExist.KickReturnTDs = (KickReturnTDs == null ? 0 : Convert.ToInt32(KickReturnTDs.StatValue));
                statsExist.PuntReturnTDs = (PuntReturnTDs == null ? 0 : Convert.ToInt32(PuntReturnTDs.StatValue));
                statsExist.FumbleRecoveryTDs = 0;
                statsExist.FieldGoalsMade = (FieldGoalsMade == null ? 0 : Convert.ToInt32(FieldGoalsMade.StatValue));
                statsExist.ExtraPointsMade = (ExtraPointsMade == null ? 0 : Convert.ToInt32(ExtraPointsMade.StatValue));
                statsExist.Safeties = (Safeties == null ? 0 : Convert.ToInt32(Safeties.StatValue));
                statsExist.PointsAllowed = (PointsAllowed == null ? 0 : Convert.ToInt32(PointsAllowed.StatValue));
                statsExist.Points = Points;
            }

            context.SubmitChanges();                

            return true;
        }
コード例 #4
0
ファイル: TaskController.cs プロジェクト: mpnieland/NPGGFFL2
        public bool UpdatePlayerStatsWeek(string playerstatsweek, string seasonWeekId)
        {
            GameCenterController gcController = new GameCenterController();
            var seasonWeekExists = context.SeasonWeeks.Where(sw => sw.SeasonWeekId == seasonWeekId).FirstOrDefault();

            if (seasonWeekExists != null)
            {
                foreach (var game in context.Games.Where(g => g.SeasonWeekId == seasonWeekExists.SeasonWeekId))
                {
                    var gameData = gcController.GetGameData(game.GameId);
                    game.HomeTeamScore = gameData.Home.TeamStats.PointsScored;
                    game.AwayTeamScore = gameData.Away.TeamStats.PointsScored;
                    game.Quarter = gameData.Quarter;
                    game.Clock = gameData.Clock;
                    game.GameData = new ASCIIEncoding().GetBytes(gameData.GameCenterJson);
                    context.SubmitChanges();

                    foreach (var playerStat in gameData.PlayerStats)
                    {
                        UpdatePlayerStats(playerStat, GetGameTimeRemaining(gameData.Quarter, gameData.Clock));
                    }
                }
            }
            else
            {
                return false;
            }

            return true;
        }
コード例 #5
0
ファイル: TaskController.cs プロジェクト: mpnieland/NPGGFFL2
        public bool UpdatePlayerStatsGame(string playerstatsgame, int gameId)
        {
            GameCenterController gcController = new GameCenterController();

            var gameExists = context.Games.Where(g => g.GameId == gameId).FirstOrDefault();

            if (gameExists != null)
            {
                var gameData = gcController.GetGameData(gameExists.GameId);
                if (gameData.Home != null && gameData.Away != null)
                {
                    gameExists.HomeTeamScore = gameData.Home.TeamStats.PointsScored;
                    gameExists.AwayTeamScore = gameData.Away.TeamStats.PointsScored;
                    gameExists.Quarter = gameData.Quarter;
                    gameExists.Clock = gameData.Clock;
                    gameExists.GameData = new ASCIIEncoding().GetBytes(gameData.GameCenterJson);
                    context.SubmitChanges();
                }

                if (gameData.PlayerStats != null)
                {
                    foreach (var playerStat in gameData.PlayerStats)
                    {
                        UpdatePlayerStats(playerStat, GetGameTimeRemaining(gameData.Quarter, gameData.Clock));
                    }
                }
            }
            else
            {
                return false;
            }

            return true;
        }        
コード例 #6
0
ファイル: TaskController.cs プロジェクト: mpnieland/NPGGFFL2
        public bool UpdatePlayerStatsAll(string playerstatsall)
        {
            GameCenterController gcController = new GameCenterController();

            foreach (var game in context.Games)
            {
                var gameData = gcController.GetGameData(game.GameId);
                foreach (var playerStat in gameData.PlayerStats)
                {
                    UpdatePlayerStats(playerStat, GetGameTimeRemaining(gameData.Quarter, gameData.Clock));
                }
            }

            return true;
        }   
コード例 #7
0
ファイル: TaskController.cs プロジェクト: mpnieland/NPGGFFL2
        public bool UpdatePlayers(string updateplayers)
        {
            bool success = true;
            GameCenterController gcController = new GameCenterController();
            PlayerController pController = new PlayerController();
            Dictionary<string, Player> playerDictionary = pController.GetPlayerDictionary();
            var players = new List<string>();
            foreach (var week in context.SeasonWeeks.Where(sw => sw.SeasonYear == 2016).OrderBy(sw => sw.SeasonWeekNum))
            {
                var gd = gcController.GetGameCenterData(week.SeasonYear, week.SeasonType, week.SeasonWeekNum);
                foreach (var g in gd)
                {
                    foreach(var p in g.Home.Stats.Where(s => s.PlayerProfileId == 0).Select(s => s.PlayerId).Distinct())
                    {
                        players.Add(p);
                    }
                    foreach(var p in g.Away.Stats.Where(s => s.PlayerProfileId == 0).Select(s => s.PlayerId).Distinct())
                    {
                        players.Add(p);                        
                    }
                }
            }

            foreach (var player in players)
            {
                if (!playerDictionary.ContainsKey(player))
                {
                    var profile = pController.GetPlayerProfile(player);
                }
            }
            
            return success;
        }