コード例 #1
0
ファイル: PagerHelper.cs プロジェクト: LuoSven/EM
 public static List<int> GetPageArray(PagerModel model)
 {
     var list = new List<int>();
      var maxPager = (int)Math.Ceiling((double)model.RecCount / model.PageSize);
      for (int i = model.CurrentPage; i <= maxPager&&i<=model.CurrentPage+4; i++)
      {
          list.Add(i);
      }
      return list;
 }
コード例 #2
0
        //public static MvcHtmlString BBCodeEditor<TModel>(this HtmlHelper<TModel> html, string name)
        //{
        //    var sb = new StringBuilder(128);
        //    sb.Append("<script type=\"text/javascript\">");
        //    sb.AppendFormat("edToolbar('{0}','/Plugins/Messaging.Forums/Scripts/BBEditor/');", name);
        //    sb.Append("</script>");

        //    return MvcHtmlString.Create(sb.ToString());
        //}

        public static MvcHtmlString Pager <TModel>(this HtmlHelper <TModel> html, PagerModel model)
        {
            if (model.TotalRecords == 0)
            {
                return(null);
            }

            var localizer = LocalizationUtilities.Resolve();

            var links = new StringBuilder();

            if (model.ShowTotalSummary && (model.TotalPages > 0))
            {
                links.Append("<li class=\"total-summary\">");
                links.Append(string.Format(model.CurrentPageText, model.PageIndex + 1, model.TotalPages, model.TotalRecords));
                links.Append("</li>");
            }
            if (model.ShowPagerItems && (model.TotalPages > 1))
            {
                if (model.ShowFirst)
                {
                    //first page
                    if ((model.PageIndex >= 3) && (model.TotalPages > model.IndividualPagesDisplayedCount))
                    {
                        model.RouteValues.page = 1;

                        links.Append("<li class=\"first-page\">");
                        //if (model.UseRouteLinks)
                        //{
                        //    links.Append(html.RouteLink(model.FirstButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.FirstPageTitle) }));
                        //}
                        //else
                        //{
                        links.Append(html.ActionLink(model.FirstButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.FirstPageTitle) }));
                        //}
                        links.Append("</li>");
                    }
                }
                if (model.ShowPrevious)
                {
                    //previous page
                    if (model.PageIndex > 0)
                    {
                        model.RouteValues.page = (model.PageIndex);

                        links.Append("<li class=\"previous-page\">");
                        //if (model.UseRouteLinks)
                        //{
                        //    links.Append(html.RouteLink(model.PreviousButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.PreviousPageTitle) }));
                        //}
                        //else
                        //{
                        links.Append(html.ActionLink(model.PreviousButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.PreviousPageTitle) }));
                        //}
                        links.Append("</li>");
                    }
                }
                if (model.ShowIndividualPages)
                {
                    //individual pages
                    int firstIndividualPageIndex = model.GetFirstIndividualPageIndex();
                    int lastIndividualPageIndex  = model.GetLastIndividualPageIndex();
                    for (int i = firstIndividualPageIndex; i <= lastIndividualPageIndex; i++)
                    {
                        if (model.PageIndex == i)
                        {
                            links.AppendFormat("<li class=\"current-page\"><span>{0}</span></li>", (i + 1));
                        }
                        else
                        {
                            model.RouteValues.page = (i + 1);

                            links.Append("<li class=\"individual-page\">");
                            //if (model.UseRouteLinks)
                            //{
                            //    links.Append(html.RouteLink((i + 1).ToString(), model.RouteActionName, model.RouteValues, new { title = string.Format(localizer(LocalizableStrings.Pager.PageLinkTitle), (i + 1)) }));
                            //}
                            //else
                            //{
                            links.Append(html.ActionLink((i + 1).ToString(), model.RouteActionName, model.RouteValues, new { title = string.Format(localizer(LocalizableStrings.Pager.PageLinkTitle), (i + 1)) }));
                            //}
                            links.Append("</li>");
                        }
                    }
                }
                if (model.ShowNext)
                {
                    //next page
                    if ((model.PageIndex + 1) < model.TotalPages)
                    {
                        model.RouteValues.page = (model.PageIndex + 2);

                        links.Append("<li class=\"next-page\">");
                        //if (model.UseRouteLinks)
                        //{
                        //    links.Append(html.RouteLink(model.NextButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.NextPageTitle) }));
                        //}
                        //else
                        //{
                        links.Append(html.ActionLink(model.NextButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.NextPageTitle) }));
                        //}
                        links.Append("</li>");
                    }
                }
                if (model.ShowLast)
                {
                    //last page
                    if (((model.PageIndex + 3) < model.TotalPages) && (model.TotalPages > model.IndividualPagesDisplayedCount))
                    {
                        model.RouteValues.page = model.TotalPages;

                        links.Append("<li class=\"last-page\">");
                        //if (model.UseRouteLinks)
                        //{
                        //    links.Append(html.RouteLink(model.LastButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.LastPageTitle) }));
                        //}
                        //else
                        //{
                        links.Append(html.ActionLink(model.LastButtonText, model.RouteActionName, model.RouteValues, new { title = localizer(LocalizableStrings.Pager.LastPageTitle) }));
                        //}
                        links.Append("</li>");
                    }
                }
            }
            var result = links.ToString();

            if (!string.IsNullOrEmpty(result))
            {
                result = "<ul>" + result + "</ul>";
            }
            return(MvcHtmlString.Create(result));
        }
コード例 #3
0
ファイル: Paginator.cshtml.cs プロジェクト: zjc-china/abp
 public void OnGet(int currentPage, string sort)
 {
     PagerModel = new PagerModel(100, 10, currentPage, 10, "/Components/Paginator", sort);
 }
コード例 #4
0
 public static async Task <List <Tuhu.Provisioning.DataAccess.Entity.Discovery.Comment> > GetCommentListSearch <TKey>(Expression <Func <Tuhu.Provisioning.DataAccess.Entity.Discovery.Comment, bool> > whereLambda, Expression <Func <Tuhu.Provisioning.DataAccess.Entity.Discovery.Comment, TKey> > orderLambda, PagerModel pager, string articleTitle)
 {
     return(await commentDal.GetCommentListSearch(whereLambda, orderLambda, pager, articleTitle));
 }
コード例 #5
0
        /// <summary>
        /// 根据标签Id,分页查询文章
        /// </summary>
        /// <param name="CategoryId">标签Id</param>
        ///<param name="pager">分页模型</param>
        /// <returns></returns>
        public async Task <List <Article> > SelectArticlesByCategoryId(int CategoryId, PagerModel pager)
        {
            var relatedArticles =
                from ac in discoveryDbContext.ArticleCategory
                where ac.CategoryTagId == CategoryId
                join a in discoveryDbContext.Article on ac.ArticleId equals a.PKID
                where a.Status == ArticleStatus.Published.ToString() && a.PublishDateTime <= DateTime.Now

                orderby a.PublishDateTime descending
                select a;

            pager.TotalItem = await relatedArticles.CountAsync();

            return(await relatedArticles.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync());
        }
