protected override bool Configure(XmlConfig.XmlConfig settings) { String timesStr = settings.GetItem("restart/times").Value; if (!String.IsNullOrEmpty(timesStr)) { if (!Int32.TryParse(timesStr, out _remainingTimes)) { Log.Warn("Cannot limit the number of restart: the times property is not well defined."); return false; } } return true; }
protected override bool Configure(XmlConfig.XmlConfig settings) { String rootXPath = string.Format("email{0}smtp{0}", XmlConfig.XmlConfig.XPathSeparator); String host = settings.GetItem(rootXPath + "host").Value; String port = settings.GetItem(rootXPath + "port").Value; String login = settings.GetItem(rootXPath + "login").Value; String password = settings.GetItem(rootXPath + "password").Value; // smtp client is mandatory! if (!CreateSmtpClient(host, port, login, password)) { return false; } rootXPath = string.Format("email{0}address{0}", XmlConfig.XmlConfig.XPathSeparator); String toAddress = settings.GetItem(rootXPath + "to").Value; String fromAddress = settings.GetItem(rootXPath + "from").Value; rootXPath = string.Format("email{0}subject", XmlConfig.XmlConfig.XPathSeparator); String subject = settings.GetItem(rootXPath).Value; String executable = settings.GetItem("executable").Value; // message is mandatory too! return PrepareMessage(toAddress, fromAddress, subject, executable, Service.DisplayName); }