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; } }); }
public static void Init() { Trace.TraceInformation("WHR: Initializing Rating Systems.."); Initialized = false; ratingCategories.ForEach(category => whr[category] = new WholeHistoryRating(category)); Task.Factory.StartNew(() => { lock (processingLock) { try { UpdateRatingIds(); using (ZkDataContext data = new ZkDataContext()) { int battles = 0; data.Database.CommandTimeout = 240; for (int month = 10 * 12; month > 0; month--) { DateTime minStartTime = DateTime.Now.AddMonths(-month); DateTime maxStartTime = DateTime.Now.AddMonths(-month + 1); foreach (SpringBattle b in data.SpringBattles .Where(x => x.StartTime > minStartTime && x.StartTime < maxStartTime) .Include(x => x.ResourceByMapResourceID) .Include(x => x.SpringBattlePlayers) .Include(x => x.SpringBattleBots) .AsNoTracking() .OrderBy(x => x.StartTime)) { battles++; ProcessBattle(b); } } Trace.TraceInformation("WHR: Read " + battles + " battles from database."); Initialized = true; whr.Values.ForEach(w => w.UpdateRatings()); } } catch (Exception ex) { Trace.TraceError("WHR: Error reading battles from DB" + ex); } } }); }
public static void Init() { Initialized = false; ratingCategories.ForEach(category => whr[category] = new WholeHistoryRating(category)); Task.Factory.StartNew(() => { lock (processingLock) { try { UpdateRatingIds(); using (ZkDataContext data = new ZkDataContext()) { for (int year = 10; year > 0; year--) { DateTime minStartTime = DateTime.Now.AddYears(-year); DateTime maxStartTime = DateTime.Now.AddYears(-year + 1); foreach (SpringBattle b in data.SpringBattles .Where(x => x.StartTime > minStartTime && x.StartTime < maxStartTime) .Include(x => x.ResourceByMapResourceID) .Include(x => x.SpringBattlePlayers) .Include(x => x.SpringBattleBots) .AsNoTracking() .OrderBy(x => x.StartTime)) { ProcessBattle(b); } } Initialized = true; whr.Values.ForEach(w => w.UpdateRatings()); } } catch (Exception ex) { Trace.TraceError("WHR: Error reading battles from DB" + ex); } } }); }