Exemple #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));
            }
        }
Exemple #2
0
        /// <summary>
        /// Create the PaymentItem Account for a user
        /// </summary>
        /// <param name="accountXmlNode">The account information xml node</param>
        /// <param name="serverAccount">The account object </param>
        /// <param name="accountForUserCallback">The callback to call when finished</param>
        public virtual void CreatePaymentItemAccountForUser(ServerAccount serverAccount, string userIpAddress, Action <ServerAccount> accountForUserCallback)
        {
            mLogger.Debug("CreatePaymentItemAccountForUser " + serverAccount.AccountId.ToString());
            try
            {
                PaymentItemsProcess paymentItems = new PaymentItemsProcess();
                UserInfo            userInfo     = GetPaymentItemsUserInfo(serverAccount, userIpAddress);
                int initialCoinAmount            = GetPaymentItemsUserInfoUserInitialCoinAmount();
                int initialCashAmount            = GetPaymentItemsUserInfoUserInitialCashAmount();

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

                        if (response != null)
                        {
                            XmlNode userNode = response.SelectSingleNode("Response/user");
                            serverAccount.PaymentItemUserId    = userNode.Attributes["id"].InnerText;
                            serverAccount.PaymentItemSecureKey = userNode.Attributes["secureKey"].InnerText;

                            UpdateServerPaymentItemsAccount(serverAccount, accountForUserCallback);
                            Metrics.Log(LogGlobals.CATEGORY_ACCOUNT, LogGlobals.EVENT_PAYMENT_ACCOUNT_CREATED, LogGlobals.PAYMENT_ACCOUNT_ID_LABEL, serverAccount.PaymentItemUserId, serverAccount.AccountId.ToString());
                        }
                    }

                    //if twoFish account creation blows an exception the we do not want to cause the game to fail
                    //so lets just continue
                    catch (System.Exception ex)
                    {
                        accountForUserCallback(serverAccount);
                    }
                };


                paymentItems.CreateNewUser(userInfo, initialCoinAmount, initialCashAmount, asyncCallback);
            }

            //if twoFish account creation blows an exception the we do not want to cause the game to fail
            //so lets just continue
            catch
            {
                accountForUserCallback(serverAccount);
            }
        }
        /// <summary>
        /// PaymentItemManager constuctor
        /// </summary>
        /// <param name="serverStateMachine">A pointer to the server state machine</param>
        /// <param name="sendMessageToReflectorCallback">A pointer to send a message to the reflector</param>
        public PaymentItemsManager(ServerStateMachine serverStateMachine) : base(serverStateMachine)
        {
            mServerStores             = new ServerStores(this);
            mMoneyPaymentNotifyClient = new MoneyPaymentNotifyClient(SendMessageToClient);

            // Initialize the remoting interface
            try
            {
                mCallToService = new RemoteCallToService();
                mCallToService.RemoteConnect();
                mCallToService.ActivateTheInterface();
                mPaymentItems = new PaymentItemsProcess();
                mPaymentItems.ActivateTheInterface();
            }
            catch
            {
                mLogger.Warn("Error in activating the payment items interface");
            }
        }