/// <summary> /// 获取数据 /// </summary> /// <returns></returns> private List <Channel> GetClassList() { //获取记录条数 int row = TypeConvert.ToInt32(this.Row.Text); //构造Type,如1文章类型、2软件类型 string type = this.Type == null ? string.Empty : this.Type.Text; //构造WHERE语句 string strWhere = string.Empty; if (this.ChannelID != null) { string[] scList = this.ChannelID.Text.Split(','); if (scList.Length > 1) { string scSql = string.Format(" AND CID IN(", scList[0]); for (int i = 1; i < scList.Length; i++) { scSql += string.Format(",{0}", scList[i]); } scSql += ")"; strWhere += scSql; } else { strWhere = string.Format(" AND CID={0}", scList[0]); } } if (this.Level != null) { switch (this.Level.Text) { case "top": strWhere += " AND Level=1"; break; case "self": break; case "sub": break; default: break; } } ArcListBLL channelBll = new ArcListBLL(); List <Channel> channelList = channelBll.GetChannelList(row, type, strWhere); return(channelList); }
/// <summary> /// 获取数据 /// </summary> /// <returns></returns> private List <Archive> GetPageList() { //获取分页条数 int pageSize = TypeConvert.ToInt32(this.PageSize.Text); //栏目ID int channelID = TypeConvert.ToInt32(Utils.GetQueryString("ID")); //TypeConvert.ToInt32(CacheAccess.GetFromCache("ChannelID")); //当前页码 int pageIndex = TypeConvert.ToInt32(Utils.GetQueryString("page")); //TypeConvert.ToInt32(CacheAccess.GetFromCache("PageIndex")); //栏目类型 string channelType = Utils.GetQueryString("type"); //object obj = CacheAccess.GetFromCache("ChannelType"); //if (obj != null) //{ // channelType = obj.ToString(); //} ArcListBLL arcBll = new ArcListBLL(); List <Archive> arcList = arcBll.GetPageList(channelID, pageSize, pageIndex); return(arcList); }
/// <summary> /// 初始化当前页面模板数据 /// </summary> protected void InitPageTemplate() { #region 获取文档内容 //获取要生成的栏目ID archiveID = Utils.GetQueryInt("ID"); if (archiveID < 0) { Message.Dialog("生成错误,生成静态页的文档ID为空!", "-1", MessageIcon.Warning); } //获取栏目类型 channelType = Utils.GetQueryInt("type"); if (channelType < 0) { ArcListBLL arclistBll = new ArcListBLL(); Message.Dialog("生成错误,请选择要生成的文档类型!", "-1", MessageIcon.Warning); } //获取生成文档当前页数,默认为第一页 pageIndex = Utils.GetQueryInt("page"); if (pageIndex < 0) { pageIndex = 1; } ArcListBLL arcBll = new ArcListBLL(); List <Archive> archiveInfo = arcBll.GetArchiveInfo(archiveID, channelType); if (archiveInfo.Count > 0) { channelID = archiveInfo[0].ClassID; } else { return; } #endregion #region 获取当前位置 ArchiveField gobal = new ArchiveField(); //获取栏目当前位置 classUrl = this.__CLASSURL.Value; position = this.__POSITION.Value; relation = this.__RELATION.Value; if (classUrl.Length == 0 || relation.Length == 0) { Arc_ClassBLL classBll = new Arc_ClassBLL(); Arc_Class classInfo = classBll.GetModel(channelID); classUrl = this.__CLASSURL.Value = classInfo.ClassPath; 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 = gobal.Position = position; } #endregion #region 获取上一篇、下一篇链接 int count = archiveInfo.Count; for (int i = 1; i < count; i++) { if (archiveInfo[i] != null) { string temp = "<a href=\"" + archiveInfo[i].Url + "\">" + archiveInfo[i].Title + "</a>"; if (archiveInfo[i].ID < archiveID) { gobal.Prior = temp; } else { gobal.Next = temp; } } } #endregion #region 获取配置信息 SiteConfigInfo site = ConfigAccess.LoadConfig <SiteConfigInfo>("CFG_SITE"); #endregion this.Document.Variables.SetValue("field", archiveInfo[0]); this.Document.Variables.SetValue("gobal", gobal); this.Document.Variables.SetValue("site", site); }
/// <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); }
/// <summary> /// 获取数据 /// </summary> /// <returns></returns> private List <Archive_List> GetArcList() { //构造Limit语句 int firstRecort = 1; int lastRecort = 1; if (this.Limit != null) { string[] temp = this.Limit.Text.Split(','); try { int f = TypeConvert.ToInt32(temp[0]); int l = TypeConvert.ToInt32(temp[1]); if (f > l) { f = l; } if (f > 0) { firstRecort = f; lastRecort = l; } } catch { throw new ParserException("Limit属性必须由\"10,20\"这样的格式组成;并且结束条数必须大于开始条数,中间用半角逗号隔开。"); } } else { if (this.Row != null) { lastRecort = TypeConvert.ToInt32(this.Row.Text); } } //构造Type,如1文章类型、2软件类型 string type = this.Type == null ? "1" : this.Type.Text; //构造WHERE语句 string strWhere = string.Empty; if (this.TitleFlag != null) { strWhere += string.Format(" AND TitleFlag={0}", this.TitleFlag.Text); } if (this.ChannelID != null && this.ChannelID.Value.GetValue() != null) { if (this.SubChannel == null ? true : TypeConvert.ToBool(this.SubChannel.Text)) { //如果包含子栏目 //string[] scList = this.ChannelID.Value.GetValue().ToString().Split(','); string[] scList = this.ChannelID.GetTextValue().Split(','); if (scList.Length > 1) { string scSql = string.Format(" AND ClassID IN(SELECT CID FROM {{0}}Arc_Class WHERE Relation LIKE '%.{0}.%'", scList[0]); for (int i = 1; i < scList.Length; i++) { scSql += string.Format(" OR Relation LIKE '%.{0}.%'", scList[i]); } scSql += ")"; strWhere += scSql; } else { strWhere = string.Format(" AND ClassID IN(SELECT CID FROM {{0}}Arc_Class WHERE Relation LIKE '%.{0}.%')", scList[0]); } } else { strWhere += string.Format(" AND ClassID IN({0})", this.ChannelID.Text); } } if (this.KeyWord != null) { string[] kwList = this.KeyWord.Text.Split(','); if (kwList.Length > 1) { string kwSql = string.Format(" AND(A.KeyWords LIKE '%{0}%'", kwList[0]); for (int i = 1; i < kwList.Length; i++) { kwSql += string.Format(" OR A.KeyWords LIKE '%{0}%'", kwList[i]); } kwSql += ")"; strWhere += kwSql; } else { strWhere += string.Format(" AND A.KeyWords LIKE '%{0}%'", kwList[0]); } } if (this.InDay != null) { double inDay; bool rv = double.TryParse(this.InDay.Text, out inDay); if (rv && inDay > 0) { strWhere += string.Format(" AND PubDate>'{0}'", DateTime.Now.AddDays(-inDay).ToShortDateString()); } } //构造ORDER BY语句 string strOrder = string.Empty; if (this.OrderBy != null) { strOrder = string.Format(" ORDER BY {0}", this.OrderBy.Text); if (this.OrderType != null) { if (String.Compare(this.OrderType.Text, "ASC", StringComparison.OrdinalIgnoreCase) == 0) { strOrder += " ASC"; } else { strOrder += " DESC"; } } } ArcListBLL arcListBll = new ArcListBLL(); List <Archive_List> arcList = arcListBll.GetArcList(firstRecort, lastRecort, type, strWhere, strOrder); return(arcList); }