C#读取xml配置文件

1 篇文章 0 订阅

目录

 

简单参考一

xml多节点配置参考二


 

 

简单参考一

xml文件RoleSetting.xml

<?xml version="1.0" encoding="utf-8" ?>
<roles>
  <item key="100" name="普通用户_乙" />
  <item key="200" name="普通用户_甲" />
  <item key="500" name="管理员用户_乙" />
  <item key="600" name="管理员用户_甲" />
  <item key="800" name="超级管理员" />
</roles>

 

 /// <summary>
        /// 角色配置读取配置xml
        /// </summary>
        /// <returns></returns>
        public static SortedList<int, string> InitRoleList()
        {
            SortedList<int, string> roleList = new SortedList<int, string>();
            // string configlFile = "G://Work//党建webai//ITExplode.Web//RoleSetting.xml";
            string fileName = "RoleSetting.xml";
            string configlFile = AppDomain.CurrentDomain.BaseDirectory + fileName;
            if (!System.IO.File.Exists(configlFile))
            {
                throw new FileNotFoundException("没有找到角色配置文件" + fileName);
            }
            try
            {
                System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
                xd.Load(configlFile);
                System.Xml.XmlElement root = xd.DocumentElement;
//用OfType<System.Xml.XmlElement>是为了排除<!--注释
                foreach (System.Xml.XmlElement item in root.ChildNodes.OfType<System.Xml.XmlElement>())
                {
                    string codeTxt = string.Empty;
                    string nameTxt = string.Empty;
                    var code = item.Attributes["key"];
                    if (code != null)
                    {
                        codeTxt = code.Value;
                    }
                    var name = item.Attributes["name"];
                    if (name != null)
                    {
                        nameTxt = name.Value;
                    }
                    int codeInt = 0;
                    if (int.TryParse(codeTxt, out codeInt))
                    {
                        roleList.Add(codeInt, nameTxt);
                    }
                }
            }
            catch (Exception ex)
            {
                string log = "解析xml文件报错," + ex.Message;
                AddLog(log);
            }
            return roleList;
        }

 

 

xml多节点配置参考二

ChannelProcess.xml文件

