Example #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);
        }
Example #2
0
        private void UpdateAccountDataForUser(ServerAccount serverAccount, UserProperties userProperties, System.Action <XmlDocument> finishedUpdatingAccountDataCallback)
        {
            serverAccount.UserProperties = userProperties;
            XmlDocument accountDataXml = AccountsXmlUtil.CreateAccountDataXml(serverAccount);

            AccountsServiceAPI.UpdateAccountData(serverAccount.AccountId, accountDataXml, finishedUpdatingAccountDataCallback);
        }
Example #3
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);
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="accountIds"></param>
        /// <param name="getAvatarForUserServiceCallback"></param>
        public static void GetAvatarForUsers(IEnumerable <AccountId> accountIds, Action <XmlDocument> getAvatarForUserServiceCallback)
        {
            string accountIdsString = AccountsXmlUtil.GetCommaSeperatedListOfAccountIdsFromList(accountIds);

            mLogger.DebugFormat("GetAvatarForUsers called accountIds={0}", accountIdsString);

            WebServiceRequest getAvatarList = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Avatars", "GetAvatars");

            getAvatarList.AddParam(kAccountIdCsvList, accountIdsString);
            getAvatarList.GetWebResponseAsync(delegate(XmlDocument xmlResponse)
            {
                mLogger.DebugFormat("GetAvatarForUsers responded accountIds={0} xmlReponse={1}", accountIdsString, xmlResponse.OuterXml);
                getAvatarForUserServiceCallback(xmlResponse);
            });
        }
Example #5
0
        public void SaveCurrentAccountData(System.Action <XmlDocument> finishedUpdatingAccountDataCallback)
        {
            XmlDocument accountDataXml = AccountsXmlUtil.CreateAccountDataXml(this);

            AccountsServiceAPI.UpdateAccountData(mAccountId, accountDataXml, finishedUpdatingAccountDataCallback);
        }