Exemple #1
0
        /// <summary>
        /// Method to run when the root command is executed.
        /// </summary>
        /// <returns>Zero if ok.</returns>
        public int OnExecuteAsync(CommandLineApplication app)
        {
            Console.WriteLine($"Settings: {JsonConvert.SerializeObject(this, Formatting.Indented)}");

            try
            {
                if (CheckOptions(app))
                {
                    // Overriding Zipato data options.
                    _zipato.BaseAddress = BaseAddress;
                    _zipato.Timeout     = Timeout;
                    _zipato.User        = User;
                    _zipato.Password    = Password;
                    _zipato.IsLocal     = IsLocal;

                    if (_zipato.CheckUserSession())
                    {
                        Console.WriteLine($"Zipato web service found at {BaseAddress}.");
                    }
                    else
                    {
                        Console.WriteLine($"Zipato web service not found at {BaseAddress}.");
                    }
                }
            }
            catch (Exception ex)
            {
                _logger?.LogError(ex, $"Exception RootCommand Run()");
                Console.WriteLine($"Error connecting to Zipato web service at {BaseAddress}.");
                return(-1);
            }

            return(0);
        }