internal static void CheckPersonalizationScope(PersonalizationScope scope) { if (scope < PersonalizationScope.User || scope > PersonalizationScope.Shared) { throw new ArgumentOutOfRangeException("scope"); } }
public static int GetCountOfState( SiteSettings siteSettings, PersonalizationScope scope, PersonalizationStateQuery query) { int result = 0; if (siteSettings != null) { Guid userGuid = Guid.Empty; if ((query.UsernameToMatch != null) && (query.UsernameToMatch.Length > 0)) { SiteUser siteUser = new SiteUser(siteSettings, query.UsernameToMatch); if (siteUser.UserId > 0) { userGuid = siteUser.UserGuid; } } bool allUsersScope = (scope == PersonalizationScope.Shared); result = SitePersonalization.GetCountOfState( siteSettings.SiteId, query.PathToMatch, allUsersScope, userGuid, query.UserInactiveSinceDate); } return result; }
public PersonalizationEntry(object value, PersonalizationScope scope, bool isSensitive) { PersonalizationProviderHelper.CheckPersonalizationScope(scope); this._value = value; this._scope = scope; this._isSensitive = isSensitive; }
public LimitedWebPartManager GetLimitedWebPartManager(PersonalizationScope scope) { ClientRuntimeContext context = base.Context; object obj; Dictionary <PersonalizationScope, LimitedWebPartManager> dictionary; if (base.ObjectData.MethodReturnObjects.TryGetValue("GetLimitedWebPartManager", out obj)) { dictionary = (Dictionary <PersonalizationScope, LimitedWebPartManager>)obj; } else { dictionary = new Dictionary <PersonalizationScope, LimitedWebPartManager>(); base.ObjectData.MethodReturnObjects["GetLimitedWebPartManager"] = dictionary; } LimitedWebPartManager limitedWebPartManager = null; if (!context.DisableReturnValueCache && dictionary.TryGetValue(scope, out limitedWebPartManager)) { return(limitedWebPartManager); } limitedWebPartManager = new LimitedWebPartManager(context, new ObjectPathMethod(context, base.Path, "GetLimitedWebPartManager", new object[] { scope })); if (!context.DisableReturnValueCache) { dictionary[scope] = limitedWebPartManager; } this.CheckScope(scope); return(limitedWebPartManager); }
internal static IDictionary GetPersonalizablePropertyValues(Control control, PersonalizationScope scope, bool excludeSensitive) { IDictionary dictionary = null; IDictionary personalizablePropertyEntries = GetPersonalizablePropertyEntries(control.GetType()); if (personalizablePropertyEntries.Count != 0) { foreach (DictionaryEntry entry in personalizablePropertyEntries) { string key = (string)entry.Key; PersonalizablePropertyEntry entry2 = (PersonalizablePropertyEntry)entry.Value; if ((!excludeSensitive || !entry2.IsSensitive) && ((scope != PersonalizationScope.User) || (entry2.Scope != PersonalizationScope.Shared))) { if (dictionary == null) { dictionary = new HybridDictionary(personalizablePropertyEntries.Count, false); } object y = FastPropertyAccessor.GetProperty(control, key, control.DesignMode); dictionary[key] = new Pair(entry2.PropertyInfo, y); } } } if (dictionary == null) { dictionary = new HybridDictionary(false); } return(dictionary); }
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 str = null; if (query != null) str = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, 0x100); return this.FindSharedState(str, pageIndex, pageSize, out totalRecords); } string path = null; DateTime defaultInactiveSinceDate = DateTime.MaxValue; string username = null; if (query != null) { path = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, 0x100); defaultInactiveSinceDate = query.UserInactiveSinceDate; username = StringUtil.CheckAndTrimString(query.UsernameToMatch, "query.UsernameToMatch", false, 0x100); } return this.FindUserState(path, defaultInactiveSinceDate, username, pageIndex, pageSize, out totalRecords); }
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 = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength); } return FindSharedState(pathToMatch, pageIndex, pageSize, out totalRecords); } else { string pathToMatch = null; DateTime inactiveSinceDate = DateTime.MinValue; string usernameToMatch = null; if (query != null) { pathToMatch = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength); inactiveSinceDate = query.UserInactiveSinceDate; usernameToMatch = PersonalizationProviderHelper.CheckAndTrimString( query.UsernameToMatch, "query.UsernameToMatch", false, MaxStringLength); } return FindUserState(pathToMatch, inactiveSinceDate, usernameToMatch, pageIndex, pageSize, out totalRecords); } }
public WebPartChrome(WebPartZoneBase zone, System.Web.UI.WebControls.WebParts.WebPartManager manager) { if (zone == null) { throw new ArgumentNullException("zone"); } this._zone = zone; this._page = zone.Page; this._designMode = zone.DesignMode; this._manager = manager; if (this._designMode) { this._personalizationEnabled = true; } else { this._personalizationEnabled = (manager != null) && manager.Personalization.IsModifiable; } if (manager != null) { this._personalizationScope = manager.Personalization.Scope; } else { this._personalizationScope = PersonalizationScope.Shared; } }
public WebPartChrome(WebPartZoneBase zone, WebPartManager manager) { if (zone == null) { throw new ArgumentNullException("zone"); } _zone = zone; _page = zone.Page; _designMode = zone.DesignMode; _manager = manager; if (_designMode) { // Consider personalization to be enabled at design-time _personalizationEnabled = true; } else { _personalizationEnabled = (manager != null && manager.Personalization.IsModifiable); } if (manager != null) { _personalizationScope = manager.Personalization.Scope; } else { // Consider scope to be shared at design-time _personalizationScope = PersonalizationScope.Shared; } }
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 str = null; if (query != null) { str = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, 0x100); } return(this.FindSharedState(str, pageIndex, pageSize, out totalRecords)); } string path = null; DateTime defaultInactiveSinceDate = PersonalizationAdministration.DefaultInactiveSinceDate; string username = null; if (query != null) { path = StringUtil.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, 0x100); defaultInactiveSinceDate = query.UserInactiveSinceDate; username = StringUtil.CheckAndTrimString(query.UsernameToMatch, "query.UsernameToMatch", false, 0x100); } return(this.FindUserState(path, defaultInactiveSinceDate, username, pageIndex, pageSize, out totalRecords)); }
public override int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query) { PersonalizationProviderHelper.CheckPersonalizationScope(scope); if (scope == PersonalizationScope.Shared) { string pathToMatch = null; if (query != null) { pathToMatch = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength); } return(GetCountOfSharedState(pathToMatch)); } else { string pathToMatch = null; DateTime userInactiveSinceDate = DateTime.MinValue; string usernameToMatch = null; if (query != null) { pathToMatch = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength); userInactiveSinceDate = query.UserInactiveSinceDate; usernameToMatch = PersonalizationProviderHelper.CheckAndTrimString( query.UsernameToMatch, "query.UsernameToMatch", false, MaxStringLength); } return(GetCountOfUserState(pathToMatch, userInactiveSinceDate, usernameToMatch)); } }
public static int GetCountOfState( SiteSettings siteSettings, PersonalizationScope scope, PersonalizationStateQuery query) { int result = 0; if (siteSettings != null) { Guid userGuid = Guid.Empty; if ((query.UsernameToMatch != null) && (query.UsernameToMatch.Length > 0)) { SiteUser siteUser = new SiteUser(siteSettings, query.UsernameToMatch); if (siteUser.UserId > 0) { userGuid = siteUser.UserGuid; } } bool allUsersScope = (scope == PersonalizationScope.Shared); result = SitePersonalization.GetCountOfState( siteSettings.SiteId, query.PathToMatch, allUsersScope, userGuid, query.UserInactiveSinceDate); } return(result); }
public override int ResetState( PersonalizationScope scope, string[] paths, string[] usernames) { return(0); }
/// <summary> /// Finds state matching given parameters /// </summary> /// <param name="scope">Scope to search</param> /// <param name="query">Query to action</param> /// <param name="pageIndex">Index of page to retrieve</param> /// <param name="pageSize">Size of page to retrieve</param> /// <param name="totalRecords">Count of records returned</param> /// <returns>Matching state</returns> public override PersonalizationStateInfoCollection FindState(PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSize, out int totalRecords) { FindStateResult result = Client.FindState(scope, query, pageIndex, pageSize); totalRecords = result.TotalRecords; return(result.StateInfoCollection); }
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 = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength); } return(FindSharedState(pathToMatch, pageIndex, pageSize, out totalRecords)); } else { string pathToMatch = null; DateTime inactiveSinceDate = DateTime.MinValue; string usernameToMatch = null; if (query != null) { pathToMatch = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength); inactiveSinceDate = query.UserInactiveSinceDate; usernameToMatch = PersonalizationProviderHelper.CheckAndTrimString( query.UsernameToMatch, "query.UsernameToMatch", false, MaxStringLength); } return(FindUserState(pathToMatch, inactiveSinceDate, usernameToMatch, pageIndex, pageSize, out totalRecords)); } }
// 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); }
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)); }
/// <devdoc> /// </devdoc> internal void LoadInternal() { if (Enabled) { _currentScope = Load(); _initialized = true; } _initializedSet = true; }
internal void LoadInternal() { if (this.Enabled) { this._currentScope = this.Load(); this._initialized = true; } this._initializedSet = true; }
/// <summary> /// Finds state matching given parameters /// </summary> /// <param name="scope">Scope to search</param> /// <param name="query">Query to action</param> /// <param name="pageIndex">Index of page to retrieve</param> /// <param name="pageSize">Size of page to retrieve</param> /// <returns>Matching state</returns> public FindStateResult FindState(PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSize) { int totalRecords = 0; PersonalizationStateInfoCollection collection = Provider.FindState(scope, query, pageIndex, pageSize, out totalRecords); FindStateResult result = new FindStateResult(); result.TotalRecords = totalRecords; result.StateInfoCollection = collection; return result; }
private PersonalizableAttribute(bool isPersonalizable, PersonalizationScope scope, bool isSensitive) { this._isPersonalizable = isPersonalizable; this._isSensitive = isSensitive; if (this._isPersonalizable) { this._scope = scope; } }
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)); }
/// <summary> /// Deletes personalization state corresponding to the specified users and specified pages from the database. /// </summary> /// <param name="scope">The personalization scope.</param> /// <param name="paths">The paths indicating where to save the data.</param> /// <param name="usernames">The user names.</param> /// <returns></returns> public override int ResetState(PersonalizationScope scope, string[] paths, string[] usernames) { bool hasPaths = !(paths == null || paths.Length == 0); bool hasUsers = !(usernames == null || usernames.Length == 0); var count = 0; var connection = new MySQLPersonalizationConnectionHelper(connectionString); connection.OpenConnection(true); if (scope == PersonalizationScope.Shared) { try { if (paths == null) // reset all state { return(PersonalizationProviderProcedures.my_aspnet_PersonalizationAdministration_DeleteAllState(true, ApplicationId, connection)); } else { return(PersonalizationProviderProcedures.my_aspnet_PersonalizationAdministration_ResetSharedState(ApplicationId, paths, connection)); } } catch (Exception ex) { if (writeExceptionsToEventLog) { WriteToEventLog(ex, "MySQLPersonalizationProvider - ResetState"); } throw; } finally { connection.CloseConnection(); } } else { DateTime dateTime = Convert.ToDateTime("2038-01-19 03:14:07.999999"); // MySQL TimeStamp MaxValue if (!hasPaths && !hasUsers) { count = PersonalizationProviderProcedures.my_aspnet_PersonalizationAdministration_DeleteAllState(true, ApplicationId, connection); } else if (!hasUsers) { count = ResetUserState(ResetUserStateMode.PerPaths, dateTime, paths, null); } else { count = ResetUserState(ResetUserStateMode.PerUsers, dateTime, paths, usernames); } } return(count); }
/// <internalonly/> /// <devdoc> /// Initializes an instance of PersonalizableAttribute with the specified values. /// </devdoc> private PersonalizableAttribute(bool isPersonalizable, PersonalizationScope scope, bool isSensitive) { Debug.Assert((isPersonalizable == true || isSensitive == false), "Only Personalizable properties can be sensitive"); _isPersonalizable = isPersonalizable; _isSensitive = isSensitive; if (_isPersonalizable) { _scope = scope; } }
public override PersonalizationStateInfoCollection FindState( PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSize, out int totalRecords) { totalRecords = 0; return(null); }
// This private method assumes input parameters have been checked private static PersonalizationStateInfoCollection FindStatePrivate( PersonalizationScope scope, PersonalizationStateQuery stateQuery, int pageIndex, int pageSize, out int totalRecords) { Initialize(); return(_provider.FindState(scope, stateQuery, pageIndex, pageSize, out totalRecords)); }
/// <summary> /// Finds state matching given parameters /// </summary> /// <param name="scope">Scope to search</param> /// <param name="query">Query to action</param> /// <param name="pageIndex">Index of page to retrieve</param> /// <param name="pageSize">Size of page to retrieve</param> /// <returns>Matching state</returns> public FindStateResult FindState(PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSize) { int totalRecords = 0; PersonalizationStateInfoCollection collection = Provider.FindState(scope, query, pageIndex, pageSize, out totalRecords); FindStateResult result = new FindStateResult(); result.TotalRecords = totalRecords; result.StateInfoCollection = collection; return(result); }
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)); }
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; } }
public override int GetCountOfState( PersonalizationScope scope, PersonalizationStateQuery query) { SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings != null) { return(PersonalizationHelper.GetCountOfState(siteSettings, scope, query)); } return(0); }
private int ResetAllState(PersonalizationScope scope) { SqlConnectionHolder connectionHolder = null; SqlConnection connection = null; int count = 0; // Extra try-catch block to prevent elevation of privilege attack via exception filter try { try { connectionHolder = GetConnectionHolder(); connection = connectionHolder.Connection; Debug.Assert(connection != null); CheckSchemaVersion(connection); SqlCommand command = new SqlCommand("dbo.aspnet_PersonalizationAdministration_DeleteAllState", connection); SetCommandTypeAndTimeout(command); SqlParameterCollection parameters = command.Parameters; SqlParameter parameter = parameters.Add(new SqlParameter("AllUsersScope", SqlDbType.Bit)); parameter.Value = (scope == PersonalizationScope.Shared); parameters.AddWithValue("ApplicationName", ApplicationName); parameter = parameters.Add(new SqlParameter("Count", SqlDbType.Int)); parameter.Direction = ParameterDirection.Output; command.ExecuteNonQuery(); parameter = command.Parameters[2]; if (parameter != null && parameter.Value != null && parameter.Value is Int32) { count = (Int32)parameter.Value; } } finally { if (connectionHolder != null) { connectionHolder.Close(); connectionHolder = null; } } } catch { throw; } return(count); }
/// <summary> /// Returns the number of records in the database that match the specified criteria. /// </summary> /// <param name="scope">The personalization scope.</param> /// <param name="query">The set of query parameters.</param> /// <remarks>For example, records corresponding to users named Jeff* that haven't been modified since January 1, 2005. Wildcard support is provider-dependent.</remarks> public override int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query) { if (query == null) { throw new ArgumentNullException("query"); } if (scope == PersonalizationScope.User) { return(GetCountUserState(query.PathToMatch.Trim(), query.UserInactiveSinceDate, query.UsernameToMatch)); } else { return(GetCountOfSharedState(query.PathToMatch.Trim())); } }
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 override int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query) { throw new NotImplementedException(); }
public override int ResetState(PersonalizationScope scope, string[] paths, string[] usernames) { PersonalizationProviderHelper.CheckPersonalizationScope(scope); paths = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(paths, "paths", false, false, maxStringLength); usernames = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(usernames, "usernames", false, true, maxStringLength); if (scope == PersonalizationScope.Shared) { PersonalizationProviderHelper.CheckUsernamesInSharedScope(usernames); return ResetSharedState(paths); } else { PersonalizationProviderHelper.CheckOnlyOnePathWithUsers(paths, usernames); return ResetUserState(paths, usernames); } }
public virtual int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query) { }
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); } }
private int ResetAllState(PersonalizationScope scope) { SqlConnectionHolder connectionHolder = null; SqlConnection connection = null; int count = 0; // Extra try-catch block to prevent elevation of privilege attack via exception filter try { try { connectionHolder = GetConnectionHolder(); connection = connectionHolder.Connection; Debug.Assert(connection != null); CheckSchemaVersion( connection ); SqlCommand command = new SqlCommand("dbo.aspnet_PersonalizationAdministration_DeleteAllState", connection); SetCommandTypeAndTimeout(command); SqlParameterCollection parameters = command.Parameters; SqlParameter parameter = parameters.Add(new SqlParameter("AllUsersScope", SqlDbType.Bit)); parameter.Value = (scope == PersonalizationScope.Shared); parameters.AddWithValue("ApplicationName", ApplicationName); parameter = parameters.Add(new SqlParameter("Count", SqlDbType.Int)); parameter.Direction = ParameterDirection.Output; command.ExecuteNonQuery(); parameter = command.Parameters[2]; if (parameter != null && parameter.Value != null && parameter.Value is Int32) { count = (Int32) parameter.Value; } } finally { if (connectionHolder != null) { connectionHolder.Close(); connectionHolder = null; } } } catch { throw; } return count; }
public virtual int ResetState(PersonalizationScope scope, string[] paths, string[] usernames) { }
// Methods public virtual PersonalizationStateInfoCollection FindState(PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSizeout , System.Int32& totalRecords) { }
public override int GetCountOfState( PersonalizationScope scope, PersonalizationStateQuery query) { SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings != null) { return PersonalizationHelper.GetCountOfState(siteSettings, scope, query); } return 0; }
// Constructors public PersonalizationEntry(object value, PersonalizationScope scope) {}
public override PersonalizationStateInfoCollection FindState(PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSize, out int totalRecords) { throw new NotImplementedException(); }
/// <summary> /// Gets the count of items in state /// </summary> /// <param name="scope">Scope to count</param> /// <param name="query">Query to action</param> /// <returns>Count of state</returns> public int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query) { return Provider.GetCountOfState(scope, query); }
/// <devdoc> /// Does the work of retrieving personalized properties. If the scope is User, the shared /// personalizable properties are not retrieved. If a non-null defaultPropertyState is /// handed in, only the properties that are different from the default values are retrieved. /// </devdoc> private static IDictionary GetPersonalizedProperties(Control control, IDictionary personalizableProperties, IDictionary defaultPropertyState, IDictionary initialPropertyState, PersonalizationScope scope) { Debug.Assert(control != null); if (personalizableProperties.Count == 0) { return null; } bool ignoreSharedProperties = (scope == PersonalizationScope.User); IDictionary properties = null; foreach (DictionaryEntry entry in personalizableProperties) { PersonalizablePropertyEntry property = (PersonalizablePropertyEntry)entry.Value; if (ignoreSharedProperties && (property.Scope == PersonalizationScope.Shared)) { continue; } PropertyInfo pi = property.PropertyInfo; Debug.Assert(pi != null); // string name = (string)entry.Key; object value = FastPropertyAccessor.GetProperty(control, name, control.DesignMode); bool saveProperty = true; // Only compare to default value if there is no initial value. if ((initialPropertyState == null || !initialPropertyState.Contains(name)) && defaultPropertyState != null) { object defaultValue = defaultPropertyState[name]; if (Object.Equals(value, defaultValue)) { saveProperty = false; } } if (saveProperty) { if (properties == null) { properties = new HybridDictionary(personalizableProperties.Count, /* caseInsensitive */ false); } properties[name] = value; } } return properties; }
/// <summary> /// Resets personalization state /// </summary> /// <param name="scope">Scope to reset</param> /// <param name="paths">Paths to data</param> /// <param name="usernames">Usernames to reset</param> /// <returns>Count of reset users</returns> public int ResetState(PersonalizationScope scope, string[] paths, string[] usernames) { return Provider.ResetState(scope, paths, usernames); }
//private PersonalizationStateInfoCollection FindSharedState( // string path, // int pageIndex, // int pageSize, // out int totalRecords) //{ // totalRecords = 0; // PersonalizationStateInfoCollection sharedStateInfoCollection // = new PersonalizationStateInfoCollection(); // if (siteSettings != null) // { // IDataReader reader = SitePersonalization.FindState( // siteSettings.SiteID, // path, // true, // Guid.Empty, // DateTime.MaxValue, // pageIndex, // pageSize); // if (reader != null) // { // while (reader.Read()) // { // string returnedPath = reader.GetString(reader.GetOrdinal("Path")); // // Data can be null if there is no data associated with the path // DateTime lastUpdatedDate = (reader.IsDBNull(reader.GetOrdinal("LastActivityDate"))) ? DateTime.MinValue : // DateTime.SpecifyKind(reader.GetDateTime(reader.GetOrdinal("LastActivityDate")), // DateTimeKind.Utc); // int size = (reader.IsDBNull(2)) ? 0 : reader.GetInt32(2); // int userDataSize = (reader.IsDBNull(3)) ? 0 : reader.GetInt32(3); // int userCount = (reader.IsDBNull(4)) ? 0 : reader.GetInt32(4); // sharedStateInfoCollection.Add(new SharedPersonalizationStateInfo( // returnedPath, lastUpdatedDate, size, userDataSize, userCount)); // } // // The reader needs to be closed so return value can be accessed // // See MSDN doc for SqlParameter.Direction for details. // reader.Close(); // reader = null; // } // // Set the total count at the end after all operations pass // //if (returnValue.Value != null && returnValue.Value is int) // //{ // // totalRecords = (int)returnValue.Value; // //} // } // return sharedStateInfoCollection; //} public override PersonalizationStateInfoCollection FindState( PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSize, out int totalRecords) { //mojoPersonalizationProviderHelper.CheckPersonalizationScope(scope); //mojoPersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize); //if (scope == PersonalizationScope.Shared) //{ // string pathToMatch = null; // if (query != null) // { // pathToMatch = CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, maxStringLength); // } // return FindSharedState(pathToMatch, pageIndex, pageSize, out totalRecords); //} //else //{ // string pathToMatch = null; // DateTime inactiveSinceDate = DefaultInactiveSinceDate; // string usernameToMatch = null; // if (query != null) // { // pathToMatch = CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, maxStringLength); // inactiveSinceDate = query.UserInactiveSinceDate; // usernameToMatch = CheckAndTrimString(query.UsernameToMatch, "query.UsernameToMatch", false, maxStringLength); // } // return FindUserState(pathToMatch, inactiveSinceDate, usernameToMatch, // pageIndex, pageSize, out totalRecords); //} throw new Exception("The method or operation is not implemented."); }
public override int ResetState(PersonalizationScope scope, string[] paths, string[] usernames) { throw new NotImplementedException(); }
public override int ResetState( PersonalizationScope scope, string[] paths, string[] usernames) { SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings == null) { return 0; } if (paths.Length != usernames.Length) { return 0; } if (paths.Length == 0) { return 0; } if (usernames.Length == 0) { return 0; } int i = 0; while (i < paths.Length) { PersonalizationHelper.ResetPersonalizationBlob( siteSettings, paths[i], usernames[i]); i += 1; } return (i + 1); }
public override PersonalizationStateInfoCollection FindState(PersonalizationScope scope, PersonalizationStateQuery query, int pageIndex, int pageSize, out int totalRecords) { totalRecords = default(int); return default(PersonalizationStateInfoCollection); }
public PersonalizationEntry(object value, PersonalizationScope scope, bool isSensitive) {}
public override int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query) { return default(int); }
private static void ExportProperty(XmlWriter writer, string name, string value, Type type, PersonalizationScope scope, bool isIPersonalizable) { writer.WriteStartElement("property"); writer.WriteAttributeString("name", name); writer.WriteAttributeString("type", GetExportName(type)); if (isIPersonalizable) { writer.WriteAttributeString("scope", scope.ToString()); } if (value == null) { writer.WriteAttributeString("null", "true"); } else { writer.WriteString(value); } writer.WriteEndElement(); }
public override int ResetState(PersonalizationScope scope, string[] paths, string[] usernames) { return default(int); }