static void CalcLeaders(DateTime?_now = null) { DateTime now; if (_now == null) { now = DateTime.UtcNow; } else { now = _now.Value; } HydrantWikiManager manager = new HydrantWikiManager(); List <Hydrant> hydrants = manager.GetHydrants(); Dictionary <Guid, User> users = manager.GetHydrantWikiUsers(); List <UserStats> final = users.Values.ToList().RebuildStats(now); DailyStanding standing = manager.GetDailyStanding(now); if (standing == null) { standing = new DailyStanding(); standing.Active = true; standing.Date = now.Date; standing.Guid = Guid.NewGuid(); standing.LastModifiedDateTime = now; } standing.ActiveUsers = final.Count; //Sort and build daily standings based on new hydrants List <Place> places = final.DeterminePlaces(UserStatSortColumn.NewHydrant); Dictionary <Guid, DailyStandingUser> dsus = places.DetermineStanding(standing.Guid); places = final.DeterminePlaces(UserStatSortColumn.ApprovedTags); dsus = places.DetermineStanding(standing.Guid, dsus); manager.Persist(final); manager.Persist(standing); manager.DeleteUserStandings(standing.Guid); manager.Persist(dsus.Values.ToList()); }
public void Persist(DailyStanding _dailyStanding) { DailyStandingDAO dao = new DailyStandingDAO(MongoDB); dao.Persist(_dailyStanding); }