Ejemplo n.º 1
0
 public void SetDynamicPagerDependency(string alia, PagerTag tag)
 {
     if (IsTopContainer() == false && this.Caller != null)
     {
         Caller.SetDynamicPagerDependency(alia, tag);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///  转化为分页标签
        /// </summary>
        public static PagerTag Parse(TagBase tag)
        {
            PagerTag pager = new PagerTag(tag.OuterDefineText);

            pager.InheriteFromBase(tag);
            return(pager);
        }
Ejemplo n.º 3
0
 public void SetDynamicPagerDependency(string alia, PagerTag tag)
 {
     if (PagerDic.ContainsKey(alia))
     {
         PagerDic[alia] = tag;
     }
     else
     {
         PagerDic.Add(alia, tag);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 解析包含标签的文本内容
        /// </summary>
        /// <param name="TxtContent">包含标签的文本内容</param>
        /// <param name="res">说依赖的相关资源对象</param>
        public static string InterpretContentWithTags(string TxtContent, IResourceDependency res)
        {
            if (!TxtContent.StartsWith("{#"))
            {
                TxtContent = "#}" + TxtContent + "{#";
            }

            PagerTag txtTag = new PagerTag();

            PagerTag.FilledInTagList(TxtContent, txtTag.tagList, res);
            txtTag.AlwaysShow = true;
            return(txtTag.ToString());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取标签的最终输出值
        /// </summary>
        public override object GetTagValue()
        {
            if (this.IsExist == true)
            {
                //OleDbHelper.AppendToFile("~/debug.log", this.Category.ToString() + Environment.NewLine + Environment.NewLine);
                //OleDbHelper.AppendToFile("~/debug.log", this.OuterDefineText + Environment.NewLine + Environment.NewLine);
                //OleDbHelper.AppendToFile("~/debug.log", this.Content + Environment.NewLine + Environment.NewLine);

                if (!ContainTags())
                {
                    return(this.GetHtmlOutPut());
                }
                else
                {
                    TagBase tag = new TagBase(this.Content);
                    if (tag.Category == TagCategory.DataListTag)
                    {
                        ListTag list = ListTag.Parse(tag, this.GetResourceDependency());
                        if (list.PageSize > 0)
                        {
                            string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? Guid.NewGuid().ToString() : list.IDentity;
                            SetDynamicPagedAlia(pagedAliaContent, list);
                            return(pagedAliaContent);
                        }
                        else
                        {
                            return(list.GetTagValue());
                        }
                    }
                    else if (tag.Category == TagCategory.PagerTag)
                    {
                        PagerTag pager     = PagerTag.Parse(tag);
                        string   pagerAlia = (string.IsNullOrEmpty(pager.IDentity)) ? Guid.NewGuid().ToString() : pager.IDentity;
                        SetDynamicPagerDependency(pagerAlia, pager);
                        return(pagerAlia);
                    }
                    else
                    {
                        //Util.Debug(false, GetResourceDependency());
                        return(TagBase.InterpretContentWithTags(GetHtmlOutPut(), GetResourceDependency()));
                    }
                }
            }
            else
            {
                //OleDbHelper.AppendToFile("~/debug.log", "NULL:" + this.OuterDefineText + Environment.NewLine + Environment.NewLine);
                return(null);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 生成网站栏目/频道静态文件
        /// </summary>
        /// <param name="aWebChannel">指定了ChannelID的实体</param>
        public void Generate(AccessWebChannel aWebChannel, ChannelGeneratorOptions options)
        {
            if (aWebChannel.IsFilled == false)
            {
                aWebChannel = (new AccessWebChannel()).GetInstanceById(aWebChannel.ChannelID) as AccessWebChannel;
            }

            if (aWebChannel != null && aWebChannel.IsExist == true && aWebChannel.IsFilled == true)
            {
                if (aWebChannel.StaticFileGenDir.IndexOf("/") == -1)
                {
                    ShowMessage("生成文件目录设置有错误,系统终止!");
                    return;
                }

                TempletSetting tptConfig = aWebChannel.TempletConfig;
                if (tptConfig == null)
                {
                    ShowMessage("该频道没有配置模板,不能生成相关文件!");
                }
                else
                {
                    string strGenFilePath, strFileName, strFileExt, strGenResult = "";
                    if (aWebChannel.StaticFileGenDir.IndexOf("{#$ChannelID$#}") != -1)
                    {
                        aWebChannel.StaticFileGenDir = aWebChannel.StaticFileGenDir.Replace("{#$ChannelID$#}", aWebChannel.ChannelID.ToString());
                    }
                    strGenFilePath = Util.ParseAppPath(aWebChannel.StaticFileGenDir);
                    //ShowMessage(strGenFilePath);
                    if (!strGenFilePath.EndsWith("\\"))
                    {
                        strGenFilePath += "\\";
                    }

                    //最终页面内容
                    string strGenFileContent = "";
                    string trackPath         = "";

                    this.UTCDateBegin = DateTime.Now.ToUniversalTime();

                    if (options != null && options.GenerateSinglePage == false)
                    {
                        ShowMessage("* 已禁止单页综合内容页生成!");
                    }
                    else
                    {
                        #region 单页综合生成
                        if (tptConfig.GenerateSinglePage == true)
                        {
                            strFileName = tptConfig.MixedSingleTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();
                            strFileExt  = tptConfig.MixedSingleTemplet.FileNameConfig.FileExtentionName;

                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.MixedSingleTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    if (!pageTpt.SiteBaseDir.EndsWith("/"))
                                    {
                                        pageTpt.SiteBaseDir += "/";
                                    }
                                    strGenResult = OleDbHelper.SetTextFileContent(strGenFilePath + strFileName + strFileExt,
                                                                                  "utf-8",
                                                                                  HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(strGenFilePath + strFileName + strFileExt);
                                    }
                                }
                                else
                                {
                                    TempletParse tpp = new TempletParse();
                                    tpp.Caller = this;
                                    tpp.SetResourceDependency(aWebChannel);
                                    tpp.TagTrack = new System.Collections.Generic.Dictionary <string, string>();
                                    tpp.TagTrack.Add("T" + pageTpt.TempletID.ToString(), pageTpt.ModifiedTime.ToString("yyyyMMddHHmmss"));
                                    tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                                    strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, tpp.ParsedResult);
                                    //插入Track代码
                                    trackPath = GetSiteRelativeUrl(strGenFilePath + strFileName + strFileExt);
                                    GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);

                                    strGenResult = OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(trackPath);
                                    }
                                }

                                if (strGenResult == "0")
                                {
                                    TrackUnit.RemoveUpdateRecord(0, trackPath);
                                    ShowMessage(string.Format("单页内容生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", GetSiteRelativeUrl(strGenFilePath + strFileName + strFileExt)));
                                }
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                        }
                        #endregion
                    }

                    if (options != null && options.GenerateListPage == false)
                    {
                        ShowMessage("* 已禁止列表页生成!");
                    }
                    else
                    {
                        #region 列表页面生成
                        if (tptConfig.GenerateListPage == true)
                        {
                            strFileExt = tptConfig.ListPageTemplet.FileNameConfig.FileExtentionName;
                            tptConfig.ListPageTemplet.FileNameConfig.FileNameTag.SetResourceDependency(aWebChannel);
                            strFileName = tptConfig.ListPageTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();

                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.ListPageTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                strGenResult = "";
                                #region 根据模板内的列表动态生成多个页
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    if (!pageTpt.SiteBaseDir.EndsWith("/"))
                                    {
                                        pageTpt.SiteBaseDir += "/";
                                    }
                                    strGenResult = OleDbHelper.SetTextFileContent(strGenFilePath + strFileName + strFileExt,
                                                                                  "utf-8",
                                                                                  HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(strGenFilePath + strFileName + strFileExt);
                                        ShowMessage(string.Format("文件生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", GetSiteRelativeUrl(strGenFilePath + strFileName + strFileExt)));
                                    }
                                }
                                else
                                {
                                    string       realContent = "", myPageHtml = "";
                                    TempletParse tpp = new TempletParse();

                                    //获取要分页变化的模块内容(含Pager)
                                    //替换分页变化的内容 + 生成多页

                                    tpp.Caller = this;
                                    tpp.SetResourceDependency(aWebChannel);

                                    tpp.TagTrack = new System.Collections.Generic.Dictionary <string, string>();
                                    tpp.TagTrack.Add("T" + pageTpt.TempletID.ToString(), pageTpt.ModifiedTime.ToString("yyyyMMddHHmmss"));
                                    tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                                    if (this.PagedObject == null)
                                    {
                                        myPageHtml = tpp.ParsedResult;
                                        //处理分页导航内容
                                        if (this.PagerDic.Count > 0)
                                        {
                                            foreach (string pagerKey in PagerDic.Keys)
                                            {
                                                myPageHtml = myPageHtml.Replace(pagerKey, "");
                                            }
                                        }

                                        strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml);
                                        //插入Track代码
                                        trackPath = GetSiteRelativeUrl(strGenFilePath + TagBase.TrimTagDefine(strFileName, '_', '-') + strFileExt);
                                        GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);
                                        strGenResult = OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);
                                        if (strGenResult == "0")
                                        {
                                            FireGeneratorFileFinished(trackPath);
                                        }
                                        TrackUnit.RemoveUpdateRecord(0, trackPath);
                                    }
                                    else
                                    {
                                        string dynTpt = tpp.ParsedResult;
                                        PagedObject.SetResourceDependency(aWebChannel);
                                        while (PagedObject.CurrentPageIndex <= PagedObject.GetPageCount())
                                        {
                                            #region 处理分页内容
                                            realContent = PagedObject.GetCurrentPageContent();
                                            //处理当前页内容
                                            myPageHtml = dynTpt.Replace(PagedContentAlia, realContent);

                                            //处理分页导航内容
                                            if (this.PagerDic.Count > 0)
                                            {
                                                foreach (string pagerKey in PagerDic.Keys)
                                                {
                                                    PagerTag Pager = PagerDic[pagerKey];
                                                    Pager.TotalRecordCount  = PagedObject.GetTotalRecordCount();
                                                    Pager.CurrentPage       = PagedObject.CurrentPageIndex;
                                                    Pager.StartIndex        = PagedObject.StartIndex;
                                                    Pager.EndIndex          = PagedObject.EndIndex;
                                                    Pager.PageSize          = PagedObject.PageSize;
                                                    Pager.DefaultPageFormat = aWebChannel.StaticFileGenDir + strFileName.Replace("{#$CIDX$#}", "{0}") + strFileExt;

                                                    //Util.Debug(false, Pager.ToString());
                                                    myPageHtml = myPageHtml.Replace(pagerKey, Pager.ToString());
                                                    //Util.Debug(false, this.PagerDic[pagerKey].OuterDefineText);
                                                }
                                            }
                                            int    currentPage     = PagedObject.CurrentPageIndex;
                                            string currentFileName = strFileName.Replace("{#$CIDX$#}", currentPage.ToString());

                                            strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml);
                                            //插入Track代码
                                            trackPath = GetSiteRelativeUrl(strGenFilePath + currentFileName + strFileExt);
                                            GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);
                                            strGenResult = OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);
                                            //清除更新请求
                                            TrackUnit.RemoveUpdateRecord(0, trackPath);

                                            if (strGenResult == "0")
                                            {
                                                FireGeneratorFileFinished(trackPath);
                                                ShowMessage(string.Format("列表页文件生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", trackPath));
                                            }

                                            if (currentPage == 1)
                                            {
                                                trackPath = strGenFilePath + currentFileName.Trim('1', '-', '_') + strFileExt;
                                                OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);
                                                FireGeneratorFileFinished(trackPath);
                                                TrackUnit.RemoveUpdateRecord(0, trackPath);
                                            }
                                            PagedObject.MoveNextPage();
                                            #endregion
                                        }
                                    }
                                    tpp.Dispose();
                                }
                                #endregion
                                if (strGenResult == "0")
                                {
                                    ShowMessage("列表页内容生成成功完成。");
                                }
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                        }
                        #endregion
                    }

                    if (options != null && options.GenerateDetailPage == false)
                    {
                        ShowMessage("* 已禁止详细内容页生成!");
                    }
                    else
                    {
                        #region 详细页面生成
                        if (tptConfig.GenerateDetailPage == true)
                        {
                            strFileExt = tptConfig.DetailPageTemplet.FileNameConfig.FileExtentionName;
                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.DetailPageTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    strFileName = tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();
                                    if (!pageTpt.SiteBaseDir.EndsWith("/"))
                                    {
                                        pageTpt.SiteBaseDir += "/";
                                    }
                                    strGenResult = OleDbHelper.SetTextFileContent(strGenFilePath + strFileName + strFileExt,
                                                                                  "utf-8",
                                                                                  HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(strGenFilePath + strFileName + strFileExt);
                                    }
                                }
                                else
                                {
                                    TempletParse tpp = new TempletParse();
                                    OleDbHelper  hp  = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey);

                                    DataTable dTab = hp.GetDataTable(string.Format("select * from Tbl_Articles where Pubed=True and Archived=false and TypeID={0} order by Sort asc,NewsID desc",
                                                                                   aWebChannel.ChannelID));

                                    if (dTab != null && dTab.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dTab.Rows.Count; i++)
                                        {
                                            AccessWebNews news = AccessWebNews.LoadFromDataRow(dTab.Rows[i]);
                                            tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.SetResourceDependency(news);
                                            strFileName = tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();

                                            MultiResDependency newsRes = new MultiResDependency(aWebChannel, news);
                                            tpp.SetResourceDependency(newsRes);
                                            tpp.TagTrack = new System.Collections.Generic.Dictionary <string, string>();
                                            tpp.TagTrack.Add("T" + pageTpt.TempletID.ToString(), pageTpt.ModifiedTime.ToString("yyyyMMddHHmmss"));
                                            tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                                            string newsfileWithFullPath = strGenFilePath + strFileName + strFileExt;
                                            if (news.VirtualPath.Length > 5)
                                            {
                                                newsfileWithFullPath = Util.ParseAppPath(news.VirtualPath);
                                            }
                                            else
                                            {
                                                news.VirtualPath = aWebChannel.StaticFileGenDir + strFileName + strFileExt;
                                                news.RefreshVirtualPath();
                                            }

                                            strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, tpp.ParsedResult);
                                            //插入Track代码
                                            trackPath = GetSiteRelativeUrl(newsfileWithFullPath);
                                            GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);

                                            strGenResult = OleDbHelper.SetTextFileContent(newsfileWithFullPath, "utf-8", strGenFileContent);
                                            if (strGenResult == "0")
                                            {
                                                TrackUnit.RemoveUpdateRecord(0, trackPath);
                                                FireGeneratorFileFinished(trackPath);
                                                ShowMessage(string.Format("内容页文件生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", trackPath));
                                            }
                                        }
                                    }

                                    tpp.Dispose();
                                }

                                if (strGenResult == "0")
                                {
                                    ShowMessage("详细页面内容生成成功完成。");
                                }
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                        }
                        #endregion
                    }
                }

                ShowMessage("已完成所有处理,如没有任何消息显示,这可能是该栏目没有内容或配置错误!");
                ShowMessage("$end$");
            }
        }