<?xml version="1.0" encoding="utf-8" ?>
<root>
  <!-- 栏目可以勾选的 流程类型列表,typeId需要和SendArtcleProcess表中的ProcessType类型值匹配  -->
  <channelProcess>
    <!--<process typeId="2000" value="基层;终审;发布"/>-->    
    <!-- 新增审核2020-4-17 10:26:39 ,终审指定人审核 -->
    <process typeId="4000" value="基层;初审;自选终审"/>    
    <!--<process typeId="5000" value="待确认;已确认"/>-->
  </channelProcess>

  <!--文章状态文本,如果新增项key不允许重复;不允许修改key,只能改name-->
  <articleStatus>
    <item name="基层审" key="20" />
    <item name="基层驳回" key="30" />
    <item name="基层丢弃" key="40" />    
    
    <item name="待初审" key="100" /> 
    <item name="初审中" key="150" />
    <item name="初审通过" key="200" />
    <item name="初审驳回" key="250" />
    <item name="初审丢弃" key="300" />
    <item name="待终审" key="350" />
    <!--<item name="终审中" key="400" />-->
    <item name="终审通过" key="450" />
    <item name="终审驳回" key="500" />
    <item name="终审丢弃" key="550" />
    <!--<item name="待采纳" key="600" />
    <item name="已采纳" key="650" />-->
    <item name="待发布" key="700" />
    <item name="已发布" key="800" />
    <item name="终止上报" key="1000" />
    <!--<item name="会审中" key="1100" />
    <item name="会审通过" key="1150" />
    <item name="会审驳回" key="1200" />-->
    <item name="待确认" key="1500" />
    <item name="已确认" key="1550" />
    <item name="已删除" key="1600" />
    <!-- 用于确认业务 -->
    <item name="不同意" key="1650" />
    <item name="草稿" key="1700" />
    <item name="不显示在我的待办" key="1800" />
  </articleStatus>

  <!-- 操作类型枚举,用于操作日志记录,enabled=0表示禁用(不显示在条件查询下拉框),1=启用 不允许修改value,新增项时value不能重复 -->
  <operateType>
    <item value="110"	title="修改用户"	 enabled="1"  />
    <item value="120"	title="发布文章"	 enabled="1"  />
    <item value="130"	title="丢弃文章"	 enabled="1"  />
    <item value="140"	title="删除用户"	 enabled="1"  />
    <item value="150"	title="驳回报送"	 enabled="1"  />
    <item value="160"	title="继续上报"	 enabled="1"  />
    <item value="170"	title="上报文章"	 enabled="1"  />
    <item value="180"	title="保存草稿"	 enabled="1"  />
    <item value="190"	title="审核报文"	 enabled="1"  />
    <item value="200"	title="查看报文"	 enabled="1"  />
    <item value="210"	title="审核通过"  enabled="0"  />
    <item value="220"	title="新增用户"	 enabled="1"  />
    <item value="230"	title="查看用户"	 enabled="1"  />   
    <item value="240"	title="登录系统"	 enabled="1"  />
    <item value="250"	title="修改文章"	 enabled="1"  />
    <item value="260"	title="终止上报"	 enabled="1"  />
    <item value="270"	title="登录失败"	 enabled="1"  />
    <item value="280"	title="设为会审"	 enabled="1"  />
    <item value="300"	title="集团分公司采纳"	  enabled="1"  />
    <item value="310"	title="采纳"	  enabled="1"  />
    <!--<item value="320"	title="已发布"	  enabled="1"  />-->
    <item value="330"	title="继续上报"	 enabled="1"  />
    <item value="400"	title="创建主任务"	  enabled="1"  />
    <item value="410"	title="创建子任务"	  enabled="1"  />
    <item value="420"	title="更新任务"	  enabled="1"  />
    <item value="430"	title="更新子任务"	  enabled="1"  />
    <item value="440"	title="删除任务"	  enabled="1"  />
    <item value="450"	title="删除子任务"	  enabled="1"  />
    <item value="500"	title="更新角色权限"	  enabled="1"  />
    <item value="600"	title="添加部门"	  enabled="1"  />
    <item value="610"	title="更新部门"	  enabled="1"  />
    <item value="620"	title="删除部门"	  enabled="1"  />
    <item value="650"	title="确认不同意"	 enabled="1"  />
    <item value="700"	title="确认同意"	 enabled="1"  />
    <item value="750"	title="调整了计算规则"	 enabled="1"  />
    <item value="800"	title="删除文章"	 enabled="1"  />
    <item value="850"	title="系统发送通知邮件"	 enabled="1"  />
    <item value="900"	title="修改了集团分公司奖励设置"	 enabled="1"  />
    <item value="1000"	title="删除奖励"	 enabled="1"  />
  </operateType>

  <!--  系统菜单,id不能重复,原数据不可修改id,sort为排序字段 -->
  <menus>
    <!-- ************系统管理 开始*********** -->
    <item id="100" parentId="0"  name="系统管理" url="/home/index" icon="system" showSystemLeftMenu="1" sort="25000" />
    
    <item id="100100" parentId="100"  name="栏目管理" url="/System/ChannelList" icon="subject" showSystemLeftMenu="1" sort="600" />
    <!--  栏目管理:按钮列表 -->
    <item id="10010001" parentId="100100" name="新增" icon="bar_add"  sort="600" />
    <item id="10010010" parentId="100100" name="编辑" icon="bar_edit"  sort="600" />

    <item id="100400" parentId="100" name="部门管理" url="/System/Organization" icon="dp_mg" showSystemLeftMenu="1" sort="600" />
    <!--  部门管理:按钮列表 -->
    <item id="10040001" parentId="100400" name="新增" icon="bar_add" sort="600" />
    <item id="10040010" parentId="100400" name="编辑" icon="bar_edit" sort="600" />
    <item id="10040020" parentId="100400" name="删除" icon="bar_delete" sort="600"/>

    <item id="100700" parentId="100" name="角色管理" url="/System/RoleList" icon="" showSystemLeftMenu="1"  sort="600" />
    <item id="10070001" parentId="100700" name="新增" icon=""  sort="600" />
    <item id="10070010" parentId="100700" name="编辑" icon=""  sort="600" />
    <item id="10070020" parentId="100700" name="删除" icon=""  sort="600" />
    <item id="10070030" parentId="100700" name="授权" icon=""  sort="600" />
    <!-- ************系统管理 结束*********** -->

    <!-- ************ 任务管理 开始 *********** -->
    <item id="400" parentId="0" name="任务管理" url="/home/index" icon="mission" showSystemLeftMenu="1"  sort="28000" />

    <item id="400100" parentId="400" name="任务列表" url="/Task/TaskListNew" icon="" showSystemLeftMenu="1" sort="600" />
    <item id="40010001" parentId="400100" name="新增" icon="" sort="600" />
    <item id="40010010" parentId="400100" name="编辑" icon="" sort="600" />
    <item id="40010020" parentId="400100" name="分解" icon="" sort="600" />
    <item id="40010030" parentId="400100" name="删除" icon="" sort="600" />


    <!--<item id="400400" parentId="400" name="任务详情" url="/Task/TaskDetail"  icon="" sort="600" />
    <item id="40040001" parentId="400400" name="新增" icon="" sort="600" />
    <item id="40040010" parentId="400400" name="编辑" icon="" sort="600" />-->
    <!-- ************ 任务管理 结束 *********** -->

    <!-- ************ 用户管理 开始 *********** -->
    <item id="700" parentId="0" name="用户管理" url="/home/index" icon="user" showSystemLeftMenu="1" sort="29000" />

    <item id="700100" parentId="700" name="用户管理" url="/User/Mange" icon="" showSystemLeftMenu="1" sort="600" />
    <!--  用户管理:按钮列表 -->
    <item id="70010001" parentId="700100" name="新增" icon="" sort="600" />
    <item id="70010010" parentId="700100" name="编辑" icon="" sort="600" />
    <item id="70010020" parentId="700100" name="禁用" icon="" sort="600" />
    <item id="70010030" parentId="700100" name="重置密码" icon="" sort="600" />
    <item id="70010040" parentId="700100" name="导入用户" icon="" sort="600" />
    <!-- ************ 用户管理 结束 *********** -->

    <!-- ************ 规则设置 开始 *********** -->
    <item id="1000" parentId="0" name="规则设置" url="/Rules/Reward" icon="settings" showSystemLeftMenu="1" sort="30000" />

    <item id="1000400" parentId="1000" name="计算规则" url="/Rules/Rules" icon="rule" showSystemLeftMenu="1" sort="600" />
    <item id="100040001" parentId="1000400" name="新增" icon=""  sort="600" />
    <item id="100040010" parentId="1000400" name="编辑" icon=""  sort="600" />
    <item id="100040030" parentId="1000400" name="删除" icon=""  sort="600" />
    
    <item id="1000100" parentId="1000" name="奖励分值" url="/Rules/Reward" icon="rule" showSystemLeftMenu="1"  sort="600" />
    <item id="100010010" parentId="1000100" name="编辑" icon=""  sort="600" />

    <item id="1000700" parentId="1000" name="分值稿酬" url="/Rules/ScoreRulesList" icon="rule" showSystemLeftMenu="1" sort="600" />
    <item id="100070001" parentId="1000700" name="新增" icon=""  sort="600" />
    <item id="100070010" parentId="1000700" name="编辑" icon=""  sort="600" />
    <!-- ************ 规则设置 结束 *********** -->

    <!-- ************ 业务管理 开始 *********** -->
    <item id="1400" parentId="0" name="业务管理" url="" icon="process" showSystemLeftMenu="1"  sort="32000" />

    <item id="1400100" parentId="1400" name="报送管理" url="/Article/SendManage" icon="rule" showSystemLeftMenu="1"  sort="600"/>
    <item id="140010001" parentId="1400100" name="上报" icon=""  sort="600" />
    <item id="140010005" parentId="1400100" name="详情" icon=""  sort="600" />
    <item id="140010010" parentId="1400100" name="编辑" icon=""  sort="600" />
    <item id="140010020" parentId="1400100" name="删除" icon=""  sort="600" />
    <item id="140010030" parentId="1400100" name="终止上报" icon="" sort="600"  />
    <item id="140010040" parentId="1400100" name="导出" icon=""  sort="600" />
    <item id="140010050" parentId="1400100" name="奖励采纳" icon=""  sort="600" />
