private void button1_Click(object sender, EventArgs e) { try { string selectedItem = ""; Type cmdType = null; if (radioButton1.Checked) { selectedItem = (string)comboBox1.SelectedItem; CreateTwoFishCommand cmd = new CreateTwoFishCommand(); cmdType = cmd.GetType(); } else { selectedItem = (string)comboBox3.SelectedItem; CreateHangoutCommand cmd = new CreateHangoutCommand(); cmdType = cmd.GetType(); } string selectedUser = (string)comboBox2.SelectedItem; if (selectedItem != null) { ServiceCommandSerializer paymentSerializer = new ServiceCommandSerializer(); PaymentCommand command = CreateCommand(selectedItem, selectedUser, cmdType, GetSelectedXml()); string xmlCommand = paymentSerializer.SerializeCommandData((ServiceCommand)command, typeof(PaymentCommand)); StreamWriter swCommand = new StreamWriter("c:\\twofishCommand.xml"); swCommand.Write(xmlCommand); swCommand.Close(); command = (PaymentCommand)paymentSerializer.DeserializeCommandData(xmlCommand, typeof(PaymentCommand)); PaymentCommand commandSecond = HandleSpecialCommand(command, selectedUser, cmdType); if (commandSecond != null) { command = commandSecond; } PaymentItem paymentItem = new PaymentItem(); XmlDocument response = paymentItem.ProcessMessage(command); response = HandleSpecialResponse(response); StreamWriter swResponse = new StreamWriter("c:\\twofishResponse.xml"); swResponse.Write(response.InnerXml); swResponse.Close(); DisplayResponse(response); } } catch (Exception ex) { XmlDocument errorResponse = CreateErrorDoc(ex.Message); DisplayResponse(errorResponse); } }
/// <summary> /// Converts the client PaymentItems command to a PaymentItems command /// </summary> /// <param name="xmlClientMessage">xml client PaymentItems command</param> /// <returns>PaymentItems command</returns> public PaymentCommand ProcessMessage(string xmlClientMessage, getUserIdDelegate getUserIdCall) { mGetUserIdCall = getUserIdCall; ServiceCommandSerializer serializer = new ServiceCommandSerializer(); PaymentCommand clientCommand = (PaymentCommand)serializer.DeserializeCommandData(xmlClientMessage, typeof(PaymentCommand)); return(ParseClientPaymentCommand(clientCommand)); }
public XmlDocument ProcessAdminPaymentItemXml(HangoutPostedFile paymentCommand) { XmlDocument response = new XmlDocument(); byte[] buffer = new byte[paymentCommand.InputStream.Length]; paymentCommand.InputStream.Read(buffer, 0, (int)paymentCommand.InputStream.Length); UTF8Encoding encoding = new UTF8Encoding(); String paymentCommandString = encoding.GetString(buffer); ServiceCommandSerializer serializer = new ServiceCommandSerializer(); PaymentCommand command = (PaymentCommand)serializer.DeserializeCommandData(paymentCommandString, typeof(PaymentCommand)); AdminCommandBase parser = new AdminCommandBase("PaymentItemsAdminService"); response = parser.ProcessRequest(command); return(response); }
/// <summary> /// Main entry point for the state server to use the PaymentItems /// This will limited to Hangout commands /// </summary> /// <param name="xmlMessage">PaymentCommand string xml message</param> /// <returns>string XML response message</returns> public string ProcessMessage(string xmlMessage) { string response = ""; try { ServiceCommandSerializer paymentSerializer = new ServiceCommandSerializer(); PaymentCommand command = (PaymentCommand)paymentSerializer.DeserializeCommandData(xmlMessage, typeof(PaymentCommand)); Hangout.Server.WebServices.HangoutCommandBase parser = new Hangout.Server.WebServices.HangoutCommandBase("InvokePaymentItemsProcess"); response = parser.ProcessRequest(command).InnerXml; } catch (Exception ex) { response = CreateErrorDoc(ex.Message); } return(response); }