You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using ZJ_BYD.ViewModel;
|
|
|
|
|
|
|
|
|
|
namespace ZJ_BYD.Untils
|
|
|
|
|
{
|
|
|
|
|
public class XmlHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取系统内置点位
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<XmlPointVM> GetSystemPoints()
|
|
|
|
|
{
|
|
|
|
|
//声明XmlDocument对象,并加载XML文件
|
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
|
doc.Load(@"ConfigFile/SystemPoints.xml"); //此处为XML文件的路径
|
|
|
|
|
//得到根节点node
|
|
|
|
|
XmlNode rootNode = doc.SelectSingleNode("SystemPoints");
|
|
|
|
|
List<XmlPointVM> xmlPointVMs = new List<XmlPointVM>();
|
|
|
|
|
//得到根节点的所有子节点
|
|
|
|
|
XmlNodeList pointsNodes = rootNode.ChildNodes;
|
|
|
|
|
|
|
|
|
|
foreach (XmlNode item in pointsNodes)
|
|
|
|
|
{
|
|
|
|
|
if (item.Name == "point")
|
|
|
|
|
{
|
|
|
|
|
XmlPointVM xmlPointVM = new XmlPointVM();
|
|
|
|
|
foreach (XmlNode pointNode in item)
|
|
|
|
|
{
|
|
|
|
|
switch (pointNode.Name)
|
|
|
|
|
{
|
|
|
|
|
case "PointCode":
|
|
|
|
|
xmlPointVM.PointCode = pointNode.InnerText;
|
|
|
|
|
break;
|
|
|
|
|
case "Address":
|
|
|
|
|
xmlPointVM.Address = pointNode.InnerText;
|
|
|
|
|
break;
|
|
|
|
|
case "PointName":
|
|
|
|
|
xmlPointVM.PointName = pointNode.InnerText;
|
|
|
|
|
break;
|
|
|
|
|
case "DataType":
|
|
|
|
|
xmlPointVM.DataType = pointNode.InnerText;
|
|
|
|
|
break;
|
|
|
|
|
case "Length":
|
|
|
|
|
xmlPointVM.Length = pointNode.InnerText;
|
|
|
|
|
break;
|
|
|
|
|
case "IsSystem":
|
|
|
|
|
xmlPointVM.IsSystem = bool.Parse(pointNode.InnerText);
|
|
|
|
|
break;
|
|
|
|
|
case "IsSaveDb":
|
|
|
|
|
xmlPointVM.IsSaveDb = bool.Parse(pointNode.InnerText);
|
|
|
|
|
break;
|
|
|
|
|
case "IsActive":
|
|
|
|
|
xmlPointVM.IsActive = bool.Parse(pointNode.InnerText);
|
|
|
|
|
break;
|
|
|
|
|
case "IsRealTime":
|
|
|
|
|
xmlPointVM.IsRealTime = bool.Parse(pointNode.InnerText);
|
|
|
|
|
break;
|
|
|
|
|
case "SortIndex":
|
|
|
|
|
xmlPointVM.SortIndex = int.Parse(pointNode.InnerText);
|
|
|
|
|
break;
|
|
|
|
|
case "Remark":
|
|
|
|
|
xmlPointVM.Remark = pointNode.InnerText;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
xmlPointVMs.Add(xmlPointVM);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return xmlPointVMs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|