コード例 #6
0
        /// <summary>
        /// 搜索文章
        /// </summary>
        /// <param name="status">文章状态</param>
        /// <param name="articleTitle">文章标题</param>
        /// <param name="startDateTime">创建开始时间</param>
        /// <param name="endDateTime">创建结束时间</param>
        /// <param name="pager">分页模型</param>
        /// <returns>文章列表</returns>
        public Task <List <Article> > SearchArticle(SqlConnection conn, ArticleStatus status, PagerModel pager, DateTime?startCreateDateTime, DateTime?endCreateDateTime, string pkid, string keyword = "", int type = 5)
        {
            List <Article> result       = new List <Article>();
            const string   selectValues = @"PKID ,
                                        Catalog ,
                                        Image ,
                                        ShowImages ,
                                        ShowType ,
                                        IsDescribe ,
                                        SmallImage ,
                                        SmallTitle ,
                                        BigTitle ,
                                        TitleColor ,
                                        Brief ,
                                        Content ,
                                        ContentUrl ,
                                        Source ,
                                        PublishDateTime ,
                                        CreateDateTime ,
                                        LastUpdateDateTime ,
                                        ClickCount ,
                                        RedirectUrl ,
                                        Vote ,
                                        Category ,
                                        CategoryTags ,
                                        Heat ,
                                        CommentIsActive ,
                                        IsRead ,
                                        ArticleBanner ,
                                        SmallBanner ,
                                        Bestla ,
                                        HotArticles ,
                                        Type ,
                                        IsShow ,
                                        ShareWX ,
                                        SharePYQ ,
                                        CreatorID ,
                                        CreatorInfo ,
                                        VehicleImage ,
                                        LikeCountNum ,
                                        ReadCountNum ,
                                        IsDelete ,
                                        IsHasBestAnswer ,
                                        RelatedArticleId ,
                                        CoverMode ,
                                        CoverImage ,
                                        Status ,
                                        ShareCountNum ,
                                        CommentCountNum ,
                                        CoverTag ,
                                        IsTopMost ,
                                        Ranking ,
                                        ContentHTML ,
                                        IsShowTouTiao ,
                                        QRCodeImg";

            List <string>     conditions = new List <string>();
            DynamicParameters parameters = new DynamicParameters();

            if (!string.IsNullOrEmpty(pkid))
            {
                int id = Convert.ToInt32(pkid);
                conditions.Add("PKID = @Id");
                parameters.Add("@Id", id);
            }
            else
            {
                string sqlStatus = string.Empty;
                if (status == ArticleStatus.Published)
                {
                    conditions.Add("Status = @Status");
                    conditions.Add("PublishDateTime < GETDATE()");
                    sqlStatus = ArticleStatus.Published.ToString();
                }
                else if (status == ArticleStatus.PrePublish)
                {
                    conditions.Add("Status = @Status");
                    conditions.Add("PublishDateTime > GETDATE()");
                    sqlStatus = ArticleStatus.Published.ToString();
                }
                else if (status != ArticleStatus.All)
                {
                    conditions.Add("Status = @Status");
                    sqlStatus = status.ToString();
                }
                parameters.Add("@Status", sqlStatus);

                if (!string.IsNullOrEmpty(keyword))
                {
                    conditions.Add("SmallTitle LIKE @Keyword");
                    parameters.Add("@Keyword", $"%{keyword}%");
                }

                if (startCreateDateTime.HasValue)
                {
                    conditions.Add("PublishDateTime > @StartCreateDateTime");
                    parameters.Add("@StartCreateDateTime", startCreateDateTime.Value);
                }

                if (endCreateDateTime.HasValue)
                {
                    conditions.Add("PublishDateTime < @EndCreateDateTime");
                    parameters.Add("@EndCreateDateTime", endCreateDateTime.Value);
                }
            }
            parameters.Add("@Type", type);

            conditions.Add("Type = @Type");
            conditions.Add("IsDelete = 0");
            string countSql  = $"Select Count(1) From Marketing..tbl_Article WITH(NOLOCK) Where {string.Join(" AND ", conditions)}";
            string selectSql = $"Select {selectValues} From Marketing..tbl_Article WITH(NOLOCK) Where {string.Join(" AND ", conditions)} Order By IsTopMost desc, PublishDateTime desc OFFSET @Skip ROWS FETCH NEXT @PageSize ROWS ONLY ";
            int    skip      = (pager.CurrentPage - 1) * pager.PageSize;
            int    pageSize  = pager.PageSize;

            parameters.Add("@Skip", skip);
            parameters.Add("@PageSize", pageSize);
            using (conn)
            {
                pager.TotalItem = conn.ExecuteScalar <int>(countSql, commandType: CommandType.Text, param: parameters);
                result          = conn.Query <Article>(selectSql, commandType: CommandType.Text, param: parameters).ToList();
            }

            return(Task.FromResult(result));
        }
コード例 #7
0
 public static IEnumerable <TireBlackListLog> SelectTireBlackListLog(string BlackNumber, PagerModel pager)
 => DalPattern.SelectTireBlackListLog(BlackNumber, pager);
コード例 #8
0
 public static IEnumerable <CouponBlackItem> GetCouponBlackList(PagerModel pager, string phoneNum)
 => DalPattern.GetCouponBlackList(pager, phoneNum);
コード例 #9
0
 public static IEnumerable <InstallFeeModel> SelectInstallFeeList(InstallFeeConditionModel condition, PagerModel pager)
 => DalInstallFee.SelectInstallFeeList(condition, pager);
コード例 #10
0
 public void OnGet(int currentPage = 1, string sort = null)
 {
     PagerModel = new PagerModel(100, 10, currentPage, 10, "Paginator", sort);
 }
コード例 #11
0
 public static IEnumerable <ActivityItem> SelectActPageOnTireChange(ListActCondition model, PagerModel pager) => DALListActivity.SelectActPageOnTireChange(model, pager);
コード例 #12
0
 public static IEnumerable <ActivityItem> SelectList(ListActCondition model, PagerModel pager) => DALListActivity.SelectList(model, pager);
コード例 #13
0
        public static IEnumerable <TireBlackListLog> SelectTireBlackListLog(string blackNumber, PagerModel pager)
        {
            string sqlStr = @"SELECT  BlackNumber ,
        OperationType AS Type ,
        Operator ,
        CreateDateTime
FROM    Tuhu_log..TireBlackListLog WITH ( NOLOCK )
WHERE   IIF(@blackNumber IS NULL, BlackNumber, @blackNumber) = BlackNumber
ORDER BY BlackNumber ,
        CreateDateTime DESC
        OFFSET @begin ROWS FETCH NEXT @step ROWS ONLY;";

            pager.TotalItem = SelectTireBlackListLogCount(blackNumber);
            using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Tuhu_log")))
            {
                using (var cmd = new SqlCommand(sqlStr))
                {
                    cmd.Parameters.AddWithValue("@blackNumber", string.IsNullOrWhiteSpace(blackNumber) ? null : blackNumber);
                    cmd.Parameters.AddWithValue("@begin", pager.PageSize * (pager.CurrentPage - 1));
                    cmd.Parameters.AddWithValue("@step", pager.PageSize);
                    cmd.CommandType = CommandType.Text;
                    return(dbHelper.ExecuteDataTable(cmd).ConvertTo <TireBlackListLog>());
                }
            }
        }
