예제 #1
0
        private void PutPageBody(XmlDocument xmlDoc)
        {
            string nodeInnerText = GetNodeInnerText(xmlDoc, "//labelname");
            string str2          = GetNodeInnerText(xmlDoc, "//sourcename");
            string input         = GetNodeInnerText(xmlDoc, "//currentpage", "1");
            string str4          = GetNodeInnerText(xmlDoc, "//total", "0");
            string str5          = GetNodeInnerText(xmlDoc, "//pagesize", "1");
            string unitname      = GetNodeInnerText(xmlDoc, "//unitname");

            if (string.IsNullOrEmpty(nodeInnerText))
            {
                this.PutErrMessage("分页标签名不能为空!");
            }
            else
            {
                PageInfo iPage = new PageInfo();
                iPage.SpanName = str2;
                iPage.PageName = string.Empty;
                int num = DataConverter.CLng(str4) / DataConverter.CLng(str5);
                if ((DataConverter.CLng(str4) % DataConverter.CLng(str5)) > 0)
                {
                    num++;
                }
                iPage.PageNum       = num;
                iPage.PageSize      = DataConverter.CLng(str5);
                iPage.CurrentPage   = DataConverter.CLng(input);
                iPage.TotalPub      = DataConverter.CLng(str4);
                iPage.IsDynamicPage = true;
                iPage.PageName      = "ajaxpage";
                this.XmlResponseWriter.WriteElementString("status", "ok");
                this.XmlResponseWriter.WriteElementString("body", LabelTransform.GetListPage(nodeInnerText, iPage, unitname));
            }
        }
        /// <summary>
        /// 分页标签解析
        /// </summary>
        /// <param name="templateInfo"></param>
        private void FiltPage(TemplateInfo templateInfo)
        {
            XmlDocument document = new XmlDocument();
            string      pattern  = @"{PE\.Page([\s\S](?!{PE))*?\/}";

            foreach (Match match in Regex.Matches(templateInfo.TemplateContent, pattern, RegexOptions.IgnoreCase))
            {
                try
                {
                    document.LoadXml(FormatLabel(match.Value));
                }
                catch (XmlException exception)
                {
                    templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.ToString(), "[err:分页标签" + match.Value.Replace("{", string.Empty).Replace("/}", string.Empty) + "错,原因:" + exception.Message + "]");
                    continue;
                }
                XmlElement firstChild = (XmlElement)document.FirstChild;
                foreach (PageInfo info in this.tempLabelPageList)
                {
                    string str2;
                    if (string.Compare(info.SpanName, XmlManage.GetAttributesValue(firstChild, "datasource"), StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        continue;
                    }
                    if (templateInfo.PageType == 1)
                    {
                        str2 = LabelTransform.GetListPage(XmlManage.GetAttributesValue(firstChild, "id"), info, XmlManage.GetAttributesValue(firstChild, "unitname"));
                    }
                    else
                    {
                        str2 = LabelTransform.GetPage(XmlManage.GetAttributesValue(firstChild, "id"), info, XmlManage.GetAttributesValue(firstChild, "unitname"));
                    }
                    string attributesValue = XmlManage.GetAttributesValue(firstChild, "span");
                    string str4            = XmlManage.GetAttributesValue(firstChild, "class");
                    if (string.IsNullOrEmpty(attributesValue))
                    {
                        attributesValue = "span";
                    }
                    if (string.IsNullOrEmpty(str4))
                    {
                        str4 = "pagecss";
                    }
                    string str5 = "<" + attributesValue + " id=\"pe100_page_" + info.SpanName + "\"";
                    if (!string.IsNullOrEmpty(str4))
                    {
                        str5 = str5 + " class=\"" + str4 + "\"";
                    }
                    str5 = str5 + ">";
                    str2 = str5 + str2 + "</" + attributesValue + ">";
                    templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.Value, str2);
                    if ((info.PageNum > 0) && info.IsMainPage)
                    {
                        templateInfo.PageNum  = info.PageNum;
                        templateInfo.TotalPub = info.TotalPub;
                    }
                }
                templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.Value, string.Empty);
            }
        }