private async Task StopAppServices(StopCommandContext context)
        {
            foreach (var appInstallation in context.AppInstallations)
            {
                _log.InfoFormat(Resources.StopCommandHandler_StopAppService, appInstallation);

                // Остановка рабочего процесса приложения
                await _appService.Stop(appInstallation, context.CommandOptions.Timeout);
            }
        }
        private Task FindAppInstallations(StopCommandContext context)
        {
            context.AppInstallations = _installDirectory.GetItems(context.CommandOptions.Id, context.CommandOptions.Version, context.CommandOptions.Instance);

            if (context.AppInstallations == null || context.AppInstallations.Length <= 0)
            {
                throw new CommandHandlerException(Resources.StopCommandHandler_CanNotFindAnyApplicationsToStop);
            }

            return(AsyncHelper.EmptyTask);
        }
        public override async Task Handle(StopCommandOptions options)
        {
            CommonHelper.CheckAdministrativePrivileges();

            var commandContext = new StopCommandContext
            {
                CommandOptions = options
            };

            var commandTransaction = new CommandTransactionManager <StopCommandContext>(_log)
                                     .Stage(Resources.StopCommandHandler_FindAppInstallations, FindAppInstallations)
                                     .Stage(Resources.StopCommandHandler_StopAppServices, StopAppServices);

            await commandTransaction.Execute(commandContext);
        }