private void PopulateControls()
        {
            imgMembership.ImageUrl      = Page.ResolveUrl("~/Data/SiteImages/uoGroup1.gif");
            imgMembership.AlternateText = Resources.Resource.SiteStatisticsMembershipLabel;

            imgNewestMember.ImageUrl      = Page.ResolveUrl("~/Data/SiteImages/uoLatest.gif");
            imgNewestMember.AlternateText = Resources.Resource.SiteStatisticsNewestMemberLabel;

            imgNewToday.ImageUrl      = Page.ResolveUrl("~/Data/SiteImages/uoNewToday.gif");
            imgNewToday.AlternateText = Resources.Resource.SiteStatisticsNewTodayLabel;

            imgNewYesterday.ImageUrl      = Page.ResolveUrl("~/Data/SiteImages/uoNewYesterday.gif");
            imgNewYesterday.AlternateText = Resources.Resource.SiteStatisticsNewYesterdayLabel;

            imgTotalUsers.ImageUrl      = Page.ResolveUrl("~/Data/SiteImages/uoOverall.gif");
            imgTotalUsers.AlternateText = Resources.Resource.SiteStatisticsTotalUsersLabel;

            MembershipStatistics membershipStatistics = CacheHelper.GetCurrentMembershipStatistics();

            if (membershipStatistics != null)
            {
                lblNewestUser.Text        = membershipStatistics.NewestUser;
                lblNewUsersToday.Text     = membershipStatistics.NewUsersToday.ToString();
                lblNewUsersYesterday.Text = membershipStatistics.NewUsersYesterday.ToString();
                lblTotalUsers.Text        = membershipStatistics.TotalUsers.ToString();
            }
        }
예제 #2
0
        private void PopulateControls()
        {
            MembershipStatistics membershipStatistics = CacheHelper.GetCurrentMembershipStatistics();

            if (membershipStatistics != null)
            {
                lblNewestUser.Text        = membershipStatistics.NewestUser;
                lblNewUsersToday.Text     = membershipStatistics.NewUsersToday.ToString();
                lblNewUsersYesterday.Text = membershipStatistics.NewUsersYesterday.ToString();
                lblTotalUsers.Text        = membershipStatistics.TotalUsers.ToString();
            }
        }
예제 #3
0
        private static void RefreshMembershipStatisticsCache(String cacheKey, int cacheTimeout)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            MembershipStatistics membershipStatistics = LoadMembershipStatistics();

            if (membershipStatistics == null)
            {
                return;
            }

            String pathToCacheDependencyFile
                = GetPathToMembershipStatisticsCacheDependencyFile();

            if (pathToCacheDependencyFile != null)
            {
                EnsureCacheFile(pathToCacheDependencyFile);
            }

            CacheDependency cacheDependency = new CacheDependency(pathToCacheDependencyFile);

            DateTime                 absoluteExpiration = DateTime.Now.AddSeconds(cacheTimeout);
            TimeSpan                 slidingExpiration  = TimeSpan.Zero;
            CacheItemPriority        priority           = CacheItemPriority.Default;
            CacheItemRemovedCallback callback           = null;

            HttpRuntime.Cache.Insert(
                cacheKey,
                membershipStatistics,
                cacheDependency,
                absoluteExpiration,
                slidingExpiration,
                priority,
                callback);
        }
예제 #4
0
        private static MembershipStatistics GetMembershipStatisticsFromCache()
        {
            string cachekey = GetMembershipStatisticsCacheKey();

            DateTime expiration = DateTime.Now.AddSeconds(WebConfigSettings.SiteSettingsCacheDurationInSeconds);

            try
            {
                MembershipStatistics memberStats = CacheManager.Cache.Get <MembershipStatistics>(cachekey, expiration, () =>
                {
                    // This is the anonymous function which gets called if the data is not in the cache.
                    // This method is executed and whatever is returned, is added to the cache with the passed in expiry time.
                    MembershipStatistics stats = LoadMembershipStatistics();
                    return(stats);
                });

                return(memberStats);
            }
            catch (Exception ex)
            {
                log.Error("failed to get memberStats from cache so loading it directly ", ex);
                return(LoadMembershipStatistics());
            }
        }