Пример #1
0
        public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption,
                                                   DateTime userInactiveSinceDate)
        {
            ProfileType?profileType = null;

            if (authenticationOption == ProfileAuthenticationOption.Anonymous)
            {
                profileType = ProfileType.Anonymous;
            }
            else if (authenticationOption == ProfileAuthenticationOption.Authenticated)
            {
                profileType = ProfileType.Authenticated;
            }

            int profilesDeleted = 0;

            using (var transaction = new TransactionScope(mConfiguration))
            {
                var profileStore = new ProfileUserDataStore(transaction);

                IList <ProfileUser> users = profileStore.FindByFields(ApplicationName, null, userInactiveSinceDate,
                                                                      profileType, PagingInfo.All);

                profilesDeleted = users.Count;

                foreach (ProfileUser user in users)
                {
                    profileStore.Delete(user.Id);
                }

                transaction.Commit();
            }

            return(profilesDeleted);
        }
Пример #2
0
        public override int DeleteProfiles(ProfileInfoCollection profiles)
        {
            int profilesDeleted = 0;

            using (var transaction = new TransactionScope(mConfiguration))
            {
                var profileStore = new ProfileUserDataStore(transaction);

                foreach (ProfileInfo profileInfo in profiles)
                {
                    ProfileUser user = profileStore.FindByName(ApplicationName, profileInfo.UserName);
                    if (user != null)
                    {
                        profileStore.Delete(user.Id);

                        profilesDeleted++;
                    }
                }

                transaction.Commit();
            }

            return(profilesDeleted);
        }
Пример #3
0
        public override int DeleteProfiles(string[] usernames)
        {
            int profilesDeleted = 0;

            using (var transaction = new TransactionScope(mConfiguration))
            {
                var profileStore = new ProfileUserDataStore(transaction);

                foreach (string userName in usernames)
                {
                    IList <ProfileUser> users = profileStore.FindByFields(ApplicationName, userName, null, null,
                                                                          PagingInfo.All);
                    profilesDeleted += users.Count;
                    foreach (ProfileUser user in users)
                    {
                        profileStore.Delete(user.Id);
                    }
                }

                transaction.Commit();
            }

            return(profilesDeleted);
        }