public static int ResetState(PersonalizationStateInfoCollection data)
        {
            int num = 0;

            PersonalizationProviderHelper.CheckNullEntries(data, "data");
            StringCollection strings = null;

            foreach (PersonalizationStateInfo info in data)
            {
                UserPersonalizationStateInfo info2 = info as UserPersonalizationStateInfo;
                if (info2 != null)
                {
                    if (ResetUserState(info2.Path, info2.Username))
                    {
                        num++;
                    }
                }
                else
                {
                    if (strings == null)
                    {
                        strings = new StringCollection();
                    }
                    strings.Add(info.Path);
                }
            }
            if (strings != null)
            {
                string[] array = new string[strings.Count];
                strings.CopyTo(array, 0);
                num += ResetStatePrivate(PersonalizationScope.Shared, array, null);
            }
            return(num);
        }
示例#2
0
 // We only want our assembly to inherit this class, so make it internal
 internal PersonalizationStateInfo(string path, DateTime lastUpdatedDate, int size)
 {
     _path = StringUtil.CheckAndTrimString(path, "path");
     PersonalizationProviderHelper.CheckNegativeInteger(size, "size");
     _lastUpdatedDate = lastUpdatedDate.ToUniversalTime();
     _size            = size;
 }
 public PersonalizationEntry(object value, PersonalizationScope scope, bool isSensitive)
 {
     PersonalizationProviderHelper.CheckPersonalizationScope(scope);
     this._value       = value;
     this._scope       = scope;
     this._isSensitive = isSensitive;
 }
示例#4
0
        public override PersonalizationStateInfoCollection FindState(PersonalizationScope scope,
                                                                     PersonalizationStateQuery query,
                                                                     int pageIndex, int pageSize,
                                                                     out int totalRecords)
        {
            PersonalizationProviderHelper.CheckPersonalizationScope(scope);
            PersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize);

            if (scope == PersonalizationScope.Shared)
            {
                string pathToMatch = null;
                if (query != null)
                {
                    pathToMatch = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, maxStringLength);
                }
                return(FindSharedState(pathToMatch, pageIndex, pageSize, out totalRecords));
            }
            else
            {
                string   pathToMatch       = null;
                DateTime inactiveSinceDate = PersonalizationAdministration.DefaultInactiveSinceDate;
                string   usernameToMatch   = null;
                if (query != null)
                {
                    pathToMatch       = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, maxStringLength);
                    inactiveSinceDate = query.UserInactiveSinceDate;
                    usernameToMatch   = StringUtil.CheckAndTrimString(query.UsernameToMatch, "query.UsernameToMatch", false, maxStringLength);
                }

                return(FindUserState(pathToMatch, inactiveSinceDate, usernameToMatch,
                                     pageIndex, pageSize, out totalRecords));
            }
        }
示例#5
0
 public override int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query)
 {
     PersonalizationProviderHelper.CheckPersonalizationScope(scope);
     if (scope == PersonalizationScope.Shared)
     {
         string pathToMatch = null;
         if (query != null)
         {
             pathToMatch = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, maxStringLength);
         }
         return(GetCountOfSharedState(pathToMatch));
     }
     else
     {
         string   pathToMatch           = null;
         DateTime userInactiveSinceDate = PersonalizationAdministration.DefaultInactiveSinceDate;
         string   usernameToMatch       = null;
         if (query != null)
         {
             pathToMatch           = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, maxStringLength);
             userInactiveSinceDate = query.UserInactiveSinceDate;
             usernameToMatch       = StringUtil.CheckAndTrimString(query.UsernameToMatch, "query.UsernameToMatch", false, maxStringLength);
         }
         return(GetCountOfUserState(pathToMatch, userInactiveSinceDate, usernameToMatch));
     }
 }
