public JSONParameters SendFormatRequest(JSONRequest formatRequest) { var jsonResult = new JavaScriptSerializer().Serialize(formatRequest); string response = AsynchronousClient.SendAndReceiveMessage(jsonResult); var JsonFormatResponse = new JavaScriptSerializer().Deserialize <JSONParameters>(response); // Convert object return(JsonFormatResponse); }
private void Connect_Btn_Click(object sender, RoutedEventArgs e) { AsynchronousClient.port = Int32.Parse(Port_Textbox.Text); AsynchronousClient.IpAddress = IPAddress_Textbox.Text; Status_Label.Content = "Connection Established"; Logger.LogMsg(Logger.Action("Socket Parameters Set: IPADDRESS='" + AsynchronousClient.port + "' PORT='" + AsynchronousClient.IpAddress + "'", Constants.INFO)); AsynchronousClient.StartClient(); }
private void Purchase_Btn_Click(object sender, RoutedEventArgs e) { try { Error_Message_Label.Text = "ERROR: "; AnswersPanel.Children.Clear(); Logger.LogMsg(Logger.Action("Select Purchase Totalizer", Constants.DEBU)); string response; JSONSendInputs jInputs = new JSONSendInputs(); JSONResponse jResponse = new JSONResponse(); jInputs.args = new List <Dictionary <string, string> >(); jInputs.messageType = "EXEC-SERVICE"; jInputs.serviceName = parameterObject.serviceName; jInputs.numArgs = parameterObject.numArgs; foreach (Dictionary <string, string> arg in parameterObject.args) { Dictionary <string, string> dict = new Dictionary <string, string>(); TextBox txt = (TextBox)FieldsPanel.FindName(arg["name"] + "_textbox"); dict.Add("position", arg["position"]); dict.Add("name", arg["name"]); dict.Add("dataType", arg["dataType"]); dict.Add("value", txt.Text); jInputs.args.Add(dict); Logger.LogMsg(Logger.Action("Purchase Totalizer Input Set: POS='" + arg["position"] + "' NAME='" + arg["name"] + "' DATATYPE='" + arg["dataType"] + "' INPUT='" + txt.Text + "'", Constants.INFO)); } var jsonResult = new JavaScriptSerializer().Serialize(jInputs); response = AsynchronousClient.SendAndReceiveMessage(jsonResult); var JsonModel = new JavaScriptSerializer().Deserialize <JSONResponse>(response); // Convert object jResponse = JsonModel; if (!jResponse.error) { foreach (Dictionary <string, string> responses in parameterObject.responses) // These are answers { string argumentName = responses["name"]; SpawnAnswer(argumentName, jResponse.response[responses["name"]]); Logger.LogMsg(Logger.Action("Purchase Totalizer Response: NAME='" + argumentName + "' VALUE='" + jResponse.response[responses["name"]] + "'", Constants.INFO)); } } else { Error_Message_Label.Text = "ERROR: " + jResponse.response["message"]; Logger.LogMsg(Logger.Action("Purchase Totalizer Error: ERROR='" + jResponse.response["message"] + "'", Constants.WARN)); } } catch (Exception ex) { Error_Message_Label.Text = "ERROR: " + ex.Message; Logger.LogMsg(Logger.Action("Purchase Totalizer PAGE Error: ERROR='" + ex.Message + "'", Constants.WARN)); } }