Esempio n. 1
0
 public static void BackupToDB(IRatingSystem ratingSystem)
 {
     if (DisableRatingSystems)
     {
         return;
     }
     Trace.TraceInformation("Backing up rating system...");
     ratingCategories.Where(category => whr[category].Equals(ratingSystem)).ForEach(category => MiscVar.SetValue("WHR_" + category.ToString(), whr[category].SerializeJSON()));
 }
Esempio n. 2
0
        public static void Init()
        {
            if (DisableRatingSystems)
            {
                return;
            }
            Initialized = false;
            ratingCategories.ForEach(category => whr[category] = new WholeHistoryRating(MiscVar.GetValue("WHR_" + category.ToString())));

            Task.Factory.StartNew(() => {
                lock (processingLock)
                {
                    ZkDataContext data    = new ZkDataContext();
                    DateTime minStartTime = DateTime.Now.AddYears(-2);
                    foreach (SpringBattle b in data.SpringBattles
                             .Where(x => x.StartTime > minStartTime)
                             .Include(x => x.ResourceByMapResourceID)
                             .Include(x => x.SpringBattlePlayers)
                             .Include(x => x.SpringBattleBots)
                             .AsNoTracking()
                             .OrderBy(x => x.SpringBattleID))
                    {
                        ProcessResult(b);
                    }
                    whr.Values.ForEach(w => w.UpdateRatings());
                    Initialized = true;
                }
            });
        }