public override async Task <bool> InvokeAsync(string paramList) { var status = true; try { var index = 0; var configs = _configBusiness.OpenDatabaseConfig().ToArray(); if (configs.Length > 1) { OutputWarning("There are {0} database targets configured. When using multiple targets you will have to update the config files manually.", configs.Length); return(false); } var defaultUrl = configs.First().Url; var response = await GetServerUrlAsync(paramList, index ++, defaultUrl); if (string.IsNullOrEmpty(response)) { status = false; return(false); } var config = _configBusiness.OpenDatabaseConfig().First(); var logonInfo = await GetUsernameAsync(paramList, index ++, config, "config_auto"); if (logonInfo == null) { status = false; return(false); } _configBusiness.InitiateApplicationConfig(); if (!InitiateDefaultCounters()) { status = false; return(false); } if (!await StartService()) { status = false; return(false); } return(true); } finally { if (!status) { OutputLine("Setup did not go as it should. Correct the issues manually and type exit when you are done.", ConsoleColor.Blue, OutputLevel.Information); OutputLine("Use the site https://github.com/poxet/Influx-Capacitor for support.", ConsoleColor.Blue, OutputLevel.Information); } } }
public void Enqueue(Point[] points) { foreach (var config in _configBusiness.OpenDatabaseConfig()) { IFormatter formatter; try { var agent = _influxDbAgentLoader.GetAgent(config); var agentInfo = agent.GetAgentInfo(); formatter = agentInfo.Item1; _outputMessage("Send to " + config.Url + " ver " + agentInfo.Item2, OutputLevel.Information); } catch (InvalidOperationException) { var ifx = new InfluxDb("http://influx-capacitor.com", "-", "-", InfluxVersion.v09x); formatter = ifx.GetFormatter(); _outputMessage("Unknown client version, simulation output for version " + ifx.GetClientVersion() + ".", OutputLevel.Warning); } foreach (var point in points) { _outputMessage(formatter.PointToString(point), OutputLevel.Information); } } }
public async override Task <bool> InvokeAsync(string paramList) { var configs = _configBusiness.OpenDatabaseConfig().ToArray(); if (configs.Length > 1) { OutputWarning("There are {0} databases configured. When using multiple targets you will have to update the config files manually.", configs.Length); return(false); } var currentConfig = configs.First(); var config = new InfluxDatabaseConfig(true, currentConfig.Url, string.Empty, string.Empty, string.Empty, null); var index = 0; var logonInfo = await GetUsernameAsync(paramList, index ++, config, "config_database"); if (logonInfo == null) { return(false); } var result = await ServiceCommands.GetServiceStatusAsync(); if (result != null) { await ServiceCommands.RestartServiceAsync(); } return(true); }
public async override Task <bool> InvokeAsync(string paramList) { var configs = _configBusiness.OpenDatabaseConfig().ToArray(); if (!configs.Any() || configs.All(x => x.Url == Constants.NoConfigUrl)) { OutputWarning("No database configuration exists."); return(false); } foreach (var config in configs) { if (config.Url == Constants.NoConfigUrl) { continue; } OutputInformation("Url: {0}", config.Url); OutputInformation("Name: {0}", config.Name); OutputInformation("Username: {0}", config.Username); try { var client = _influxDbAgentLoader.GetAgent(config); OutputInformation("Connect: {0}", await client.CanConnect()); OutputInformation("Version: {0}", await client.VersionAsync()); } catch (InvalidOperationException) { OutputError("Unable to connect to database."); } OutputInformation(""); } return(true); }