示例#6
0
 public SharedPersonalizationStateInfo(string path, DateTime lastUpdatedDate, int size, int sizeOfPersonalizations, int countOfPersonalizations) : base(path, lastUpdatedDate, size)
 {
     PersonalizationProviderHelper.CheckNegativeInteger(sizeOfPersonalizations, "sizeOfPersonalizations");
     PersonalizationProviderHelper.CheckNegativeInteger(countOfPersonalizations, "countOfPersonalizations");
     this._sizeOfPersonalizations  = sizeOfPersonalizations;
     this._countOfPersonalizations = countOfPersonalizations;
 }
 public static int ResetUserState(string path, string[] usernames)
 {
     path      = StringUtil.CheckAndTrimString(path, "path");
     usernames = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(usernames, "usernames", true, true, -1);
     string [] paths = new string [] { path };
     return(ResetStatePrivate(PersonalizationScope.User, paths, usernames));
 }
        // This private method assumes input parameters have been checked
        private static int ResetStatePrivate(PersonalizationScope scope, string[] paths, string[] usernames)
        {
            Initialize();
            int count = _provider.ResetState(scope, paths, usernames);

            PersonalizationProviderHelper.CheckNegativeReturnedInteger(count, "ResetState");
            return(count);
        }
        private static int GetCountOfStatePrivate(PersonalizationScope scope, PersonalizationStateQuery stateQuery)
        {
            Initialize();
            int countOfState = _provider.GetCountOfState(scope, stateQuery);

            PersonalizationProviderHelper.CheckNegativeReturnedInteger(countOfState, "GetCountOfState");
            return(countOfState);
        }
        // This private method assumes input parameters have been checked
        private static int ResetInactiveUserStatePrivate(string path, DateTime userInactiveSinceDate)
        {
            Initialize();
            int count = _provider.ResetUserState(path, userInactiveSinceDate);

            PersonalizationProviderHelper.CheckNegativeReturnedInteger(count, "ResetUserState");
            return(count);
        }
 public static PersonalizationStateInfoCollection GetAllState(PersonalizationScope scope,
                                                              int pageIndex, int pageSize,
                                                              out int totalRecords)
 {
     PersonalizationProviderHelper.CheckPersonalizationScope(scope);
     PersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize);
     return(FindStatePrivate(scope, null, pageIndex, pageSize, out totalRecords));
 }
        public static PersonalizationStateInfoCollection GetAllInactiveUserState(DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
        {
            PersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize);
            PersonalizationStateQuery stateQuery = new PersonalizationStateQuery {
                UserInactiveSinceDate = userInactiveSinceDate
            };

            return(FindStatePrivate(PersonalizationScope.User, stateQuery, pageIndex, pageSize, out totalRecords));
        }
        public static int GetCountOfState(PersonalizationScope scope, string pathToMatch)
        {
            PersonalizationProviderHelper.CheckPersonalizationScope(scope);
            pathToMatch = StringUtil.CheckAndTrimString(pathToMatch, "pathToMatch", false);
            PersonalizationStateQuery stateQuery = new PersonalizationStateQuery();

            stateQuery.PathToMatch = pathToMatch;
            return(GetCountOfStatePrivate(scope, stateQuery));
        }
        public static PersonalizationStateInfoCollection FindSharedState(string pathToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            pathToMatch = System.Web.Util.StringUtil.CheckAndTrimString(pathToMatch, "pathToMatch", false);
            PersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize);
            PersonalizationStateQuery stateQuery = new PersonalizationStateQuery {
                PathToMatch = pathToMatch
            };

            return(FindStatePrivate(PersonalizationScope.Shared, stateQuery, pageIndex, pageSize, out totalRecords));
        }
        public static PersonalizationStateInfoCollection FindInactiveUserState(string pathToMatch, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
        {
            pathToMatch     = System.Web.Util.StringUtil.CheckAndTrimString(pathToMatch, "pathToMatch", false);
            usernameToMatch = System.Web.Util.StringUtil.CheckAndTrimString(usernameToMatch, "usernameToMatch", false);
            PersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize);
            PersonalizationStateQuery stateQuery = new PersonalizationStateQuery {
                PathToMatch           = pathToMatch,
                UsernameToMatch       = usernameToMatch,
                UserInactiveSinceDate = userInactiveSinceDate
            };

            return(FindStatePrivate(PersonalizationScope.User, stateQuery, pageIndex, pageSize, out totalRecords));
        }
示例#16
0
 protected virtual void ChangeScope(PersonalizationScope scope)
 {
     PersonalizationProviderHelper.CheckPersonalizationScope(scope);
     if (scope != this._currentScope)
     {
         if ((scope == PersonalizationScope.Shared) && !this.CanEnterSharedScope)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartPersonalization_CannotEnterSharedScope"));
         }
         this._currentScope = scope;
         this._scopeToggled = true;
     }
 }
