Exemple #1
0
 /// <summary>
 /// 设置动态分页的显示信息
 /// </summary>
 /// <param name="alia">占位字符串键值</param>
 /// <param name="tag">当前分页信息的对象</param>
 public void SetDynamicPagerDependency(string alia, PagerTag tag)
 {
     if (PagerDic.ContainsKey(alia))
     {
         PagerDic[alia] = tag;
     }
     else
     {
         PagerDic.Add(alia, tag);
     }
 }
Exemple #2
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            /***********************
             * 1.通过模板编号获取模板
             * 2.模板解析器解析输出
             *   2.1 设置模板解析依赖资源 TempletDriving
             *   2.2 解析内容并输出网页
             *
             ***************************/
            TempletDriving tptRes = new TempletDriving(context);

            #region 页面渲染处理
            context.Response.Write(tptRes.GetDefinition("$TempletID$"));
            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(Convert.ToInt32(tptRes.GetDefinition("$TempletID$"))) as PageTemplet;
            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
            {
                #region 根据模板内的列表动态显示当前页内容
                if (pageTpt.IsMixedSyntax == false)
                {
                    DisplayContent(context, HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));
                    return;
                }
                else
                {
                    string             realContent = "", myPageHtml = "";
                    TempletParse       tpp = new TempletParse();
                    MultiResDependency res = new MultiResDependency(tptRes);

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

                    //OleDbHelper.AppendToFile("~/debug.log", tpp.ParsedResult);
                    if (this.PagedObject == null)
                    {
                        myPageHtml = tpp.ParsedResult;
                        //+处理分页导航内容
                        if (this.PagerDic.Count > 0)
                        {
                            foreach (string pagerKey in PagerDic.Keys)
                            {
                                myPageHtml = myPageHtml.Replace(pagerKey, "");
                            }
                        }
                        DisplayContent(context, HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml));
                    }
                    else
                    {
                        string dynTpt           = tpp.ParsedResult;
                        string currentPageMatch = "";
                        PagedObject.SetResourceDependency(res);
                        string currentPage = tptRes.GetDefinition("$CurrentPage$").ToString();
                        if (currentPage != null && Util.IsMatch(@"^(\d+)$", currentPage, 1, 1, PagedObject.GetPageCount(),
                                                                out currentPageMatch))
                        {
                            PagedObject.CurrentPageIndex = int.Parse(currentPage);
                        }
                        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;

                                string formatDef = "$PagerFormat$";
                                if (tptRes.IsDefined(formatDef))
                                {
                                    Pager.DefaultPageFormat = tptRes.GetDefinition(formatDef).ToString();
                                }
                                myPageHtml = myPageHtml.Replace(pagerKey, Pager.ToString());
                            }
                        }
                        #endregion
                        DisplayContent(context, HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml));
                    }
                    tpp.Dispose();
                }
                #endregion
            }
            else
            {
                ShowMessage(context, "页面模板实体还原失败,请检查配置是否正确!");
            }
            #endregion
        }
Exemple #3
0
 /// <summary>
 /// 测试标签
 /// </summary>
 /// <param name="text">文本(经过格式化)</param>
 /// <param name="origin">原始文本</param>
 /// <param name="regex">正则表达式</param>
 /// <param name="type">目标标签类型</param>
 private void MatchTag(string text, string origin, Regex regex, TagType type)
 {
     if (this.Config.tagregex.TagPairEndTest.IsMatch(text) || this.Config.tagregex.EmptyTest.IsMatch(text) ||
         this.Config.tagregex.ifTagKeyTest.IsMatch(text))
     {
         return;
     }
     TheMatch = regex.Match(text);
     if (TheMatch.Success)
     {
         this.Html = this.Html.Replace(origin, text);
         if (type == TagType._tag_list)
         {
             text = FindFirstListTagStr(text, this.TagList.Count());
         }
         if (type == TagType._tag_command)
         {
             CMDTag tag = new CMDTag(text, origin, Deep, this.Config, this.TagList.Count);
             GetCMD(tag);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_list)
         {
             if (this is SubListPage)
             {
                 ListTag tag = new ListTag(text, origin, Deep, (this as SubListPage).PageName, this.Config, this.TagList.Count);
                 this.TagList.Add(tag);
             }
             else
             {
                 ListTag tag = new ListTag(text, origin, Deep, this is ItemPage ? (this as ItemPage).PageName : "", this.Config, this.TagList.Count);
                 this.TagList.Add(tag);
             }
         }
         else if (type == TagType._tag_read)
         {
             ReadTag tag = new ReadTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_label)
         {
             LabelTag tag = new LabelTag(text, origin, Deep, this is LabelPage ? (this as LabelPage).PageName : "", this.Config, this.TagList.Count);
             tag.LazyLoad();
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_static)
         {
             StaticTag tag = new StaticTag(text, origin, Deep, this is StaticPage ? (this as StaticPage).PageName : "", this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_filed)
         {
             FieldTag tag = new FieldTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_method)
         {
             MethodTag tag = new MethodTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_pager)
         {
             PagerTag tag = new PagerTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_form)
         {
             FormTag tag = new FormTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
             this.TagCallBack = "form";
         }
         else if (type == TagType._tag_json)
         {
             JsonTag tag = new JsonTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
             this.TagCallBack = "json";
         }
     }
 }