コード例 #1
0
        public ActionResult RefreshReport(string cacheKey)
        {
            PageReportCache ReportCache = ChimeraWebsite.Helpers.AppCache.RefreshPageReportSummary(cacheKey);

            if (ReportCache != null)
            {
                return(RedirectToAction("Index", "Dashboard", new { selectedPageType = ReportCache.SelectedPageType, pageReportType = ReportCache.PageReportType, dateFrom = ReportCache.DateFrom, dateTo = ReportCache.DateTo }));
            }

            return(RedirectToAction("Index", "Dashboard"));
        }
コード例 #2
0
        /// <summary>
        /// Force a refresh on a report in the cache
        /// </summary>
        /// <param name="cacheKey"></param>
        public static PageReportCache RefreshPageReportSummary(string cacheKey)
        {
            Dictionary <string, PageReportCache> CurrentPageReportDictionary = PageReportDictionary;

            if (CurrentPageReportDictionary.ContainsKey(cacheKey))
            {
                PageReportCache ReportCache = CurrentPageReportDictionary[cacheKey];

                ReportCache.LastAccessedUtc = DateTime.UtcNow.AddHours(1);

                ReportCache.ReportSummary = PageReport.GeneratePageReport(ReportCache.PageReportType, ReportCache.DateFrom, ReportCache.DateTo, ReportCache.SelectedPageType);

                CurrentPageReportDictionary[cacheKey] = ReportCache;

                PageReportDictionary = CurrentPageReportDictionary;

                return(ReportCache);
            }

            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Check the app cache and see if this report cache has expired.
        /// </summary>
        /// <param name="selectedPageType"></param>
        /// <param name="pageReportType"></param>
        /// <param name="dateFrom"></param>
        /// <param name="dateTo"></param>
        /// <returns></returns>
        public static PageReportCache GetPageReportSummary(string selectedPageType, PageReportType pageReportType, DateTime dateFrom, DateTime dateTo)
        {
            string CacheKey = String.Format("{0}|{1}|{2}|{3}", selectedPageType.ToUpper(), pageReportType, dateFrom.ToString("MM/dd/yyyy"), dateTo.ToString("MM/dd/yyyy"));

            PageReportSummary ReportSummary = new PageReportSummary();

            Dictionary <string, PageReportCache> PageReportDictionary = (Dictionary <string, PageReportCache>)HttpContext.Current.Application[PAGE_REPORT_APP_CACHE] ?? new Dictionary <string, PageReportCache>();

            bool RunNewReport = false;

            if (PageReportDictionary.ContainsKey(CacheKey))
            {
                if (PageReportDictionary[CacheKey].LastAccessedUtc <= DateTime.UtcNow)
                {
                    RunNewReport = true;
                }
                else
                {
                    ReportSummary = PageReportDictionary[CacheKey].ReportSummary;
                }
            }
            else
            {
                RunNewReport = true;
            }

            if (RunNewReport)
            {
                ReportSummary = PageReport.GeneratePageReport(pageReportType, dateFrom, dateTo, selectedPageType);

                PageReportDictionary[CacheKey] = new PageReportCache(CacheKey, DateTime.UtcNow.AddHours(1), ReportSummary, selectedPageType, pageReportType, dateFrom, dateTo);

                HttpContext.Current.Application[PAGE_REPORT_APP_CACHE] = PageReportDictionary;
            }

            return(PageReportDictionary[CacheKey]);
        }