예제 #1
0
        public void CreateAccountForUser(string fbAccountId, string fbSessionKey, string nickName, string firstName, string lastName, string userIpAddress, string campaignId, string referrerId, Action <ServerAccount> createAccountForUserCallback)
        {
            mLogger.Debug(String.Format("CreateAccountForUser {0} {1} {2} {3} {4} {5} {6} {7}", fbAccountId, fbSessionKey, nickName, firstName, lastName, userIpAddress, campaignId, referrerId));
            Action <XmlDocument> createServerAccountServiceCallback = delegate(XmlDocument receivedXmlCreateNewAccount)
            {
                XmlNode newAccountXmlNode = receivedXmlCreateNewAccount.SelectSingleNode("Accounts/Account");
                //if we get a null xml node when trying to create an account, we need to throw an error
                if (newAccountXmlNode == null)
                {
                    StateServerAssert.Assert(new System.Exception("Error: unable to create a new account.. do you have a valid facebook Account Id, Session key, nickname, firstname, lastname, campaignId, and referredId?  Check your client data file! Returned Xml: " + receivedXmlCreateNewAccount.OuterXml));
                    createAccountForUserCallback(null);
                }
                else
                {
                    ServerAccount serverAccount = AccountsXmlUtil.GetAccountFromXml(newAccountXmlNode);
                    serverAccount.IpAddress = userIpAddress;
                    SaveCurrentAccountData(serverAccount);
                    CreatePaymentItemAccountForUser(serverAccount, userIpAddress, createAccountForUserCallback);

                    Metrics.Log(LogGlobals.CATEGORY_ACCOUNT, LogGlobals.EVENT_ACCOUNT_CREATED, LogGlobals.ACCOUNT_ID_LABEL, serverAccount.AccountId.ToString(), serverAccount.AccountId.ToString());
                }
            };

            CallCreateServerAccountService(fbAccountId, fbSessionKey, nickName, firstName, lastName, userIpAddress, campaignId, referrerId, createServerAccountServiceCallback);
        }
예제 #2
0
        public void GetAccountForUser(string fbAccountId, string fbSessionKey, string nickName, string firstName, string lastName, string userIpAddress, string campaignId, string referrerId, Action <ServerAccount> getAccountForUserCallback)
        {
            Action <XmlDocument> getAccountForFacebookIdCallback = delegate(XmlDocument receivedXmlGetAccount)
            {
                //<Accounts>
                //  <Account accountId="" fbaccountid="" tfaccountId="" nickname="" firstname="" lastname=""/>
                //</Accounts>
                XmlNode accountXmlNode = receivedXmlGetAccount.SelectSingleNode("Accounts/Account");
                if (accountXmlNode != null)
                {
                    ServerAccount serverAccount = AccountsXmlUtil.GetAccountFromXml(accountXmlNode);

                    if (serverAccount != null)
                    {
                        serverAccount.IpAddress = userIpAddress;
                        mLogger.Info("GetAccountForUser, ServerAccount: " + serverAccount.ToString());
                        serverAccount.SaveCurrentAccountData(delegate(XmlDocument returnedXmlDocument)
                        {
                        });
                        if (serverAccount.PaymentItemUserId.Trim().Length == 0)
                        {
                            mLogger.Debug("GetAccountForUser.CreatePaymentItemsAccount");
                            CreatePaymentItemAccountForUser(serverAccount, userIpAddress, getAccountForUserCallback);
                        }
                        else
                        {
                            mLogger.Debug("GetAccountForUser, calling callback");
                            getAccountForUserCallback(serverAccount);
                        }
                    }
                    else
                    {
                        StateServerAssert.Assert(new Exception("Could not extract the account from the Xml"));
                    }
                }
                else
                {
                    CreateAccountForUser(fbAccountId, fbSessionKey, nickName, firstName, lastName, userIpAddress, campaignId, referrerId, delegate(ServerAccount newServerAccount)
                    {
                        getAccountForUserCallback(newServerAccount);
                    }
                                         );
                }
            };

            try
            {
                CallGetServerAccountForFacebookIdService(fbAccountId, getAccountForFacebookIdCallback);
            }
            catch (System.Exception)
            {
                mLogger.Warn("Could not get an account for facebook id: " + fbAccountId);
                getAccountForUserCallback(null);
            }
        }