Esempio n. 1
0
        public void CleanOutExpiredStats()
        {
            SessionStats.LoadLegacyData(ownerSession);
            var  manager    = TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>();
            var  db         = manager.GetDbContext();
            long TSminus24h = DateTime.Now.AddHours(-24).Ticks;
            var  pokestopTimestampsToDelete = db.PokestopTimestamp.Where(t => t.Account == manager.GetCurrentAccount() && t.Timestamp < TSminus24h);

            db.PokestopTimestamp.RemoveRange(pokestopTimestampsToDelete);

            var pokemonTimestampsToDelete = db.PokemonTimestamp.Where(t => t.Account == manager.GetCurrentAccount() && t.Timestamp < TSminus24h);

            db.PokemonTimestamp.RemoveRange(pokemonTimestampsToDelete);
            db.SaveChanges();
        }
Esempio n. 2
0
        public void AddPokemonTimestamp(Int64 ts)
        {
            SessionStats.LoadLegacyData(ownerSession);
            var manager  = TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>();
            var db       = manager.GetDbContext();
            var existing = db.PokemonTimestamp.Where(t => t.Timestamp == ts).FirstOrDefault();

            if (existing == null)
            {
                var currentAccount = manager.GetCurrentAccount();

                var stat = new Model.PokemonTimestamp
                {
                    Timestamp = ts,
                    Account   = manager.GetCurrentAccount()
                };
                db.PokemonTimestamp.Add(stat);
                db.SaveChanges();
            }
        }