/// <summary> /// 处理栏目列表页分页标签PageContents /// </summary> /// <param name="filePath"></param> /// <param name="pageInfo"></param> /// <param name="stlLabelList"></param> /// <param name="pageContentsElementParser"></param> /// <param name="contentBuilder"></param> /// <param name="stlElementTranslated"></param> /// <param name="totalNum"></param> /// <param name="pageCount"></param> private void PageContentsDetail(string filePath, PageInfo pageInfo, List <string> stlLabelList, StlPageContents pageContentsElementParser, StringBuilder contentBuilder, string stlElementTranslated, int totalNum, int pageCount, int currentPageIndex) { var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null); var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex); thePageInfo.AddLastPageScript(pageInfo); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); thePageInfo.ClearLastPageScript(pageInfo); pageInfo.ClearLastPageScript(); }
private static async Task CreateChannelAsync(int siteId, int channelId) { var siteInfo = SiteManager.GetSiteInfo(siteId); var nodeInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (nodeInfo == null) { return; } if (!string.IsNullOrEmpty(nodeInfo.LinkUrl)) { return; } if (!ELinkTypeUtils.IsCreatable(nodeInfo)) { return; } var templateInfo = channelId == siteId ? TemplateManager.GetIndexPageTemplateInfo(siteId) : TemplateManager.GetChannelTemplateInfo(siteId, channelId); var filePath = PathUtility.GetChannelPageFilePath(siteInfo, channelId, 0); var pageInfo = new PageInfo(channelId, 0, siteInfo, templateInfo); var contextInfo = new ContextInfo(pageInfo) { ContextType = EContextType.Channel }; var contentBuilder = new StringBuilder(TemplateManager.GetTemplateContent(siteInfo, templateInfo)); var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString()); var stlPageContentElement = string.Empty; foreach (var label in stlLabelList) { if (!StlParserUtility.IsStlChannelElement(label, ChannelAttribute.PageContent)) { continue; } stlPageContentElement = label; break; } //如果标签中存在<stl:channel type="PageContent"></stl:channel> if (!string.IsNullOrEmpty(stlPageContentElement))//内容存在 { var innerBuilder = new StringBuilder(stlPageContentElement); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); var contentAttributeHtml = innerBuilder.ToString(); var pageCount = StringUtils.GetCount(ContentUtility.PagePlaceHolder, contentAttributeHtml) + 1;//一共需要的页数 Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageChannelId, pageInfo.PageContentId, pageInfo.SiteInfo, pageInfo.TemplateInfo); var index = contentAttributeHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal); var length = index == -1 ? contentAttributeHtml.Length : index; var pagedContentAttributeHtml = contentAttributeHtml.Substring(0, length); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentElement, pagedContentAttributeHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, 0); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); if (index != -1) { contentAttributeHtml = contentAttributeHtml.Substring(length + ContentUtility.PagePlaceHolder.Length); } } } //如果标签中存在<stl:pageContents> else if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList); var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); var pageContentsElementParser = new StlPageContents(stlElement, pageInfo, contextInfo, false); int totalNum; var pageCount = pageContentsElementParser.GetPageCount(out totalNum); Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageChannelId, pageInfo.PageContentId, pageInfo.SiteInfo, pageInfo.TemplateInfo); var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); thePageInfo.AddLastPageScript(pageInfo); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); thePageInfo.ClearLastPageScript(pageInfo); pageInfo.ClearLastPageScript(); } } //如果标签中存在<stl:pageChannels> else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlLabelList); var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); var pageChannelsElementParser = new StlPageChannels(stlElement, pageInfo, contextInfo, false); int totalNum; var pageCount = pageChannelsElementParser.GetPageCount(out totalNum); Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageChannelId, pageInfo.PageContentId, pageInfo.SiteInfo, pageInfo.TemplateInfo); var pageHtml = pageChannelsElementParser.Parse(currentPageIndex, pageCount); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); } } //如果标签中存在<stl:pageSqlContents> else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList); var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); var pageSqlContentsElementParser = new StlPageSqlContents(stlElement, pageInfo, contextInfo, false); int totalNum; var pageCount = pageSqlContentsElementParser.GetPageCount(out totalNum); Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageChannelId, pageInfo.PageContentId, pageInfo.SiteInfo, pageInfo.TemplateInfo); var pageHtml = pageSqlContentsElementParser.Parse(currentPageIndex, pageCount); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); } } //如果标签中存在<stl:StlPageInputContents> //else if (StlParserUtility.IsStlElementExists(StlPageInputContents.ElementName, stlLabelList)) //{ // var stlElement = StlParserUtility.GetStlElement(StlPageInputContents.ElementName, stlLabelList); // var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); // var pageInputContentsElementParser = new StlPageInputContents(stlElement, pageInfo, contextInfo, true); // int totalNum; // var pageCount = pageInputContentsElementParser.GetPageCount(out totalNum); // Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, filePath, false); // for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) // { // var thePageInfo = new PageInfo(pageInfo.PageChannelId, pageInfo.PageContentId, pageInfo.SiteInfo, pageInfo.TemplateInfo, null); // var pageHtml = pageInputContentsElementParser.Parse(currentPageIndex, pageCount); // var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); // StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum); // filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); // GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); // } //} else { Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, filePath, false); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, contentBuilder); } }
//public void CreateIndex() //{ // var templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, 0, ETemplateType.IndexPageTemplate); // if (templateInfo == null) return; // var pageInfo = new PageInfo(PublishmentSystemId, 0, PublishmentSystemInfo, templateInfo, null); // var contextInfo = new ContextInfo(pageInfo); // var filePath = PathUtility.GetIndexPageFilePath(PublishmentSystemInfo, templateInfo.CreatedFileFullName, IsHeadquarters); // var contentBuilder = new StringBuilder(StlCacheManager.FileContent.GetTemplateContent(PublishmentSystemInfo, templateInfo)); // StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false); // GenerateFile(filePath, pageInfo.TemplateInfo.Charset, contentBuilder); //} public void CreateChannel(int nodeId) { var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId); if (nodeInfo == null) { return; } //if (nodeId == PublishmentSystemId) //{ // CreateIndex(); // return; //} if (!string.IsNullOrEmpty(nodeInfo.LinkUrl)) { return; } if (!ELinkTypeUtils.IsCreatable(nodeInfo)) { return; } var templateInfo = nodeId == PublishmentSystemId?TemplateManager.GetTemplateInfo(PublishmentSystemId, 0, ETemplateType.IndexPageTemplate) : TemplateManager.GetTemplateInfo(PublishmentSystemId, nodeId, ETemplateType.ChannelTemplate); var filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, nodeId, 0); var pageInfo = new PageInfo(nodeId, 0, PublishmentSystemInfo, templateInfo, null); var contextInfo = new ContextInfo(pageInfo); var contentBuilder = new StringBuilder(StlCacheManager.FileContent.GetTemplateContent(PublishmentSystemInfo, templateInfo)); var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString()); var stlPageContentElement = string.Empty; foreach (var label in stlLabelList) { if (!StlParserUtility.IsStlChannelElement(label, NodeAttribute.PageContent)) { continue; } stlPageContentElement = label; break; } //如果标签中存在<stl:channel type="PageContent"></stl:channel> if (!string.IsNullOrEmpty(stlPageContentElement))//内容存在 { var innerBuilder = new StringBuilder(stlPageContentElement); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); var contentAttributeHtml = innerBuilder.ToString(); var pageCount = StringUtils.GetCount(ContentUtility.PagePlaceHolder, contentAttributeHtml) + 1;//一共需要的页数 StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null); var index = contentAttributeHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal); var length = index == -1 ? contentAttributeHtml.Length : index; var pagedContentAttributeHtml = contentAttributeHtml.Substring(0, length); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentElement, pagedContentAttributeHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, 0); filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); if (index != -1) { contentAttributeHtml = contentAttributeHtml.Substring(length + ContentUtility.PagePlaceHolder.Length); } } } //如果标签中存在<stl:pageContents> else if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList); var stlElementTranslated = StlPageContents.Translate(stlElement); var pageContentsElementParser = new StlPageContents(stlElement, pageInfo, contextInfo, false); int totalNum; var pageCount = pageContentsElementParser.GetPageCount(out totalNum); StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null); var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex); thePageInfo.AddLastPageScript(pageInfo); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); thePageInfo.ClearLastPageScript(pageInfo); pageInfo.ClearLastPageScript(); } } //如果标签中存在<stl:pageChannels> else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlLabelList); var stlElementTranslated = StlPageChannels.Translate(stlElement); var pageChannelsElementParser = new StlPageChannels(stlElement, pageInfo, contextInfo, false); int totalNum; var pageCount = pageChannelsElementParser.GetPageCount(out totalNum); StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null); var pageHtml = pageChannelsElementParser.Parse(currentPageIndex, pageCount); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); } } //如果标签中存在<stl:pageSqlContents> else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList); var stlElementTranslated = StlPageSqlContents.Translate(stlElement); var pageSqlContentsElementParser = new StlPageSqlContents(stlElement, pageInfo, contextInfo, false); int totalNum; var pageCount = pageSqlContentsElementParser.GetPageCount(out totalNum); StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null); var pageHtml = pageSqlContentsElementParser.Parse(currentPageIndex, pageCount); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); } } //如果标签中存在<stl:StlPageInputContents> else if (StlParserUtility.IsStlElementExists(StlPageInputContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageInputContents.ElementName, stlLabelList); var stlElementTranslated = StlPageInputContents.Translate(stlElement); var pageInputContentsElementParser = new StlPageInputContents(stlElement, pageInfo, contextInfo, true); int totalNum; var pageCount = pageInputContentsElementParser.GetPageCount(out totalNum); StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null); var pageHtml = pageInputContentsElementParser.Parse(currentPageIndex, pageCount); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); } } else { StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, contentBuilder); } }
private static async Task CreateChannelAsync(int siteId, int channelId) { var siteInfo = SiteManager.GetSiteInfo(siteId); var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (!ChannelManager.IsCreatable(siteInfo, channelInfo)) { return; } var templateInfo = channelId == siteId ? TemplateManager.GetIndexPageTemplateInfo(siteId) : TemplateManager.GetChannelTemplateInfo(siteId, channelId); var filePath = PathUtility.GetChannelPageFilePath(siteInfo, channelId, 0); var pageInfo = new PageInfo(channelId, 0, siteInfo, templateInfo, new Dictionary <string, object>()); var contextInfo = new ContextInfo(pageInfo) { ContextType = EContextType.Channel }; var contentBuilder = new StringBuilder(TemplateManager.GetTemplateContent(siteInfo, templateInfo)); var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString()); //如果标签中存在<stl:channel type="PageContent"></stl:channel> if (StlParserUtility.IsStlChannelElementWithTypePageContent(stlLabelList)) //内容存在 { var stlElement = StlParserUtility.GetStlChannelElementWithTypePageContent(stlLabelList); var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); contentBuilder.Replace(stlElement, stlElementTranslated); var innerBuilder = new StringBuilder(stlElement); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); var pageContentHtml = innerBuilder.ToString(); var pageCount = StringUtils.GetCount(ContentUtility.PagePlaceHolder, pageContentHtml) + 1; //一共需要的页数 Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = pageInfo.Clone(); var index = pageContentHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal); var length = index == -1 ? pageContentHtml.Length : index; var pageHtml = pageContentHtml.Substring(0, length); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, 0); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); if (index != -1) { pageContentHtml = pageContentHtml.Substring(length + ContentUtility.PagePlaceHolder.Length); } } } //如果标签中存在<stl:pageContents> else if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList); var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); var pageContentsElementParser = new StlPageContents(stlElement, pageInfo, contextInfo); var pageCount = pageContentsElementParser.GetPageCount(out var totalNum); pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery); Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = pageInfo.Clone(); var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); thePageInfo.AddLastPageScript(pageInfo); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); thePageInfo.ClearLastPageScript(pageInfo); pageInfo.ClearLastPageScript(); } } //如果标签中存在<stl:pageChannels> else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlLabelList); var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); var pageChannelsElementParser = new StlPageChannels(stlElement, pageInfo, contextInfo); var pageCount = pageChannelsElementParser.GetPageCount(out var totalNum); pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery); Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = pageInfo.Clone(); var pageHtml = pageChannelsElementParser.Parse(currentPageIndex, pageCount); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); } } //如果标签中存在<stl:pageSqlContents> else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList); var stlElementTranslated = StlParserManager.StlEncrypt(stlElement); var pageSqlContentsElementParser = new StlPageSqlContents(stlElement, pageInfo, contextInfo); var pageCount = pageSqlContentsElementParser.GetPageCount(out var totalNum); pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery); Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { var thePageInfo = pageInfo.Clone(); var pageHtml = pageSqlContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml)); StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum); filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId, currentPageIndex); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder); } } else { Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false); await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, contentBuilder); } }