Exemplo n.º 1
0
        protected override async Task ExecuteAsync(IConsole console)
        {
            var creationTask = ServerAccessor.CreateMinerAsync(Name, Username, Password);
            var minerResult  = await creationTask.Try();

            if (minerResult == null)
            {
                var response = (creationTask.Exception.InnerException as HttpRequestException)?.StatusCode;
                if (response == null || !response.HasValue)
                {
                    throw creationTask.Exception.InnerException;
                }
                var responseCode = response.Value;

                if (responseCode == HttpStatusCode.NotFound)
                {
                    await ErrorLineAsync("This pool does not support miner creation!");
                }
                else
                {
                    throw creationTask.Exception.InnerException;
                }

                return;
            }

            await SuccessLineAsync("Successfully created miner!");
            await TableAsync(new Dictionary <string, Func <CreateMinerResult, object> >()
            {
                ["Id"]    = x => x.Info.Id,
                ["Name"]  = x => x.Info.Name,
                ["Token"] = x => x.Token,
            }, new[] { minerResult });
        }