Esempio n. 1
0
        public SiteMember GetMember(object membershipId)
        {
            const string logMethodName = ".GetMember(object membershipId)";

            _log.Debug(logMethodName + " - Begin Method");
            IMemberAccountData accountData = null;
            IMemberProfileData profileData = null;

            try
            {
                _log.Debug(logMethodName + " - Calling ISecurityAdapter.GetMember(membershipId)");

                accountData = _adapter.GetMember(membershipId);
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + " - Error retrieving member accound data from Security Adapter " + _adapter.GetType().FullName);

                throw new WtfException(logMethodName + " - Error retrieving member accound data from Security Adapter" + _adapter.GetType().FullName, ex);
            }

            try
            {
                _log.Debug(logMethodName + " - Calling IContextDataAdapter.GetMemberProfile(membershipId)");

                profileData = _provider.GetMemberProfile(accountData.MemberId);
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + " - Error retrieving member accound data from Data Provider" + _provider.GetType().FullName, ex);

                throw new WtfException(logMethodName + " - Error retrieving member accound data from Data Provider " + _provider.GetType().FullName, ex);
            }

            SiteMember siteMember = null;

            try
            {
                siteMember = new SiteMember(accountData, profileData);
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + " - Unable to create SiteMember(MemberAccountData, MemberProfileData) instance", ex);

                throw new WtfException(logMethodName + " - Unable to create SiteMember(MemberAccountData, MemberProfileData) instance", ex);
            }

            _log.Debug(logMethodName + " - End Method");
            return(siteMember);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles lazy loading of profile data. Note that current implmentation loads ALL data for the profile
        /// when this method is called.
        /// </summary>
        private void LoadProfileData()
        {
            String logMethodName = ".LoadProfileData() - ";

            _log.Debug(logMethodName + "Begin Method");

            if (!_profileDataLoaded)
            {
                _log.Debug(logMethodName + "Loading Member Profile Data");

                IMemberProfileData profileData = null;

                try
                {
                    _log.Debug(logMethodName + "Calling IContextDataProvider.GetMemberProfile(Object membershipId, Dictionary<String, Object> providerKeys)");
                    _log.Debug(string.Format("_memberId = {0}", _memberId != null ? _memberId : "NULL"));
                    //COV-10330 check for NULL
                    if (_memberId != null)
                    {
                        profileData = _provider.GetMemberProfile(_memberId);
                    }
                }
                catch (Exception ex)
                {
                    String message = logMethodName + "Error getting profile data";
                    _log.Error(message, ex);

                    throw new WtfException(message, ex);
                }

                //If the profile is null it means one does not exsist for this user yet.
                if (profileData != null)
                {
                    _profileData = new MemberProfileData(profileData);
                    _newProfile  = false;
                    _log.Debug(logMethodName + "Profile Data found and loaded successfully");
                }
                else
                {
                    //Internally mark that we have a new profile here. Thie allows save to
                    //work properly.
                    _profileData = new MemberProfileData();
                    _newProfile  = true;
                    _log.Debug(logMethodName + "No profile data found for user, creating empty profile record");
                }

                //_profileData.MemberId = _memberId; //_profileData.MemberId is the memberId in the SALTDb lets leave it alone
                _profileData.Id     = _memberId;
                _orignalProfileData = _profileData;
                //We still set the profile loaded to true because it is in fact loaded.
                //Also this keeps us from hitting the provider over and over as the properties
                //are accessed.
                _profileDataLoaded = true;
            }
            else
            {
                _log.Debug(logMethodName + "Member profile data has already been loaded, skipping");
            }

            _log.Debug(string.Format("About to set WTFSession.ProfileId = {0}", _profileData.Id != null?_profileData.Id:"NULL"));
            WTFSession.ProfileId = _profileData.Id;

            _log.Debug(logMethodName + "End Method");
        }