⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 labeltransform.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 4 页
字号:
                foreach (XmlNode node2 in document.FirstChild.ChildNodes)
                {
                    if (node2.Name != "attributes")
                    {
                        labelInfo.LabelDefineData[node2.Name] = node2.InnerText;
                        continue;
                    }
                    string innerText = node2.SelectSingleNode("name").InnerText;
                    string str2 = labelInfo.OriginalData[innerText];
                    string[] strArray = node2.SelectSingleNode("default").InnerText.Split(new string[] { "|||" }, StringSplitOptions.None);
                    if (strArray.Length > 1)
                    {
                        if (string.IsNullOrEmpty(str2))
                        {
                            labelInfo.AttributesData[innerText] = strArray[0];
                        }
                        else
                        {
                            int index = DataConverter.CLng(str2);
                            if (index >= strArray.Length)
                            {
                                index = 0;
                            }
                            labelInfo.AttributesData[innerText] = strArray[index];
                        }
                        continue;
                    }
                    if (string.IsNullOrEmpty(str2))
                    {
                        labelInfo.AttributesData[innerText] = node2.SelectSingleNode("default").InnerText;
                        continue;
                    }
                    labelInfo.AttributesData[innerText] = str2;
                }
            }
            catch (XmlException exception)
            {
                labelInfo.LabelContent = new StringBuilder("[err:DataSource'" + labelId + "'XML定义错,原因:" + exception.Message + "]");
                return labelInfo;
            }
            if (DataConverter.CBool(labelInfo.OriginalData["page"]))
            {
                labelInfo.PageSize = DataConverter.CLng(labelInfo.OriginalData["pagesize"]);
            }
            labelInfo.LabelContent = SqlAttributesProc(labelInfo).LabelContent;
            if (labelInfo.Error > 0)
            {
                if (labelInfo.Error >= 2)
                {
                    LogLabelTransformException(labelInfo);
                    labelInfo.LabelContent.Remove(0, labelInfo.LabelContent.Length);
                    labelInfo.LabelContent.Append("[err:标签\"" + labelId + "\"查询数据库时出现异常。有关错误的完整说明,请到后台日志管理中查看“异常记录”。]");
                }
                return labelInfo;
            }
            if (DataConverter.CBool(labelInfo.OriginalData["xslt"]))
            {
                XPathNavigator navigator;
                XmlDocument document2 = new XmlDocument();
                try
                {
                    document2.LoadXml(labelInfo.LabelContent.ToString());
                    navigator = document2.CreateNavigator();
                }
                catch (XmlException exception2)
                {
                    labelInfo.LabelContent = new StringBuilder("[err:DataSource'" + labelId + "'得到的XML数据错误,原因:" + exception2.Message + "]");
                    return labelInfo;
                }
                labelInfo.LabelContent = new StringBuilder();
                XsltArgumentList arguments = new XsltArgumentList();
                XslCompiledTransform cacheXslCompiledTransform = GetCacheXslCompiledTransform(labelInfo, cacheLabelByName.Template.ToString());
                if (cacheXslCompiledTransform == null)
                {
                    return labelInfo;
                }
                foreach (string str3 in labelInfo.AttributesData.AllKeys)
                {
                    arguments.AddParam(str3, "", labelInfo.AttributesData[str3]);
                }
                arguments.AddExtensionObject("labelproc", InsideStaticLabelObject);
                try
                {
                    cacheXslCompiledTransform.Transform((IXPathNavigable) navigator, arguments, (TextWriter) new StringWriter(labelInfo.LabelContent));
                }
                catch (XsltException exception3)
                {
                    labelInfo.LabelContent = new StringBuilder("[err:DataSource'" + labelId + "'模板转换错误,原因:" + exception3.Message + "]");
                    return labelInfo;
                }
            }
            return labelInfo;
        }

        public static string GetListPage(string pagerName, PageInfo iPage, string unitname)
        {
            if (string.IsNullOrEmpty(pagerName) || (iPage == null))
            {
                return string.Empty;
            }
            if (iPage.PageNum <= 0)
            {
                return string.Empty;
            }
            XmlDocument document = new XmlDocument();
            StringBuilder template = PagerManage.GetPagerByName(pagerName).Template;
            if (!string.IsNullOrEmpty(template.ToString()))
            {
                XmlNodeList list = null;
                bool flag = false;
                int count = 0;
                if (!string.IsNullOrEmpty(iPage.PageOtherSet))
                {
                    try
                    {
                        document.LoadXml(iPage.PageOtherSet);
                        list = document.SelectNodes("pageset/item");
                        count = list.Count;
                        flag = true;
                    }
                    catch (XmlException)
                    {
                    }
                }
                template.Replace("{$pagename/}", iPage.PageName).Replace("{$sourcename/}", iPage.SpanName).Replace("{$spanname/}", pagerName);
                string pattern = @"\{\$loop(([\s\S])*?)\}(([\s\S])*?)\{\$\/loop\}";
                foreach (Match match in Regex.Matches(template.ToString(), pattern, RegexOptions.Compiled))
                {
                    string str2 = match.Groups[3].Value;
                    int num2 = 0;
                    if (!string.IsNullOrEmpty(match.Groups[1].Value))
                    {
                        string xml = "<loopbody " + match.Groups[1].Value + "/>";
                        try
                        {
                            document.LoadXml(xml);
                            XmlElement firstChild = (XmlElement) document.FirstChild;
                            num2 = DataConverter.CLng(XmlManage.GetAttributesValue(firstChild, "range"));
                        }
                        catch (XmlException exception)
                        {
                            return ("[err:分页标签'" + pagerName + "'{loop}部位定义格式错,原因:" + exception.Message + "]");
                        }
                    }
                    string[] strArray = str2.Split(new string[] { "$$$" }, StringSplitOptions.None);
                    int num3 = 0;
                    int pageNum = iPage.PageNum;
                    if (count > pageNum)
                    {
                        pageNum = count;
                    }
                    if ((num2 > 0) && (iPage.PageNum > ((num2 * 2) + 1)))
                    {
                        if (iPage.CurrentPage > (num2 + 1))
                        {
                            if (iPage.CurrentPage > (iPage.PageNum - (num2 + 1)))
                            {
                                num3 = iPage.PageNum - ((num2 * 2) + 1);
                                pageNum = iPage.PageNum;
                            }
                            else
                            {
                                num3 = iPage.CurrentPage - (num2 + 1);
                                pageNum = iPage.CurrentPage + num2;
                            }
                        }
                        else
                        {
                            pageNum = (num2 * 2) + 1;
                        }
                    }
                    StringBuilder builder2 = new StringBuilder();
                    for (int i = num3; i < pageNum; i++)
                    {
                        string str4 = string.Empty;
                        if ((iPage.CurrentPage == (i + 1)) && (strArray.Length > 1))
                        {
                            str4 = strArray[strArray.Length - 1].Replace("{$pageid/}", Convert.ToString((int) (i + 1)));
                        }
                        else
                        {
                            str4 = strArray[0].Replace("{$pageid/}", Convert.ToString((int) (i + 1)));
                        }
                        if (i < count)
                        {
                            string innerText = string.Empty;
                            string str6 = string.Empty;
                            if (flag)
                            {
                                foreach (XmlNode node in list[i].SelectNodes("title"))
                                {
                                    innerText = node.InnerText;
                                }
                                foreach (XmlNode node2 in list[i].SelectNodes("url"))
                                {
                                    str6 = node2.InnerText;
                                }
                            }
                            if (!string.IsNullOrEmpty(str4))
                            {
                                if (!string.IsNullOrEmpty(innerText))
                                {
                                    str4 = str4.Replace("{$pagetitle/}", innerText);
                                }
                                else
                                {
                                    str4 = str4.Replace("{$pagetitle/}", i.ToString());
                                }
                                if (!string.IsNullOrEmpty(str6))
                                {
                                    str4 = str4.Replace("{$pageurl/}", str6);
                                }
                                else if ((iPage != null) && !string.IsNullOrEmpty(iPage.PageName))
                                {
                                    str4 = str4.Replace("{$pageurl/}", iPage.PageName.Replace("{$pageid/}", Convert.ToString((int) (i + 1))));
                                }
                            }
                        }
                        else if (!string.IsNullOrEmpty(str4))
                        {
                            str4 = str4.Replace("{$pagetitle/}", Convert.ToString((int) (i + 1)));
                            if ((iPage != null) && !string.IsNullOrEmpty(iPage.PageName))
                            {
                                str4 = str4.Replace("{$pageurl/}", iPage.PageName.Replace("{$pageid/}", Convert.ToString((int) (i + 1))));
                            }
                        }
                        builder2.Append(str4);
                    }
                    template.Replace(match.ToString(), builder2.ToString());
                }
                if ((iPage != null) && !string.IsNullOrEmpty(iPage.PageName))
                {
                    template.Replace("{$unitname/}", unitname);
                    template.Replace("{$firsturl/}", iPage.PageName.Replace("{$pageid/}", "1"));
                    template.Replace("{$endid/}", iPage.PageNum.ToString());
                    template.Replace("{$endurl/}", iPage.PageName.Replace("{$pageid/}", iPage.PageNum.ToString()));
                    int num6 = 1;
                    if (iPage.CurrentPage > 1)
                    {
                        num6 = iPage.CurrentPage - 1;
                    }
                    template.Replace("{$prvurl/}", iPage.PageName.Replace("{$pageid/}", num6.ToString()));
                    template.Replace("{$prvid/}", num6.ToString());
                    int num7 = iPage.PageNum;
                    if (iPage.CurrentPage < iPage.PageNum)
                    {
                        num7 = iPage.CurrentPage + 1;
                    }
                    template.Replace("{$nexturl/}", iPage.PageName.Replace("{$pageid/}", num7.ToString()));
                    template.Replace("{$nextid/}", num7.ToString());
                    template.Replace("{$currentid/}", iPage.CurrentPage.ToString());
                    template.Replace("{$currenturl/}", iPage.PageName.Replace("{$pageid/}", iPage.CurrentPage.ToString()));
                    template.Replace("{$totalpub/}", iPage.TotalPub.ToString());
                    template.Replace("{$pagesize/}", iPage.PageSize.ToString());
                    template.Replace("{$installdir/}", InsideStaticLabelObject.InstallDir());
                    template.Replace("{$originurl/}", iPage.PageName);
                }
            }
            return template.ToString();
        }

        public static string GetPage(string pagerName, PageInfo iPage, string unitname)
        {
            if (string.IsNullOrEmpty(pagerName) || (iPage == null))
            {
                return string.Empty;
            }
            if (iPage.PageNum <= 0)
            {
                return string.Empty;
            }
            XmlDocument document = new XmlDocument();
            StringBuilder template = PagerManage.GetPagerByName(pagerName).Template;
            if (!string.IsNullOrEmpty(template.ToString()))
            {
                XmlNodeList list = null;
                bool flag = false;
                int count = 0;
                if (!string.IsNullOrEmpty(iPage.PageOtherSet))
                {
                    try

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -