public static void DeleteDeviceNode(string xPath)
        {
            string path = Paths.AGENT_DEVICES;

            if (File.Exists(path))
            {
                var doc = XML.Files.ReadDocument(path);
                if (doc != null)
                {
                    var devicesNode = doc.SelectSingleNode("//Devices");

                    var node = doc.SelectSingleNode(xPath);
                    if (node != null && devicesNode != null)
                    {
                        node.InnerText = null;
                        node.InnerXml  = null;

                        node.RemoveAll();
                        devicesNode.RemoveChild(node);

                        // Check if node was only device
                        if (devicesNode.ChildNodes.Count == 0)
                        {
                            XML.Nodes.Add(doc, "//Devices/Device");
                            XML.Attributes.Set(doc, "//Devices/Device", "id", "dummy");
                            XML.Attributes.Set(doc, "//Devices/Device", "uuid", "dummy");
                            XML.Attributes.Set(doc, "//Devices/Device", "name", "dummy");
                        }

                        XML.Files.WriteDocument(doc, path, true);

                        AgentManagement.Restart();
                    }
                }
            }
        }
        public static void WriteDeviceNode(XmlNode node)
        {
            string path = Paths.AGENT_DEVICES;

            try
            {
                if (File.Exists(path))
                {
                    var doc = XML.Files.ReadDocument(path);
                    if (doc != null)
                    {
                        var root = doc.DocumentElement;

                        var devices = root.SelectSingleNode("Devices");

                        var importNode = doc.ImportNode(node, true);
                        devices.AppendChild(importNode);

                        var dummyNode = doc.SelectSingleNode("//Device[@id=\"dummy\"]");
                        if (dummyNode != null)
                        {
                            dummyNode.InnerText = null;
                            dummyNode.InnerXml  = null;

                            dummyNode.RemoveAll();
                            devices.RemoveChild(dummyNode);
                        }

                        XML.Files.WriteDocument(doc, path);

                        AgentManagement.Restart();
                    }
                }
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); }
        }