Esempio n. 1
0
        /// <summary>
        /// 列表页分页
        /// </summary>
        /// <param name="path">第一页生成路径</param>
        /// <param name="template">列表模板</param>
        /// <param name="loopitem">循环项内容</param>
        /// <param name="loopitemrule">循环规则</param>
        /// <param name="pageSize">每页显示条数</param>
        /// <param name="dt">数据集合</param>
        protected override string ConvertPagingList(string path, string template, string loopitem, string loopitemrule, int pageSize, System.Data.DataTable dt)
        {
            int           totalPage   = PageSeting.GetPageCount(dt.Rows.Count, pageSize);
            StringBuilder strListItem = new StringBuilder();
            string        strList     = string.Empty;
            int           tlen        = 0;
            int           clen        = 0;

            for (int i = 1; i <= totalPage; i++)
            {
                for (int n = (i - 1) * pageSize; n < i * pageSize; n++)
                {
                    strListItem.Append(ReplayListLable(tlen, clen, true, loopitem, dt.Rows[n]));
                }
                strList            = template.Replace(loopitemrule, strListItem.ToString());
                strList            = strList.Replace("{#page}", PageSeting.GetPageNumbers(i, totalPage, string.Format("{0}_{1}", path, 1), pageSize, "", "")); //分页
                strListItem.Length = 0;                                                                                                                        //清空stringbuilder 数据
                //创建静态页
            }
            return(strList);
        }
Esempio n. 2
0
        /// <summary>
        /// 内容页分页
        /// </summary>
        /// <param name="path">第一页生成路径</param>
        /// <param name="template">内容页模板</param>
        ///<param name="content">文章内容</param>
        ///<param name="tag">文章正文标签{#.content}</param>
        public virtual void ConvertPagingContent(string path, string template, string content, string tag)
        {
            string strPage = string.Empty;

            if (content.IndexOf("{#pagenext}") != -1)
            {
                string[] strContent = content.Split(new string[] { "{#pagenext}" }, StringSplitOptions.RemoveEmptyEntries);
                int      i          = 0;
                foreach (string str in strContent)
                {
                    i++;
                    strPage = template.Replace(tag, str);
                    strPage = strPage.Replace("{#page}", PageSeting.GetPageNumbers(i, strContent.Length, string.Format("{0}_{1}", path, i), 10, "", ""));//分页标签
                    tool.CreateHtml(content, path);
                }
            }
            else
            {
                strPage = template.Replace(tag, content);
                tool.CreateHtml(content, path);
            }
        }