/// <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); }
/// <summary> /// 获取图片列表 /// </summary> /// <param name="page">第几页</param> /// <param name="attachMentDisplayName">附件名称</param> /// <returns></returns> private string ImageListToHtml(int pageCurrent, string attachMentDisplayName) { int totalcount = 0; int page = 10; string where = string.Empty; StringBuilder sb = new StringBuilder(); if (attachMentDisplayName != string.Empty) { where = string.Format("Attribute=1 and DisplayName like '%{0}%'", attachMentDisplayName); } else { where = "Attribute=1"; } DataTable dtImageList = bllAttachment.GetAttachmentList(pageCurrent, page, where, out totalcount); if (dtImageList != null && dtImageList.Rows.Count > 0) { int checkID = 1; sb.Append("<div id=\"content\">"); sb.Append("<ul>"); foreach (DataRow dr in dtImageList.Rows) { string chk_Id = "chk_" + checkID; string displayName = dr["DisplayName"].ToString().Split('.')[0]; sb.Append("<li>"); sb.Append("<dl>"); sb.Append("<dt>"); sb.Append("<a onclick=\"selectImage('" + chk_Id + "')\" href=\"javascript:void(0);\">"); if (dr["AbbrPhotoPath"].ToString() != string.Empty) { sb.Append("<img src=\"" + dr["AbbrPhotoPath"].ToString() + "\" alt=\"" + displayName + "\" />"); } else { sb.Append("<img src=\"" + dr["AttachMentPath"].ToString() + "\" alt=\"" + displayName + "\" />"); } sb.Append("</a>"); sb.Append("</dt>"); sb.Append("<dd>"); if (dr["AbbrPhotoPath"].ToString() != string.Empty) { sb.Append(" <input type=\"checkbox\" id=\"" + chk_Id + "\" name=\"items\" value=\"" + dr["AbbrPhotoPath"].ToString() + "\" />"); } else { sb.Append(" <input type=\"checkbox\" id=\"" + chk_Id + "\" name=\"items\" value=\"" + dr["AttachMentPath"].ToString() + "\" />"); } sb.Append("<label title=\"" + displayName + "\" for=\"" + chk_Id + "\">" + (displayName.Length > 9 ? displayName.Substring(0, 9) : displayName) + "</label>"); sb.Append("</dd>"); sb.Append("</dl>"); sb.Append("</li>"); checkID++; } sb.Append("</ul>"); sb.Append("</div>"); int pagecount = PageSeting.GetPageCount(totalcount, page); sb.Append("<div style=\"position:absolute;right:0;bottom:-3px;z-index:-1 \">"); sb.Append("<div class=\"grayr\" style=\"height:30px;line-height:30px;\">"); sb.Append(PageSeting.GetAjaxPage(pageCurrent, pagecount, "LoadData", page)); sb.Append("</div>"); sb.Append("</div>"); } return(sb.ToString()); }
private string AttachmentListToHtml(int pageCurrent, int attachMentType, string attachMentDisplayName) { int idnum = 1; int totalcount = 0; int page = 10; string where = string.Empty; StringBuilder sb = new StringBuilder(); if (attachMentDisplayName != string.Empty) { where = string.Format("Attribute={0} and DisplayName like '%{1}%'", attachMentType, attachMentDisplayName); } else { where = string.Format("Attribute={0}", attachMentType); } DataTable dtAttachMentList = bllAttachment.GetAttachmentList(pageCurrent, page, where, out totalcount); if (dtAttachMentList != null && dtAttachMentList.Rows.Count > 0) { sb.Append("<div id=\"content\">"); sb.Append("<table class=\"table_data\">"); sb.Append("<thead>"); sb.Append("<tr>"); sb.Append("<th>ID</th>"); sb.Append("<th>选择</th>"); sb.Append("<th>标题</th>"); sb.Append("<th>大小</th>"); sb.Append("<th>发布者</th>"); sb.Append("<th>发布时间</th>"); sb.Append("</tr>"); sb.Append("</thead>"); sb.Append("<tbody id=\"tab\">"); foreach (DataRow dr in dtAttachMentList.Rows) { string chk_id = "chk_" + idnum.ToString(); sb.Append("<tr onclick='selectImage(\"" + chk_id + "\")'>"); sb.Append("<td>" + idnum + "</td>"); sb.Append("<td><input type=\"checkbox\" id=\"" + chk_id + "\" value=\"" + dr["AttachMentPath"] + "\" name=\"items\" onclick='selectImage(\"" + chk_id + "\")' /> </td>"); sb.Append("<td>" + dr["DisplayName"].ToString() + "</td>"); sb.Append("<td>" + dr["AttachMentSize"].ToString() + "</td>"); sb.Append("<td>" + dr["PubLisher"] + "</td>"); sb.Append("<td>" + dr["AddDate"].ToString() + "</td>"); sb.Append("</tr>"); idnum++; } sb.Append("</tbody>"); sb.Append("</table>"); sb.Append("</div>"); int pagecount = PageSeting.GetPageCount(totalcount, page); sb.Append("<div style=\"position:absolute;right:0px;bottom:-3px;z-index:-1; \">"); sb.Append("<div class=\"grayr\" style=\"height:30px;line-height:30px;\">"); sb.Append(PageSeting.GetAjaxPage(pageCurrent, pagecount, "LoadData", page)); sb.Append("</div>"); sb.Append("</div>"); } return(sb.ToString()); }
/// <summary> /// 初始化当前页面模板数据 /// </summary> protected void InitPageTemplate() { //获取要生成的栏目ID channelID = Utils.GetQueryInt("ID"); if (channelID < 0) { Message.Dialog("生成错误,生成静态页的栏目ID为空!", "-1", MessageIcon.Warning); } //获取栏目类型 channelType = Utils.GetQueryString("type"); if (channelType.Length == 0) { ArcListBLL arclistBll = new ArcListBLL(); channelType = arclistBll.GetChannelType(channelID); } //获取记录总数 totalRecord = Utils.GetQueryInt("total"); if (totalRecord < 0) { ArcListBLL arclistBll = new ArcListBLL(); totalRecord = arclistBll.GetArcCount(channelID, channelType); } //获取生成栏目当前页数 pageIndex = Utils.GetQueryInt("page"); if (pageIndex < 0) { Message.Dialog("生成错误,生成静态页的当前页数为空!", "-1", MessageIcon.Warning); } //获取分页大小 pageSize = Utils.GetQueryInt("size"); //获取分页选项 pageItem = this.__PAGEITEM.Value; if (pageSize < 0 || pageItem.Length == 0) { //分页大小和分页选项从PageList标签中获取 ElementCollection <Tag> tags = this.Document.GetChildTagsByTagName("PageList"); foreach (Tag tag in tags) { pageSize = TypeConvert.ToInt32(tag.Attributes["PageSize"].Value); pageItem = tag.Attributes["Item"].Value.ToString(); } this.__PAGEITEM.Value = pageItem; } //获取栏目当前位置 classUrl = this.__CLASSURL.Value; listTemplet = this.__LISTTEMPLET.Value; indexRule = this.__INDEXRULE.Value; position = this.__POSITION.Value; relation = this.__RELATION.Value; if (classUrl.Length == 0 || listTemplet.Length == 0 || indexRule.Length == 0 || relation.Length == 0) { Arc_ClassBLL classBll = new Arc_ClassBLL(); Arc_Class classInfo = classBll.GetModel(channelID); classUrl = this.__CLASSURL.Value = classInfo.ClassPath; listTemplet = this.__LISTTEMPLET.Value = classInfo.ListTemplet; indexRule = this.__INDEXRULE.Value = classInfo.IndexRule; relation = this.__RELATION.Value = classInfo.Relation.TrimEnd('.').Replace('.', ','); } if (position.Length == 0) { Arc_ClassBLL classBll = new Arc_ClassBLL(); DataTable dt = classBll.GetThisPlace(relation); position += "<a href=\"/\">首页</a> » "; for (int i = 0; i < dt.Rows.Count; i++) { position += "<a href=\"" + dt.Rows[i]["ClassEName"] + "\">" + dt.Rows[i]["ClassName"] + "</a>"; if (i + 1 < dt.Rows.Count) { position += " » "; } } this.__POSITION.Value = position; } //设置自定义属性 PageListField field = new PageListField(); field.CurrentPage = pageIndex; field.TotalPage = PageSeting.GetPageCount(totalRecord, pageSize); field.TotalRecord = totalRecord; field.PageIndex = PageSeting.GetPageNum(pageIndex, field.TotalPage, 10, "createlist.aspx?id=10&page={0}", pageItem); field.Position = position; //gobal.PageIndex = gobal.PageIndex.Replace(string.Format("list/{0}/1/", channelID), "index.html"); this.Document.Variables.SetValue("field", field); }