コード例 #14
0
        public static IEnumerable <TireBlackListItem> GetTireBlackList(string blackNumber, int type, PagerModel pager)
        {
            string sqlStr = @"SELECT  BlackNumber ,
        Type ,
        CreateDateTime ,
        EndTime
FROM    Configuration..CommonBlackList WITH ( NOLOCK )
WHERE   ( @type = 0
          OR @type = Type
        )
        AND IIF(@blackNumber IS NULL, BlackNumber, @blackNumber) = BlackNumber
ORDER BY CreateDateTime DESC
        OFFSET @begin ROWS FETCH NEXT @step ROWS ONLY;";

            pager.TotalItem = GetTireBlackListCount(blackNumber, type);

            using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Gungnir")))
            {
                return(dbHelper.ExecuteDataTable(sqlStr, CommandType.Text, new SqlParameter[]
                {
                    new SqlParameter("@type", type),
                    new SqlParameter("@blackNumber", string.IsNullOrWhiteSpace(blackNumber) ? null : blackNumber),
                    new SqlParameter("@begin", pager.PageSize * (pager.CurrentPage - 1)),
                    new SqlParameter("@step", pager.PageSize)
                }).ConvertTo <TireBlackListItem>());
            }
        }
コード例 #15
0
        protected virtual void BuildResultView()
        {
            Content modelData;
            try
            {
                modelData = GetModel() as Content;
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
                Controls.Clear();
                Controls.Add(new LiteralControl("ContentView error: " + ex.Message));
                return;
            }
            if (modelData != null) modelData.AllChildren = AllChildren;

            var model = new ContentCollectionViewModel {State = this.State};
            var childCount = modelData != null ? modelData.ChildCount : 0;
            var pm = new PagerModel(childCount, State, string.Empty);
            model.Pager = pm;
            model.Content = modelData;
            if (RenderingMode == RenderMode.Xslt)
            {
                try
                {
                    XmlModelData = model.ToXPathNavigator();
                }
                catch (Exception ex)
                {
                    Logger.Write(ex.ToString());
                    Logger.WriteException(ex);
                }
            }
            else
            {
                var viewPath = RenderingMode == RenderMode.Native
                                   ? "/root/Global/Renderers/ContentCollectionView.ascx"
                                   : Renderer;

                var presenter = Page.LoadControl(viewPath);
               
                Controls.Add(presenter);
                PresenterClientId = presenter.ClientID;
                if (presenter is ContentCollectionView)
                {
                    ((ContentCollectionView) presenter).Model = model;
                }
                if (modelData != null)
                {
                    var itemlist = presenter.FindControl(ContentListID);
                    if (itemlist != null)
                    {
                        ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemlist,
                                                                                            modelData.Children);
                    }
                    itemlist = presenter.FindControl("ViewDatasource");
                    if (itemlist != null)
                    {
                        ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemlist,
                                                                                            modelData.Children);
                    }
                }

                var itemPager = presenter.FindControl("ContentListPager");
                if (itemPager != null)
                {
                    ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemPager,
                                                                                        model.Pager.PagerActions);
                }


                
            }
        }
コード例 #16
0
        public async Task <IViewComponentResult> InvokeAsync(string customerProfileId, int pageNumber)
        {
            var customer = await _customerService.GetCustomerById(customerProfileId);

            if (customer == null)
            {
                return(Content(""));
            }

            if (pageNumber > 0)
            {
                pageNumber -= 1;
            }

            var pageSize = _forumSettings.LatestCustomerPostsPageSize;

            var list = await _forumService.GetAllPosts("", customer.Id, string.Empty, false, pageNumber, pageSize);

            var latestPosts = new List <PostsModel>();

            foreach (var forumPost in list)
            {
                var posted = string.Empty;
                if (_forumSettings.RelativeDateTimeFormattingEnabled)
                {
                    posted = forumPost.CreatedOnUtc.ToString("f");
                }
                else
                {
                    posted = _dateTimeHelper.ConvertToUserTime(forumPost.CreatedOnUtc, DateTimeKind.Utc).ToString("f");
                }
                var forumtopic = await _forumService.GetTopicById(forumPost.TopicId);

                if (forumtopic != null)
                {
                    latestPosts.Add(new PostsModel {
                        ForumTopicId    = forumPost.TopicId,
                        ForumTopicTitle = forumtopic.Subject,
                        ForumTopicSlug  = forumtopic.GetSeName(),
                        ForumPostText   = forumPost.FormatPostText(),
                        Posted          = posted
                    });
                }
            }

            var pagerModel = new PagerModel(_localizationService)
            {
                PageSize         = list.PageSize,
                TotalRecords     = list.TotalCount,
                PageIndex        = list.PageIndex,
                ShowTotalSummary = false,
                RouteActionName  = "CustomerProfilePaged",
                UseRouteLinks    = true,
                RouteValues      = new RouteValues {
                    pageNumber = pageNumber, id = customerProfileId
                }
            };

            var model = new ProfilePostsModel {
                PagerModel = pagerModel,
                Posts      = latestPosts,
            };

            return(View(model));
        }
コード例 #17
0
        public List <ProjectModel> Get(ProjectModel filter)
        {
            PagerModel pager = new PagerModel(0, Int32.MaxValue - 1, "", "");

            return(GetProjectCollection(filter, pager).Data);
        }
コード例 #18
0
        public RequestResult <List <ProjectModel> > GetProjectCollection(ProjectModel parameters, PagerModel pagerParameters)
        {
            ProjectDA DAProject = new ProjectDA();

            return(DAProject.GetProjectCollection(parameters, pagerParameters));
        }
コード例 #19
0
 public static IEnumerable <TireBlackListItem> GetTireBlackList(string blackNumber, int type, PagerModel pager)
 {
     if ((type == 2 || (type == 4)) && !string.IsNullOrWhiteSpace(blackNumber))
     {
         if (Guid.TryParse(blackNumber, out Guid value))
         {
             blackNumber = value.ToString("D");
         }
     }
     return(DalPattern.GetTireBlackList(blackNumber, type, pager));
 }
コード例 #20
0
 public CustomerOutOfStockSubscriptionsModel()
 {
     Subscriptions = new List <OutOfStockSubscriptionModel>();
     PagerModel    = new PagerModel();
 }
