| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using System.IO;
- using System.Reflection;
- using System.Xml;
- using IwbZero.IwbBase;
- using IwbZero.ToolCommon.StringModel;
- namespace IwbZero.Processes
- {
- public class IwbProcess : IIwbId
- {
- public static IwbProcess LoadById(string piProcessId)
- {
- string fileName = "IwbZero.Processes.ProcessInfos.Process.xml";
- XmlDocument xDoc = new XmlDocument();
- Assembly asm = Assembly.GetExecutingAssembly();
- //读取嵌入式资源
- Stream sm = asm.GetManifestResourceStream(fileName);
- if (sm != null)
- {
- xDoc.Load(sm);
- }
- if (!xDoc.HasChildNodes)
- {
- return null;
- }
- XmlNode xmlNode = xDoc.LastChild;
- return LoadByXmlNode(xmlNode, piProcessId);
- }
- public static IwbProcess LoadByXmlNode(XmlNode xmlNode, string piProcessId)
- {
- if (!xmlNode.HasChildNodes)
- {
- return null;
- }
- foreach (XmlNode child in xmlNode.ChildNodes)
- {
- if (child.Attributes?["id"] != null && child.Attributes["id"].Value.UAndT() == piProcessId.UAndT())
- {
- IwbProcess process = new IwbProcess()
- {
- Id = piProcessId,
- ProcessId = child.Attributes["id"].Value,
- };
- if (child.HasChildNodes)
- {
- foreach (XmlNode node in child.ChildNodes)
- {
- switch (node.Name.Trim())
- {
- case "Name":
- process.ProcessName = node.FirstChild?.Value;
- break;
- case "Parameters":
- process.ProcessParameters = node.FirstChild?.Value;
- break;
- case "Description":
- process.Description = node.FirstChild?.Value;
- break;
- case "ProcessType":
- process.Description = node.FirstChild?.Value;
- break;
- case "Script":
- process.ProcessScript = node.FirstChild?.Value;
- break;
- case "Class":
- process.ProcessClass = node.FirstChild?.Value;
- break;
- case "Lib":
- process.ProcessLib = node.FirstChild?.Value;
- break;
- case "IsStatic":
- process.IsStatic = node.FirstChild?.Value.ValB() ?? false;
- break;
- }
- }
- }
- return process;
- }
- }
- return null;
- }
- public string Id { get; set; }
- public string ProcessId { get; set; }
- public string ProcessName { get; set; }
- public string ProcessParameters { get; set; }
- public string Description { get; set; }
- public string ProcessType { get; set; }
- public string ProcessScript { get; set; }
- public string ProcessClass { get; set; }
- public string ProcessLib { get; set; }
- public bool IsStatic { get; set; }
- }
- }
|