public static void GetNameValuePairDetails(ref DataTable yourDataTable) { yourDataTable = (DataTable)HttpContext.Current.Cache[CachedNameValuePairDetailsTableName]; if (yourDataTable == null) { MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs myNameValuePairDetails = new BNameValuePairs(mSecurityProfile); yourDataTable = myNameValuePairDetails.GetAllNameValuePairDetail(); CacheController.AddToCacheDependency(CachedNameValuePairDetailsTableName, yourDataTable); } }
/// <summary> /// Retrieves all security entities from the either the database or cache /// </summary> /// <returns>A Collection of MSecurityEntityProfile</returns> public static Collection <MSecurityEntityProfile> Profiles() { Collection <MSecurityEntityProfile> mRetVal = null; mRetVal = (Collection <MSecurityEntityProfile>)(HttpContext.Current.Cache[s_CacheName]); if (mRetVal == null) { BSecurityEntity mBSecurityEntity = new BSecurityEntity(DefaultProfile(), ConfigSettings.CentralManagement); mRetVal = mBSecurityEntity.SecurityEntities(); CacheController.AddToCacheDependency(s_CacheName, mRetVal); } return(mRetVal); }
/// <summary> /// Gets the messages. /// </summary> /// <returns>Collection{MMessageProfile}.</returns> public static Collection <MMessageProfile> Messages() { MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); string mCacheName = MessagesUnitCachedCollectionName(mSecurityEntityProfile.Id); Collection <MMessageProfile> mMessageCollection = null; mMessageCollection = (Collection <MMessageProfile>)HttpContext.Current.Cache[mCacheName]; if (mMessageCollection == null) { BMessages mBMessages = new BMessages(mSecurityEntityProfile, ConfigSettings.CentralManagement); mMessageCollection = mBMessages.GetMessages(mSecurityEntityProfile.Id); CacheController.AddToCacheDependency(mCacheName, mMessageCollection); } return(mMessageCollection); }
/// <summary> /// Retrieves all functions from the either the database or cache /// </summary> /// <returns>A Collection of MFunctinProfiles</returns> public static Collection <MFunctionProfile> Functions() { MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); BFunctions mBFunctions = new BFunctions(mSecurityEntityProfile, ConfigSettings.CentralManagement); String mCacheName = mSecurityEntityProfile.Id.ToString(CultureInfo.InvariantCulture) + "_Functions"; Collection <MFunctionProfile> mRetVal = null; mRetVal = (Collection <MFunctionProfile>)(HttpContext.Current.Cache[mCacheName]); if (mRetVal == null) { mRetVal = mBFunctions.GetFunctions(mSecurityEntityProfile.Id); CacheController.AddToCacheDependency(mCacheName, mRetVal); } return(mRetVal); }
/// <summary> /// Gets the directories. /// </summary> /// <returns>Collection{MDirectoryProfile}.</returns> public static Collection <MDirectoryProfile> Directories() { MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); BDirectories mBDirectories = new BDirectories(mSecurityEntityProfile, ConfigSettings.CentralManagement); String mCacheName = mSecurityEntityProfile.Id.ToString(CultureInfo.InvariantCulture) + "_" + s_DirectoryInfoCachedName; Collection <MDirectoryProfile> mRetVal = null; mRetVal = (Collection <MDirectoryProfile>)(HttpContext.Current.Cache[mCacheName]); if (mRetVal == null) { mRetVal = mBDirectories.Directories(); CacheController.AddToCacheDependency(mCacheName, mRetVal); } return(mRetVal); }
/// <summary> /// Retrieves the current profile. /// </summary> /// <returns>MAccountProfile</returns> /// <remarks>If context does not contain a referance to an account anonymous will be returned</remarks> public static MAccountProfile CurrentProfile() { Logger mLog = Logger.Instance(); mLog.Debug("AccountUtility::GetCurrentProfile() Started"); MAccountProfile mRetProfile = null; String mAccountName = HttpContextUserName(); if (mAccountName.Trim() == s_AnonymousAccount) { if (HttpContext.Current.Cache != null) { mRetProfile = (MAccountProfile)(HttpContext.Current.Cache[s_CachedAnonymousAccount]); if (mRetProfile == null) { mRetProfile = GetProfile(mAccountName); CacheController.AddToCacheDependency(s_CachedAnonymousAccount, mRetProfile); } } else { mLog.Debug("AccountUtility::GetCurrentProfile() No cache available"); } } if (mRetProfile == null) { if (HttpContext.Current.Session != null) { mRetProfile = (MAccountProfile)HttpContext.Current.Session[mAccountName + "_Session"]; if (mRetProfile == null) { mRetProfile = GetProfile(mAccountName); if (mRetProfile != null) { HttpContext.Current.Session[mAccountName + "_Session"] = mRetProfile; } } } else { mLog.Debug("AccountUtility::GetCurrentProfile() No Session available"); mRetProfile = GetProfile(mAccountName); } } mLog.Debug("AccountUtility::GetCurrentProfile() Done"); return(mRetProfile); }
/// <summary> /// Gets the menu. /// </summary> /// <param name="account">The account.</param> /// <param name="menuType">Type of the menu.</param> /// <returns>DataTable.</returns> public static DataTable GetMenu(String account, MenuType menuType) { if (string.IsNullOrEmpty(account)) { throw new ArgumentNullException("account", "account cannot be a null reference (Nothing in VB) or empty!"); } BAccounts mBAccount = new BAccounts(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); DataTable mRetVal = null; if (account.ToUpper(CultureInfo.InvariantCulture) == "ANONYMOUS") { String mAnonMenu = menuType.ToString() + "Anonymous"; mRetVal = (DataTable)HttpContext.Current.Cache[mAnonMenu]; if (mRetVal == null) { mRetVal = mBAccount.GetMenu(account, menuType); CacheController.AddToCacheDependency(mAnonMenu, mRetVal); } } else { String mMenuName = account + "_" + menuType.ToString() + "_MenuData"; if (HttpContext.Current.Session != null) { mRetVal = (DataTable)HttpContext.Current.Session[mMenuName]; if (mRetVal == null) { mRetVal = mBAccount.GetMenu(account, menuType); foreach (DataRow item in mRetVal.Rows) { item["URL"] = "?Action=" + item["URL"].ToString(); } HttpContext.Current.Session[mMenuName] = mRetVal; } } else { mRetVal = mBAccount.GetMenu(account, menuType); foreach (DataRow item in mRetVal.Rows) { item["URL"] = "?Action=" + item["URL"].ToString(); } } } return(mRetVal); }
/// <summary> /// Gets all roles by BU. /// </summary> /// <param name="securityEntitySeqId">The SECURIT y_ ENTIT y_ SE q_ ID.</param> /// <returns>DataTable.</returns> public static DataTable GetAllRolesBySecurityEntity(int securityEntitySeqId) { DataTable mySecurityEntityRoles = null; // attempt to retrieve the information from cache mySecurityEntityRoles = (DataTable)HttpContext.Current.Cache[SecurityEntitiesRolesCacheName(securityEntitySeqId)]; // if the information was not avalible in cache // then retieve the information from the DB and put it into // cache for subsequent use. if (mySecurityEntityRoles == null) { BRoles myBRoles = new BRoles(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); mySecurityEntityRoles = myBRoles.GetRolesBySecurityEntity(securityEntitySeqId); CacheController.AddToCacheDependency(SecurityEntitiesRolesCacheName(securityEntitySeqId), mySecurityEntityRoles); } return(mySecurityEntityRoles); }
/// <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); }
/// <summary> /// Gets the function type collection. /// </summary> /// <returns>Collection{MFunctionTypeProfile}.</returns> public static Collection <MFunctionTypeProfile> FunctionTypeCollection() { Collection <MFunctionTypeProfile> mFunctionTypeCollection = (Collection <MFunctionTypeProfile>)HttpContext.Current.Cache[s_FunctionTypeCachedCollectionName]; if (mFunctionTypeCollection == null) { mFunctionTypeCollection = new Collection <MFunctionTypeProfile>(); foreach (DataRow mDataRow in FunctionTypes().Rows) { if ((mDataRow["Function_Type_Seq_ID"] != null)) { // Add function types to the collection MFunctionTypeProfile mProfile = new MFunctionTypeProfile(mDataRow); mFunctionTypeCollection.Add(mProfile); } } CacheController.AddToCacheDependency(s_FunctionTypeCachedCollectionName, mFunctionTypeCollection); } return(mFunctionTypeCollection); }