Exemplo n.º 1
0
        /// <summary>
        /// Get the store PaymentItems response and update the store data with a new response
        /// </summary>
        /// <param name="storeName">The name of the store</param>
        private void GetAndUpdateTheStoreInventory(string storeName)
        {
            try
            {
                PaymentItemsProcess      paymentItemProcess = new PaymentItemsProcess();
                ServiceCommandSerializer serializer         = new ServiceCommandSerializer();

                PaymentCommand paymentItemCommand = new PaymentCommand();
                paymentItemCommand.Verb = "GetStoreInventory";

                // Add stage name to storeName in request.   Don't store the stage name in variable, so the code doesn't have to care about stage.
                string stage = System.Configuration.ConfigurationSettings.AppSettings["Stage"];
                paymentItemCommand.Parameters.Add("storeName", storeName + "_" + stage);
                string xmlPaymentItemsMessage = serializer.SerializeCommandData(paymentItemCommand, typeof(PaymentCommand));
                string response = paymentItemProcess.ProcessMessageBlocking(xmlPaymentItemsMessage, null, null);

                XmlDocument xmlResponse = new XmlDocument();
                xmlResponse.LoadXml(response);

                xmlResponse = RemoveItemTypes(xmlResponse);
                xmlResponse = AddAssetsToStoreInventoryItems(xmlResponse, storeName);

                CopyResponseToStoreData(xmlResponse, storeName);
            }

            catch (Exception ex)
            {
                mLogger.Error(String.Format("Error in GetAndUpdateTheStoreInventory for Store {0} Error: {1} ", storeName, ex));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invokes the remote PaymentItems ProcessMessage service call
        /// </summary>
        /// <param name="serviceCommand">PaymentItemCommand</param>
        /// <returns>xml string response from the PaymentItems service call</returns>
        protected override string InvokeServiceCommandHandler(ServiceCommand serviceCommand)
        {
            ServiceCommandSerializer serializer = new ServiceCommandSerializer();
            string xmlPaymentItemsMessage       = serializer.SerializeCommandData(serviceCommand, typeof(PaymentCommand));

            return(mPaymentItemProcess.ProcessMessage(xmlPaymentItemsMessage));
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        /// <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));
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandName"></param>
        /// <param name=""></param>
        /// <param name="commandArgs"></param>
        /// <returns></returns>
        public string CreatePaymentCommand(string commandName, Dictionary <string, string> commandArgs)
        {
            string command = "";

            PaymentCommand paymentCommand = null;

            switch (commandName)
            {
            case "GetUserBalance":
                paymentCommand = CreateSimpleCommand("GetUserBalance", commandArgs);
                break;

            case "AddVirtualCoinForUser":
                paymentCommand = AddVirtualCoinForUser(commandArgs);
                break;

            case "GetUserInventory":
                paymentCommand = GetUserInventory(commandArgs);
                break;

            case "GetStoreInventory":
                paymentCommand = GetHangoutStoreInventory(commandArgs);
                break;

            case "PurchaseItems":
                paymentCommand = PurchaseItems(commandArgs);
                break;

            case "PurchaseItemsGift":
                paymentCommand = PurchaseItemsGift(commandArgs);
                break;

            case "GameCurrencyOffers":
                paymentCommand = CreateSimpleCommand("PurchaseOffers", commandArgs);
                break;

            case "PurchaseGameCurrencyPayPal":
                paymentCommand = PurchaseGameCurrencyPayPal(commandArgs);
                break;

            case "PurchaseGameCurrencyCreditCard":
                paymentCommand = PurchaseGameCurrencyCreditCard(commandArgs);
                break;

            case "SecurePaymentInfo":
                paymentCommand = CreateCommandWithNoParams("SecurePaymentInfo");
                break;

            default:
                throw (new Exception("Invalid Payment Items Command"));
            }

            ServiceCommandSerializer serializer = new ServiceCommandSerializer();

            command = serializer.SerializeCommandData(paymentCommand, typeof(PaymentCommand));

            return(command);
        }
Exemplo n.º 6
0
        private XmlDocument ProcessAdminPaymentItem(PaymentCommand paymentCommand, string baseServicesRoot)
        {
            ServiceCommandSerializer serializer = new ServiceCommandSerializer();
            string xmlPaymentItemsMessage       = serializer.SerializeCommandData(paymentCommand, typeof(PaymentCommand));

            UTF8Encoding encoding = new UTF8Encoding();

            Byte[] byteArray = encoding.GetBytes(xmlPaymentItemsMessage);

            WebServiceRequest request = new WebServiceRequest(baseServicesRoot, "PaymentItemsService", "ProcessAdminPaymentItemXml");

            request.AddParam("paymentCommand", byteArray);

            XmlDocument xmlResponse = request.GetWebResponse();

            return(xmlResponse);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        /// <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);
        }