示例#17
0
 public override int ResetState(PersonalizationScope scope, string[] paths, string[] usernames)
 {
     PersonalizationProviderHelper.CheckPersonalizationScope(scope);
     paths     = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(paths, "paths", false, false, 0x100);
     usernames = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(usernames, "usernames", false, true, 0x100);
     if (scope == PersonalizationScope.Shared)
     {
         PersonalizationProviderHelper.CheckUsernamesInSharedScope(usernames);
         return(this.ResetSharedState(paths));
     }
     PersonalizationProviderHelper.CheckOnlyOnePathWithUsers(paths, usernames);
     return(this.ResetUserState(paths, usernames));
 }
        public static bool ResetUserState(string path, string username)
        {
            path     = System.Web.Util.StringUtil.CheckAndTrimString(path, "path");
            username = PersonalizationProviderHelper.CheckAndTrimStringWithoutCommas(username, "username");
            string[] paths     = new string[] { path };
            string[] usernames = new string[] { username };
            int      num       = ResetStatePrivate(PersonalizationScope.User, paths, usernames);

            if (num > 1)
            {
                throw new HttpException(System.Web.SR.GetString("PersonalizationAdmin_UnexpectedResetUserStateReturnValue", new object[] { num.ToString(CultureInfo.CurrentCulture) }));
            }
            return(num == 1);
        }
        public static PersonalizationStateInfoCollection FindUserState(string pathToMatch,
                                                                       string usernameToMatch,
                                                                       int pageIndex, int pageSize,
                                                                       out int totalRecords)
        {
            pathToMatch     = StringUtil.CheckAndTrimString(pathToMatch, "pathToMatch", false);
            usernameToMatch = StringUtil.CheckAndTrimString(usernameToMatch, "usernameToMatch", false);
            PersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize);
            PersonalizationStateQuery stateQuery = new PersonalizationStateQuery();

            stateQuery.PathToMatch     = pathToMatch;
            stateQuery.UsernameToMatch = usernameToMatch;
            return(FindStatePrivate(PersonalizationScope.User, stateQuery, pageIndex,
                                    pageSize, out totalRecords));
        }
        public static bool ResetUserState(string path, string username)
        {
            path     = StringUtil.CheckAndTrimString(path, "path");
            username = PersonalizationProviderHelper.CheckAndTrimStringWithoutCommas(username, "username");
            string [] paths     = new string [] { path };
            string [] usernames = new string[] { username };
            int       count     = ResetStatePrivate(PersonalizationScope.User, paths, usernames);

            Debug.Assert(count >= 0);
            if (count > 1)
            {
                throw new HttpException(SR.GetString(SR.PersonalizationAdmin_UnexpectedResetUserStateReturnValue, count.ToString(CultureInfo.CurrentCulture)));
            }
            return(count == 1);
        }
示例#21
0
        protected virtual void ChangeScope(PersonalizationScope scope)
        {
            PersonalizationProviderHelper.CheckPersonalizationScope(scope);

            if (scope == _currentScope)
            {
                return;
            }

            if ((scope == PersonalizationScope.Shared) && (!CanEnterSharedScope))
            {
                throw new InvalidOperationException(SR.GetString(SR.WebPartPersonalization_CannotEnterSharedScope));
            }

            _currentScope = scope;
            _scopeToggled = true;
        }
        public static int ResetState(PersonalizationStateInfoCollection data)
        {
            int count = 0;

            PersonalizationProviderHelper.CheckNullEntries(data, "data");

            StringCollection sharedPaths = null;

            foreach (PersonalizationStateInfo stateInfo in data)
            {
                UserPersonalizationStateInfo userStateInfo = stateInfo as UserPersonalizationStateInfo;
                if (userStateInfo != null)
                {
                    if (ResetUserState(userStateInfo.Path, userStateInfo.Username))
                    {
                        count += 1;
                    }
                }
                else
                {
                    if (sharedPaths == null)
                    {
                        sharedPaths = new StringCollection();
                    }
                    sharedPaths.Add(stateInfo.Path);
                }
            }

            if (sharedPaths != null)
            {
                string [] sharedPathsArray = new string [sharedPaths.Count];
                sharedPaths.CopyTo(sharedPathsArray, 0);
                count += ResetStatePrivate(PersonalizationScope.Shared, sharedPathsArray, null);
            }
            return(count);
        }
 public static int ResetAllState(PersonalizationScope scope)
 {
     PersonalizationProviderHelper.CheckPersonalizationScope(scope);
     return(ResetStatePrivate(scope, null, null));
 }
 public static int ResetSharedState(string[] paths)
 {
     paths = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(paths, "paths", true, false, -1);
     return(ResetStatePrivate(PersonalizationScope.Shared, paths, null));
 }
 public static int ResetUserState(string[] usernames)
 {
     usernames = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(usernames, "usernames", true, true, -1);
     return(ResetStatePrivate(PersonalizationScope.User, null, usernames));
 }