/// <summary> /// Create the Pipe Message using the received method and parameters /// </summary> /// <param name="method"></param> /// <param name="parameters"></param> /// <returns></returns> private string CreateMessage(CommunicatorMethods method, object parameters) { try { PipeMessage pipeMessage = new PipeMessage { Method = method.ToString().ToLower(), Params = parameters }; return(JObject.FromObject(pipeMessage).ToString()); } catch (Exception ex) { Log.Info(COMMUNICATOR_LOG, string.Format("Sent (NOK): {0} Message Creation failure.\r\n{0}", method.ToString().ToUpper(), ex.ToString())); return(string.Empty); } }
/// <summary> /// Send a message using pipes to the Acrelec.Mockingbird.Core.Service.exe payment driver /// </summary> /// <param name="message">The message to be sent</param> /// <returns>True - If the message was send successfully</returns> public bool SendMessage(CommunicatorMethods method, object parameters) { //Generate the message string that will be sent via pipes string message = CreateMessage(method, parameters); //Check if the message was successfully generated if (string.IsNullOrEmpty(message)) { return(true); } //Send the message and check it the send was successful if (pipeClient.SendMessage(CORE_PIPE_SERVER_NAME, message)) { Log.Info(COMMUNICATOR_LOG, "Sent (OK): " + message); return(true); } else { Log.Info(COMMUNICATOR_LOG, "Sent (NOK): " + message); return(false); } }