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

                // Остановка рабочего процесса приложения
                await _appService.Stop(appInstallation, context.CommandOptions.Timeout);
            }
        }
        private Task FindAppInstallations(RestartCommandContext 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.StartCommandHandler_CanNotFindAnyApplicationsToStart);
            }

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

            var commandContext = new RestartCommandContext
            {
                CommandOptions = options
            };

            var commandTransaction = new CommandTransactionManager <RestartCommandContext>(_log)
                                     .Stage(Resources.StartCommandHandler_FindAppInstallations, FindAppInstallations)
                                     .Stage(Resources.StopCommandHandler_StopAppServices, StopAppServices)
                                     .Stage(Resources.StartCommandHandler_StartAppServices, StartAppServices);

            await commandTransaction.Execute(commandContext);
        }