private void CreateNewFC()
        {
            Dictionary <string, FacilityClass> dict       = new Dictionary <string, FacilityClass>();
            List <IBaseLayer> logicBaseTree1GetRootLayers = this.logicBaseTree1.GetRootLayers();

            if (logicBaseTree1GetRootLayers != null)
            {
                foreach (IBaseLayer layer in logicBaseTree1GetRootLayers)
                {
                    if (!(layer is TreeNodeFacilityClass))
                    {
                        continue;
                    }
                    TreeNodeFacilityClass tn = layer as TreeNodeFacilityClass;
                    FacilityClass         fc = tn.CustomValue as FacilityClass;
                    dict[fc.Name] = fc;
                }
            }
            FormCreateFacilityClass dlg = new FormCreateFacilityClass(dict);

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FacilityClass         fc       = new FacilityClass(dlg.FCName, dlg.FCAlias);
                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);
            }
        }
 private bool SaveData(string fileName)
 {
     try
     {
         XmlDocument    document = new XmlDocument();
         XmlDeclaration newChild = document.CreateXmlDeclaration("1.0", "utf-8", null);
         document.AppendChild(newChild);
         XmlNode node = document.CreateElement("FacilityClassManager");
         document.AppendChild(node);
         List <IBaseLayer> logicBaseTree1GetRootLayers = this.logicBaseTree1.GetRootLayers();
         if (logicBaseTree1GetRootLayers != null)
         {
             foreach (IBaseLayer layer in logicBaseTree1GetRootLayers)
             {
                 if (!(layer is TreeNodeFacilityClass))
                 {
                     continue;
                 }
                 TreeNodeFacilityClass tn = layer as TreeNodeFacilityClass;
                 FacilityClass         fc = tn.CustomValue as FacilityClass;
                 if (fc == null)
                 {
                     continue;
                 }
                 XmlElement element = document.CreateElement("FacilityClass");
                 element.SetAttribute("name", fc.Name.Trim());
                 element.SetAttribute("alias", layer.Name.Trim());
                 element.SetAttribute("fc2D", (fc.Fc2D == null) ? "" : fc.Fc2D.Trim());
                 element.SetAttribute("fc3D", (fc.Fc3D == null) ? "" : fc.Fc3D.Trim());
                 XmlNode fcNode = node.AppendChild(element);
                 if (fcNode == null)
                 {
                     continue;
                 }
                 foreach (FieldInfo fi in fc.FieldInfoCollection)
                 {
                     XmlElement ele = document.CreateElement("StdField");
                     ele.SetAttribute("name", fi.Name.Trim());
                     ele.SetAttribute("alias", fi.Alias.Trim());
                     ele.SetAttribute("datatype", fi.DataType.Trim());
                     ele.SetAttribute("systemname", fi.SystemName.Trim());
                     ele.SetAttribute("systemalias", fi.SystemAlias.Trim());
                     ele.SetAttribute("canquery", fi.CanQuery ? "true" : "false");
                     ele.SetAttribute("needcheck", fi.NeedCheck ? "true" : "false");
                     ele.SetAttribute("canstats", fi.CanStats ? "true" : "false");
                     fcNode.AppendChild(ele);
                 }
             }
         }
         document.Save(fileName);
         return(true);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("保存数据失败!", "提示");
         return(false);
     }
 }
 private void logicBaseTree1_OnHitTest(MouseButtons button, int x, int y, IBaseLayer layer)
 {
     if (layer is TreeNodeFacilityClass)
     {
         TreeNodeFacilityClass tn = layer as TreeNodeFacilityClass;
         if (layer.CustomValue is FacilityClass)
         {
             this.ucFieldManage1.SetData(layer.CustomValue as FacilityClass);
         }
     }
 }
        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)
            {
            }
        }