Example #1
0
        private void LoadTeam(NflTeam team, string teamCode)
        {
            var ep        = new EpMetric();
            var metricsHt = new Hashtable();

            var dg    = _tflWs.GetAllGames(teamCode, Season);
            var games = dg.Tables["sched"];

            foreach (DataRow drg in games.Rows)
            {
                var g = new NFLGame(drg);
                if (!g.IsRecent())
                {
                    continue;
                }

                if (!g.MetricsCalculated)
                {
                    g.TallyMetrics(String.Empty);
                }
                var hashCode = string.Format("{0}{1}{2}", teamCode, g.Season, g.Week);
                if (g.IsHome(teamCode))
                {
                    ep.HomeTeam      = teamCode;
                    ep.OffTDp        = g.HomeTDp;
                    ep.OffTDr        = g.HomeTDr;
                    ep.OffSakAllowed = g.HomeSaKa;
                    ep.DefTDp        = g.AwayTDp;
                    ep.DefTDr        = g.AwayTDr;
                    ep.DefSak        = g.AwaySaKa;
                    ep.HomePasses    = g.HomePasses;
                    ep.HomeRuns      = g.HomeRuns;
                }
                else
                {
                    ep.AwayTeam      = g.AwayTeam;
                    ep.OffTDp        = g.AwayTDp;
                    ep.OffTDr        = g.AwayTDr;
                    ep.OffSakAllowed = g.AwaySaKa;
                    ep.DefTDp        = g.HomeTDp;
                    ep.DefTDr        = g.HomeTDr;
                    ep.DefSak        = g.HomeSaKa;
                    ep.AwayPasses    = g.AwayPasses;
                    ep.AwayRuns      = g.AwayRuns;
                }

                if (DoBreakdowns)
                {
                    AddBreakdown(teamCode, ep, g);
                }

                if (ep.Total() <= 0)
                {
                    continue;
                }

                ep.WeekSeed = Utility.WeekSeed(g.Season, g.Week);
                if (!metricsHt.ContainsKey(hashCode))
                {
                    metricsHt.Add(hashCode, ep);
                }
            }
            team.SetMetrics(metricsHt);
#if DEBUG
            //Utility.PrintIndexAndKeysAndValues( metricsHt );
#endif
        }