コード例 #1
0
        public IPageOfItems <ScheduleItem> GetScheduleItems(Event evnt, ScheduleItemFilterCriteria scheduleItemFilterCriteria)
        {
            int pageIndex = 0;
            int pageSize  = 50;

            if (context.RequestDataFormat == RequestDataFormat.Web)
            {
                pageIndex = scheduleItemFilterCriteria.PageIndex;
                pageSize  = scheduleItemFilterCriteria.PageSize;
            }

            IPageOfItems <ScheduleItem> scheduleItems =
                cache.GetItems <IPageOfItems <ScheduleItem>, ScheduleItem>(
                    string.Format("GetScheduleItems-FilterCriteria:{0}", scheduleItemFilterCriteria),
                    new CachePartition(pageIndex, pageSize),
                    () => repository.GetScheduleItems(new PagingInfo(pageIndex, pageSize), evnt, context.User.IsAuthenticated && context.User.Cast <User>() != null ? context.User.Cast <User>().ID : Guid.Empty, scheduleItemFilterCriteria).FillTags(tagService),
                    si => si.GetDependencies()
                    );

            if (context.RequestDataFormat.IsFeed())
            {
                scheduleItems = scheduleItems.Since(si => si.Modified, context.HttpContext.Request.IfModifiedSince());
            }

            return(scheduleItems);
        }
コード例 #2
0
        public IPageOfItems <ScheduleItem> GetScheduleItems(EventAddress eventAddress, ScheduleItemFilterCriteria scheduleItemFilterCriteria)
        {
            string dataFormat = context.RequestContext.RouteData.Values["dataFormat"] as String;
            int    pageIndex  = scheduleItemFilterCriteria.PageIndex;
            int    pageSize   = scheduleItemFilterCriteria.PageSize;

            if (dataFormat != null)
            {
                dataFormat = dataFormat.ToLower();

                if (dataFormat == "rss" || dataFormat == "atom" || dataFormat == "sign" || dataFormat == "ics")
                {
                    pageIndex = 0;
                    pageSize  = 1000;
                }
            }


            var cacheKey          = string.Format("GetScheduleItems-FilterCriteria:{0}", scheduleItemFilterCriteria);
            var authenticatedUser = context.User.IsAuthenticated && context.User.Cast <UserAuthenticated>() != null;
            var userId            = Guid.Empty;

            if (authenticatedUser)
            {
                userId    = context.User.Cast <UserAuthenticated>().ID;
                cacheKey += String.Concat("-UserID:", userId);
            }

            IPageOfItems <ScheduleItem> scheduleItems =
                cache.GetItems <IPageOfItems <ScheduleItem>, ScheduleItem>(
                    cacheKey,
                    new CachePartition(pageIndex, pageSize),
                    () => repository.GetScheduleItems(eventAddress, userId, scheduleItemFilterCriteria).GetPage(pageIndex, pageSize).FillTags(tagService),
                    si => si.GetDependencies()
                    );

            SetScheduleItemUsers(scheduleItems);

            return(scheduleItems);
        }