MxWeiXinPF.DAL/url_rewrite.cs

(开头部分) 18KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using MxWeiXinPF.Common;

namespace MxWeiXinPF.DAL
{
    public class url_rewrite
    {
        #region 增、删、改操作=================================================
        /// <summary>
        /// 增加节点
        /// </summary>
        public bool Add(Model.url_rewrite model)
        {
            try
            {
                string filePath = Utils.GetXmlMapPath(MXKeys.FILE_URL_XML_CONFING);
                XmlDocument doc = new XmlDocument();
                doc.Load(filePath);
                XmlNode xn = doc.SelectSingleNode("urls");
                XmlElement xe = doc.CreateElement("rewrite");
                if (!string.IsNullOrEmpty(model.name))
                    xe.SetAttribute("name", model.name);
                if (!string.IsNullOrEmpty(model.type))
                    xe.SetAttribute("type", model.type);
                if (!string.IsNullOrEmpty(model.page))
                    xe.SetAttribute("page", model.page);
                if (!string.IsNullOrEmpty(model.inherit))
                    xe.SetAttribute("inherit", model.inherit);
                if (!string.IsNullOrEmpty(model.templet))
                    xe.SetAttribute("templet", model.templet);
                if (!string.IsNullOrEmpty(model.channel))
                    xe.SetAttribute("channel", model.channel.ToString());
                XmlNode newXn = xn.AppendChild(xe);

                //创建子节点
                foreach (Model.url_rewrite_item modelt in model.url_rewrite_items)
                {
                    XmlElement xeItem = doc.CreateElement("item");
                    if (!string.IsNullOrEmpty(modelt.path))
                        xeItem.SetAttribute("path", modelt.path);
                    if (!string.IsNullOrEmpty(modelt.pattern))
                        xeItem.SetAttribute("pattern", modelt.pattern);
                    if (!string.IsNullOrEmpty(modelt.querystring))
                        xeItem.SetAttribute("querystring", modelt.querystring);
                    newXn.AppendChild(xeItem);
                }

                doc.Save(filePath);
                return true;
            }
            catch
            {
                return false;
            }
        }

后面还有 340 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。