private object GetSettingsCallback(CacheItemArgs cacheItemArgs) { var moduleId = (int)cacheItemArgs.ParamList[0]; var tabModuleId = (int)cacheItemArgs.ParamList[1]; return new Settings(moduleId, tabModuleId); }
private static Dictionary<int, DesktopModuleInfo> GetDesktopModulesInternal(int portalID) { string cacheKey = string.Format(DataCache.DesktopModuleCacheKey, portalID); var args = new CacheItemArgs(cacheKey, DataCache.DesktopModuleCacheTimeOut, DataCache.DesktopModuleCachePriority, portalID); Dictionary<int, DesktopModuleInfo> desktopModules = (portalID == Null.NullInteger) ? CBO.GetCachedObject<Dictionary<int, DesktopModuleInfo>>(args, GetDesktopModulesCallBack) : CBO.GetCachedObject<Dictionary<int, DesktopModuleInfo>>(args, GetDesktopModulesByPortalCallBack); return desktopModules; }
public IEnumerable<SearchType> GetSearchTypes() { var cachArg = new CacheItemArgs(SearchTypesCacheKey, 120, CacheItemPriority.Default); return CBO.GetCachedObject<IList<SearchType>>(cachArg, delegate { return CBO.FillCollection<SearchType>(DataProvider.Instance().GetAllSearchTypes()); }); }
private static List<SelectListItem> GetStatusDropdownList(CacheItemArgs args) { var locale = (string)args.ParamList[0]; var res = new List<SelectListItem>(); foreach (var v in System.Enum.GetValues(typeof(Connect.Conference.Core.Common.SessionStatus))) { res.Add(new SelectListItem { Text = Localization.GetString(v.ToString(), SharedResourceFileName), Value = ((int)v).ToString() }); } return res.OrderBy(i => i.Value).ToList(); }
/// <summary> /// Callback method that dynamically loads a type of template, using reflection /// </summary> /// <param name="cacheItemArgs">Arguments, containing moduleid and tabModuleId </param> /// <returns>ITemplate</returns> private object GetTemplateCallback(CacheItemArgs cacheItemArgs) { var moduleId = (int)cacheItemArgs.ParamList[0]; var tabModuleId = (int)cacheItemArgs.ParamList[1]; var moduleSettings = new SettingsController().GetModuleSettings(moduleId, tabModuleId); Type type = Type.GetType("DotNetNuke.Modules.Announcements.Components.Template." + moduleSettings.TemplateType); if (type != null && type.IsClass) { var template = Activator.CreateInstance(type, new object[] { moduleId, tabModuleId, moduleSettings.TemplateName }); return template; } return null; }
private object GetCustomAliasesCallback(CacheItemArgs cacheItemArgs) { var portalID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = DataProvider.Instance().GetTabCustomAliases(portalID); var dic = new Dictionary<int, Dictionary<string, string>>(); try { while (dr.Read()) { //fill business object var tabId = (int)dr["TabId"]; var customAlias = (string)dr["httpAlias"]; var cultureCode = (string)dr["cultureCode"]; //add Custom Alias to dictionary if (dic.ContainsKey(tabId)) { //Add Custom Alias to Custom Alias Collection already in dictionary for TabId dic[tabId][cultureCode] = customAlias; } else { //Create new Custom Alias Collection for TabId var collection = new Dictionary<string, string> {{cultureCode, customAlias}}; //Add Collection to Dictionary dic.Add(tabId, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return dic; }
private object GetAliasSkinsCallback(CacheItemArgs cacheItemArgs) { var portalID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = DataProvider.Instance().GetTabAliasSkins(portalID); var dic = new Dictionary<int, List<TabAliasSkinInfo>>(); try { while (dr.Read()) { //fill business object var tabAliasSkin = CBO.FillObject<TabAliasSkinInfo>(dr, false); //add Tab Alias Skin to dictionary if (dic.ContainsKey(tabAliasSkin.TabId)) { //Add Tab Alias Skin to Tab Alias Skin Collection already in dictionary for TabId dic[tabAliasSkin.TabId].Add(tabAliasSkin); } else { //Create new Tab Alias Skin Collection for TabId var collection = new List<TabAliasSkinInfo> { tabAliasSkin }; //Add Collection to Dictionary dic.Add(tabAliasSkin.TabId, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return dic; }
private static object GetCachedDataFromDictionary(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired) { object cachedObject; bool isFound; using (dictionaryCache.GetReadLock()) { isFound = dictionaryCache.TryGetValue(cacheItemArgs.CacheKey, out cachedObject); } if (!isFound) { // get object from data source using delegate try { cachedObject = cacheItemExpired != null?cacheItemExpired(cacheItemArgs) : null; } catch (Exception ex) { cachedObject = null; Exceptions.LogException(ex); } using (dictionaryCache.GetWriteLock()) { if (!dictionaryCache.ContainsKey(cacheItemArgs.CacheKey)) { if (cachedObject != null) { dictionaryCache[cacheItemArgs.CacheKey] = cachedObject; } } } } return(cachedObject); }
private static object GetCompiledResourceFileCallBack(CacheItemArgs cacheItemArgs) { string resourceFile = (string)cacheItemArgs.Params[0]; string locale = (string)cacheItemArgs.Params[1]; PortalSettings portalSettings = (PortalSettings)cacheItemArgs.Params[2]; string systemLanguage = DotNetNuke.Services.Localization.Localization.SystemLocale; string defaultLanguage = portalSettings.DefaultLanguage; string fallbackLanguage = DotNetNuke.Services.Localization.Localization.SystemLocale; Locale targetLocale = LocaleController.Instance.GetLocale(locale); if (!String.IsNullOrEmpty(targetLocale.Fallback)) { fallbackLanguage = targetLocale.Fallback; } // get system default and merge the specific ones one by one var res = GetResourceFile(resourceFile); if (res == null) { return new Dictionary<string, string>(); } res = MergeResourceFile(res, GetResourceFileName(resourceFile, systemLanguage, portalSettings.PortalId)); if (defaultLanguage != systemLanguage) { res = MergeResourceFile(res, GetResourceFileName(resourceFile, defaultLanguage, -1)); res = MergeResourceFile(res, GetResourceFileName(resourceFile, defaultLanguage, portalSettings.PortalId)); } if (fallbackLanguage != defaultLanguage) { res = MergeResourceFile(res, GetResourceFileName(resourceFile, fallbackLanguage, -1)); res = MergeResourceFile(res, GetResourceFileName(resourceFile, fallbackLanguage, portalSettings.PortalId)); } if (locale != fallbackLanguage) { res = MergeResourceFile(res, GetResourceFileName(resourceFile, locale, -1)); res = MergeResourceFile(res, GetResourceFileName(resourceFile, locale, portalSettings.PortalId)); } return res; }
private static object GetPortalAliasLookupCallBack(CacheItemArgs cacheItemArgs) { #pragma warning disable 612,618 return new PortalAliasController().GetPortalAliases(); #pragma warning restore 612,618 }
private static object GetMessageTabCallback(CacheItemArgs cacheItemArgs) { var portalSettings = cacheItemArgs.Params[0] as PortalSettings; var profileTab = TabController.Instance.GetTab(portalSettings.UserTabId, portalSettings.PortalId, false); if (profileTab != null) { var childTabs = TabController.Instance.GetTabsByPortal(profileTab.PortalID).DescendentsOf(profileTab.TabID); foreach (var tab in childTabs) { foreach (var kvp in ModuleController.Instance.GetTabModules(tab.TabID)) { var module = kvp.Value; if (module.DesktopModule.FriendlyName == "Message Center") { return tab.TabID; } } } } //default to User Profile Page return portalSettings.UserTabId; }
/// ----------------------------------------------------------------------------- /// <summary> /// GetCachedObject gets an object from the Cache /// </summary> /// <typeparam name="TObject">The type of th object to fetch</typeparam> /// <param name="cacheItemArgs">A CacheItemArgs object that provides parameters to manage the /// cache AND to fetch the item if the cache has expired</param> /// <param name="cacheItemExpired">A CacheItemExpiredCallback delegate that is used to repopulate /// the cache if the item has expired</param> /// ----------------------------------------------------------------------------- public static TObject GetCachedObject <TObject>(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired) { return(DataCache.GetCachedData <TObject>(cacheItemArgs, cacheItemExpired)); }
private IFileInfo GetBackgroundFileInfoCallBack(CacheItemArgs itemArgs) { return FileManager.Instance.GetFile(PortalSettings.PortalId, PortalSettings.BackgroundFile); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetModuleControlsCallBack gets a Dictionary of Module Controls from /// the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// <history> /// [cnurse] 01/14/2008 Created /// </history> /// ----------------------------------------------------------------------------- private static object GetModuleControlsCallBack(CacheItemArgs cacheItemArgs) { return CBO.FillDictionary(key, dataProvider.GetModuleControls(), new Dictionary<int, ModuleControlInfo>()); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetModulePermissionsCallBack gets a Dictionary of ModulePermissionCollections by /// Module from the the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- private object GetModulePermissionsCallBack(CacheItemArgs cacheItemArgs) { var tabID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetModulePermissionsByTabID(tabID); var dic = new Dictionary<int, ModulePermissionCollection>(); try { while (dr.Read()) { //fill business object var modulePermissionInfo = CBO.FillObject<ModulePermissionInfo>(dr, false); //add Module Permission to dictionary if (dic.ContainsKey(modulePermissionInfo.ModuleID)) { dic[modulePermissionInfo.ModuleID].Add(modulePermissionInfo); } else { //Create new ModulePermission Collection for ModuleId var collection = new ModulePermissionCollection {modulePermissionInfo}; //Add Permission to Collection //Add Collection to Dictionary dic.Add(modulePermissionInfo.ModuleID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return dic; }
private IList<IRedirection> GetRedirectionsByPortalCallBack(CacheItemArgs cacheItemArgs) { int portalId = (int)cacheItemArgs.ParamList[0]; return CBO.FillCollection<Redirection>(DataProvider.Instance().GetRedirections(portalId)).Cast<IRedirection>().ToList(); }
/// <summary> /// get a redirection list for portal. /// </summary> /// <param name="portalId">redirection id.</param> /// <returns>List of redirection.</returns> public IList<IRedirection> GetRedirectionsByPortal(int portalId) { string cacheKey = string.Format(DataCache.RedirectionsCacheKey, portalId); var cacheArg = new CacheItemArgs(cacheKey, DataCache.RedirectionsCacheTimeOut, DataCache.RedirectionsCachePriority, portalId); return CBO.GetCachedObject<IList<IRedirection>>(cacheArg, GetRedirectionsByPortalCallBack); }
private object GetVocabulariesCallBack(CacheItemArgs cacheItemArgs) { return CBO.FillQueryable<Vocabulary>(_DataService.GetVocabularies()).ToList(); }
private static object GetCachedDataFromRuntimeCache(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired) { object objObject = GetCache(cacheItemArgs.CacheKey); // if item is not cached if (objObject == null) { //Get Unique Lock for cacheKey object @lock = GetUniqueLockObject(cacheItemArgs.CacheKey); // prevent other threads from entering this block while we regenerate the cache lock (@lock) { // try to retrieve object from the cache again (in case another thread loaded the object since we first checked) objObject = GetCache(cacheItemArgs.CacheKey); // if object was still not retrieved if (objObject == null) { // get object from data source using delegate try { objObject = cacheItemExpired(cacheItemArgs); } catch (Exception ex) { objObject = null; Exceptions.LogException(ex); } // set cache timeout int timeOut = cacheItemArgs.CacheTimeOut * Convert.ToInt32(Host.PerformanceSetting); // if we retrieved a valid object and we are using caching if (objObject != null && timeOut > 0) { // save the object in the cache SetCache(cacheItemArgs.CacheKey, objObject, cacheItemArgs.CacheDependency, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(timeOut), cacheItemArgs.CachePriority, cacheItemArgs.CacheCallback); // check if the item was actually saved in the cache if (GetCache(cacheItemArgs.CacheKey) == null) { // log the event if the item was not saved in the cache ( likely because we are out of memory ) var log = new LogInfo { LogTypeKey = EventLogController.EventLogType.CACHE_OVERFLOW.ToString() }; log.LogProperties.Add(new LogDetailInfo(cacheItemArgs.CacheKey, "Overflow - Item Not Cached")); LogController.Instance.AddLog(log); } } //This thread won so remove unique Lock from collection RemoveUniqueLockObject(cacheItemArgs.CacheKey); } } } return(objObject); }
/// <summary> /// get all redirections defined in system. /// </summary> /// <returns>List of redirection.</returns> public IList<IRedirection> GetAllRedirections() { var cacheArg = new CacheItemArgs(AllRedirectionsCacheKey, DataCache.RedirectionsCacheTimeOut, DataCache.RedirectionsCachePriority, ""); return CBO.GetCachedObject<IList<IRedirection>>(cacheArg, GetAllRedirectionsCallBack); }
public static TObject GetCachedData <TObject>(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired) { // declare local object and try and retrieve item from the cache return(GetCachedData <TObject>(cacheItemArgs, cacheItemExpired, false)); }
private IList<IRedirection> GetAllRedirectionsCallBack(CacheItemArgs cacheItemArgs) { return CBO.FillCollection<Redirection>(DataProvider.Instance().GetAllRedirections()).Cast<IRedirection>().ToList(); }
private Dictionary<int, BaseResultController> GetSearchResultControllers() { var cachArg = new CacheItemArgs(SeacrchContollersCacheKey, 120, CacheItemPriority.Default); return CBO.GetCachedObject<Dictionary<int, BaseResultController>>(cachArg, GetSearchResultsControllersCallBack); }
private object GetFolderPermissionsCallBack(CacheItemArgs cacheItemArgs) { var PortalID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetFolderPermissionsByPortal(PortalID); var dic = new Dictionary<string, FolderPermissionCollection>(); try { while (dr.Read()) { //fill business object var folderPermissionInfo = CBO.FillObject<FolderPermissionInfo>(dr, false); string dictionaryKey = folderPermissionInfo.FolderPath; if (string.IsNullOrEmpty(dictionaryKey)) { dictionaryKey = "[PortalRoot]"; } //add Folder Permission to dictionary if (dic.ContainsKey(dictionaryKey)) { //Add FolderPermission to FolderPermission Collection already in dictionary for FolderPath dic[dictionaryKey].Add(folderPermissionInfo); } else { //Create new FolderPermission Collection for TabId var collection = new FolderPermissionCollection {folderPermissionInfo}; //Add Permission to Collection //Add Collection to Dictionary dic.Add(dictionaryKey, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { CBO.CloseDataReader(dr, true); } return dic; }
private Dictionary<int, BaseResultController> GetSearchResultsControllersCallBack(CacheItemArgs cacheItem) { var searchTypes = SearchHelper.Instance.GetSearchTypes(); var resultControllers = new Dictionary<int, BaseResultController>(); foreach (var searchType in searchTypes) { try { var searchControllerType = Reflection.CreateType(searchType.SearchResultClass); var searchController = Reflection.CreateObject(searchControllerType); resultControllers.Add(searchType.SearchTypeId, (BaseResultController)searchController); } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } } return resultControllers; }
/// ----------------------------------------------------------------------------- /// <summary> /// GetTabPermissionsCallBack gets a Dictionary of TabPermissionCollections by /// Tab from the the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- private object GetTabPermissionsCallBack(CacheItemArgs cacheItemArgs) { var portalID = (int)cacheItemArgs.ParamList[0]; var dic = new Dictionary<int, TabPermissionCollection>(); if (portalID > -1) { IDataReader dr = dataProvider.GetTabPermissionsByPortal(portalID); try { while (dr.Read()) { //fill business object var tabPermissionInfo = CBO.FillObject<TabPermissionInfo>(dr, false); //add Tab Permission to dictionary if (dic.ContainsKey(tabPermissionInfo.TabID)) { //Add TabPermission to TabPermission Collection already in dictionary for TabId dic[tabPermissionInfo.TabID].Add(tabPermissionInfo); } else { //Create new TabPermission Collection for TabId var collection = new TabPermissionCollection { tabPermissionInfo }; //Add Collection to Dictionary dic.Add(tabPermissionInfo.TabID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } } return dic; }
private static object GetMembershipUserCallBack(CacheItemArgs cacheItemArgs) { string userName = cacheItemArgs.ParamList[0].ToString(); return System.Web.Security.Membership.GetUser(userName); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetDesktopModulePermissionsCallBack gets a Dictionary of DesktopModulePermissionCollections by /// DesktopModule from the the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// <history> /// [cnurse] 01/15/2008 Created /// </history> /// ----------------------------------------------------------------------------- private static object GetDesktopModulePermissionsCallBack(CacheItemArgs cacheItemArgs) { return FillDesktopModulePermissionDictionary(provider.GetDesktopModulePermissions()); }
/// <summary> /// GetXMLContent loads the xml content from a web resource into an XmlReader. /// </summary> /// <param name = "contentUrl"></param> /// <param name = "credential"></param> /// <param name="useCache"></param> /// <returns>A Xml Reader</returns> private static XmlReader GetXmlContent(string contentUrl, Credential credential , bool useCache) { var cacheKey = GetCacheKey(contentUrl, credential); var args = new CacheItemArgs(cacheKey, 0,CacheItemPriority.Normal, contentUrl, credential ); var doc = useCache ? CBO.GetCachedObject<XmlDocument>(args, GetDocument) : GetDocument(args); return new XmlNodeReader(doc); }
private static int GetMessageTab(PortalSettings sendingPortal) { var cacheKey = string.Format("MessageTab:{0}", sendingPortal.PortalId); //TODO Create Dedault Const cache timeout var cacheItemArgs = new CacheItemArgs(cacheKey, 30, CacheItemPriority.Default, sendingPortal); return CBO.GetCachedObject<int>(cacheItemArgs, GetMessageTabCallback); }
private static XmlDocument GetDocument(CacheItemArgs args) { var url = args.ParamList[0].ToString(); var credential = (Credential) args.ParamList[1]; var doc = new XmlDocument(); try { using (var rep = GetDocumentResponse(url,credential )) { using (var receiveStream = rep.GetResponseStream()) { if (receiveStream != null) doc.Load(receiveStream); } } } catch (Exception ex) { //prevents caching of empty XmlDocuments doc = null; Exceptions.LogException(ex); } return doc; }
private static object GetAuthenticationServicesCallBack(CacheItemArgs cacheItemArgs) { return CBO.FillCollection<AuthenticationInfo>(provider.GetAuthenticationServices()); }
private IEnumerable<RoleGroupInfo> GetRoleGroupsInternal(int portalId) { var cacheArgs = new CacheItemArgs(GetRoleGroupsCacheKey(portalId), DataCache.RoleGroupsCacheTimeOut, DataCache.RoleGroupsCachePriority); return CBO.GetCachedObject<IEnumerable<RoleGroupInfo>>(cacheArgs, c => CBO.FillCollection<RoleGroupInfo>(dataProvider.GetRoleGroups(portalId))); }
public static TObject GetCachedObject <TObject>(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired, bool saveInDictionary) { return(DataCache.GetCachedData <TObject>(cacheItemArgs, cacheItemExpired, saveInDictionary)); }
private object GetTabTitleCallBack(CacheItemArgs cacheItemArgs) { var moduleId = (int)cacheItemArgs.ParamList[0]; var moduleInfo = _moduleController.GetModule(moduleId); if (moduleInfo != null) { return moduleInfo.ParentTab.TabName; } return string.Empty; }