コード例 #21
0
        public static List <ProductPriceModel> FetchProductList(ProductListRequest request, PagerModel pager, bool isExport)
        {
            #region SQL
            var SqlStr = @"SELECT	T.CP_Brand AS Brand ,
		T.PID AS PID ,
		T.DisplayName AS ProductName ,
		S.cost AS Cost ,
		P.LowestPrice AS LowestLimit ,
		T.cy_list_price AS Price ,
		S.taobao_tuhuid AS TBPID ,
		S.taobao_tuhuprice AS TBPrice ,
		S.taobao2_tuhuid AS TB2PID ,
		S.taobao2_tuhuprice AS TB2Price ,
		S.tianmao1_tuhuprice AS TM1Price ,
		S.tianmao1_tuhuid AS TM1PID ,
		S.tianmao2_tuhuprice AS TM2Price ,
		S.tianmao2_tuhuid AS TM2PID ,
		S.tianmao3_tuhuprice AS TM3Price ,
		S.tianmao3_tuhuid AS TM3PID ,
		S.tianmao4_tuhuid AS TM4PID ,
		S.tianmao4_tuhuprice AS TM4Price ,
		S.jingdongflagship_tuhuprice AS JDFlagShipPrice ,
		S.jingdongflagship_tuhuid AS JDFlagShipPID ,
		S.jingdong_tuhuprice AS JDPrice ,
		S.jingdong_tuhuid AS JDPID,
        e.CanUseCoupon as CanUseCoupon
FROM	Tuhu_productcatalog..vw_Products AS T WITH ( NOLOCK )
		LEFT JOIN Tuhu_productcatalog..TireLowestPrice AS P WITH ( NOLOCK ) ON T.PID = P.PID
		LEFT JOIN Tuhu_bi..dm_Product_SalespredictData AS S WITH ( NOLOCK ) ON T.PID = S.PID
        left join Tuhu_productcatalog..tbl_ProductExtraProperties as e  WITH ( NOLOCK ) on e.pid=t.pid
WHERE	T.IsShow = 1
		AND ( ( T.PID LIKE '%' + @pid + '%'
				OR @pid IS NULL
				)
				AND T.PID LIKE 'TR-%'
			)
		AND ( T.DisplayName LIKE '%' + @productname + '%'
				OR @productname IS NULL
			)
		AND ( T.CP_Brand = @Brand
				OR @Brand IS NULL
			)
		AND ( @OnSaleStatus = 0
				OR @OnSaleStatus = 1
				AND T.OnSale = 1
				OR @OnSaleStatus = 2
				AND T.OnSale = 0
			)
		AND ( {0}
			)"            ;
            SqlStr += isExport ? ";" : @"ORDER BY s.num_threemonth desc
		OFFSET @start ROWS FETCH NEXT @step ROWS ONLY;"        ;
            #endregion +
            pager.TotalItem = FetchProductListCount(request);
            List <string> ManyCustomPrice   = request.ManyCustomPrice?.Split('|').ToList();
            int           Contrast          = request.Contrast;
            string        SingleCustomPrice = GetSqlParameter(request.SingleCustomPrice);
            double        Proportion        = request.Proportion;
            var           sqlPara           = "1 = 1";
            if (request.Type > 0 && ManyCustomPrice != null && !string.IsNullOrWhiteSpace(SingleCustomPrice) && Contrast != 0)
            {
                sqlPara = "1 <> 1";
                var ContrastSig = Contrast == -1 ? "<=" : ">=";
                foreach (var item in ManyCustomPrice)
                {
                    var realPara = GetSqlParameter(item);
                    if (!string.IsNullOrWhiteSpace(realPara))
                    {
                        sqlPara += $@" OR ( ISNULL({realPara}, 0) > 0
						AND {realPara} / IIF(ISNULL({SingleCustomPrice}, 0) = 0, 1, {SingleCustomPrice}) {ContrastSig} {Proportion})"                        ;
                    }
                }
            }
            //string.Format(SqlStr, sqlPara);
            SqlStr = string.Format(SqlStr, sqlPara);
            using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Tuhu_Gungnir_BI")))
            {
                using (var cmd = new SqlCommand(SqlStr))
                {
                    cmd.CommandTimeout = 3 * 60;
                    cmd.CommandType    = CommandType.Text;
                    cmd.Parameters.AddWithValue("@pid", request.PID);
                    cmd.Parameters.AddWithValue("@productname", request.ProductName);
                    cmd.Parameters.AddWithValue("@OnSaleStatus", request.OnSale);
                    cmd.Parameters.AddWithValue("@Brand", request.Brand);
                    cmd.Parameters.AddWithValue("@start", (request.PageIndex - 1) * request.PageSize);
                    cmd.Parameters.AddWithValue("@step", request.PageSize);
                    var result = dbHelper.ExecuteDataTable(cmd);
                    return(result.ConvertTo <ProductPriceModel>()?.ToList() ?? new List <ProductPriceModel>());
                }
            }
        }
コード例 #22
0
        public ActionResult Posts(int customerProfileId, int page)
        {
            var customer = _customerService.GetCustomerById(customerProfileId);

            if (customer == null)
            {
                return(RedirectToRoute("HomePage"));
            }

            if (page > 0)
            {
                page -= 1;
            }

            var pageSize = _forumSettings.LatestCustomerPostsPageSize;

            var list = _forumService.GetAllPosts(0, customer.Id, string.Empty, false, page, pageSize);

            var latestPosts = new List <PostsModel>();

            foreach (var forumPost in list)
            {
                var posted = string.Empty;
                if (_forumSettings.RelativeDateTimeFormattingEnabled)
                {
                    posted = forumPost.CreatedOnUtc.RelativeFormat(true, "f");
                }
                else
                {
                    posted = _dateTimeHelper.ConvertToUserTime(forumPost.CreatedOnUtc, DateTimeKind.Utc).ToString("f");
                }

                latestPosts.Add(new PostsModel()
                {
                    ForumTopicId    = forumPost.TopicId,
                    ForumTopicTitle = forumPost.ForumTopic.Subject,
                    ForumTopicSlug  = forumPost.ForumTopic.GetSeName(),
                    ForumPostText   = forumPost.FormatPostText(),
                    Posted          = posted
                });
            }

            var pagerModel = new PagerModel()
            {
                PageSize         = list.PageSize,
                TotalRecords     = list.TotalCount,
                PageIndex        = list.PageIndex,
                ShowTotalSummary = false,
                RouteActionName  = "CustomerProfilePaged",
                UseRouteLinks    = true,
                RouteValues      = new RouteValues {
                    page = page, id = customerProfileId
                }
            };

            var model = new ProfilePostsModel()
            {
                PagerModel = pagerModel,
                Posts      = latestPosts,
            };

            return(PartialView(model));
        }