<!--<item id="140010070" parentId="1400100" name="发布" icon="" sort="600" />-->
    <item id="140010080" parentId="1400100" name="删除奖励采纳" icon="" sort="600" />

    <item id="1400400" parentId="1400" name="我的待办" url="/Article/MyWaitList" icon="rule" showSystemLeftMenu="1" sort="600" />
    <item id="140040001" parentId="1400400" name="查看" icon=""  sort="600"  />
    <!--<item id="140040010" parentId="1400400" name="编辑" icon=""  sort="600" />-->
    <item id="140040030" parentId="1400400" name="审核按钮(有审核权限必√)" icon=""  sort="600" />
    <!--  此两项作为有审核权限依据,对应数据库表ProcessCheckSet字段RoleId -->
    <item id="140040055" parentId="1400400" name="基层审核权限" icon="" showSystemLeftMenu="0" sort="600" />
    <item id="140040080" parentId="1400400" name="初审权限" icon="" showSystemLeftMenu="0" sort="600" />
    <item id="140040090" parentId="1400400" name="终审权限" icon="" showSystemLeftMenu="0" sort="600" />    
    <item id="140040070" parentId="1400400" name="确认按钮" icon="" sort="600" />
    <item id="140040040" parentId="1400400" name="继续上报" icon="" sort="600" />
    <!--<item id="140040050" parentId="1400400" name="采纳" icon=""  sort="600" />-->
    <!--<item id="140040060" parentId="1400400" name="发布" icon=""  sort="600" />-->
    <!-- 处理我的待办里面,楼道视频不需要显示情况 2020-1-7 11:29:14 添加 -->
    <!--<item id="140040095" parentId="1400400" name="完成" icon="" sort="600" />-->

    <item id="1400900" parentId="1400" name="发布处理" url="/Article/PublishHandle" icon="rule" showSystemLeftMenu="1"  sort="600" />

    <item id="1400500" parentId="1400" name="审核历史" url="/Article/CheckHistory" icon="rule" showSystemLeftMenu="1"  sort="600"/>
    <item id="140050001" parentId="1400500" name="查看" icon="" sort="600" />

    <!--<item id="1400600" parentId="1400" name="采纳历史" url="/History/AcceptList" icon="rule" showSystemLeftMenu="1" sort="600" />
     <item id="140060001" parentId="1400600" name="查看" icon="" sort="600" />-->

    <item id="1400700" parentId="1400" name="发布历史" url="/History/PublishHistoryList" icon="rule"  showSystemLeftMenu="1"  sort="600"/>
    <item id="140070001" parentId="1400700" name="查看" icon=""  sort="600" />

    <item id="1400800" parentId="1400" name="我的文章" url="/History/MyArticleHistory" icon="rule" showSystemLeftMenu="1"  sort="600"/>
    <item id="140080001" parentId="1400800" name="查看" icon=""   sort="600"/>
    <!-- ************ 业务管理 结束 *********** -->

    <item id="1700" parentId="0" name="系统通知" url="/Notify/NotifyList" icon="sys-notice"  showSystemLeftMenu="1"  sort="35000"/>
    <item id="1700100" parentId="1700" name="系统通知" url="/Notify/NotifyList" showSystemLeftMenu="1"  sort="600"/>

    <item id="2000" parentId="0" name="日志管理" url="/Log/LoginLog" icon="logs" showSystemLeftMenu="1"  sort="30000"/>
    <item id="2000100" parentId="2000" name="登录日志" url="/Log/LoginLog"   icon="rule" showSystemLeftMenu="1"  sort="600"/>
    <item id="2000300" parentId="2000" name="操作日志" url="/Log/OperLog"   icon="rule" showSystemLeftMenu="1"  sort="600"/>

    <item id="2400" parentId="0" name="公告管理" url="/Notice/NoticeList" icon="announce" showSystemLeftMenu="1"    sort="40000"/>    
    <item id="2400100" parentId="2400" name="公告管理" url="/Notice/NoticeList" icon="rule" showSystemLeftMenu="1"  sort="600"/>
    <item id="240010001" parentId="2400100" name="新增" icon="" showSystemLeftMenu="0" sort="600" />
    <item id="240010010" parentId="2400100" name="编辑" icon="" showSystemLeftMenu="0" sort="600" />
    <item id="240010020" parentId="2400100" name="删除" icon="" showSystemLeftMenu="0" sort="600" />
    <item id="240010030" parentId="2400100" name="查看" icon="" showSystemLeftMenu="0" sort="600" />

    <item id="2700" parentId="0" name="统计分析" url="/Statistics/UserStatistics" icon="stat"  showSystemLeftMenu="1"   sort="50000"/>
    <item id="2700200" parentId="2700" name="人员统计" url="/Statistics/UserStatistics" icon="rule" showSystemLeftMenu="1"   sort="600"/>
    <item id="270020010" parentId="2700200" name="导出" icon="" showSystemLeftMenu="0"/>
    <item id="2700300" parentId="2700" name="部门统计" url="/Statistics/DepartStatistics" icon="rule" showSystemLeftMenu="1"   sort="600"/>
    <item id="270030010" parentId="2700300" name="导出" icon="" showSystemLeftMenu="0"/>

    <!--  单独的配置,用于区分是【门户】用户还是【新闻宣传】用户-->
    <item id="388888" parentId="0" name="用户类型:门户用户" url="" icon=""  showSystemLeftMenu="0"  sort="60000" />
    <item id="499999" parentId="0" name="用户类型:党群用户" url="" icon="" showSystemLeftMenu="0"  sort="60000" />
  </menus>
  <!-- 搜集到的系统发布到Sharepoint的栏目 -->
  <sharePoint.publishChannel>    
    <item name="单位要闻"           url="/sites/ssdwcms/yyqyjy/dwyw"  />
    <item name="领导讲话"           url="/sites/ssdwcms/yyqyjy/ldjh"  />   
    <item name="通知公告"           url="/sites/ssdwcms/yyqyjy/tzgg"  />
    <item name="基层动态"           url="/sites/ssdwcms/yyqyjy/jcdt"  />   
    <item name="行业动态"           url="/sites/ssdwcms/yyqyjy/hyrd"  />
    <item name="媒体聚焦"           url="/sites/ssdwcms/yyqyjy/mtjj"  />
    <item name="学术交流"           url="/sites/ssdwcms/yyqyjy/xsjl"  />
    <item name="前沿资讯"           url="/sites/ssdwcms/yyqyjy/xxqb"  />
    <item name="页岩动态"           url="/sites/ssdwcms/yyqyjy/yydt"  />
  </sharePoint.publishChannel>
