/// <summary> /// Save the client choices to the database. /// </summary> /// <param name="clientChoicesState">MClientChoicesState</param> /// <param name="updateContext">bool</param> /// <remarks></remarks> public static void Save(MClientChoicesState clientChoicesState, bool updateContext) { if (clientChoicesState == null) { throw new ArgumentNullException("clientChoicesState", "clientChoicesState cannot be a null reference (Nothing in Visual Basic)! (Nothing in VB)!"); } MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.DefaultProfile(); BClientChoices mBClientChoices = new BClientChoices(mSecurityEntityProfile, ConfigSettings.CentralManagement); mBClientChoices.Save(clientChoicesState); if (updateContext) { if (HttpContext.Current.Cache != null) { HttpContext.Current.Cache[MClientChoices.SessionName] = clientChoicesState; } } }
/// <summary> /// Gets the state of the client choices. /// </summary> /// <param name="account">The account.</param> /// <param name="fromDB">if set to <c>true</c> [from database].</param> /// <returns>MClientChoicesState.</returns> public static MClientChoicesState GetClientChoicesState(String account, bool fromDB) { if (string.IsNullOrEmpty(account)) { throw new ArgumentNullException("account", "account cannot be a null reference (Nothing in VB) or empty!"); } MClientChoicesState mRetVal = null; MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.DefaultProfile(); BClientChoices mBClientChoices = new BClientChoices(mSecurityEntityProfile, ConfigSettings.CentralManagement); if (fromDB) { return(mBClientChoices.GetClientChoicesState(account)); } if (account.Trim().ToLower(CultureInfo.CurrentCulture) != "anonymous") { if (HttpContext.Current.Session != null) { mRetVal = (MClientChoicesState)HttpContext.Current.Session[MClientChoices.SessionName]; if (mRetVal == null) { mRetVal = mBClientChoices.GetClientChoicesState(account); HttpContext.Current.Session[MClientChoices.SessionName] = mRetVal; } else if (mRetVal.AccountName.Trim().ToUpper(CultureInfo.InvariantCulture) != account.Trim().ToUpper(CultureInfo.InvariantCulture)) { mRetVal = mBClientChoices.GetClientChoicesState(account); HttpContext.Current.Session[MClientChoices.SessionName] = mRetVal; } } } else { mRetVal = (MClientChoicesState)HttpContext.Current.Cache[s_CachedAnonymousChoicesState]; if (mRetVal == null) { mRetVal = mBClientChoices.GetClientChoicesState(account); CacheController.AddToCacheDependency(ClientChoicesUtility.s_CachedAnonymousChoicesState, mRetVal); } } return(mRetVal); }