Exemplo n.º 1
0
        void Helper_ReceivedServiceResponse(object sender, TVA.EventArgs <ServiceResponse> e)
        {
            string     response         = e.Argument.Type;
            string     message          = e.Argument.Message;
            string     responseToClient = string.Empty;
            UpdateType responseType     = UpdateType.Information;

            if (!string.IsNullOrEmpty(response))
            {
                // Reponse types are formatted as "Command:Success" or "Command:Failure"
                string[] parts = response.Split(':');
                string   action;
                bool     success;

                if (parts.Length > 1)
                {
                    action  = parts[0].Trim().ToTitleCase();
                    success = (string.Compare(parts[1].Trim(), "Success", true) == 0);
                }
                else
                {
                    action  = response;
                    success = true;
                }

                if (success)
                {
                    if (string.IsNullOrEmpty(message))
                    {
                        responseToClient = string.Format("{0} command processed successfully.\r\n\r\n", action);
                    }
                    else
                    {
                        responseToClient = string.Format("{0}\r\n\r\n", message);
                    }
                }
                else
                {
                    responseType = UpdateType.Alarm;
                    if (string.IsNullOrEmpty(message))
                    {
                        responseToClient = string.Format("{0} failure.\r\n\r\n", action);
                    }
                    else
                    {
                        responseToClient = string.Format("{0} failure: {1}\r\n\r\n", action, message);
                    }
                }

                DisplayMessage(responseType, responseToClient);
            }
        }
Exemplo n.º 2
0
 void dataSubscriber_StatusMessage(object sender, TVA.EventArgs <string> e)
 {
     //System.Diagnostics.Debug.WriteLine("SUBSCRIPTION: " + e.Argument);
 }
Exemplo n.º 3
0
 void dataSubscriber_ProcessException(object sender, TVA.EventArgs <Exception> e)
 {
     //System.Diagnostics.Debug.WriteLine("SUBSCRIPTION: EXCEPTION: " + e.Argument.Message);
 }
Exemplo n.º 4
0
 void Helper_ReceivedServiceUpdate(object sender, TVA.EventArgs <UpdateType, string> e)
 {
     DisplayMessage(e.Argument1, e.Argument2);
 }