コード例 #1
0
        public void ToggleSort()
        {
            SortParm srt = this.ParseSort();

            if (!String.IsNullOrEmpty(this.SortByNew))
            {
                if (srt.SortField.ToLowerInvariant() == this.SortByNew.ToLowerInvariant())
                {
                    if (srt.SortDirection.EndsWith("ASC"))
                    {
                        this.OrderBy = String.Format("{0}  DESC", this.SortByNew);
                    }
                    else
                    {
                        this.OrderBy = String.Format("{0}  ASC", this.SortByNew);
                    }
                }
                else
                {
                    this.OrderBy    = String.Format("{0}  ASC", this.SortByNew);
                    this.PageNumber = 1;
                }
            }

            this.SortByNew = String.Empty;
        }
コード例 #2
0
        public SortParm ParseSort()
        {
            SortParm sort = new SortParm(this.OrderBy);

            if (this.DefaultMax && this.TotalPages > 0)
            {
                this.PageNumber = this.TotalPages;
            }

            return(sort);
        }
コード例 #3
0
        public SortParm ParseSort()
        {
            SortParm sort = new SortParm(this.OrderBy);

            if (this.DefaultMax && this.TotalPages > 0) {
                this.PageNumber = this.TotalPages;
            }

            return sort;
        }
コード例 #4
0
		public List<ContentPage> GetPagedSortedContent(Guid siteID, ContentPageType.PageType entryType, bool bActiveOnly, int pageSize, int pageNumber, string sSortParm) {
			SortParm srt = new SortParm(sSortParm);

			IQueryable<vw_carrot_Content> query1 = CannedQueries.GetAllByTypeList(db, siteID, bActiveOnly, entryType);

			return PerformDataPagingQueryableContent(siteID, bActiveOnly, pageSize, pageNumber, srt.SortField, srt.SortDirection, query1);
		}
コード例 #5
0
        public static List<EditHistory> GetHistoryList(string orderBy, int pageNumber, int pageSize,
            Guid siteID, bool showLatestOnly, DateTime? editDate, Guid? editUserID)
        {
            SortParm srt = new SortParm(orderBy);

            if (String.IsNullOrEmpty(srt.SortField)) {
                srt.SortField = "EditDate";
            }

            if (String.IsNullOrEmpty(srt.SortDirection)) {
                srt.SortDirection = "DESC";
            }

            Guid userID = Guid.Empty;
            if (editUserID.HasValue) {
                userID = editUserID.Value;
            }

            DateTime dateStart = DateTime.UtcNow.Date.AddDays(-2);
            DateTime dateEnd = DateTime.UtcNow.Date.AddDays(1);

            if (editDate.HasValue) {
                dateStart = editDate.Value.Date.AddDays(-8);
                dateEnd = editDate.Value.Date.AddDays(1);
            }

            int startRec = pageNumber * pageSize;

            if (pageSize < 0 || pageSize > 200) {
                pageSize = 25;
            }

            if (pageNumber < 0 || pageNumber > 10000) {
                pageNumber = 0;
            }

            bool IsContentProp = false;

            srt.SortField = (from p in ReflectionUtilities.GetPropertyStrings(typeof(vw_carrot_EditHistory))
                             where p.ToLowerInvariant().Trim() == srt.SortField.ToLowerInvariant().Trim()
                             select p).FirstOrDefault();

            if (!String.IsNullOrEmpty(srt.SortField)) {
                IsContentProp = ReflectionUtilities.DoesPropertyExist(typeof(vw_carrot_EditHistory), srt.SortField);
            }

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                List<EditHistory> _history = null;

                IQueryable<vw_carrot_EditHistory> QueryInput = (from h in _db.vw_carrot_EditHistories
                                                                where h.SiteID == siteID
                                                                    && (!showLatestOnly || h.IsLatestVersion == true)
                                                                    && (!editDate.HasValue
                                                                          || (h.EditDate.Date >= dateStart.Date && h.EditDate.Date <= dateEnd.Date))
                                                                    && (!editUserID.HasValue || h.EditUserId == userID)
                                                                select h);

                if (IsContentProp) {
                    QueryInput = ReflectionUtilities.SortByParm<vw_carrot_EditHistory>(QueryInput, srt.SortField, srt.SortDirection);
                } else {
                    QueryInput = (from c in QueryInput
                                  orderby c.EditDate descending
                                  where c.SiteID == siteID
                                  select c).AsQueryable();
                }

                _history = (from h in QueryInput.Skip(startRec).Take(pageSize) select new EditHistory(h)).ToList();

                return _history;
            }
        }
コード例 #6
0
		public static List<PostComment> PaginateComments(IQueryable<vw_carrot_Comment> lstComments, int iPageNbr, int iPageSize, string SortBy) {
			int startRec = iPageNbr * iPageSize;

			SortParm srt = new SortParm(SortBy);

			if (String.IsNullOrEmpty(srt.SortField)) {
				srt.SortField = "CreateDate";
			}

			if (String.IsNullOrEmpty(srt.SortDirection)) {
				srt.SortDirection = "DESC";
			}

			lstComments = ReflectionUtilities.SortByParm<vw_carrot_Comment>(lstComments, srt.SortField, srt.SortDirection);

			return lstComments.Skip(startRec).Take(iPageSize).ToList().Select(v => new PostComment(v)).ToList();
		}