Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Given the session returns the PaymentItems UserId
        /// If the paymentItems UserId is not available from ServerAccounts
        /// (The paymentItems UserId is not in our db)
        /// then call CreateNewUser blocking to create account or get paymentItems UserId
        /// If teh account is still not available log the error and return a empty string
        /// Then call account update asynchronous without a return and continue.
        /// </summary>
        /// <param name="sessionId">The users session id</param>
        /// <returns>The PaymentItems userId</returns>
        public string GetPaymentItemsUserId(Guid sessionId)
        {
            string userId            = "";
            string xmlResponseString = "";

            try
            {
                ServerAccount account = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(sessionId);
                userId = account.PaymentItemUserId.ToString();

                //call CreateNewUser blocking to create account or get user id
                //since we do not have a paymentItemsId in our db.
                //Then call account update and continue.
                if (userId.Trim().Length == 0)
                {
                    mLogger.Info("GetPaymentItemsUserId: Creating new payment items user for hangout user: "******"/Response/user").Attributes["id"].InnerText;
                    account.PaymentItemSecureKey = responseDoc.SelectSingleNode("/Response/user").Attributes["secureKey"].InnerText;

                    userId = account.PaymentItemUserId;

                    mServerStateMachine.UsersManager.UpdateServerPaymentItemsAccount(account, null);
                }
            }

            catch (Exception ex)
            {
                mLogger.Error("Error getPaymentItemsUserId, response = " + xmlResponseString, ex);
            }

            return(userId);
        }