AWSRedrive.PowerShellMessageProcessor.ProcessMessage C# (CSharp) Method

ProcessMessage() public method

public ProcessMessage ( string message, AWSRedrive.ConfigurationEntry configurationEntry ) : void
message string
configurationEntry AWSRedrive.ConfigurationEntry
return void
        public void ProcessMessage(string message, ConfigurationEntry configurationEntry)
        {
            using (var ps = PowerShell.Create())
            {
                var script = File.ReadAllText(configurationEntry.RedriveScript);

                // We expect that not-throwing an exception signifies a successful execution.
                // For debugging purposes, we'll assemble and show the output.
                var results = ps.AddScript(script).AddParameter("content", message).Invoke();

                var sb = new StringBuilder();
                foreach (var result in results)
                {
                    sb.AppendLine(result.ToString());
                }

                var logString = sb.ToString();
                if (!string.IsNullOrEmpty(logString))
                {
                    Logger.Debug($"Script output: {logString}");
                }
                else
                {
                    Logger.Debug("No script output was produced");
                }
            }
        }
    }
PowerShellMessageProcessor