コード例 #23
0
        /// <summary>
        /// 根据标签Id查询相关文章
        /// </summary>
        /// <param name="CategoryId">标签Id</param>
        /// <param name="articleId">文章Id</param>
        /// <param name="pager">分页模型</param>
        /// <returns></returns>
        public async Task <List <RelatedArticle> > SelectRelatedAticleByCategoryId(int articleId, int CategoryId, PagerModel pager)
        {
            var relatedArticles =
                from ac in discoveryDbContext.ArticleCategory
                where ac.CategoryTagId == CategoryId
                join a in discoveryDbContext.Article on ac.ArticleId equals a.PKID
                where a.Status == ArticleStatus.Published.ToString() && a.PublishDateTime <= DateTime.Now &&
                a.PKID != articleId
                orderby a.PublishDateTime descending
                select new RelatedArticle
            {
                PKID            = a.PKID,
                Title           = a.SmallTitle,
                CoverTag        = a.CoverTag,
                CoverImage      = a.CoverImage,
                PublishDateTime = a.PublishDateTime.Value
            };

            pager.TotalItem = await relatedArticles.CountAsync();

            return(await relatedArticles.Skip((pager.CurrentPage - 1) *pager.PageSize).Take(pager.PageSize).ToListAsync());
        }
コード例 #24
0
 /// <summary>
 /// 查询保养价格审核记录
 /// </summary>
 /// <param name="pID"></param>
 /// <param name="pager"></param>
 /// <returns></returns>
 public static IEnumerable <PriceUpdateAuditModel> SelectAuditLogByPID(string pID, PagerModel pager)
 {
     using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Gungnir_AlwaysOnRead")))
     {
         var dt = dbHelper.ExecuteDataTable(@"SELECT  EUTP.* ,
                                                      VP.DisplayName AS ProductName ,
                                                      VP.CP_Brand AS Brand,
                                                      Count(1) OVER() AS TotalCount
                                             FROM     Configuration.dbo.tbl_BaoYangPriceUpdateAudit AS EUTP WITH ( NOLOCK )
                                                      JOIN Tuhu_productcatalog.dbo.vw_Products AS VP WITH ( NOLOCK ) ON EUTP.PID = VP.PID
                                             WHERE    ( EUTP.PID = @PID
                                                        OR @PID IS NULL
                                                      )
                                                      AND AuditStatus IN ( 1, 2 )
                                             ORDER BY PKID DESC
                                             OFFSET ( @PageIndex - 1 ) * @PageSize ROWS
                                             FETCH NEXT @PageSize ROWS ONLY;", CommandType.Text,
                                            new SqlParameter[] {
             new SqlParameter("@PageIndex", pager.CurrentPage),
             new SqlParameter("@PageSize", pager.PageSize),
             new SqlParameter("@PID", pID)
         });
         if (dt != null && dt.Rows.Count > 0)
         {
             pager.TotalItem = Convert.ToInt32(dt.Rows[0]["TotalCount"] ?? 0);
         }
         return(dt.ConvertTo <PriceUpdateAuditModel>());
     }
 }