Ejemplo n.º 7
0
 public void SetDynamicPagerDependency(string alia, PagerTag tag)
 {
     if (PagerDic.ContainsKey(alia))
     {
         PagerDic[alia] = tag;
     }
     else
     {
         PagerDic.Add(alia, tag);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 ///  转化为分页标签
 /// </summary>
 public static PagerTag Parse(TagBase tag)
 {
     PagerTag pager = new PagerTag(tag.OuterDefineText);
     pager.InheriteFromBase(tag);
     return pager;
 }
Ejemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest Request = context.Request;

            if (Util.IsNumerical(Request.QueryString["ChannelID"]))
            {
                AccessWebChannel aWebChannel = new AccessWebChannel(Int32.Parse(Request.QueryString["ChannelID"]));
                if (aWebChannel.IsFilled == false)
                {
                    aWebChannel = (new AccessWebChannel()).GetInstanceById(aWebChannel.ChannelID) as AccessWebChannel;
                }

                if (aWebChannel != null && aWebChannel.IsExist == true && aWebChannel.IsFilled == true)
                {
                    TempletSetting tptConfig = aWebChannel.TempletConfig;
                    if (tptConfig == null)
                    {
                        ShowMessage("该频道没有配置模板,不能动态显示相关内容!");
                        return;
                    }

                    if (Request.QueryString["Action"] == "list")
                    {
                        if (tptConfig.GenerateListPage == true)
                        {
                            #region 列表页面生成
                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.ListPageTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                #region 根据模板内的列表动态显示当前页内容
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    DisplayContent(HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));
                                    return;
                                }
                                else
                                {
                                    string       realContent = "", myPageHtml = "";
                                    TempletParse tpp = new TempletParse();

                                    tpp.Caller = this;
                                    tpp.SetResourceDependency(aWebChannel);
                                    tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                                    if (this.PagedObject == null)
                                    {
                                        myPageHtml = tpp.ParsedResult;
                                        //处理分页导航内容
                                        if (this.PagerDic.Count > 0)
                                        {
                                            foreach (string pagerKey in PagerDic.Keys)
                                            {
                                                myPageHtml = myPageHtml.Replace(pagerKey, "");
                                            }
                                        }
                                        DisplayContent(HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml));
                                    }
                                    else
                                    {
                                        string dynTpt           = tpp.ParsedResult;
                                        string currentPageMatch = "";
                                        PagedObject.SetResourceDependency(aWebChannel);
                                        if (Request.QueryString["Page"] != null && Util.IsMatch(@"^(\d+)$", Request.QueryString["Page"], 1, 1, PagedObject.GetPageCount(), out currentPageMatch))
                                        {
                                            PagedObject.CurrentPageIndex = int.Parse(Request.QueryString["Page"]);
                                        }
                                        else
                                        {
                                            PagedObject.CurrentPageIndex = 1;
                                        }

                                        #region 显示分页内容
                                        realContent = PagedObject.GetCurrentPageContent();
                                        //处理当前页内容
                                        myPageHtml = dynTpt.Replace(PagedContentAlia, realContent);

                                        //处理分页导航内容
                                        if (this.PagerDic.Count > 0)
                                        {
                                            foreach (string pagerKey in PagerDic.Keys)
                                            {
                                                PagerTag Pager = PagerDic[pagerKey];
                                                Pager.TotalRecordCount = PagedObject.GetTotalRecordCount();
                                                Pager.CurrentPage      = PagedObject.CurrentPageIndex;
                                                Pager.StartIndex       = PagedObject.StartIndex;
                                                Pager.EndIndex         = PagedObject.EndIndex;
                                                Pager.PageSize         = PagedObject.PageSize;

                                                Pager.DefaultPageFormat = Request.ServerVariables["SCRIPT_NAME"] + "?ChannelID=" + aWebChannel.ChannelID.ToString() + "&action=list&Page={0}";
                                                myPageHtml = myPageHtml.Replace(pagerKey, Pager.ToString());
                                            }
                                        }
                                        DisplayContent(HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml));
                                        #endregion
                                    }
                                    tpp.Dispose();
                                }
                                #endregion
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                            #endregion
                        }
                        else
                        {
                            ShowMessage("没有可以直接查看的分页内容!");
                        }
                    }
                    else
                    {
                        if (tptConfig.GenerateSinglePage == true)
                        {
                            #region 单页综合生成
                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.MixedSingleTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    DisplayContent(HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));
                                }
                                else
                                {
                                    TempletParse tpp = new TempletParse();
                                    tpp.Caller = this;
                                    tpp.SetResourceDependency(aWebChannel);
                                    tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);
                                    DisplayContent(HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, tpp.ParsedResult));
                                }
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                            #endregion
                        }
                        else
                        {
                            ShowMessage("没有可以直接查看的单页综合内容!");
                        }
                    }
                }
                else
                {
                    ShowMessage("频道资料无效!");
                }
            }
            else
            {
                //根据ID找到频道、 应用频道模板、分析模板内容输出
                if (Util.IsNumerical(Request.QueryString["ID"]))
                {
                    ViewNews(Int32.Parse(Request.QueryString["ID"]));
                }
                else
                {
                    ShowMessage("请指定要查看的动态内容!");
                }
            }
        }
