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)
     {
     }
 }
 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);
             }
         }
     }
 }
Esempio n. 3
0
 public SubClass(string name, int groupid, MajorClass parent)
 {
     this.name    = name;
     this.groupid = groupid;
     this.parent  = parent;
 }