コード例 #25
0
        /// <summary>
        /// Prepare a common pager
        /// </summary>
        /// <typeparam name="TModel">Model type</typeparam>
        /// <param name="html">HTML helper</param>
        /// <param name="model">Pager model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the pager
        /// </returns>
        /// <remarks>We have two pagers: The first one can have custom routes. The second one just adds query string parameter</remarks>
        public static async Task <IHtmlContent> PagerAsync <TModel>(this IHtmlHelper <TModel> html, PagerModel model)
        {
            if (model.TotalRecords == 0)
            {
                return(new HtmlString(string.Empty));
            }

            var localizationService = EngineContext.Current.Resolve <ILocalizationService>();

            var links = new StringBuilder();

            if (model.ShowTotalSummary && (model.TotalPages > 0))
            {
                links.Append("<li class=\"total-summary\">");
                links.Append(string.Format(await model.GetCurrentPageTextAsync(), model.PageIndex + 1, model.TotalPages, model.TotalRecords));
                links.Append("</li>");
            }

            if (model.ShowPagerItems && (model.TotalPages > 1))
            {
                if (model.ShowFirst)
                {
                    //first page
                    if ((model.PageIndex >= 3) && (model.TotalPages > model.IndividualPagesDisplayedCount))
                    {
                        model.RouteValues.pageNumber = 1;

                        links.Append("<li class=\"first-page\">");
                        if (model.UseRouteLinks)
                        {
                            var link = html.RouteLink(await model.GetFirstButtonTextAsync(),
                                                      model.RouteActionName,
                                                      model.RouteValues,
                                                      new { title = await localizationService.GetResourceAsync("Pager.FirstPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        else
                        {
                            var link = html.ActionLink(await model.GetFirstButtonTextAsync(),
                                                       model.RouteActionName,
                                                       model.RouteValues,
                                                       new { title = await localizationService.GetResourceAsync("Pager.FirstPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        links.Append("</li>");
                    }
                }

                if (model.ShowPrevious)
                {
                    //previous page
                    if (model.PageIndex > 0)
                    {
                        model.RouteValues.pageNumber = model.PageIndex;

                        links.Append("<li class=\"previous-page\">");
                        if (model.UseRouteLinks)
                        {
                            var link = html.RouteLink(await model.GetPreviousButtonTextAsync(),
                                                      model.RouteActionName,
                                                      model.RouteValues,
                                                      new { title = await localizationService.GetResourceAsync("Pager.PreviousPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        else
                        {
                            var link = html.ActionLink(await model.GetPreviousButtonTextAsync(),
                                                       model.RouteActionName,
                                                       model.RouteValues,
                                                       new { title = await localizationService.GetResourceAsync("Pager.PreviousPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        links.Append("</li>");
                    }
                }

                if (model.ShowIndividualPages)
                {
                    //individual pages
                    var firstIndividualPageIndex = model.GetFirstIndividualPageIndex();
                    var lastIndividualPageIndex  = model.GetLastIndividualPageIndex();
                    for (var i = firstIndividualPageIndex; i <= lastIndividualPageIndex; i++)
                    {
                        if (model.PageIndex == i)
                        {
                            links.AppendFormat("<li class=\"current-page\"><span>{0}</span></li>", i + 1);
                        }
                        else
                        {
                            model.RouteValues.pageNumber = i + 1;

                            links.Append("<li class=\"individual-page\">");
                            if (model.UseRouteLinks)
                            {
                                var link = html.RouteLink((i + 1).ToString(),
                                                          model.RouteActionName,
                                                          model.RouteValues,
                                                          new { title = string.Format(await localizationService.GetResourceAsync("Pager.PageLinkTitle"), i + 1) });
                                links.Append(await link.RenderHtmlContentAsync());
                            }
                            else
                            {
                                var link = html.ActionLink((i + 1).ToString(),
                                                           model.RouteActionName,
                                                           model.RouteValues,
                                                           new { title = string.Format(await localizationService.GetResourceAsync("Pager.PageLinkTitle"), i + 1) });
                                links.Append(await link.RenderHtmlContentAsync());
                            }
                            links.Append("</li>");
                        }
                    }
                }

                if (model.ShowNext)
                {
                    //next page
                    if ((model.PageIndex + 1) < model.TotalPages)
                    {
                        model.RouteValues.pageNumber = (model.PageIndex + 2);

                        links.Append("<li class=\"next-page\">");
                        if (model.UseRouteLinks)
                        {
                            var link = html.RouteLink(await model.GetNextButtonTextAsync(),
                                                      model.RouteActionName,
                                                      model.RouteValues,
                                                      new { title = await localizationService.GetResourceAsync("Pager.NextPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        else
                        {
                            var link = html.ActionLink(await model.GetNextButtonTextAsync(),
                                                       model.RouteActionName,
                                                       model.RouteValues,
                                                       new { title = await localizationService.GetResourceAsync("Pager.NextPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        links.Append("</li>");
                    }
                }

                if (model.ShowLast)
                {
                    //last page
                    if (((model.PageIndex + 3) < model.TotalPages) && (model.TotalPages > model.IndividualPagesDisplayedCount))
                    {
                        model.RouteValues.pageNumber = model.TotalPages;

                        links.Append("<li class=\"last-page\">");
                        if (model.UseRouteLinks)
                        {
                            var link = html.RouteLink(await model.GetLastButtonTextAsync(),
                                                      model.RouteActionName,
                                                      model.RouteValues,
                                                      new { title = await localizationService.GetResourceAsync("Pager.LastPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        else
                        {
                            var link = html.ActionLink(await model.GetLastButtonTextAsync(),
                                                       model.RouteActionName,
                                                       model.RouteValues,
                                                       new { title = await localizationService.GetResourceAsync("Pager.LastPageTitle") });
                            links.Append(await link.RenderHtmlContentAsync());
                        }
                        links.Append("</li>");
                    }
                }
            }

            var result = links.ToString();

            if (!string.IsNullOrEmpty(result))
            {
                result = "<ul>" + result + "</ul>";
            }

            return(new HtmlString(result));
        }
コード例 #26
0
        public virtual CustomerProductReviewsModel PrepareCustomerProductReviewsModel(int?page)
        {
            var pageSize  = _catalogSettings.ProductReviewsPageSizeOnAccountPage;
            int pageIndex = 0;

            if (page > 0)
            {
                pageIndex = page.Value - 1;
            }

            var list = _productService.GetAllProductReviews(customerId: _workContext.CurrentCustomer.Id,
                                                            approved: null,
                                                            pageIndex: pageIndex,
                                                            pageSize: pageSize);

            var productReviews = new List <CustomerProductReviewModel>();

            foreach (var review in list)
            {
                var product            = review.Product;
                var productReviewModel = new CustomerProductReviewModel
                {
                    Title         = review.Title,
                    ProductId     = product.Id,
                    ProductName   = product.GetLocalized(p => p.Name),
                    ProductSeName = product.GetSeName(),
                    Rating        = review.Rating,
                    ReviewText    = review.ReviewText,
                    ReplyText     = review.ReplyText,
                    WrittenOnStr  = _dateTimeHelper.ConvertToUserTime(product.CreatedOnUtc, DateTimeKind.Utc).ToString("g")
                };

                if (_catalogSettings.ProductReviewsMustBeApproved)
                {
                    productReviewModel.ApprovalStatus = review.IsApproved
                        ? _localizationService.GetResource("Account.CustomerProductReviews.ApprovalStatus.Approved")
                        : _localizationService.GetResource("Account.CustomerProductReviews.ApprovalStatus.Pending");
                }
                productReviews.Add(productReviewModel);
            }

            var pagerModel = new PagerModel
            {
                PageSize         = list.PageSize,
                TotalRecords     = list.TotalCount,
                PageIndex        = list.PageIndex,
                ShowTotalSummary = false,
                RouteActionName  = "CustomerProductReviewsPaged",
                UseRouteLinks    = true,
                RouteValues      = new CustomerProductReviewsModel.CustomerProductReviewsRouteValues {
                    page = pageIndex
                }
            };

            var model = new CustomerProductReviewsModel
            {
                ProductReviews = productReviews,
                PagerModel     = pagerModel
            };

            return(model);
        }
コード例 #27
0
        //we have two pagers:
        //The first one can have custom routes
        //The second one just adds query string parameter
        public static IHtmlContent Pager <TModel>(this IHtmlHelper <TModel> html, PagerModel model)
        {
            if (model.TotalRecords == 0)
            {
                return(null);
            }

            var localizationService = EngineContext.Current.Resolve <ILocalizationService>();

            var links = new StringBuilder();

            if (model.ShowTotalSummary && (model.TotalPages > 0))
            {
                links.Append("<li class=\"total-summary page-item\">");
                links.Append(string.Format(model.CurrentPageText, model.PageIndex + 1, model.TotalPages, model.TotalRecords));
                links.Append("</li>");
            }
            if (model.ShowPagerItems && (model.TotalPages > 1))
            {
                if (model.ShowFirst)
                {
                    //first page
                    if ((model.PageIndex >= 3) && (model.TotalPages > model.IndividualPagesDisplayedCount))
                    {
                        model.RouteValues.pageNumber = 1;

                        links.Append("<li class=\"first-page page-item\">");
                        if (model.UseRouteLinks)
                        {
                            links.Append(html.RouteLink(model.FirstButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.FirstPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        else
                        {
                            links.Append(html.ActionLink(model.FirstButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.FirstPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        links.Append("</li>");
                    }
                }
                if (model.ShowPrevious)
                {
                    //previous page
                    if (model.PageIndex > 0)
                    {
                        model.RouteValues.pageNumber = (model.PageIndex);

                        links.Append("<li class=\"previous-page page-item\">");
                        if (model.UseRouteLinks)
                        {
                            links.Append(html.RouteLink(model.PreviousButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.PreviousPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        else
                        {
                            links.Append(html.ActionLink(model.PreviousButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.PreviousPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        links.Append("</li>");
                    }
                }
                if (model.ShowIndividualPages)
                {
                    //individual pages
                    int firstIndividualPageIndex = model.GetFirstIndividualPageIndex();
                    int lastIndividualPageIndex  = model.GetLastIndividualPageIndex();
                    for (int i = firstIndividualPageIndex; i <= lastIndividualPageIndex; i++)
                    {
                        if (model.PageIndex == i)
                        {
                            links.AppendFormat("<li class=\"current-page page-item\"><a class=\"page-link\">{0}</a></li>", (i + 1));
                        }
                        else
                        {
                            model.RouteValues.pageNumber = (i + 1);

                            links.Append("<li class=\"individual-page page-item\">");
                            if (model.UseRouteLinks)
                            {
                                links.Append(html.RouteLink((i + 1).ToString(), model.RouteActionName, model.RouteValues, new { title = String.Format(localizationService.GetResource("Pager.PageLinkTitle"), (i + 1)), @class = "page-link" }).ToHtmlString());
                            }
                            else
                            {
                                links.Append(html.ActionLink((i + 1).ToString(), model.RouteActionName, model.RouteValues, new { title = String.Format(localizationService.GetResource("Pager.PageLinkTitle"), (i + 1)), @class = "page-link" }).ToHtmlString());
                            }
                            links.Append("</li>");
                        }
                    }
                }
                if (model.ShowNext)
                {
                    //next page
                    if ((model.PageIndex + 1) < model.TotalPages)
                    {
                        model.RouteValues.pageNumber = (model.PageIndex + 2);

                        links.Append("<li class=\"next-page page-item\">");
                        if (model.UseRouteLinks)
                        {
                            links.Append(html.RouteLink(model.NextButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.NextPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        else
                        {
                            links.Append(html.ActionLink(model.NextButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.NextPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        links.Append("</li>");
                    }
                }
                if (model.ShowLast)
                {
                    //last page
                    if (((model.PageIndex + 3) < model.TotalPages) && (model.TotalPages > model.IndividualPagesDisplayedCount))
                    {
                        model.RouteValues.pageNumber = model.TotalPages;

                        links.Append("<li class=\"last-page page-item\">");
                        if (model.UseRouteLinks)
                        {
                            links.Append(html.RouteLink(model.LastButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.LastPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        else
                        {
                            links.Append(html.ActionLink(model.LastButtonText, model.RouteActionName, model.RouteValues, new { title = localizationService.GetResource("Pager.LastPageTitle"), @class = "page-link" }).ToHtmlString());
                        }
                        links.Append("</li>");
                    }
                }
            }
            var result = links.ToString();

            if (!String.IsNullOrEmpty(result))
            {
                result = "<ul class=\"pagination\">" + result + "</ul>";
            }
            return(new HtmlString(result));
        }
コード例 #28
0
        protected virtual void BuildResultView()
        {
            Content modelData;

            try
            {
                modelData = GetModel() as Content;
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
                Controls.Clear();
                Controls.Add(new LiteralControl("ContentView error: " + ex.Message));
                return;
            }
            if (modelData != null)
            {
                modelData.AllChildren = AllChildren;
            }

            var model = new ContentCollectionViewModel {
                State = this.State
            };
            var childCount = modelData != null ? modelData.ChildCount : 0;
            var pm         = new PagerModel(childCount, State, string.Empty);

            model.Pager   = pm;
            model.Content = modelData;
            if (RenderingMode == RenderMode.Xslt)
            {
                try
                {
                    XmlModelData = model.ToXPathNavigator();
                }
                catch (Exception ex)
                {
                    Logger.Write(ex.ToString());
                    Logger.WriteException(ex);
                }
            }
            else
            {
                var viewPath = RenderingMode == RenderMode.Native
                                   ? "/root/Global/Renderers/ContentCollectionView.ascx"
                                   : Renderer;

                var presenter = Page.LoadControl(viewPath);

                Controls.Add(presenter);
                PresenterClientId = presenter.ClientID;
                if (presenter is ContentCollectionView)
                {
                    ((ContentCollectionView)presenter).Model = model;
                }
                if (modelData != null)
                {
                    var itemlist = presenter.FindControl(ContentListID);
                    if (itemlist != null)
                    {
                        ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemlist,
                                                                                            modelData.Children);
                    }
                    itemlist = presenter.FindControl("ViewDatasource");
                    if (itemlist != null)
                    {
                        ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemlist,
                                                                                            modelData.Children);
                    }
                }

                var itemPager = presenter.FindControl("ContentListPager");
                if (itemPager != null)
                {
                    ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemPager,
                                                                                        model.Pager.PagerActions);
                }
            }
        }
コード例 #29
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. Parents CreateChildControls() logic moved here for processing 
        /// data of input renderer.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            var controIdlList = new List<string>();

            if (!String.IsNullOrEmpty(QueryTemplate))
            {
                foreach (var param in HttpContext.Current.Request.Params.AllKeys)
                {
                    if (this.QueryTemplate.Contains("%" + param + "%"))
                    {
                        _hasUrlInput = true;
                        break;
                    }
                }

                foreach (var key in HttpContext.Current.Request.Form.AllKeys)
                {
                    var controlName = string.Empty;
                    if (key.Contains('$'))
                    {
                        controlName = key.Remove(0, key.LastIndexOf('$') + 1); 
                    }
                    if (QueryTemplate.Contains("%" + controlName + "%"))
                    {
                        _hasFormInput = true;
                        break;
                    }
                } 
            }

            if (_hasFormInput || HttpContext.Current.Request.QueryString.ToString().Contains(Math.Abs((PortalContext.Current.ContextNode.Path + this.ID).GetHashCode()).ToString()) || _hasUrlInput)
            {
                this.GetQueryFilter();  // initialize query filter to see if query is invalid for empty search
                var errorPanel = this.FindControlRecursive(EmptyQueryErrorPanelID);
                if (errorPanel != null)
                    errorPanel.Visible = _invalidQuery;
                if (_invalidQuery)
                    return;

                Content modelData;
                try
                {
                    modelData = GetModel() as Content;

                }
                catch (Exception ex)
                {
                    Logger.WriteException(ex);
                    Controls.Clear();
                    Controls.Add(new LiteralControl("ContentView error: " + ex.Message));
                    return;
                }

                var rootContent = modelData as Content;
                if (rootContent != null) rootContent.AllChildren = AllChildren;

                var model = new ParametricSearchViewModel() { State = State };

                var searchParamList = new List<SearchParameter>();

                foreach (var searchParam in _searchParams)
                {
                    searchParamList.Add(new SearchParameter() { Name = searchParam.Key, Value = searchParam.Value });
                }

                model.SearchParameters = searchParamList.ToArray();

                try
                {
                    var childCount = rootContent != null ? rootContent.ChildCount : 0;
                    var pm = new PagerModel(childCount, State, string.Empty);
                    model.Pager = pm;

                    if (RenderingMode == RenderMode.Xslt)
                    {
                        try
                        {
                            XmlModelData = model.ToXPathNavigator();
                        }
                        catch (Exception ex)
                        {
                            Logger.Write(ex.ToString());
                            Logger.WriteException(ex);
                        }
                    }
                    else if (RenderingMode == RenderMode.Ascx || RenderingMode == RenderMode.Native)
                    {
                        model.Content = rootContent;
                        if (CanCache && Cacheable && IsInCache)
                            return;

                        var viewPath = RenderingMode == RenderMode.Native
                                           ? "/root/Global/Renderers/ContentCollectionView.ascx"
                                           : Renderer;

                        var presenter = Page.LoadControl(viewPath);
                        if (presenter is ContentCollectionView)
                        {
                            ((ContentCollectionView)presenter).Model = model;
                        }
                        if (rootContent != null)
                        {
                            var itemlist = presenter.FindControl(ContentListID);
                            if (itemlist != null)
                            {
                                ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemlist,
                                                                                                    rootContent.Children);
                            }
                        }

                        var itemPager = presenter.FindControl("ContentListPager");
                        if (itemPager != null)
                        {
                            ContentQueryPresenterPortlet.DataBindingHelper.SetDataSourceAndBind(itemPager,
                                                                                                model.Pager.PagerActions);
                        }

                        Controls.Add(presenter);
                    }

                }
                catch (ParserException ex)
                {
                    var errorText = new LiteralControl { Text = ex.Message };
                    Controls.Add(errorText);
                }
                catch (Exception ex)
                {
                    var errorText = new LiteralControl { Text = ex.ToString() };
                    Controls.Add(errorText);
                }
            }
            ChildControlsCreated = true;
        }
コード例 #30
0
        /// <summary>
        /// Prepare the profile posts model
        /// </summary>
        /// <param name="customer">Customer</param>
        /// <param name="page">Number of posts page</param>
        /// <returns>Profile posts model</returns>
        public virtual ProfilePostsModel PrepareProfilePostsModel(Customer customer, int page)
        {
            if (customer == null)
            {
                throw new ArgumentNullException(nameof(customer));
            }

            if (page > 0)
            {
                page -= 1;
            }

            var pageSize = _forumSettings.LatestCustomerPostsPageSize;

            var list = _forumService.GetAllPosts(0, customer.Id, string.Empty, false, page, pageSize);

            var latestPosts = new List <PostsModel>();

            foreach (var forumPost in list)
            {
                var posted = string.Empty;
                if (_forumSettings.RelativeDateTimeFormattingEnabled)
                {
                    var languageCode = _workContext.WorkingLanguage.LanguageCulture;
                    var postedAgo    = forumPost.CreatedOnUtc.RelativeFormat(languageCode);
                    posted = string.Format(_localizationService.GetResource("Common.RelativeDateTime.Past"), postedAgo);
                }
                else
                {
                    posted = _dateTimeHelper.ConvertToUserTime(forumPost.CreatedOnUtc, DateTimeKind.Utc).ToString("f");
                }

                var topic = _forumService.GetTopicById(forumPost.TopicId);

                latestPosts.Add(new PostsModel
                {
                    ForumTopicId    = topic.Id,
                    ForumTopicTitle = topic.Subject,
                    ForumTopicSlug  = _forumService.GetTopicSeName(topic),
                    ForumPostText   = _forumService.FormatPostText(forumPost),
                    Posted          = posted
                });
            }

            var pagerModel = new PagerModel
            {
                PageSize         = list.PageSize,
                TotalRecords     = list.TotalCount,
                PageIndex        = list.PageIndex,
                ShowTotalSummary = false,
                RouteActionName  = "CustomerProfilePaged",
                UseRouteLinks    = true,
                RouteValues      = new RouteValues {
                    pageNumber = page, id = customer.Id
                }
            };

            var model = new ProfilePostsModel
            {
                PagerModel = pagerModel,
                Posts      = latestPosts,
            };

            return(model);
        }
コード例 #31
0
        public IViewComponentResult Invoke(PagerModel pagerModel)
        {
            PagerModel = pagerModel;

            return(View(ViewPath));
        }
コード例 #32
0
 public static IEnumerable <TirePatternModel> SelectList(TirePatternModel model, PagerModel pager) => DalPattern.SelectList(model, pager);
コード例 #33
0
        private ActionResult RenderByTagOrCategory(RenderModel model, int?p, string tagGroup, string baseUrl)
        {
            var tagPage = model.Content as ArticulateVirtualPage;

            if (tagPage == null)
            {
                throw new InvalidOperationException("The RenderModel.Content instance must be of type " + typeof(ArticulateVirtualPage));
            }

            //create a blog model of the main page
            var rootPageModel = new ListModel(model.Content.Parent);

            var contentByTag = Umbraco.GetContentByTag(rootPageModel, tagPage.Name, tagGroup, baseUrl);

            //this is a special case in the event that a tag contains a '.', when this happens we change it to a '-'
            // when generating the URL. So if the above doesn't return any tags and the tag contains a '-', then we
            // will replace them with '.' and do the lookup again
            if (contentByTag == null && tagPage.Name.Contains("-"))
            {
                contentByTag = Umbraco.GetContentByTag(
                    rootPageModel,
                    tagPage.Name.Replace('-', '.'),
                    tagGroup,
                    baseUrl);
            }

            if (contentByTag == null)
            {
                return(new HttpNotFoundResult());
            }

            if (p != null && p.Value == 1)
            {
                return(new RedirectToUmbracoPageResult(model.Content, UmbracoContext));
            }

            if (p == null || p.Value <= 0)
            {
                p = 1;
            }

            //TODO: I wonder about the performance of this - when we end up with thousands of blog posts,
            // this will probably not be so efficient. I wonder if using an XPath lookup for batches of children
            // would work? The children count could be cached. I'd rather not put blog posts under 'month' nodes
            // just for the sake of performance. Hrm.... Examine possibly too.

            var totalPosts = contentByTag.PostCount;
            var pageSize   = rootPageModel.PageSize;
            var totalPages = totalPosts == 0 ? 1 : Convert.ToInt32(Math.Ceiling((double)totalPosts / pageSize));

            //Invalid page, redirect without pages
            if (totalPages < p)
            {
                return(new RedirectToUmbracoPageResult(model.Content.Parent, UmbracoContext));
            }

            var pager = new PagerModel(
                pageSize,
                p.Value - 1,
                totalPages,
                totalPages > p ? model.Content.Url.EnsureEndsWith('?') + "p=" + (p + 1) : null,
                p > 2 ? model.Content.Url.EnsureEndsWith('?') + "p=" + (p - 1) : p > 1 ? model.Content.Url : null);

            var listModel = new ListModel(tagPage, contentByTag.Posts, pager);

            return(View(PathHelper.GetThemeViewPath(listModel, "List"), listModel));
        }
コード例 #34
0
        public PagerModel<ListInsuree> GetPagedInsurees(int page = 1, int pageSize = 10, string sort = "Id",
            string sortDir = "ASC")
        {
            var totalRecords = _insureeRepository.FindAll().Count();
            var data = new List<ListInsuree>();
            var insurees =
                _insureeRepository.FindAll()
                    .OrderBy(BuildOrderBy(sort, sortDir))
                    .Skip(page * pageSize - pageSize)
                    .Take(pageSize);

            _mapper.Map(insurees, data);

            var model = new PagerModel<ListInsuree>
            {
                Data = data,
                PageNumber = page,
                PageSize = pageSize,
                TotalPages = (int) Math.Ceiling(totalRecords / (double) pageSize)
            };

            _logger.Info($"Returning PagerModel: {model}");

            return model;
        }