Ejemplo n.º 10
0
Archivo: TagBase.cs Proyecto: vbyte/fmq
        /// <summary>
        /// 解析包含标签的文本内容
        /// </summary>
        /// <param name="TxtContent">包含标签的文本内容</param>
        /// <param name="res">说依赖的相关资源对象</param>
        public static string InterpretContentWithTags(string TxtContent, IResourceDependency res)
        {
            if (!TxtContent.StartsWith("{#"))
            {
                TxtContent = "#}" + TxtContent + "{#";
            }

            PagerTag txtTag = new PagerTag();
            PagerTag.FilledInTagList(TxtContent, txtTag.tagList, res);
            txtTag.AlwaysShow = true;
            return txtTag.ToString();
        }
Ejemplo n.º 11
0
 public void SetDynamicPagerDependency(string alia, PagerTag tag)
 {
     if (IsTopContainer() == false && this.Caller != null)
     {
         Caller.SetDynamicPagerDependency(alia, tag);
     }
 }
Ejemplo n.º 12
0
 public AutoItem(string tagdef)
     : base(tagdef)
 {
     PagerTag.FilledInTagList(tagdef, tagList, this);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 解析模板内容
        /// </summary>
        public void SetTaggedObjectCollection(string tptContent)
        {
            StringBuilder sb = new StringBuilder(tptContent.Length);
            Regex         regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            int           idxBegin = 0, idxEnd = 0;

            //Util.Debug(false, "------------------------begin---------------");
            MatchCollection mc = regEx.Matches(tptContent, idxBegin);

            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    //Util.Debug(false, tptContent.Substring(idxBegin, idxEnd - idxBegin));
                    sb.Append(tptContent.Substring(idxBegin, idxEnd - idxBegin));
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tptContent);
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + " " + tag.Category.ToString() + "\n#####");
                //OleDbHelper.AppendToFile("~/debug.log", "parse Tag..." + tag.OuterDefineText + " \r\n " + tag.Category.ToString() + Environment.NewLine + Environment.NewLine);
                #region 处理标签内容
                if (tag.Category == TagCategory.CustomTag)
                {
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(this.GetResourceDependency());
                    //Util.Debug(false, "tpp: " + this.GetResourceDependency() + dbTag.OuterDefineText);
                    if (dbTag.IsExist == true)
                    {
                        dbTag.Caller = this;
                        sb.Append(dbTag.GetTagValue());
                        if (!this.TagTrack.ContainsKey("B" + dbTag.IDentity))
                        {
                            this.TagTrack.Add("B" + dbTag.IDentity, dbTag.PublishDate.ToString("yyyyMMddHHmmss"));
                        }
                    }
                }
                else if (tag.Category == TagCategory.DataListTag)
                {
                    //{#List:Repeater#}
                    ListTag list = ListTag.Parse(tag, this.GetResourceDependency());
                    //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Res:"
                    //    + this.GetResourceDependency().ToString());
                    if (this.GeneratorListContent == true)
                    {
                        #region 直接获取列表标签内容
                        if (list.GetPageCount() < 2)
                        {
                            sb.Append(list.GetTagValue());
                        }
                        else
                        {
                            string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? new Guid().ToString() : list.IDentity;
                            SetDynamicPagedAlia(pagedAliaContent, list);
                            sb.Append(pagedAliaContent);
                        }
                        #endregion
                    }
                    else
                    {
                        //设置列表标签占位符号
                        string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? new Guid().ToString() : list.IDentity;
                        SetDynamicPagedAlia(pagedAliaContent, list);
                        sb.Append(pagedAliaContent);
                    }
                }
                else if (tag.Category == TagCategory.PagerTag)
                {
                    //{#Pager#}
                    PagerTag pager     = PagerTag.Parse(tag);
                    string   pagerAlia = (string.IsNullOrEmpty(pager.IDentity)) ? new Guid().ToString() : pager.IDentity;
                    SetDynamicPagerDependency(pagerAlia, pager);
                    sb.Append(pagerAlia);
                }
                else if (tag.Category == TagCategory.ServerTag)
                {
                    //服务端标签定义格式为
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    //系统标签(函数)定义格式为 {#$ $#} {# ... () ... #}
                    // 系统标签: {#$this.PrimaryNews["Content"]$#}
                    if (tag.OuterDefineText.StartsWith("{#$this.") && this._resDependency != null)
                    {
                        sb.Append(this.GetResourceDependency().GetDefinition(tag.OuterDefineText));
                    }
                    else
                    {
                        SystemTag sysTag = new SystemTag(tag.TagDefinition);
                        sysTag.SetResourceDependency(GetResourceDependency());
                        sb.Append(sysTag.ToString());
                    }
                    //Util.Debug(false, tag.OuterDefineText);
                    //OleDbHelper.AppendToFile("~/log.txt", tag.OuterDefineText);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (this._resDependency != null)
                    {
                        //Util.Debug(false, tag.OuterDefineText);
                        sb.Append(this.GetResourceDependency().GetDefinition(tag.OuterDefineText));
                    }
                }

                #endregion

                idxBegin = tag.DefinedIndexEnd;
                //Util.Debug(false, tptContent.Substring(idxBegin, 5));
                //Util.Debug(m.Value);
                mc = regEx.Matches(tptContent, idxBegin);
            }
            if (idxBegin < tptContent.Length)
            {
                sb.Append(tptContent.Substring(idxBegin));
                //Util.Debug(false, tptContent.Substring(idxBegin));
            }
            this.ParsedResult = sb.ToString();
            //Util.Debug(false, "------------------------End---------------");
            //OleDbHelper.SetTextFileContent(@"~/@docs/temp.html", "utf-8",
            //    HtmlTextGenerator.GetRightHtmlText("/templet/1/", sb.ToString()));
        }