コード例 #1
0
        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);
                }
            }
        }