</root>

C#读取配置文件ChannelProcess.xml

using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WuZiFenGongSiInfomation.Models.Veiw
{
    /// <summary>
    /// 配置文件数据
    /// </summary>
    public class CommonData
    {
      
        /// <summary>
        /// 栏目可以选择的流程类型列表
        /// </summary>
        public static readonly Dictionary<int, string[]> ChannelSelectProcessList = new Dictionary<int, string[]>();

        /// <summary>
        /// 文章状态 列表
        /// </summary>
        public static readonly Dictionary<int, string> ArticleStatusList = new Dictionary<int, string>();

        /// <summary>
        ///操作类型枚举 列表
        /// </summary>
        public static readonly Dictionary<int, string> OperateTypeList = new Dictionary<int, string>();

        /// <summary>
        ///菜单列表
        /// </summary>
        public static readonly List<Menus> MenusList = new List<Menus>();

        /// <summary>
        /// 系统发布到Sharepoint的栏目
        /// </summary>
        /// 2020-3-4 17:07:14 添加
        public static readonly SortedList<string, string> SharePointPublishChannelList = new SortedList<string, string>();

        static CommonData()
        {
            try
            {  
                //读取webconfig中的节点channelProcess
                string pathProcess = AppDomain.CurrentDomain.BaseDirectory + "ChannelProcess.xml";
                if (!System.IO.File.Exists(pathProcess))
                {
                    throw new FileNotFoundException("没有找到栏目流程配置文件" + pathProcess);
                }
                System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
                xd.Load(pathProcess);
                System.Xml.XmlElement root = xd.DocumentElement;
                var list = root.GetElementsByTagName("channelProcess");
                if (list == null)
                {
                    throw new Exception("配置文件ChannelProcess.xml读取配置channelProcess节点未找到");
                }
                var node_channelProcess = list[0];
                if (node_channelProcess.HasChildNodes)
                {
                    foreach (System.Xml.XmlElement item in node_channelProcess.ChildNodes.OfType<System.Xml.XmlElement>())
                    {
                        //流程类型
                        int typeId = 0;
                        //流程字符串
                        string processData = string.Empty;
                        var typeObj = item.Attributes["typeId"];
                        if (typeObj != null)
                        {
                            typeId = Convert.ToInt32(typeObj.Value);
                        }
                        var valeObj = item.Attributes["value"];
                        if (valeObj != null)
                        {
                            processData = valeObj.Value;
                        }
                        //根据字符“;”拆分
                        string[] arr = processData.Split(';');
                        ChannelSelectProcessList.Add(typeId, arr);
                    }
                }

                //读取文章状态配置
                var articleStatus = root.GetElementsByTagName("articleStatus");
                if (articleStatus == null)
                {
                    throw new Exception("配置文件ChannelProcess.xml读取配置articleStatus节点未找到");
                }
                var articleStatusNode = articleStatus[0];
                if (articleStatusNode.HasChildNodes)
                {
                    foreach (System.Xml.XmlElement item in articleStatusNode.ChildNodes.OfType<System.Xml.XmlElement>())
                    {
                        //文章状态值
                        int key = 0;
                        //文章状态文本
                        string status = string.Empty;
                        var keyObj = item.Attributes["key"];
                        if (keyObj != null)
                        {
                            key = Convert.ToInt32(keyObj.Value);
                        }
                        var nameObj = item.Attributes["name"];
                        if (nameObj != null)
                        {
                            status = nameObj.Value;
                        }
                        ArticleStatusList.Add(key, status);
                    }
                }

                //加载操作日志枚举
                var operateType = root.GetElementsByTagName("operateType");
                if (operateType == null)
                {
                    throw new Exception("配置文件ChannelProcess.xml读取配置operateType节点未找到");
                }
                var operateTypeNode = operateType[0];
                if (operateTypeNode.HasChildNodes)
                {
                    foreach (System.Xml.XmlElement item in operateTypeNode.ChildNodes.OfType<System.Xml.XmlElement>())
                    {
                        //操作值
                        int value = 0;
                        //操作类型描述
                        string title = string.Empty;
                        //是否启用
                        int enabled = 0;
                        var enabledObj = item.Attributes["enabled"];
                        if (enabledObj != null)
                        {
                            enabled = Convert.ToInt32(enabledObj.Value);
                        }
                        if (enabled == 0)
                        {
                            continue;
                        }
                        var keyObj = item.Attributes["value"];
                        if (keyObj != null)
                        {
                            value = Convert.ToInt32(keyObj.Value);
                        }
                        var nameObj = item.Attributes["title"];
                        if (nameObj != null)
                        {
                            title = nameObj.Value;
                        }
                        OperateTypeList.Add(value, title);
                    }
                }

                //MenusList读取菜单  
                var menusNodeObj = root.GetElementsByTagName("menus");
                if (menusNodeObj == null)
                {
                    throw new Exception("配置文件ChannelProcess.xml读取配置menusNodeObj节点未找到");
                }
                var menusNode = menusNodeObj[0];
                if (menusNode.HasChildNodes)
                {
                    foreach (System.Xml.XmlElement item in menusNode.ChildNodes.OfType<System.Xml.XmlElement>())
                    {
                        Menus menus = new Menus();
                        var idObj = item.Attributes["id"];
                        if (idObj != null)
                        {
                            menus.Id = idObj.Value.Trim();
                        }
                        var parentIdObj = item.Attributes["parentId"];
                        if (parentIdObj != null)
                        {
                            menus.ParentId = parentIdObj.Value.Trim();
                        }
                        var nameObj = item.Attributes["name"];
                        if (nameObj != null)
                        {
                            menus.Name = nameObj.Value.Trim();
                        }
                        var urlObj = item.Attributes["url"];
                        if (urlObj != null)
                        {
                            menus.Url = urlObj.Value;
                        }
                        var iconObj = item.Attributes["icon"];
                        if (iconObj != null)
                        {
                            menus.Icon = iconObj.Value;
                        }
                        //2019-11-3 12:44:54 添加
                        var showSystemLeftMenuObj = item.Attributes["showSystemLeftMenu"];
                        if (showSystemLeftMenuObj != null)
                        {
                            menus.ShowSystemLeftMenu = Convert.ToInt16(showSystemLeftMenuObj.Value);
                        }

                    //排序
                    var sortObj = item.Attributes["sort"];
                    menus.Sort = "50000";
                    if (sortObj != null)
                    {
                        menus.Sort = sortObj.Value;
                    }

                        MenusList.Add(menus);
                    }
                }

                //SharePointPublishChannelList
                //搜集到的系统发布到Sharepoint的栏目
                var _publishChannel = root.GetElementsByTagName("sharePoint.publishChannel");
                if (_publishChannel == null)
                {
                    throw new Exception("配置文件ChannelProcess.xml读取配置sharePoint.publishChannel节点未找到");
                }
                var _publishNode = _publishChannel[0];
                if (_publishNode.HasChildNodes)
                {
                    foreach (System.Xml.XmlElement item in _publishNode.ChildNodes.OfType<System.Xml.XmlElement>())
                    {
                        string name = string.Empty;
                        string url = string.Empty;
                        var nameObj = item.Attributes["name"];
                        if (nameObj != null)
                        {
                            name = nameObj.Value.Trim();
                        }
                        var urlObj = item.Attributes["url"];
                        if (urlObj != null)
                        {
                            url = urlObj.Value.Trim();
                        }
                        SharePointPublishChannelList.Add(name, url);
                    }
                }
            }
            catch (Exception ex)
            {
                //LogHelpter.AddLog("初始化配置报错,类WuZiFenGongSiInfomation.Models.Veiw.CommonData," + ex.Message);
            }
        }
 
    }
}

 Menus实体:

//功用:菜单实体,用xml文件配置的
//创建时间:2020-12-24 16:46:54
//作者:王浩力

using System;
using System.Collections.Generic;
using System.Text;

namespace WebNetCore5_Img_Storage.Model
{
    /// <summary>
    /// 菜单VIEW
    /// </summary>
    public struct MenuView
    {
        /// <summary>
        /// 菜单id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 父级id
        /// </summary>
        public string ParentId { get; set; }

        /// <summary>
        /// 菜单名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 菜单url
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 是否显示在系统界面菜单中,1=显示,0=不显示
        /// </summary>
        public byte? ShowLeftMenu { get; set; }

        /// <summary>
        /// 排序,小的排前面
        /// </summary>
        /// <remarks>
        /// 创建时间:2021-3-31 16:50:23
        /// </remarks>
        public string Sort { get; set; }

}
}

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王焜棟琦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值