public Collection <string> SetPropertiesForCurrentUser(IDictionary <string, object> values, bool authenticatedUserOnly)
        {
            ApplicationServiceHelper.EnsureProfileServiceEnabled();

            HttpContext context = HttpContext.Current;

            if (authenticatedUserOnly)
            {
                ApplicationServiceHelper.EnsureAuthenticated(context);
            }

            return(ProfileService.SetProfile(context, values));
        }
        public Dictionary <string, object> GetPropertiesForCurrentUser(IEnumerable <string> properties, bool authenticatedUserOnly)
        {
            ApplicationServiceHelper.EnsureProfileServiceEnabled();

            HttpContext context = HttpContext.Current;

            if (authenticatedUserOnly)
            {
                ApplicationServiceHelper.EnsureAuthenticated(context);
            }

            return(ProfileService.GetProfile(context, properties));
        }
        /// <summary>
        /// When overridden in a derived class, retrieves profile information for profiles in which the user name matches the specified user names.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Web.Profile.ProfileInfoCollection"/> containing user-profile information for profiles where the user name matches the supplied <paramref name="usernameToMatch"/> parameter.
        /// </returns>
        /// <param name="authenticationOption">One of the <see cref="T:System.Web.Profile.ProfileAuthenticationOption"/> values, specifying whether anonymous, authenticated, or both types of profiles are returned.
        ///                 </param><param name="usernameToMatch">The user name to search for.
        ///                 </param><param name="pageIndex">The index of the page of results to return.
        ///                 </param><param name="pageSize">The size of the page of results to return.
        ///                 </param><param name="totalRecords">When this method returns, contains the total number of profiles.
        ///                 </param>
        public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            if (pageIndex < 1 || pageSize < 1)
                throw new ApplicationException(string.Format("{0} page index.", _ERR_INVALID_PARAMETER));

            ProfileInfoCollection profiles = new ProfileInfoCollection();

            int counter = 0;
            int startIndex = pageSize * (pageIndex - 1);
            int endIndex = startIndex + pageSize - 1;

            var foundProfile = new ProfileService().GetByUsernameApplicationName(usernameToMatch, this.ApplicationName);
            //totalRecords = profileList.Count;
            totalRecords = 0;
            if (foundProfile != null)
            {
                totalRecords = 1;
                profiles.Add(new ProfileInfo(foundProfile.Username, foundProfile.IsAnonymous.Value, foundProfile.LastActivityDate.Value, foundProfile.LastUpdatedDate.Value, 0));
            }

            return profiles;
        }
        /// <summary>
        /// When overridden in a derived class, retrieves user-profile data from the data source for profiles in which the last activity date occurred on or before the specified date.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Web.Profile.ProfileInfoCollection"/> containing user-profile information about the inactive profiles.
        /// </returns>
        /// <param name="authenticationOption">One of the <see cref="T:System.Web.Profile.ProfileAuthenticationOption"/> values, specifying whether anonymous, authenticated, or both types of profiles are returned.
        ///                 </param><param name="userInactiveSinceDate">A <see cref="T:System.DateTime"/> that identifies which user profiles are considered inactive. If the <see cref="P:System.Web.Profile.ProfileInfo.LastActivityDate"/>  of a user profile occurs on or before this date and time, the profile is considered inactive.
        ///                 </param><param name="pageIndex">The index of the page of results to return.
        ///                 </param><param name="pageSize">The size of the page of results to return.
        ///                 </param><param name="totalRecords">When this method returns, contains the total number of profiles.
        ///                 </param>
        public override ProfileInfoCollection GetAllInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
        {
            if (pageIndex < 1 || pageSize < 1)
                throw new ApplicationException(string.Format("{0} page index.", _ERR_INVALID_PARAMETER));

            ProfileInfoCollection profiles = new ProfileInfoCollection();

            int counter = 0;
            int startIndex = pageSize * (pageIndex - 1);
            int endIndex = startIndex + pageSize - 1;

            var profileList = new TList<Profile>();
            var profileService = new ProfileService();
            foreach (var item in profileService.GetAll())
            {
                if (item.LastActivityDate.Value < userInactiveSinceDate)
                {
                    profileList.Add(item);
                }
            }

            totalRecords = profileList.Count;

            foreach (Profile profile in profileList)
            {
                if (counter >= startIndex)
                {
                    profiles.Add(new ProfileInfo(profile.Username, profile.IsAnonymous.Value, profile.LastActivityDate.Value, profile.LastUpdatedDate.Value, 0));
                }

                if (counter >= endIndex)
                {
                    break;
                }

                counter++;
            }

            return profiles;
        }
        /// <summary>
        /// When overridden in a derived class, returns the number of profiles in which the last activity date occurred on or before the specified date.
        /// </summary>
        /// <returns>
        /// The number of profiles in which the last activity date occurred on or before the specified date.
        /// </returns>
        /// <param name="authenticationOption">One of the <see cref="T:System.Web.Profile.ProfileAuthenticationOption"/> values, specifying whether anonymous, authenticated, or both types of profiles are returned.
        ///                 </param><param name="userInactiveSinceDate">A <see cref="T:System.DateTime"/> that identifies which user profiles are considered inactive. If the <see cref="P:System.Web.Profile.ProfileInfo.LastActivityDate"/>  of a user profile occurs on or before this date and time, the profile is considered inactive.
        ///                 </param>
        public override int GetNumberOfInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            var profileList = new TList<Profile>();
            var profileService = new ProfileService();
            foreach (var item in profileService.GetAll())
            {
                if (item.LastActivityDate.Value < userInactiveSinceDate)
                {
                    profileList.Add(item);
                }
            }

            return profileList.Count;
        }
        /// <summary>
        /// When overridden in a derived class, deletes all user-profile data for profiles in which the last activity date occurred before the specified date.
        /// </summary>
        /// <returns>
        /// The number of profiles deleted from the data source.
        /// </returns>
        /// <param name="authenticationOption">One of the <see cref="T:System.Web.Profile.ProfileAuthenticationOption"/> values, specifying whether anonymous, authenticated, or both types of profiles are deleted.
        ///                 </param><param name="userInactiveSinceDate">A <see cref="T:System.DateTime"/> that identifies which user profiles are considered inactive. If the <see cref="P:System.Web.Profile.ProfileInfo.LastActivityDate"/>  value of a user profile occurs on or before this date and time, the profile is considered inactive.
        ///                 </param>
        public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            int count = 0;
            var profileService = new ProfileService();
            foreach (var profile in profileService.GetAll())
            {
                if (profile.LastActivityDate.Value < userInactiveSinceDate)
                {
                    DeleteProfile(profile.Username);
                    count++;
                }
            }

            return count;
        }