Пример #1
0
        public NflTeam GetTeam(string season, string teamCode)
        {
#if DEBUG
            //Utility.Announce( string.Format( "TeamMaster:Getting Team {0} for {1}", teamCode, season ) );
#endif
            NflTeam team;
            var     key = season + teamCode;
            if (TheHt.ContainsKey(key))
            {
                team = (NflTeam)TheHt[key];
                team.SetRecord(season);
                CacheHits++;
            }
            else
            {
                //  new it up
#if DEBUG
                //Utility.Announce( string.Format( "TeamMaster:Instantiating Team {0} for {1}", teamCode, season ) );
#endif
                team = new NflTeam(teamCode, season);
                PutTeam(team);
                IsDirty = true;
                CacheMisses++;
            }
            return(team);
        }
Пример #2
0
        public NflStat GetStat(string season, string week, string teamCode, string statType)
        {
            var stat = new NflStat
            {
                Season   = season,
                TeamCode = teamCode,
                Week     = week,
                StatType = statType,
                Quantity = 0.0M
            };

#if DEBUG
//			Utility.Announce( string.Format( "StatMaster:Getting Stat {0}", stat.FormatKey() ) );
#endif

            var key = stat.FormatKey();
            if (TheHt.ContainsKey(key))
            {
                stat = (NflStat)TheHt[key];
                CacheHits++;
            }
            else
            {
                //  new it up
#if DEBUG
//				Utility.Announce( string.Format( "StatMaster:Instantiating Stat {0}", stat.FormatKey() ) );
#endif
                PutStat(stat);
                IsDirty = true;
                CacheMisses++;
            }
            return(stat);
        }
Пример #3
0
 public void PutTeam(NflTeam team)
 {
     if (!TheHt.ContainsKey(Key(team)))
     {
         TheHt.Add(Key(team), team);
     }
 }
Пример #4
0
        public TorrentItem GetItem(TorrentItem item)
        {
            TorrentItem m;
            var         theTitle = TitleNormaliser.NormaliseTitle(item.Title, item.Type);

            if (TheHt.ContainsKey(theTitle))
            {
                m = (TorrentItem)TheHt[item.Title.ToUpper()];
                CacheHits++;
            }
            else
            {
                //  new it up
                m = new TorrentItem
                {
                    Filename    = item.Filename,
                    Title       = TitleNormaliser.NormaliseTitle(item.Title, item.Type),
                    LibraryDate = item.LibraryDate,
                    Type        = item.Type
                };
                PutItem(m);
                CacheMisses++;
            }
            return(m);
        }
Пример #5
0
 void PutSeason(NflSeason s)
 {
     if (!TheHt.ContainsKey(s.Year))
     {
         TheHt.Add(s.Year, s);
         IsDirty = true;
     }
 }
Пример #6
0
        public bool HaveItem(string title, string type)
        {
            var ntitle = TitleNormaliser.NormaliseTitle(title, type);
            var haveIt = TheHt.ContainsKey(ntitle);

            if (!haveIt)
            {
                Logger.Trace($"   ...Raw title is >{title}<");
            }
            return(haveIt);
        }
Пример #7
0
        public void PutItem(LogItem m)
        {
            var filespec = m.Filespec;

            if (filespec != null &&
                !TheHt.ContainsKey(filespec))
            {
                TheHt.Add(filespec, m);
                IsDirty = true;
            }
        }
Пример #8
0
 public void PutPlayer(NFLPlayer p)
 {
     if (p.PlayerCode != null)
     {
         if (!TheHt.ContainsKey(p.PlayerCode))
         {
             TheHt.Add(p.PlayerCode, p);
             IsDirty = true;
         }
     }
 }
Пример #9
0
        public void PutStat(YahooOutput stat)
        {
            if (stat.Quantity == 0.0M)
            {
                return;
            }

            IsDirty = true;
            if (TheHt.ContainsKey(stat.FormatKey()))
            {
                TheHt[stat.FormatKey()] = stat;
                return;
            }
            TheHt.Add(stat.FormatKey(), stat);
        }
Пример #10
0
        public void PutItem(TorrentItem m)
        {
            var title = m.Title;

            if (!TheHt.ContainsKey(title))
            {
                TheHt.Add(title, m);
                IsDirty = true;
                Logger.Trace($"    {title} added to HT");
            }
            else
            {
                Logger.Trace($"    {title} already in HT");
            }
        }
Пример #11
0
        public void PutItem(
            CountItem item)
        {
            var name = item.Name;

            if (!TheHt.ContainsKey(name))
            {
                TheHt.Add(
                    key: name,
                    value: item);
                IsDirty = true;
            }
            else
            {
                TheHt[name] = item;
            }
        }
Пример #12
0
        public NFLWeek GetWeek(string season, int week)
        {
            NFLWeek w;
            var     weekKey = string.Format("{0}:{1:0#}", season, week);

            if (TheHt.ContainsKey(weekKey))
            {
                w = (NFLWeek)TheHt[weekKey];
                CacheHits++;
            }
            else
            {
                w = new NFLWeek(int.Parse(season), week, loadGames: true);
                PutWeek(w);
                CacheMisses++;
            }
            return(w);
        }
