public static void UpdateConfiguration(ServantAgentConfiguration configuration, string saveToDirectory = null) { var configFile = Path.Combine(saveToDirectory ?? ConfigFileDirectory, ConfigFileFileName); File.WriteAllText(configFile, Json.SerializeToString(configuration)); TinyIoCContainer.Current.Register(configuration); }
public static ServantAgentConfiguration GetConfigurationFromDisk() { var configFile = Path.Combine(ConfigFileDirectory, ConfigFileFileName); ServantAgentConfiguration configuration; if (!File.Exists(configFile)) { configuration = new ServantAgentConfiguration { ServantIoHost = "https://www.servant.io", InstallationGuid = Guid.NewGuid() }; UpdateConfiguration(configuration); } else { configuration = Json.DeserializeFromString<ServantAgentConfiguration>(File.ReadAllText(configFile)); } return configuration; }
public static ServantAgentConfiguration GetConfigurationFromDisk() { var configFile = Path.Combine(ConfigFileDirectory, ConfigFileFileName); ServantAgentConfiguration configuration; if (!File.Exists(configFile)) { configuration = new ServantAgentConfiguration { ServantIoHost = "https://www.servant.io", InstallationGuid = Guid.NewGuid() }; UpdateConfiguration(configuration); } else { configuration = Json.DeserializeFromString <ServantAgentConfiguration>(File.ReadAllText(configFile)); } return(configuration); }
private static void SendServerInfo(ServantAgentConfiguration configuration) { ReplyOverHttp(new CommandResponse(CommandResponse.ResponseType.ServerInfo) { Message = Json.SerializeToString( new ServerInfo() { ServantVersion = configuration.Version, ServerName = Environment.MachineName, OperatingSystem = OperatingSystemHelper.GetOsVersion(), TotalSites = SiteManager.TotalSites, TotalApplicationPools = SiteManager.TotalApplicationPools } ), Success = true }); }