/// <summary> /// When overridden in a derived class, deletes profile properties and information /// for profiles that match the supplied list of user names. /// </summary> /// <param name="usernames">A string array of user names for profiles to be deleted.</param> /// <returns>The number of profiles deleted from the data source.</returns> public int DeleteProfiles(string[] usernames) { int deleteCount = 0; // For each user name found delete the profile. foreach (string user in usernames) { // Get the profile for the current user name. Nequeo.DataAccess.CloudInteraction.Data.Profile profile = GetSpecificProfile(user); // If a profile exits. if (profile != null) { // Delete all profile values and profiles. if (DeleteProfileValue(profile.ProfileID)) { if (DeleteProfile(user)) { deleteCount++; } } } } // The number of profiles deleted. return(deleteCount); }
/// <summary> /// When overridden in a derived class, deletes profile properties and information /// for the supplied list of profiles. /// </summary> /// <param name="profiles">A System.Web.Profile.ProfileInfoCollection of information about profiles /// that are to be deleted.</param> /// <returns>The number of profiles deleted from the data source.</returns> public int DeleteProfiles(System.Web.Profile.ProfileInfoCollection profiles) { int deleteCount = 0; // For each profile found delete the profile. foreach (ProfileInfo p in profiles) { // Get the profile for the current user name. Nequeo.DataAccess.CloudInteraction.Data.Profile profile = GetSpecificProfile(p.UserName); // If a profile exits. if (profile != null) { // Delete all profile values and profiles. if (DeleteProfileValue(profile.ProfileID)) { if (DeleteProfile(p.UserName)) { deleteCount++; } } } } // The number of profiles deleted. return(deleteCount); }
/// <summary> /// Returns the collection of settings property values for the specified application /// instance and settings property group. /// </summary> /// <param name="context">A System.Configuration.SettingsContext describing the current application use.</param> /// <param name="collection">A System.Configuration.SettingsPropertyCollection containing the settings /// property group whose values are to be retrieved.</param> /// <returns>A System.Configuration.SettingsPropertyValueCollection containing the values /// for the specified settings property group.</returns> public System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection collection) { string username = (string)context["UserName"]; bool isAuthenticated = (bool)context["IsAuthenticated"]; // Create a new SettingsPropertyValueCollection instance. SettingsPropertyValueCollection svc = new SettingsPropertyValueCollection(); // Get the profile for the current user name. Nequeo.DataAccess.CloudInteraction.Data.Profile profile = GetSpecificProfile(username); // If a profile exits. if (profile != null) { // For each property setting. foreach (SettingsProperty prop in collection) { bool propertyFound = false; // Get the value for the current property name. object value = GetProfilePropertyValue(profile, isAuthenticated, prop.Name, out propertyFound); // If the property has been found. if (propertyFound) { // Add the value to the property collection. SettingsPropertyValue pv = new SettingsPropertyValue(prop); pv.PropertyValue = value; svc.Add(pv); } else { throw new ProviderException("Unsupported property " + prop.Name); } } // Updates the LastActivityDate and LastUpdatedDate values when profile properties UpdateActivityDates(username, isAuthenticated, true); } else { // Make sure that the profile exists for the username if authenticated. if (isAuthenticated) { throw new ProviderException("Profile username : "******" does not exist."); } } // Return the SettingsPropertyValueCollection return(svc); }
/// <summary> /// Get the specific profile for the current application. /// </summary> /// <param name="username">The username.</param> /// <returns>The profile; else null.</returns> private Nequeo.DataAccess.CloudInteraction.Data.Profile GetSpecificProfile(string username) { // Get the user data. Nequeo.DataAccess.CloudInteraction.Data.Extension.Profile profileExt = new Nequeo.DataAccess.CloudInteraction.Data.Extension.Profile(); Nequeo.DataAccess.CloudInteraction.Data.Profile profile = profileExt.Select.SelectDataEntity( u => (u.Username == username) && (u.ApplicationName == ApplicationName) ); // Return the profile. return(profile); }
/// <summary> /// Get the current property value. /// </summary> /// <param name="profile">The profile.</param> /// <param name="isAuthenticated">Is the user authenticated or anonymous.</param> /// <param name="propertyName">The name of the property to search for.</param> /// <param name="propertyFound">Has the property been found.</param> /// <returns>The property value.</returns> private object GetProfilePropertyValue(Nequeo.DataAccess.CloudInteraction.Data.Profile profile, bool isAuthenticated, string propertyName, out bool propertyFound) { propertyFound = false; // Is opposite; is anonymous then not authenticated. bool isAnonymous = !isAuthenticated; bool isAnonymousProfile = false; // Attempt to find the property value for the property name // within the current profile id. Nequeo.DataAccess.CloudInteraction.Data.ProfileValue profileValue = GetSpecificPropertyValue(profile.ProfileID, propertyName); if (profileValue != null) { propertyFound = true; } else { return(null); } // If an anonymous value has been set. if (profile.IsAnonymous != null) { // Get the current is anonymous value. isAnonymousProfile = profile.IsAnonymous.Value; // If anonymous values match then return the property value if (isAnonymousProfile == isAnonymous) { return(profileValue.PropertyValue); } else { return(null); } } else { return(profileValue.PropertyValue); } }
/// <summary> /// Sets the values of the specified group of property settings. /// </summary> /// <param name="context">A System.Configuration.SettingsContext describing the current application usage.</param> /// <param name="collection">A System.Configuration.SettingsPropertyValueCollection representing the group /// of property settings to set.</param> public void SetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyValueCollection collection) { string username = (string)context["UserName"]; bool isAuthenticated = (bool)context["IsAuthenticated"]; // Get the profile for the current user name. Nequeo.DataAccess.CloudInteraction.Data.Profile profile = GetSpecificProfile(username); // If a profile exits. if (profile != null) { long profileID = profile.ProfileID; // For each property setting. foreach (SettingsPropertyValue pv in collection) { bool propertyFound = false; string propertyName = pv.Property.Name; // Get the value for the current property name. object value = GetProfilePropertyValue(profile, isAuthenticated, propertyName, out propertyFound); // If the property has been found. if (propertyFound) { // Update the property. bool retUpdate = new Nequeo.DataAccess.CloudInteraction.Data.Extension.ProfileValue(). Update.UpdateItemPredicate( new Data.ProfileValue() { PropertyValue = pv.PropertyValue.ToString() }, u => (u.ProfileID == profileID) && (u.PropertyName == propertyName) ); } else { // Insert the property. bool retInsert = new Nequeo.DataAccess.CloudInteraction.Data.Extension.ProfileValue(). Insert.InsertItem( new Data.ProfileValue() { ProfileID = profileID, PropertyName = propertyName, PropertyType = "System.String", PropertyValue = pv.PropertyValue.ToString() } ); } } // Updates the LastActivityDate and LastUpdatedDate values when profile properties UpdateActivityDates(username, isAuthenticated, false); } else { // Make sure that the profile exists for the username if authenticated. if (isAuthenticated) { throw new ProviderException("Profile username : "******" does not exist."); } } }