protected override void OnSessionChange(SessionChangeDescription changeDescription) { try { Restart(); } catch (Exception ex) when(!AutoLog) { string directory = AppDomain.CurrentDomain.BaseDirectory; string filePath = Path.Combine(directory, UtcNow.ToString("OnSessionChange failure at yyyy-MM-dd HH_mm_ss")); File.AppendAllText(filePath, ex.ToString()); } }
protected override void OnPause() { try { _NancyHost.Stop(); } catch (Exception ex) when(!AutoLog) { string directory = AppDomain.CurrentDomain.BaseDirectory; string filePath = Path.Combine(directory, UtcNow.ToString("OnPause failure at yyyy-MM-dd HH_mm_ss")); File.AppendAllText(filePath, ex.ToString()); } }
protected override void OnStart(string[] args) { try { AutoLog = bool.Parse(ConfigurationManager.AppSettings["AutoLog"] ?? "true"); _NancyHost = CreateHost(); _NancyHost.Start(); } catch (Exception ex) when(!AutoLog) { string directory = AppDomain.CurrentDomain.BaseDirectory; string filePath = Path.Combine(directory, UtcNow.ToString("OnStart failure at yyyy-MM-dd HH_mm_ss")); File.AppendAllText(filePath, ex.ToString()); } }
protected override void OnCustomCommand(int command) { try { if (command != (int)Command.Restart) { return; } //useful for config changes Restart(); } catch (Exception ex) when(!AutoLog) { string directory = AppDomain.CurrentDomain.BaseDirectory; string filePath = Path.Combine(directory, UtcNow.ToString("OnCustomCommand failure at yyyy-MM-dd HH_mm_ss")); File.AppendAllText(filePath, ex.ToString()); } }
void IXmlSerializable.WriteXml(XmlWriter writer) { writer.WriteAttributeString("Date", Date.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("UtcNow", UtcNow.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("TimeZone", TimeZone.ToString()); writer.WriteAttributeString("Culture", CurrentCulture); writer.WriteAttributeString("UICulture", CurrentUICulture); writer.WriteStartElement("OSVersion"); ((IXmlSerializable)OSVersion).WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("Frameworks"); foreach (var o in FrameworksVersions) { writer.WriteElementString("Framework", o.ToString()); } writer.WriteEndElement(); writer.WriteStartElement("Pathes"); if (Paths.IsNotEmpty()) { foreach (var pair in Paths) { writer.WriteStartElement("Path"); writer.WriteAttributeString("Name", pair.Name); writer.WriteAttributeString("Value", pair.Value.ToString()); writer.WriteEndElement(); } } writer.WriteEndElement(); writer.WriteStartElement("DomainInfo"); ((IXmlSerializable)DomainInfo).WriteXml(writer); writer.WriteEndElement(); }