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

📄 labelxmlshow.aspx.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Template
{
    using PowerEasy.Components;
    using PowerEasy.Templates;
    using PowerEasy.Web.UI;
    using System;
    using System.Configuration;
    using System.IO;
    using System.Text;
    using System.Web;
    using System.Xml;

    public class LabelXmlShow : AdminPage
    {
        private string Dbtype;
        private string labelname;
        private string xmlfilepath;

        protected void Page_PreRender(object sender, EventArgs e)
        {
            this.labelname = BasePage.RequestString("name");
            if (!string.IsNullOrEmpty(this.labelname))
            {
                string path = ConfigurationManager.AppSettings["PowerEasy:LabelXsltPath"];
                this.xmlfilepath = HttpContext.Current.Server.MapPath(path) + @"\" + this.labelname + ".config";
                this.Dbtype = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataType");
                string presstr = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource");
                string str3 = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlString");
                string istr = string.Empty;
                XmlDocument document = new XmlDocument();
                document.Load(this.xmlfilepath);
                XmlNodeList attriblist = document.SelectNodes("root/attributes");
                presstr = this.ParaProc(attriblist, presstr);
                str3 = this.ParaProc(attriblist, str3).Replace("@pagesize", "10").Replace("@startrow", "0");
                if ((string.Compare(this.Dbtype, "xml_read") != 0) && string.IsNullOrEmpty(str3))
                {
                    base.Response.Write("查询语句为空!");
                }
                else
                {
                    istr = LabelManage.GetDBQuery(this.Dbtype, presstr, str3, attriblist);
                    this.XmlProc(this.Dbtype, presstr, istr);
                }
            }
            else
            {
                base.Response.Write("标签名称为空!");
            }
        }

        protected string ParaProc(XmlNodeList attriblist, string presstr)
        {
            foreach (XmlNode node in attriblist)
            {
                string[] strArray = node.SelectSingleNode("default").InnerText.Split(new string[] { "|||" }, StringSplitOptions.None);
                if (strArray.Length > 1)
                {
                    presstr = presstr.Replace("@" + node.SelectSingleNode("name").InnerText, strArray[0]);
                    continue;
                }
                presstr = presstr.Replace("@" + node.SelectSingleNode("name").InnerText, node.SelectSingleNode("default").InnerText);
            }
            return presstr;
        }

        protected void XmlProc(string dbtype, string isource, string istr)
        {
            XmlDocument document = new XmlDocument();
            if ((string.Compare(dbtype, "static") != 0) && (string.Compare(dbtype, "xml_read") != 0))
            {
                if (string.IsNullOrEmpty(istr))
                {
                    base.Response.Write("查询结果为空,请检查数据库中是否有数据,或查询条件是否正确!");
                }
                else
                {
                    string str2;
                    if (((str2 = istr) != null) && (str2 == "queryerr"))
                    {
                        base.Response.Write("查询错,请检查您的查询语句是否符合规则!");
                    }
                    else
                    {
                        try
                        {
                            document.LoadXml(istr);
                        }
                        catch (XmlException exception)
                        {
                            base.Response.Write(exception.Message);
                            return;
                        }
                        base.Response.Clear();
                        base.Response.Buffer = true;
                        base.Response.Charset = "utf-8";
                        base.Response.AddHeader("Content-Disposition", "attachment;filename=labelout.xml");
                        base.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
                        base.Response.ContentType = "Application/Octet-Stream";
                        base.Response.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        base.Response.Write(document.OuterXml);
                    }
                }
            }
            else if (string.Compare(dbtype, "xml_read") == 0)
            {
                string str;
                HttpContext current = HttpContext.Current;
                if (current != null)
                {
                    str = current.Server.MapPath("~/" + isource);
                }
                else
                {
                    str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, isource);
                }
                try
                {
                    document.Load(str);
                }
                catch (XmlException exception2)
                {
                    base.Response.Write(exception2.Message);
                    return;
                }
                base.Response.Clear();
                base.Response.Buffer = true;
                base.Response.Charset = "utf-8";
                base.Response.AddHeader("Content-Disposition", "attachment;filename=labelout.xml");
                base.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
                base.Response.ContentType = "Application/Octet-Stream";
                base.Response.Write(document.OuterXml);
            }
        }
    }
}

⌨️ 快捷键说明

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