GSF.ServiceProcess.ServiceHelper.SendActionableResponse C# (CSharp) Method

SendActionableResponse() public method

Sends an actionable response to client along with an optional formatted message and attachment.
This method is used to send an actionable client response that can be used for responding to an event after a command has been issued.
public SendActionableResponse ( GSF.ServiceProcess.ClientRequestInfo requestInfo, bool success, object attachment = null, string status = null ) : void
requestInfo GSF.ServiceProcess.ClientRequestInfo instance containing the client request.
success bool Flag that determines if this response to client request was a success.
attachment object Attachment to send with response.
status string Formatted status message to send with response.
return void
        public void SendActionableResponse(ClientRequestInfo requestInfo, bool success, object attachment = null, string status = null, params object[] args)
        {
            try
            {
                string responseType = requestInfo.Request.Command + (success ? ":Success" : ":Failure");
                string message = "";

                if (!string.IsNullOrWhiteSpace(status))
                {
                    if (args.Length == 0)
                        message = status + "\r\n\r\n";
                    else
                        message = string.Format(status, args) + "\r\n\r\n";
                }

                ServiceResponse response = new ServiceResponse(responseType, CurtailMessageLength(message));

                // Add any specified attachment to the service response
                if ((object)attachment != null)
                    response.Attachments.Add(attachment);

                // Add original command arguments as an attachment
                response.Attachments.Add(requestInfo.Request.Arguments);

                // Send response to service
                SendResponse(requestInfo.Sender.ClientID, response);

                OnUpdatedStatus(requestInfo.Sender.ClientID, response.Message, success ? UpdateType.Information : UpdateType.Alarm);
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                UpdateStatus(UpdateType.Alarm, "Failed to send actionable client response with attachment due to an exception: " + ex.Message + "\r\n\r\n");
            }
        }
ServiceHelper