예제 #1
0
        private void HandleRegisterSuccess(GuestControllerResult <LogInResponse> result, IEnumerable <Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem> marketing, Action <IRegisterResult> callback)
        {
            IList <IInvalidProfileItemError> profileItemErrors = null;

            try
            {
                if (!result.Success)
                {
                    callback(new RegisterResult(success: false, null, null));
                    return;
                }
                IRegisterResult registerResult = GuestControllerErrorParser.GetRegisterResult(result.Response.error);
                if (registerResult != null)
                {
                    callback(registerResult);
                    return;
                }
                profileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
                if (result.Response.data == null)
                {
                    if (result.Response.error != null && profileItemErrors == null)
                    {
                        logger.Critical("Received unhandled error exception" + JsonParser.ToJson(result.Response.error));
                    }
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                    return;
                }
                LogInData loginData = result.Response.data;
                if (loginData.displayName == null || loginData.etag == null || loginData.profile == null || loginData.token == null || loginData.token.access_token == null)
                {
                    logger.Critical("Invalid login data:" + JsonParser.ToJson(loginData));
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                    return;
                }
                loginData.profile.status = GuestControllerErrorParser.GetAccountStatusCode(result.Response.error, loginData.profile.status);
                string countryCode = GuestControllerUtils.GetCountryCode(loginData.profile);
                database.StoreSession(loginData.token.swid, loginData.token.access_token, loginData.token.refresh_token, loginData.displayName.displayName, loginData.profile.firstName, loginData.etag, loginData.profile.ageBand, loginData.displayName.proposedDisplayName, loginData.displayName.proposedStatus, loginData.profile.status, updateLastProfileRefreshTime: true, countryCode);
                mixSessionStarter.Start(loginData.token.swid, loginData.token.access_token, delegate
                {
                    HandleMixSessionStartSuccess(profileItemErrors, loginData.token.swid, loginData.profile, loginData.displayName, marketing, callback);
                }, delegate
                {
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                });
            }
            catch (CorruptionException ex)
            {
                logger.Fatal("Corruption detected during registration: " + ex);
                callback(new RegisterCorruptionDetectedResult());
            }
            catch (Exception ex2)
            {
                logger.Critical("Unhandled exception: " + ex2);
                callback(new RegisterResult(success: false, null, profileItemErrors));
            }
        }
예제 #2
0
 private static void HandleUpdateProfileResult(AbstractLogger logger, IDatabase database, string swid, IEpochTime epochTime, GuestControllerResult <ProfileResponse> result, IInternalRegistrationProfile profile, Action <IUpdateProfileResult> callback)
 {
     try
     {
         if (!result.Success)
         {
             callback(new UpdateProfileResult(success: false, null));
             return;
         }
         IList <IInvalidProfileItemError> registerProfileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
         if (result.Response.data == null)
         {
             callback(new UpdateProfileResult(success: false, registerProfileItemErrors));
             return;
         }
         ProfileData profileData = result.Response.data;
         if (profileData.displayName != null)
         {
             database.UpdateSessionDocument(swid, delegate(SessionDocument doc)
             {
                 doc.DisplayNameText           = profileData.displayName.displayName;
                 doc.ProposedDisplayName       = profileData.displayName.proposedDisplayName;
                 doc.ProposedDisplayNameStatus = profileData.displayName.proposedStatus;
                 doc.FirstName              = profileData.profile.firstName;
                 doc.AccountStatus          = profileData.profile.status;
                 doc.LastProfileRefreshTime = epochTime.Seconds;
             });
         }
         profile.Update(profileData.profile, profileData.displayName, profileData.marketing);
         callback(new UpdateProfileResult(success: true, registerProfileItemErrors));
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         callback(new UpdateProfileResult(success: false, null));
     }
 }