Esempio n. 1
0
        public void FirePostActions(AbstractCommand command)
        {
            try
            {
                AfterAction?.Invoke(command);
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Failed to invoke action after command ran successfully.", exception);
            }

            try
            {
                if (ShouldPingAfter)
                {
                    IO.Http.Get(PingAfterUrl);
                }
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Ping failed for {PingAfterUrl} after command ran successfully.", exception);
            }

            var emailSubject  = $"Command completed: {command.Name}";
            var commandOutput = command.FlushBuffer();

            try
            {
                if (ShouldEmailOutput)
                {
                    new Mail()
                    {
                        Host     = MailSettings.Host,
                        Port     = MailSettings.Port,
                        Username = MailSettings.Username,
                        Password = MailSettings.Password,
                    }
                }
                .Send(MailSettings.From, EmailOutputToAddress, emailSubject, commandOutput);
            }