Example #1
0
 public static Task InstallAsync(
     this IInstallationService installer,
     IEnumerable <IService> services,
     bool concurrent  = false,
     string?directory = null,
     CancellationToken cancellationToken = default)
 => concurrent
         ? Task.WhenAll(services.Select(x => installer.InstallAsync(x, directory, cancellationToken)))
         : InstallAsync(installer, services, directory, cancellationToken);
Example #2
0
 public static async Task InstallAsync(
     this IInstallationService installer,
     IEnumerable <IService> services,
     string?directory = null,
     CancellationToken cancellationToken = default)
 {
     foreach (var service in services)
     {
         await installer.InstallAsync(service, directory, cancellationToken);
     }
 }
        public async Task <JsonResult> Install(InstallationModel model)
        {
            if (!ModelState.IsValid)
            {
                var result = new InstallationResult();
                ModelState.SelectMany(x => x.Value.Errors).Each(x => result.Errors.Add(x.ErrorMessage));
                return(Json(result));
            }
            else
            {
                var result = await _installService.InstallAsync(model, HttpContext.RequestServices.AsLifetimeScope());

                return(Json(result));
            }
        }
Example #4
0
            public async Task <int> InvokeAsync(InvocationContext context)
            {
                var parseResult = context.ParseResult;
                var concurrent  = parseResult.ValueForOption(_concurrent);
                var directory   = parseResult.ValueForOption(_directory);
                var services    = parseResult.ValueForArgument(_services) !.ToList();

                _logger.BoolOption(nameof(concurrent), concurrent);
                _logger.Option(nameof(directory), directory !);
                _logger.Option(nameof(services), services !);

                var toInstall = _registry
                                .Join(
                    services !,
                    x => x.Key,
                    x => x,
                    (pair, _) => (Name: pair.Key, Service: pair.Value),
                    StringComparer.OrdinalIgnoreCase)
                                .ToList();

                var names = toInstall.Select(x => x.Name).ToList();

                _logger.ServicesToInstall(names);
                _logger.UnmatchedServices(services.Except(names, StringComparer.OrdinalIgnoreCase));

                try
                {
                    await _installer.InstallAsync(
                        toInstall.Select(x => x.Service),
                        concurrent,
                        directory,
                        context.GetCancellationToken());

                    _logger.InstallationSucceeded();

                    return(context.ResultCode);
                }
                catch (Exception e)
                {
                    _logger.InstallationFailed(e);
                    return(1);
                }
            }
Example #5
0
        public async Task <JsonResult> Install(InstallationModel model)
        {
            var result = await _installService.InstallAsync(model, HttpContext.RequestServices.AsLifetimeScope());

            return(Json(result));
        }