Beispiel #1
0
        public static XmlDocument LoadConfigFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                ConfigFileManager.CreateConfigFile(filePath);
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(filePath);
            return(doc);
        }
Beispiel #2
0
        public static void AddMessageLog(string message)
        {
            string       directoryName = ConfigFileManager.GetLogPath();
            string       realLogName   = directoryName + "\\" + LOG_NAME + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt";
            StreamWriter log;

            if (!File.Exists(realLogName))
            {
                log = new StreamWriter(realLogName);
            }
            else
            {
                log = File.AppendText(realLogName);
            }

            log.WriteLine(message);
            log.WriteLine();
            log.Close();
        }
Beispiel #3
0
        public static void AddDevice(string deviceIPAddress, string deviceName)
        {
            string configFilePath = ConfigFileManager.GetConfigurationFilePath();

            var xmlConfigFile = ConfigFileManager.LoadConfigFile(configFilePath);

            XmlNode xNodeServer = xmlConfigFile.CreateNode(XmlNodeType.Element, "Device", string.Empty);

            XmlAttribute xAttributeSite = xmlConfigFile.CreateAttribute("IPAddress");

            xAttributeSite.Value = deviceIPAddress;
            xNodeServer.Attributes.Append(xAttributeSite);

            XmlAttribute xAttributeName = xmlConfigFile.CreateAttribute("Name");

            xAttributeName.Value = deviceName;
            xNodeServer.Attributes.Append(xAttributeName);

            xmlConfigFile.GetElementsByTagName("Devices")[0]
            .InsertAfter(xNodeServer, xmlConfigFile.GetElementsByTagName("Devices")[0].LastChild);

            xmlConfigFile.Save(configFilePath);
        }
Beispiel #4
0
        public static void AddSDK(string sdkPath, string sdkName)
        {
            string configFilePath = ConfigFileManager.GetConfigurationFilePath();

            var xmlConfigFile = ConfigFileManager.LoadConfigFile(configFilePath);

            XmlNode xNodeServer = xmlConfigFile.CreateNode(XmlNodeType.Element, "SDK", string.Empty);

            XmlAttribute xAttributeSite = xmlConfigFile.CreateAttribute("Path");

            xAttributeSite.Value = sdkPath;
            xNodeServer.Attributes.Append(xAttributeSite);

            XmlAttribute xAttributeName = xmlConfigFile.CreateAttribute("Name");

            xAttributeName.Value = sdkName;
            xNodeServer.Attributes.Append(xAttributeName);

            xmlConfigFile.GetElementsByTagName("SDKs")[0]
            .InsertAfter(xNodeServer, xmlConfigFile.GetElementsByTagName("SDKs")[0].LastChild);

            xmlConfigFile.Save(configFilePath);
        }
Beispiel #5
0
        public static List <Device> GetDevices()
        {
            string filePath = GetConfigurationFilePath();

            if (!File.Exists(filePath))
            {
                ConfigFileManager.CreateConfigFile(filePath);
            }

            var devices = new List <Device>();

            var doc = ConfigFileManager.LoadConfigFile(filePath);

            XmlNode xServersNode = doc.DocumentElement.ChildNodes[1];

            foreach (XmlNode node in xServersNode.ChildNodes)
            {
                Device sdk = Device.GetDeviceFromXmlNode(node);
                devices.Add(sdk);
            }

            return(devices);
        }
Beispiel #6
0
        public static List <SDK> GetSDKs()
        {
            string filePath = GetConfigurationFilePath();

            if (!File.Exists(filePath))
            {
                ConfigFileManager.CreateConfigFile(filePath);
            }

            var sdks = new List <SDK>();

            var doc = ConfigFileManager.LoadConfigFile(filePath);

            XmlNode xServersNode = doc.DocumentElement.FirstChild;

            foreach (XmlNode node in xServersNode.ChildNodes)
            {
                SDK sdk = SDK.GetSDKFromXmlNode(node);
                sdks.Add(sdk);
            }

            return(sdks);
        }