Exemplo n.º 1
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.º 2
0
        /// <summary>
        /// Parser for PaymentITems command
        /// </summary>
        /// <param name="message">The message from the client</param>
        /// <param name="senderId">The senderId GUID</param>
        public override void ReceiveRequest(Message message, Guid senderId)
        {
            string xmlData = (string)message.Data[0];

            System.Action <string> asyncCallback = delegate(string paymentItemsCommand)
            {
                try
                {
                    XmlDocument response = new XmlDocument();
                    response.LoadXml(paymentItemsCommand);

                    string noun = response.SelectSingleNode("/Response").Attributes["noun"].InnerText;
                    string verb = response.SelectSingleNode("/Response").Attributes["verb"].InnerText;

                    // Append special info to response for some payment items commands
                    PaymentItemsProcessClientMessage clientMessage = new PaymentItemsProcessClientMessage();
                    response = clientMessage.SpecialResponse(response, noun, verb, mServerStores);

                    // Award items in the hangout db that correspond with this purchase
                    AwardPurchasedItems(response, noun, verb, senderId);

                    response = GetPaymentItemSecurePaymentInfoEncrypted(response, noun, verb, senderId);

                    Message       paymentItemsResponse = new Message();
                    List <object> dataObject           = new List <object>();
                    dataObject.Add(response.InnerXml);
                    paymentItemsResponse.PaymentItemsMessage(dataObject);
                    paymentItemsResponse.Callback = message.Callback;

                    mLogger.DebugFormat("ProcessMessageAsync responded: {0},{1}.  Response Size:{2}", noun, verb, paymentItemsCommand.Length);

                    mServerStateMachine.SendMessageToReflector(paymentItemsResponse, senderId);
                }
                catch (System.Exception ex)
                {
                    mLogger.ErrorFormat("Error in PaymentItems asyncCallback {0} {1}", ex, paymentItemsCommand);
                }
            };
            getUserIdDelegate getUserId  = new getUserIdDelegate(GetPaymentItemsUserId);
            XmlDocument       xmlRequest = new XmlDocument();

            xmlRequest.LoadXml(xmlData);
            mLogger.DebugFormat("ProcessMessageAsync called: {0}", xmlRequest.SelectSingleNode("/Request").Attributes["verb"].InnerText);
            mPaymentItems.ProcessMessageAsync(xmlData, asyncCallback, mServerStores, getUserId);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method used to start a ProcessMessage blocking method call
        /// If this is a cached message then retreive the data from the response data from the cache
        /// <param name="xmlClientMessage">PaymentItem client message</param>
        /// <param name="xmlClientMessage"></param>
        /// <returns>PaymentItems xml string response</returns>
        public string ProcessMessageBlocking(string xmlClientMessage, ServerStores serverStores, getUserIdDelegate getUserIdCall)
        {
            string response = "";

            try
            {
                PaymentItemsProcessClientMessage clientMessage = new PaymentItemsProcessClientMessage();
                ServiceCommand serviceCommand = (ServiceCommand)clientMessage.ProcessMessage(xmlClientMessage, getUserIdCall);
                if (clientMessage.IsCachedMessage((PaymentCommand)serviceCommand, serverStores))
                {
                    response = clientMessage.GetCachedStoreData((PaymentCommand)serviceCommand, serverStores);
                }
                else
                {
                    response = InvokeServiceBlocking(serviceCommand);
                }
            }

            catch (Exception ex)
            {
                response = String.Format("<Error><Message>{0}</Message></Error>", ex);
                mLogger.Error(String.Format("Error ProcessMessageBlocking: {0}", response));
            }

            return(response);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Method used to start a ProcessMessage async method call
        /// This method processes PaymentItems messages
        /// If this is a cached message then retreive the data from the response data from the cache
        /// </summary>
        /// <param name="xmlClientMessage">PaymentItem client message</param>
        /// <param name="sender">List of session GUID's to send the response to</param>
        /// <param name="callback">Callback that is called on response from service</param>
        /// <returns>blank if no error else the error message</returns>
        public string ProcessMessageAsync(string xmlClientMessage, System.Action <string> callback, ServerStores serverStores, getUserIdDelegate getUserIdCall)
        {
            string response = "";

            try
            {
                PaymentItemsProcessClientMessage clientMessage = new PaymentItemsProcessClientMessage();
                ServiceCommand serviceCommand = (ServiceCommand)clientMessage.ProcessMessage(xmlClientMessage, getUserIdCall);
                if (clientMessage.IsCachedMessage((PaymentCommand)serviceCommand, serverStores))
                {
                    response = clientMessage.GetCachedStoreData((PaymentCommand)serviceCommand, serverStores);
                    clientMessage.PaymentItemsReturn(response, callback);
                }
                else if (clientMessage.IsDoNothing((PaymentCommand)serviceCommand))
                {
                    response = clientMessage.createDoNothingResponse((PaymentCommand)serviceCommand);
                    clientMessage.PaymentItemsReturn(response, callback);
                }
                else
                {
                    InvokeServiceAsync(serviceCommand, callback);
                }
            }

            catch (Exception ex)
            {
                response = String.Format("<Error><Message>{0}</Message></Error>", ex);
                mLogger.Error(String.Format("Error ProcessMessageAsync: {0}", response));
            }

            return(response);
        }