public void LoadData(string fileName) { if (string.IsNullOrEmpty(fileName)) { return; } Dictionary <string, FacilityClass> dict = new Dictionary <string, FacilityClass>(); try { if (!File.Exists(fileName)) { if (!File.Exists(fileName)) { string path = System.IO.Path.GetDirectoryName(fileName) + "\\"; if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); if (di == null) { return; } } XmlDocument document = new XmlDocument(); XmlDeclaration newChild = document.CreateXmlDeclaration("1.0", "utf-8", null); document.AppendChild(newChild); XmlNode node = document.CreateElement("FacilityClassManager"); document.AppendChild(node); document.Save(fileName); } } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); if (xmlDoc == null) { return; } XmlNode root = xmlDoc.SelectSingleNode("FacilityClassManager"); if (root == null) { return; } foreach (XmlNode node in root.ChildNodes) { if (node.Name != "FacilityClass") { continue; } if (node.Attributes["name"] == null) { continue; } string name = "", alias = ""; if (node.Attributes["name"] != null) { name = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(name)) { continue; } } if (node.Attributes["alias"] != null) { alias = node.Attributes["alias"].Value.Trim(); } FacilityClass fc = new FacilityClass(name, alias); if (node.Attributes["fc2D"] != null) { fc.Fc2D = node.Attributes["fc2D"].Value.Trim(); } if (node.Attributes["fc3D"] != null) { fc.Fc3D = node.Attributes["fc3D"].Value.Trim(); } if (dict.ContainsKey(fc.Name)) { continue; } dict[fc.Name] = fc; foreach (XmlNode cnode in node.ChildNodes) { if (cnode.Name != "StdField") { continue; } if (cnode.Attributes["name"] == null) { continue; } string fieldName = "", fieldAliasName = "", dataType = "", fieldSystemName = "", fieldSystemAliasName = "", fieldCanQuery = "", fieldNeedCheck = "", fieldCanStats = ""; if (cnode.Attributes["name"] != null) { fieldName = cnode.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName)) { continue; } } if (cnode.Attributes["alias"] != null) { fieldAliasName = cnode.Attributes["alias"].Value.Trim(); } if (cnode.Attributes["datatype"] != null) { dataType = cnode.Attributes["datatype"].Value.Trim(); } if (cnode.Attributes["systemname"] != null) { fieldSystemName = cnode.Attributes["systemname"].Value.Trim(); } if (cnode.Attributes["systemalias"] != null) { fieldSystemAliasName = cnode.Attributes["systemalias"].Value.Trim(); } if (cnode.Attributes["canquery"] != null) { fieldCanQuery = cnode.Attributes["canquery"].Value.Trim(); } if (cnode.Attributes["needcheck"] != null) { fieldNeedCheck = cnode.Attributes["needcheck"].Value.Trim(); } if (cnode.Attributes["canstats"] != null) { fieldCanStats = cnode.Attributes["canstats"].Value.Trim(); } bool bCanQuery = false; if (!string.IsNullOrEmpty(fieldCanQuery) && fieldCanQuery == "true") { bCanQuery = true; } bool bNeedCheck = false; if (!string.IsNullOrEmpty(fieldNeedCheck) && fieldNeedCheck == "true") { bNeedCheck = true; } bool bCanStats = false; if (!string.IsNullOrEmpty(fieldCanStats) && fieldCanStats == "true") { bCanStats = true; } FieldInfo fi = new FieldInfo(fieldName, fieldAliasName, fieldSystemName, fieldSystemAliasName, bCanQuery, bNeedCheck, bCanStats, dataType); fc.AddFieldInfo(fi); } TreeNodeFacilityClass treenode = new TreeNodeFacilityClass() { Name = string.IsNullOrEmpty(fc.Alias) ? fc.Name : fc.Alias, CustomValue = fc }; treenode.OwnNode = this.logicBaseTree1.TreeList.AppendNode(new object[] { treenode.Name }, (TreeListNode)null); } } catch (Exception ex) { } }