public static LoginData Read() { LoginData result = null; string path = Path.Combine(FileLocations.TrakHound, SERVER_CREDENTIALS_FILENAME); if (File.Exists(path)) { try { var xml = new XmlDocument(); xml.Load(path); string username = XML_Functions.GetInnerText(xml, "Username"); string token = XML_Functions.GetInnerText(xml, "Token"); if (username != null && token != null) { result = new LoginData(); result.Username = username; result.Token = token; } } catch (Exception ex) { logger.Error(ex); } } return(result); }
public static AgentConfiguration Read(DeviceConfiguration config) { var result = new AgentConfiguration(); result.Address = XML_Functions.GetInnerText(config.Xml, "//Agent/Address"); int port = 80; int.TryParse(XML_Functions.GetInnerText(config.Xml, "//Agent/Port"), out port); result.Port = port; result.DeviceName = XML_Functions.GetInnerText(config.Xml, "//Agent/DeviceName"); return(result); }
public static bool Save(XmlDocument xml, string path) { bool result = false; if (xml != null) { try { string filePath = XML_Functions.GetInnerText(xml, "UniqueId"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } xml.Save(Path.Combine(path, Path.ChangeExtension(filePath, ".xml"))); result = true; } catch (Exception ex) { logger.Error(ex); } } return(result); }
public static bool Save(XmlDocument xml, string path) { bool result = false; if (xml != null) { try { string filePath = XML_Functions.GetInnerText(xml, "UniqueId"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } xml.Save(Path.Combine(path, Path.ChangeExtension(filePath, ".xml"))); result = true; } catch (Exception ex) { Logger.Log("Error during Configuration Xml Save : " + ex.Message, LogLineType.Warning); } } return(result); }