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

📄 pagermanage.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace PowerEasy.Templates
{
    using PowerEasy.Components;
    using PowerEasy.Model.TemplateProc;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Web;
    using System.Web.Caching;
    using System.Xml;

    public sealed class PagerManage
    {
        private PagerManage()
        {
        }

        public static bool Add(PagerManageInfo ainfo)
        {
            string path = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath) + @"\" + ainfo.Name + ".config";
            string str2 = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath);
            try
            {
                if (!Directory.Exists(str2))
                {
                    Directory.CreateDirectory(str2);
                }
                if (!File.Exists(path))
                {
                    XmlDocument document = new XmlDocument();
                    XmlNode newChild = document.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                    document.AppendChild(newChild);
                    XmlElement element = document.CreateElement("", "root", "");
                    XmlElement element2 = document.CreateElement("", "LabelType", "");
                    element2.InnerText = ainfo.Type;
                    element.AppendChild(element2);
                    XmlElement element3 = document.CreateElement("", "LabelImage", "");
                    element3.InnerText = ainfo.Image;
                    element.AppendChild(element3);
                    XmlElement element4 = document.CreateElement("", "LabelIntro", "");
                    element4.InnerText = ainfo.Intro;
                    element.AppendChild(element4);
                    XmlElement element5 = document.CreateElement("", "LabelTemplate", "");
                    element5.InnerText = ainfo.Template.ToString();
                    element.AppendChild(element5);
                    document.AppendChild(element);
                    using (StreamWriter writer = new StreamWriter(path, false, Encoding.GetEncoding("utf-8")))
                    {
                        writer.Write(document.InnerXml);
                    }
                    return true;
                }
                return false;
            }
            catch (IOException)
            {
                return false;
            }
            catch (XmlException)
            {
                return false;
            }
        }

        public static bool Copy(string labelName)
        {
            string sourceFileName = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath) + @"\" + labelName + ".config";
            string destFileName = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath) + @"\";
            for (int i = 1; i < 100; i++)
            {
                string path = destFileName + labelName + "(" + i.ToString() + ").config";
                if (!File.Exists(path))
                {
                    destFileName = path;
                    break;
                }
            }
            try
            {
                File.Copy(sourceFileName, destFileName, false);
            }
            catch (IOException)
            {
                return false;
            }
            return true;
        }

        public static bool Delete(string labelNames)
        {
            foreach (string str in labelNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
            {
                string path = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath) + @"\" + str + ".config";
                try
                {
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }
                catch (IOException exception)
                {
                    throw new IOException(exception.Message);
                }
            }
            return true;
        }

        public static bool Exists(string pagerName)
        {
            return File.Exists(HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath) + @"\" + pagerName + ".config");
        }

        public static PagerManageInfo GetPagerByName(string name)
        {
            string str;
            if (HttpContext.Current != null)
            {
                str = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath) + @"\" + name + ".config";
            }
            else
            {
                str = AppDomain.CurrentDomain.BaseDirectory + PagerLabelLibPath + @"\" + name + ".config";
            }
            if (File.Exists(str))
            {
                try
                {
                    PagerManageInfo info;
                    FileInfo info2 = new FileInfo(str);
                    XmlDocument document = new XmlDocument();
                    using (StreamReader reader = info2.OpenText())
                    {
                        document.Load(reader);
                        info = new PagerManageInfo();
                        info.Image = document.SelectSingleNode("root/LabelImage").InnerText;
                        info.Intro = document.SelectSingleNode("root/LabelIntro").InnerText;
                        info.Template = new StringBuilder(document.SelectSingleNode("root/LabelTemplate").InnerText);
                        info.Type = document.SelectSingleNode("root/LabelType").InnerText;
                        info.Name = name;
                        info.UpDateTime = info2.LastWriteTime;
                    }
                    return info;
                }
                catch (IOException)
                {
                    return new PagerManageInfo(true);
                }
                catch (XmlException)
                {
                    return new PagerManageInfo(true);
                }
            }
            return new PagerManageInfo(true);
        }

        public static IList<PagerManageInfo> GetPagerList(string type)
        {
            string key = "CK_Label_PagerLabelList_Type_" + type;
            List<PagerManageInfo> list = new List<PagerManageInfo>();
            if (SiteCache.Get(key) == null)
            {
                string str2;
                if (HttpContext.Current != null)
                {
                    str2 = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath);
                }
                else
                {
                    str2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PagerLabelLibPath);
                }
                DirectoryInfo info = new DirectoryInfo(str2);
                if (info.Exists)
                {
                    foreach (FileInfo info2 in info.GetFiles())
                    {
                        try
                        {
                            using (StreamReader reader = info2.OpenText())
                            {
                                XmlDocument document = new XmlDocument();
                                document.Load(reader);
                                PagerManageInfo item = new PagerManageInfo();

⌨️ 快捷键说明

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