Beispiel #1
0
        public static int GetPopularStoriesCount(int hostID, bool isPublished, StoryListSortBy sortBy)
        {
            string cacheKey = String.Format("Kick_PopularStoryCount_{0}_{1}_{2}", hostID, isPublished, sortBy);
            CacheManager <string, int?> countCache = GetCountCache();

            int?count = countCache[cacheKey];

            if (count == null)
            {
                count = Story.GetPopularStoriesCount(hostID, isPublished, sortBy);
                countCache.Insert(cacheKey, count, CacheHelper.CACHE_DURATION_IN_SECONDS);
            }

            return(count.Value);
        }
        private void RenderLink(StoryListSortBy linkSortBy, string caption, HtmlTextWriter writer)
        {
            string url = "/";
            string cssClass = "PopularStoryHeaderLink";
            string javaScript = "";
            string sortByText = linkSortBy.ToString().ToLower();

            if(linkSortBy != StoryListSortBy.RecentlyPromoted)
                url += "popular/" + sortByText;

            if(linkSortBy == this.KickPage.UrlParameters.StoryListSortBy)
                cssClass += " PopularStoryHeaderLinkSelected";

            writer.WriteLine(@"<a id=""StoryListHeader_{0}"" href=""{1}"" {2} class=""{3}"">{4}</a>", sortByText, url, javaScript, cssClass, caption);
        }
        private void RenderLink(StoryListSortBy linkSortBy, string caption, HtmlTextWriter writer)
        {
            string url        = "/";
            string cssClass   = "PopularStoryHeaderLink";
            string javaScript = "";
            string sortByText = linkSortBy.ToString().ToLower();

            if (linkSortBy != StoryListSortBy.RecentlyPromoted)
            {
                url += "popular/" + sortByText;
            }

            if (linkSortBy == this.KickPage.UrlParameters.StoryListSortBy)
            {
                cssClass += " PopularStoryHeaderLinkSelected";
            }

            writer.WriteLine(@"<a id=""StoryListHeader_{0}"" href=""{1}"" {2} class=""{3}"">{4}</a>", sortByText, url, javaScript, cssClass, caption);
        }
Beispiel #4
0
        private static DateTime GetStartDate(StoryListSortBy sortBy)
        {
            switch (sortBy)
            {
            case StoryListSortBy.Today:
                return(DateTime.Now.AddDays(-1));

            case StoryListSortBy.PastWeek:
                return(DateTime.Now.AddDays(-7));

            case StoryListSortBy.PastTenDays:
                return(DateTime.Now.AddDays(-10));

            case StoryListSortBy.PastMonth:
                return(DateTime.Now.AddDays(-31));

            case StoryListSortBy.PastYear:
                return(DateTime.Now.AddDays(-365));

            default:
                throw new ArgumentException("Invalid sortBy");
            }
        }
 public ApiPagedList<ApiStory> GetUpcomingStories(int? pageNumber, int? pageSize, StoryListSortBy? timePeriod)
 {
     return Story.Api.GetUpcomingStoriesPagedAndSorted(this.HostProfile.HostID,
         pageNumber ?? defaultPageNumber, pageSize ?? defaultPageSize,
         timePeriod ?? defaultTimePeriod);
 }
Beispiel #6
0
        public static StoryCollection GetPopularStories(int hostID, bool isPublished, StoryListSortBy sortBy, int pageNumber, int pageSize)
        {
            pageSize = TrimPageSize(pageSize);
            string cacheKey = String.Format("StoryCollection_{0}_{1}_{2}_{3}_{4}", hostID, isPublished, sortBy, pageNumber, pageSize);

            CacheManager <string, StoryCollection> storyCache = GetStoryCollectionCache();

            StoryCollection stories = storyCache[cacheKey];

            if (stories == null)
            {
                stories = Story.GetPopularStories(hostID, isPublished, sortBy, pageNumber, pageSize);
                storyCache.Insert(cacheKey, stories, CacheHelper.CACHE_DURATION_IN_SECONDS);
            }


            return(stories);
        }
Beispiel #7
0
        public static int GetPopularStoriesCount(int hostID, bool isPublished, StoryListSortBy sortBy)
        {
            string cacheKey = String.Format("Kick_PopularStoryCount_{0}_{1}_{2}", hostID, isPublished, sortBy);
            CacheManager<string, int?> countCache = GetCountCache();

            int? count = countCache[cacheKey];
            if (count == null) {
                count = Story.GetPopularStoriesCount(hostID, isPublished, sortBy);
                countCache.Insert(cacheKey, count, CacheHelper.CACHE_DURATION_IN_SECONDS);
            }

            return count.Value;
        }
