/// <summary> /// Object initilizes using the data in the provided data object. If the data matches a user held by providers then /// restore, update, save etc will work properly. /// </summary> /// <param name="accountData">Account data object</param> /// <param name="profileData">Profile data object</param> public SiteMember(IMemberAccountData accountData, IMemberProfileData profileData) { String logMethodName = ".ctor(IMemberAccountData accountData, IMemberProfileData profileData) - "; _log.Debug(logMethodName + "Begin Method"); Init(); try { _log.Debug(logMethodName + "Loading Member Account"); _memberAccount = new MemberAccount(accountData); } catch (Exception ex) { _log.Error(logMethodName + "Unable to create member account instance from data object provided", ex); throw new WtfException("Unable to create member account instance from data object provided", ex); } //TODO - JHL: Making Profile Member Id = iKey = profileData.Id, but should it be AD Key (_memberAccount.MemberId) try { _log.Debug(logMethodName + "Loading Member Profile"); _memberProfile = new MemberProfile(profileData.Id, profileData, false); } catch (Exception ex) { _log.Error(logMethodName + "Unable to create member profile instance from data object provided", ex); throw new WtfException("Unable to create member profile instance from data object provided", ex); } _log.Debug(logMethodName + "End Method"); }
private static IMemberProfileData createNewMemberProfile(IMemberProfileData profile, Dictionary <String, Object> providerKeys) { AsaMemberAdapter adapter = new AsaMemberAdapter(); ASAMemberModel member = ConvertProfileToASAMember(profile, providerKeys); member = adapter.Create(member).Member; profile = ConvertASAMembertoProfile(member, providerKeys); return(profile); }
public override IMemberProfileData CreateMemberProfile(IMemberProfileData profile, Dictionary <String, Object> providerKeys = null) { String logMethodName = ".CreateMemberProfile(IMemberProfileData profile, Dictionary<String, Object> providerKeys = null) - "; _log.Debug(logMethodName + "Begin Method"); IMemberProfileData iMemberProfileData = createNewMemberProfile(profile, providerKeys); _log.Debug(logMethodName + "End Method"); return(iMemberProfileData); }
private static ASAMemberModel ConvertProfileToASAMember(IMemberProfileData profile, Dictionary <String, Object> providerKeys = null) { const string logMethodName = ".ConvertProfileToASAMember(IMemberProfileData profile, Dictionary<String, Object> providerKeys = null) - "; _log.Debug(logMethodName + "Begin Method"); var model = new ASAMemberModel(); //The memberID for the framework is the ADKey in avectra and AD model.ActiveDirectoryKey = profile.ActiveDirectoryKey.ToString(); model.LegalFirstName = profile.FirstName; model.LastName = profile.LastName; model.FirstName = profile.FirstName; model.DisplayName = profile.DisplayName; model.Source = profile.Source; model.YearOfBirth = profile.YearOfBirth; model.USPostalCode = profile.USPostalCode; model.SALTSchoolTypeID = profile.SALTSchoolTypeID; model.MembershipId = profile.MemberId.ToString(); model.GradeLevel = profile.GradeLevel; model.EnrollmentStatus = profile.EnrollmentStatus; model.InvitationToken = profile.InvitationToken; model.IsCommunityActive = profile.IsCommunityActive; model.WelcomeEmailSent = profile.WelcomeEmailSent; model.ContactFrequency = profile.ContactFrequency; model.Emails = new List <MemberEmailModel> { new MemberEmailModel() { EmailAddress = profile.EmailAddress, IsPrimary = true } }; if (profile.Organizations != null) { foreach (MemberOrganizationData organizationData in profile.Organizations) { MemberOrganizationModel mom = new MemberOrganizationModel(); mom.OrganizationId = organizationData.OrganizationId; mom.OECode = organizationData.OECode; mom.BranchCode = organizationData.BranchCode; mom.ExpectedGraduationYear = organizationData.ExpectedGraduationYear; mom.IsOrganizationDeleted = organizationData.IsOrganizationDeleted; model.Organizations.Add(mom); } } _log.Debug(logMethodName + "End Method"); return(model); }
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); }
public override IMemberAccountData CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status) { String logMethodName = ".CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status) - "; _log.Debug(logMethodName + "Begin Method"); MemberAccountData accountData = (MemberAccountData)base.CreateMember(authInfo, profile, out status); _log.Debug("Create Member Status: " + status.ToString()); //PROBLEM?: Here we still try to set account data even if there was a problem successfully creating the member. SetAccountDataFromAD(ref accountData); RecreateIndividualIdCookie(accountData.MemberId.ToString()); _log.Debug(logMethodName + "End Method"); return(accountData); }
public override IMemberProfileData UpdateMemberProfile(IMemberProfileData profile, Dictionary <String, Object> providerKeys = null) { String logMethodName = ".UpdateMemberProfile(IMemberProfileData profile, Dictionary<String, Object> providerKeys = null) - "; _log.Debug(logMethodName + "Begin Method"); ASAMemberModel model = ConvertProfileToASAMember(profile, providerKeys); model.ActiveDirectoryKey = profile.Id.ToString(); UpdateProfileModel(model); ClearCachedModel(profile.MemberId); AsaMemberAdapter adapter = new AsaMemberAdapter(); profile = ConvertASAMembertoProfile(adapter.GetMemberByEmail(profile.EmailAddress)); _log.Debug(logMethodName + "End Method"); return(profile); }
/// <summary> /// Handles conversion of an incoming IMemberProfileData class into a concrete type we can expose higher up. /// </summary> /// <param name="data">Member profile</param> internal MemberProfileData(IMemberProfileData data) { ActiveDirectoryKey = data.ActiveDirectoryKey; MemberId = data.MemberId; ProviderKeys = data.ProviderKeys; FirstName = data.FirstName; LastName = data.LastName; DisplayName = data.DisplayName; Source = data.Source; ContactFrequency = data.ContactFrequency; InvitationToken = data.InvitationToken; MembershipStartDate = data.MembershipStartDate; EnrollmentStatus = data.EnrollmentStatus; GradeLevel = data.GradeLevel; EmailAddress = data.EmailAddress; USPostalCode = data.USPostalCode; YearOfBirth = data.YearOfBirth; SALTSchoolTypeID = data.SALTSchoolTypeID; LastModified = data.LastModified; LastModifiedBy = data.LastModifiedBy; IsCommunityActive = data.IsCommunityActive; WelcomeEmailSent = data.WelcomeEmailSent; //put organizations on.... if (data.Organizations != null && data.Organizations.Any()) { Organizations = new MemberOrganizationList <MemberOrganizationData>(); foreach (MemberOrganizationData orgainzation in data.Organizations) { Organizations.Add(orgainzation); } } }
/// <summary> /// Creates and instance of the member profile using the profile data and accepting the boolean to set anonymous on this instance. /// The member ID is passed so that refresh and reload will access the backend data stores should those methods be called. /// /// NOTE: All data is lazy loaded on first property access. /// </summary> /// <param name="memberId">Unique member ID to load</param> /// <param name="isAnonymous">true=anonymous; false=not anonymous</param> /// <param name="profileData"></param> internal MemberProfile(Object memberId, IMemberProfileData profileData, Boolean isAnonymous) { String logMethodName = ".ctor(Object memberId, IMemberProfileData profileData, Boolean isAnonymous) - "; _log.Debug(logMethodName + "Begin Method"); _isAnonymous = isAnonymous; _memberId = memberId; _provider = IntegrationLoader.CurrentContextDataProvider; _profileData = new MemberProfileData(profileData); _profileData.MemberId = profileData.MemberId; _orignalProfileData = _profileData; _profileDataLoaded = true; _newProfile = false; _log.Debug(logMethodName + "End Method"); }
//NOTE: TODO: RE-Evaulate the use of interfaces here at this layer. It is asking the provider developer to take //certain things on faith. We may want another type of interface or simply commit to the providers that thr framework //will take a specific conrete implmnentation. public override IMemberProfileData CreateMemberProfile(IMemberProfileData profile, Dictionary <String, Object> providerKeys = null) { IMemberProfileData returnProfile = profile; SqlProfile profileData = profile.ToSqlProfile(); profileData.Id = Guid.NewGuid(); if (profileData != null) { try { _dataContext.Profiles.Add(profileData); _dataContext.SaveChanges(); } catch (Exception ex) { throw new DataProviderException("Unable to create member profile", ex); } ((MemberProfileData)returnProfile).Id = profileData.Id; } return(returnProfile); }
/// <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"); }
public IMemberProfileData UpdateMemberProfile(IMemberProfileData profile, Dictionary <string, object> providerKeys = null) { throw new NotImplementedException(); }
public override IMemberProfileData UpdateMemberProfile(IMemberProfileData profile, Dictionary <String, Object> providerKeys = null) { SqlProfile profileData = profile.ToSqlProfile(); if (profileData != null) { try { SqlProfile profileInStore = GetMemberProfileData(profile.MemberId); if (profileInStore != null) { DbEntityEntry entry = _dataContext.Entry(profileInStore); if (entry != null) { entry.CurrentValues.SetValues(profileData); /* * if (profileData.Phones != null && profileData.Phones.Count > 0) * { * * entry.Collection("Phones").EntityEntry.CurrentValues.SetValues(profileData.Phones); * entry.Collection("Phones").EntityEntry.CurrentValues.SetValues(profileData.Phones); * }*/ } } else { //If there is no profile then we need to create it return(CreateMemberProfile(profile)); } if (profileData.Addresses != null && profileData.Addresses.Count > 0) { foreach (MailingAddress address in profileData.Addresses) { MailingAddress lookup = profileInStore.Addresses.FirstOrDefault(a => a.Id == address.Id); if (lookup != null) { DbEntityEntry mailEntry = _dataContext.Entry(lookup); mailEntry.CurrentValues.SetValues(address); } else { profileInStore.Addresses.Add(address); } } } if (profileData.Phones != null && profileData.Phones.Count > 0) { foreach (PhoneNumber number in profileData.Phones) { PhoneNumber lookup = profileInStore.Phones.FirstOrDefault(p => p.Id == number.Id); if (lookup != null) { DbEntityEntry phoneEntry = _dataContext.Entry(lookup); phoneEntry.CurrentValues.SetValues(number); } else { profileInStore.Phones.Add(number); } } } if (profileData.EmailContacts != null && profileData.EmailContacts.Count > 0) { foreach (EmailAddress email in profileData.EmailContacts) { EmailAddress lookup = profileInStore.EmailContacts.FirstOrDefault(p => p.Id == email.Id); if (lookup != null) { DbEntityEntry emailEntry = _dataContext.Entry(lookup); emailEntry.CurrentValues.SetValues(email); } else { profileInStore.EmailContacts.Add(email); } } } _dataContext.SaveChanges(); } catch (Exception ex) { throw new DataProviderException("Error updating profile data", ex); } } return(profile); }
public virtual IMemberAccountData CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status) { String logMethodName = ".CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status) - "; _log.Debug(logMethodName + " - Begin Method"); status = MemberCreationStatus.Error; IMemberAccountData data = null; MembershipCreateStatus createStatus = MembershipCreateStatus.Success; try { // Membership.CreateUser Method - throws exception MembershipCreateUserException if user is // not created: // http://msdn.microsoft.com/en-us/library/t8yy6w3h.aspx data = new MembershipUserWrapper(Membership.CreateUser( authInfo.Username, authInfo.Password, authInfo.Email)); } catch (MembershipCreateUserException e) { createStatus = e.StatusCode; _log.Debug(logMethodName + " - User " + authInfo.Username + " was not created - status=" + createStatus); } catch (Exception ex) { SaltADMembershipProvider.ADConnector.LogActiveDirectoryMembershipProviderProperties(); throw new SecurityAdapterException("An error has occured in the .NET Membership provider while calling Membership.CreateUser(username, password, username) for username " + authInfo.Username, ex); } switch (createStatus) { case MembershipCreateStatus.Success: status = MemberCreationStatus.Success; //FormsAuthentication.SetAuthCookie(authInfo.Username, true); //FormsAuthentication.Authenticate(authInfo.Username, authInfo.Password); break; case MembershipCreateStatus.DuplicateEmail: status = MemberCreationStatus.DuplicateEmail; break; case MembershipCreateStatus.DuplicateProviderUserKey: status = MemberCreationStatus.DuplicateUserName; break; case MembershipCreateStatus.DuplicateUserName: status = MemberCreationStatus.DuplicateUserName; break; case MembershipCreateStatus.InvalidAnswer: status = MemberCreationStatus.InvalidAnswer; break; case MembershipCreateStatus.InvalidEmail: status = MemberCreationStatus.InvalidEmail; break; case MembershipCreateStatus.InvalidPassword: status = MemberCreationStatus.InvalidPassword; break; case MembershipCreateStatus.InvalidProviderUserKey: status = MemberCreationStatus.InvalidUserName; break; case MembershipCreateStatus.InvalidQuestion: status = MemberCreationStatus.InvalidQuestion; break; case MembershipCreateStatus.InvalidUserName: status = MemberCreationStatus.InvalidUserName; break; case MembershipCreateStatus.ProviderError: status = MemberCreationStatus.AdapterError; break; case MembershipCreateStatus.UserRejected: status = MemberCreationStatus.UserRejected; break; default: status = MemberCreationStatus.Error; break; } _log.Debug(logMethodName + " - End Method"); return(data); }
public IMemberAccountData CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status) { status = MemberCreationStatusResponse; return(CreateMemberResponse); }
public static SqlProfile ToSqlProfile(this IMemberProfileData memberProfile) { try { SqlProfile sqlProfile = new SqlProfile(); //First the singletons Guid recordId; if (memberProfile.Id != null) { if (Guid.TryParse(memberProfile.Id.ToString(), out recordId)) { sqlProfile.Id = recordId; } else { sqlProfile.Id = Guid.Empty; } } Guid memberId; if (memberProfile.MemberId != null) { if (Guid.TryParse(memberProfile.MemberId.ToString(), out memberId)) { sqlProfile.MemberId = memberId; } else { sqlProfile.MemberId = Guid.Empty; } } sqlProfile.FirstName = memberProfile.FirstName; sqlProfile.LastName = memberProfile.LastName; sqlProfile.Nickname = memberProfile.Nickname; sqlProfile.DOB = memberProfile.DOB; sqlProfile.LastModified = memberProfile.LastModified; sqlProfile.LastModifiedBy = memberProfile.LastModifiedBy; sqlProfile.MembershipStartDate = memberProfile.MembershipStartDate; //Now the lists and complex types if (memberProfile.Addresses != null && memberProfile.Addresses.Count > 0) { sqlProfile.Addresses = (IList <MailingAddress>)memberProfile.Addresses.ToDataStoreList <MemberAddressData, MailingAddress>(); } if (memberProfile.Phones != null && memberProfile.Phones.Count > 0) { sqlProfile.Phones = (IList <PhoneNumber>)memberProfile.Phones.ToDataStoreList <MemberPhoneData, PhoneNumber>(); } if (memberProfile.EmailContacts != null && memberProfile.EmailContacts.Count > 0) { sqlProfile.EmailContacts = (IList <EmailAddress>)memberProfile.EmailContacts.ToDataStoreList <MemberEmailData, EmailAddress>(); } return(sqlProfile); } catch (Exception ex) { throw new DataProviderException("Error converting member data to data store format", ex); } }
public abstract IMemberProfileData CreateMemberProfile(IMemberProfileData profile, Dictionary <String, Object> providerKeys = null);
public IMemberProfileData CreateMemberProfile(IMemberProfileData profile, Dictionary <string, object> providerKeys = null) { return(CreateMemberProfileResponse); }