public DashboardWithCachedQueries GetDashboard([FromBody] Lite <DashboardEntity> dashboard) { var db = DashboardLogic.RetrieveDashboard(dashboard); if (db.CacheQueryConfiguration == null) { return new DashboardWithCachedQueries { Dashboard = db, CachedQueries = new List <CachedQueryEntity>() } } ; var cachedQueries = DashboardLogic.GetCachedQueries(dashboard).ToList(); if (db.CacheQueryConfiguration.AutoRegenerateWhenOlderThan is int limit) { var maxDate = cachedQueries.Max(a => (DateTime?)a.CreationDate); if (maxDate == null || maxDate.Value.AddMinutes(limit) < Clock.Now) { lock (lockKey) { cachedQueries = DashboardLogic.GetCachedQueries(dashboard).ToList(); maxDate = cachedQueries.Max(a => (DateTime?)a.CreationDate); if (maxDate == null || maxDate.Value.AddMinutes(limit) < Clock.Now) { using (UserHolder.UserSession(AuthLogic.SystemUser !)) db.Execute(DashboardOperation.RegenerateCachedQueries); cachedQueries = DashboardLogic.GetCachedQueries(dashboard).ToList(); } } } } return(new DashboardWithCachedQueries { Dashboard = db, CachedQueries = cachedQueries, }); } }
public ViewResult View(Lite <DashboardEntity> panel, Lite <Entity> currentEntity) { DashboardPermission.ViewDashboard.AssertAuthorized(); var cp = DashboardLogic.RetrieveDashboard(panel); if (cp.EntityType != null) { if (currentEntity == null) { throw new ArgumentNullException("currentEntity"); } ViewData["currentEntity"] = currentEntity.Retrieve(); } return(View(DashboardClient.ViewPrefix.FormatWith("Dashboard"), cp)); }