Beispiel #8
0
        public static StoryCollection GetPopularStories(int hostID, bool isPublished, StoryListSortBy sortBy, int pageNumber, int pageSize)
        {
            pageSize = TrimPageSize(pageSize);
            string cacheKey = String.Format("StoryCollection_{0}_{1}_{2}_{3}_{4}", hostID, isPublished, sortBy, pageNumber, pageSize);

            CacheManager<string, StoryCollection> storyCache = GetStoryCollectionCache();

            StoryCollection stories = storyCache[cacheKey];
            if (stories == null) {
                stories = Story.GetPopularStories(hostID, isPublished, sortBy, pageNumber, pageSize);
                storyCache.Insert(cacheKey, stories, CacheHelper.CACHE_DURATION_IN_SECONDS);
            }

            return stories;
        }
Beispiel #9
0
 public static ApiPagedList<ApiStory> GetUpcomingStoriesPagedAndSorted(int hostID, int pageNumber, int pageSize, StoryListSortBy timePeriod)
 {
     ApplyPageLimits(ref pageNumber, ref pageSize);
     PagedStoryCollection pagedCollection = new PagedStoryCollection();
     pagedCollection.Items = StoryCache.GetPopularStories(hostID, false, timePeriod, pageNumber, pageSize);
     pagedCollection.Total = StoryCache.GetPopularStoriesCount(hostID, false, timePeriod);
     return pagedCollection.ToApi();
 }
Beispiel #10
0
 private static DateTime GetStartDate(StoryListSortBy sortBy)
 {
     switch (sortBy) {
         case StoryListSortBy.Today:
             return DateTime.Now.AddDays(-1);
         case StoryListSortBy.PastWeek:
             return DateTime.Now.AddDays(-7);
         case StoryListSortBy.PastTenDays:
             return DateTime.Now.AddDays(-10);
         case StoryListSortBy.PastMonth:
             return DateTime.Now.AddDays(-31);
         case StoryListSortBy.PastYear:
             return DateTime.Now.AddDays(-365);
         default:
             throw new ArgumentException("Invalid sortBy");
     }
 }
Beispiel #11
0
 public static int GetPopularStoriesCount(int hostID, bool isPublished, StoryListSortBy sortBy)
 {
     Query query = GetStoryQuery(hostID, isPublished, GetStartDate(sortBy), DateTime.Now);
     return query.GetCount(Story.Columns.StoryID);
 }
Beispiel #12
0
 public static StoryCollection GetPopularStories(int hostID, bool isPublished, StoryListSortBy sortBy, int pageIndex, int pageSize)
 {
     Query query = GetStoryQuery(hostID, isPublished, GetStartDate(sortBy), DateTime.Now);
     query = query.ORDER_BY(Story.Columns.KickCount, "DESC");
     query.PageIndex = pageIndex;
     query.PageSize = pageSize;
     StoryCollection stories = new StoryCollection();
     stories.Load(query.ExecuteReader());
     return stories;
 }
Beispiel #13
0
            public static ApiPagedList <ApiStory> GetUpcomingStoriesPagedAndSorted(int hostID, int pageNumber, int pageSize, StoryListSortBy timePeriod)
            {
                ApplyPageLimits(ref pageNumber, ref pageSize);
                PagedStoryCollection pagedCollection = new PagedStoryCollection();

                pagedCollection.Items = StoryCache.GetPopularStories(hostID, false, timePeriod, pageNumber, pageSize);
                pagedCollection.Total = StoryCache.GetPopularStoriesCount(hostID, false, timePeriod);
                return(pagedCollection.ToApi());
            }
Beispiel #14
0
        public static int GetPopularStoriesCount(int hostID, bool isPublished, StoryListSortBy sortBy)
        {
            Query query = GetStoryQuery(hostID, isPublished, GetStartDate(sortBy), DateTime.Now);

            return(query.GetCount(Story.Columns.StoryID));
        }
Beispiel #15
0
        public static StoryCollection GetPopularStories(int hostID, bool isPublished, StoryListSortBy sortBy, int pageIndex, int pageSize)
        {
            Query query = GetStoryQuery(hostID, isPublished, GetStartDate(sortBy), DateTime.Now);

            query           = query.ORDER_BY(Story.Columns.KickCount, "DESC");
            query.PageIndex = pageIndex;
            query.PageSize  = pageSize;
            StoryCollection stories = new StoryCollection();

            stories.Load(query.ExecuteReader());
            return(stories);
        }