Пример #13
0
        public NflSeason GetSeason(string season, bool teamsOnly)
        {
            NflSeason s;

            if (TheHt.ContainsKey(season))
            {
                s = (NflSeason)TheHt[season];
                CacheHits++;
            }
            else
            {
                //  new it up
                s = new NflSeason(season, teamsOnly);
                PutSeason(s);
                CacheMisses++;
            }
            return(s);
        }
Пример #14
0
        public void PutRating(HillenPowerRating stat)
        {
            if (stat.Quantity == 0.0M)
            {
                return;
            }

            IsDirty = true;
            if (TheHt.ContainsKey(stat.FormatKey()))
            {
                TheHt[stat.FormatKey()] = stat;
#if DEBUG
                //Utility.Announce( string.Format( "HillenMaster:Putting Stat {0}", stat.FormatKey() ) );
#endif
                return;
            }
            TheHt.Add(stat.FormatKey(), stat);
#if DEBUG
            //Utility.Announce( string.Format( "HillenMaster:Adding Stat {0}", stat.FormatKey() ) );
#endif
        }
Пример #15
0
        public override decimal GetStat(string theKey)
        {
            var season   = theKey.Substring(0, 4);
            var week     = theKey.Substring(5, 2);
            var playerId = theKey.Substring(8, 8);

            var stat = new YahooOutput
            {
                Season   = season,
                Week     = week,
                PlayerId = playerId,
                Quantity = 0.0M
            };

            Announce($"StatMaster:Getting Stat {stat.FormatKey()}");
            var testStat = "2017:05:WATSDE02";

            if (testStat == stat.FormatKey())
            {
                Announce($"StatMaster:Test Stat {stat.FormatKey()}");
            }

            var key = stat.FormatKey();

            if (TheHt.ContainsKey(key))
            {
                stat = ( YahooOutput )TheHt[key];
                CacheHits++;
            }
            else
            {
                //  new it up
                Announce($"StatMaster:Instantiating Stat {stat.FormatKey()}");
                PutStat(stat);
                IsDirty = true;
                CacheMisses++;
            }
            return(stat.Quantity);
        }
Пример #16
0
        public override decimal GetStat(string theKey)
        {
            var season   = theKey.Substring(0, 4);
            var week     = theKey.Substring(5, 2);
            var playerId = theKey.Substring(8, 8);

            var stat = new YahooOutput
            {
                Season   = season,
                Week     = week,
                PlayerId = playerId,
                Quantity = 0.0M
            };

#if DEBUG
//			Utility.Announce( string.Format( "StatMaster:Getting Stat {0}", stat.FormatKey() ) );
#endif

            var key = stat.FormatKey();
            if (TheHt.ContainsKey(key))
            {
                stat = (YahooOutput)TheHt[key];
                CacheHits++;
            }
            else
            {
                //  new it up
#if DEBUG
//				Utility.Announce( string.Format( "StatMaster:Instantiating Stat {0}", stat.FormatKey() ) );
#endif
                PutStat(stat);
                IsDirty = true;
                CacheMisses++;
            }
            return(stat.Quantity);
        }
Пример #17
0
        public NFLPlayer GetPlayer(string playerId)
        {
            NFLPlayer p;

            if (TheHt.ContainsKey(playerId))
            {
                p = (NFLPlayer)TheHt[playerId];
                CacheHits++;
#if DEBUG
                //RosterLib.Utility.Announce( "PlayerMaster.GetPlayer: Player " + playerId + " got from cache");
#endif
            }
            else
            {
                //  new it up
#if DEBUG
                //RosterLib.Utility.Announce( string.Format( "PlayerMaster.GetPlayer: Player {0} not in cache", playerId ));
#endif
                p = new NFLPlayer(playerId);
                PutPlayer(p);
                CacheMisses++;
            }
            return(p);
        }
Пример #18
0
        public override decimal GetStat(string theKey)
        {
            var season   = theKey.Substring(0, 4);
            var week     = theKey.Substring(5, 2);
            var teamCode = theKey.Substring(8, 2);

            var stat = new HillenPowerRating
            {
                Season   = season,
                Week     = week,
                TeamCode = teamCode,
                Quantity = 0.0M
            };

#if DEBUG
            Utility.Announce(string.Format("HillenMaster:Getting Stat {0}", stat.FormatKey()));
#endif

            var key = stat.FormatKey();
            if (TheHt.ContainsKey(key))
            {
                stat = (HillenPowerRating)TheHt[key];
                CacheHits++;
            }
            else
            {
                //  new it up
#if DEBUG
                Utility.Announce(string.Format("HillenMaster:Instantiating Stat {0}", stat.FormatKey()));
#endif
                PutRating(stat);
                IsDirty = true;
                CacheMisses++;
            }
            return(stat.Quantity);
        }