public LogicGroup(string name, string alias = "", LogicGroup parent = null) { this.name = name; this.alias = alias; this.listLogicGroup = new List <LogicGroup>(); this.listMajorClass = new List <MajorClass>(); this.parent = parent; }
public MajorClass(string name, string alias = "", string classifyField = "", string fc2D = "", string fc3D = "", LogicGroup parent = null) { this.name = name; this.alias = alias; this.classifyField = classifyField; this.fc2D = fc2D; this.fc3D = fc3D; this.listSubClasses = new List <SubClass>(); this.parent = parent; }
private void RecursiveReadConfig(XmlNodeList list, LogicGroup parent) { if (list == null) { return; } foreach (XmlNode node in list) { if (node.Name == "LogicGroup") { string fieldName = "", fieldAliasName = ""; if (node.Attributes["name"] != null) { fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName)) { continue; } } if (node.Attributes["alias"] != null) { fieldAliasName = node.Attributes["alias"].Value.Trim(); } LogicGroup lg = new LogicGroup(fieldName, fieldAliasName, parent); parent.LogicGroups.Add(lg); RecursiveReadConfig(node.ChildNodes, lg); } if (node.Name == "MajorClass") { string fieldName = "", fieldAliasName = "", classifyFieldName = "", fc2D = "", fc3D = ""; if (node.Attributes["name"] != null) { fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName)) { continue; } } if (node.Attributes["alias"] != null) { fieldAliasName = node.Attributes["alias"].Value.Trim(); } if (node.Attributes["classifyfield"] != null) { classifyFieldName = node.Attributes["classifyfield"].Value.Trim(); } if (node.Attributes["fc2D"] != null) { fc2D = node.Attributes["fc2D"].Value.Trim(); } if (node.Attributes["fc3D"] != null) { fc3D = node.Attributes["fc3D"].Value.Trim(); } MajorClass mc = new MajorClass(fieldName, fieldAliasName, classifyFieldName, fc2D, fc3D, parent); parent.MajorClasses.Add(mc); this._allMajorClass.Add(mc); foreach (XmlNode cnode in node.ChildNodes) { if (cnode.Name != "SubClass") { continue; } string scname = "", scgroupid = ""; if (cnode.Attributes["name"] != null) { scname = cnode.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(scname)) { continue; } } if (cnode.Attributes["groupid"] != null) { scgroupid = cnode.Attributes["groupid"].Value.Trim(); } int groupid = 0; if (!int.TryParse(scgroupid, out groupid)) { groupid = 0; } SubClass sc = new SubClass(scname, groupid, mc); mc.SubClasses.Add(sc); this._allSubClass.Add(sc); } } } }
private void ReadConfig() { try { string xmlFilePath = Config.GetConfigValue("LogicDataStructureXmlPath3D"); if (!System.IO.File.Exists(xmlFilePath)) { return; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlFilePath); if (xmlDoc == null) { return; } XmlNode root = xmlDoc.SelectSingleNode("LogicDataStructure"); if (root == null) { return; } foreach (XmlNode node in root.ChildNodes) { if (node.Name == "LogicGroup") { string fieldName = "", fieldAliasName = ""; if (node.Attributes["name"] != null) { fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName)) { continue; } } if (node.Attributes["alias"] != null) { fieldAliasName = node.Attributes["alias"].Value.Trim(); } LogicGroup lg = new LogicGroup(fieldName, fieldAliasName, null); this._rootLogicGroups.Add(lg); RecursiveReadConfig(node.ChildNodes, lg); } if (node.Name == "MajorClass") { string fieldName = "", fieldAliasName = "", classifyFieldName = "", fc2D = "", fc3D = ""; if (node.Attributes["name"] != null) { fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName)) { continue; } } if (node.Attributes["alias"] != null) { fieldAliasName = node.Attributes["alias"].Value.Trim(); } if (node.Attributes["classifyfield"] != null) { classifyFieldName = node.Attributes["classifyfield"].Value.Trim(); } if (node.Attributes["fc2D"] != null) { fc2D = node.Attributes["fc2D"].Value.Trim(); } if (node.Attributes["fc3D"] != null) { fc3D = node.Attributes["fc3D"].Value.Trim(); } MajorClass mc = new MajorClass(fieldName, fieldAliasName, classifyFieldName, fc2D, fc3D, null); this._rootMajorClasses.Add(mc); this._allMajorClass.Add(mc); foreach (XmlNode cnode in node.ChildNodes) { if (cnode.Name != "SubClass") { continue; } string scname = "", scgroupid = ""; if (cnode.Attributes["name"] != null) { scname = cnode.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(scname)) { continue; } } if (cnode.Attributes["groupid"] != null) { scgroupid = cnode.Attributes["groupid"].Value.Trim(); } int groupid = 0; if (!int.TryParse(scgroupid, out groupid)) { groupid = 0; } SubClass sc = new SubClass(scname, groupid, mc); mc.SubClasses.Add(sc); this._allSubClass.Add(sc); } } } } catch (Exception ex) { } }