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); }
/// ----------------------------------------------------------------------------- /// <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]; IDataReader dr = dataProvider.GetTabPermissionsByPortal(portalID); var dic = new Dictionary <int, TabPermissionCollection>(); 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 object LoadBannersCallback(CacheItemArgs cacheItemArgs) { var PortalId = (int)cacheItemArgs.ParamList[0]; var BannerTypeId = (int)cacheItemArgs.ParamList[1]; var GroupName = (string)cacheItemArgs.ParamList[2]; //get list of all banners List <BannerInfo> FullBannerList = CBO.FillCollection <BannerInfo>(_dataService.FindBanners(PortalId, BannerTypeId, GroupName)); //create list of active banners var ActiveBannerList = new List <BannerInfo>(); foreach (BannerInfo objBanner in FullBannerList) { if (IsBannerActive(objBanner)) { ActiveBannerList.Add(objBanner); } } return(ActiveBannerList); }
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 object GetFolderPermissionsCallBack(CacheItemArgs cacheItemArgs) { int PortalID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetFolderPermissionsByPortal(PortalID); Dictionary <string, FolderPermissionCollection> dic = new Dictionary <string, FolderPermissionCollection>(); try { FolderPermissionInfo obj; while (dr.Read()) { obj = CBO.FillObject <FolderPermissionInfo>(dr, false); string dictionaryKey = obj.FolderPath; if (string.IsNullOrEmpty(dictionaryKey)) { dictionaryKey = "[PortalRoot]"; } if (dic.ContainsKey(dictionaryKey)) { dic[dictionaryKey].Add(obj); } else { FolderPermissionCollection collection = new FolderPermissionCollection(); collection.Add(obj); dic.Add(dictionaryKey, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { CBO.CloseDataReader(dr, true); } return(dic); }
//Enable the call to ViewEngineCollection FindPartialView method with useCache=false public static ViewEngineResult FindPartialView(this ViewEngineCollection viewEngineCollection, ControllerContext controllerContext, string partialViewName, bool useCache) { try { var cacheKey = CreateCacheKey(controllerContext, "Partial", partialViewName, string.Empty, (controllerContext.Controller as IDnnController)?.ModuleContext.PortalId ?? 0); var cachArg = new CacheItemArgs(cacheKey, 120, CacheItemPriority.Default, "Find", viewEngineCollection, new object[] { new Func <IViewEngine, ViewEngineResult>( e => e.FindPartialView(controllerContext, partialViewName, false)), false }); return(useCache ? CBO.GetCachedObject <ViewEngineResult>(cachArg, CallFind) : CallFind(cachArg)); } catch (Exception) { return(viewEngineCollection.FindPartialView(controllerContext, partialViewName)); } }
private T Load(CacheItemArgs args) { var ctlModule = (ModuleInfo)args.ParamList[0]; var portalId = ctlModule == null ? (int)args.ParamList[1] : ctlModule.PortalID; var settings = new T(); this.Mapping.ForEach(mapping => { string settingValue = null; var attribute = mapping.Attribute; var property = mapping.Property; // TODO: Make more extensible, enable other attributes to be defined if (attribute is HostSettingAttribute && HostController.Instance.GetSettings().ContainsKey(mapping.FullParameterName)) { settingValue = HostController.Instance.GetSettings()[mapping.FullParameterName].Value; } else if (attribute is PortalSettingAttribute && portalId != -1 && PortalController.Instance.GetPortalSettings(portalId).ContainsKey(mapping.FullParameterName)) { settingValue = PortalController.Instance.GetPortalSettings(portalId)[mapping.FullParameterName]; } else if (attribute is TabModuleSettingAttribute && ctlModule != null && ctlModule.TabModuleSettings.ContainsKey(mapping.FullParameterName)) { settingValue = (string)ctlModule.TabModuleSettings[mapping.FullParameterName]; } else if (attribute is ModuleSettingAttribute && ctlModule != null && ctlModule.ModuleSettings.ContainsKey(mapping.FullParameterName)) { settingValue = (string)ctlModule.ModuleSettings[mapping.FullParameterName]; } if (settingValue != null && property.CanWrite) { this.DeserializeProperty(settings, property, attribute, settingValue); } }); return(settings); }
public IList <Relationship> GetRelationshipsByPortalId(int portalId) { var pid = portalId; if (PortalController.IsMemberOfPortalGroup(portalId)) { pid = PortalController.GetEffectivePortalId(portalId); } var cacheArgs = new CacheItemArgs( string.Format(DataCache.RelationshipByPortalIDCacheKey, pid), DataCache.RelationshipByPortalIDCacheTimeOut, DataCache.RelationshipByPortalIDCachePriority, pid); return(CBO.GetCachedObject <IList <Relationship> >( cacheArgs, c => CBO.FillCollection <Relationship>( this._dataService.GetRelationshipsByPortalId( (int)c.ParamList[0])))); }
//Enable the call to ViewEngineCollection FindView method with useCache=false public static ViewEngineResult FindView(this ViewEngineCollection viewEngineCollection, ControllerContext controllerContext, string viewName, string masterName, bool useCache) { try { var cacheKey = CreateCacheKey(controllerContext, "View", viewName, masterName); var cachArg = new CacheItemArgs(cacheKey, 120, CacheItemPriority.Default, "Find", viewEngineCollection, new object[] { new Func <IViewEngine, ViewEngineResult>( e => e.FindView(controllerContext, viewName, masterName, false)), false }); return(useCache ? CBO.GetCachedObject <ViewEngineResult>(cachArg, CallFind) : CallFind(cachArg)); } catch (Exception) { return(viewEngineCollection.FindView(controllerContext, viewName, masterName)); } }
private object GetUrlCacheItemsCallBack(CacheItemArgs cacheItemArgs) { int PortalId = (int)cacheItemArgs.ParamList[0]; //UrlRuleConfiguration config = UrlRuleConfiguration.GenerateConfig(PortalId); List <OpenOutputCacheItem> items = new List <OpenOutputCacheItem>(); var provider = OutputCachingProvider.Instance("FileOutputCachingProvider") as OpenOutputCachingProvider; if (provider != null) { foreach (var item in provider.GetCacheItems()) { items.Add(item); } } int CacheTimeout = 20 * Convert.ToInt32(DotNetNuke.Entities.Host.Host.PerformanceSetting); cacheItemArgs.CacheTimeOut = CacheTimeout; cacheItemArgs.CacheDependency = new DNNCacheDependency(null, null); #if DEBUG cacheItemArgs.CacheCallback = new CacheItemRemovedCallback(this.RemovedCallBack); #endif return(items); }
private void InitializeInternal() { var type = typeof(T); Scope = String.Empty; IsCacheable = false; IsScoped = false; CacheArgs = null; var scopeAttribute = DataUtil.GetAttribute <ScopeAttribute>(type); if (scopeAttribute != null) { Scope = scopeAttribute.Scope; } IsScoped = (!String.IsNullOrEmpty(Scope)); var cacheableAttribute = DataUtil.GetAttribute <CacheableAttribute>(type); if (cacheableAttribute != null) { IsCacheable = true; var cacheKey = !String.IsNullOrEmpty(cacheableAttribute.CacheKey) ? cacheableAttribute.CacheKey : String.Format("OR_{0}", type.Name); var cachePriority = cacheableAttribute.CachePriority; var cacheTimeOut = cacheableAttribute.CacheTimeOut; if (IsScoped) { cacheKey += "_" + Scope + "_{0}"; } CacheArgs = new CacheItemArgs(cacheKey, cacheTimeOut, cachePriority); } }
internal virtual object SearchContentSourceCallback(CacheItemArgs cacheItem) { var searchTypes = CBO.FillCollection <SearchType>(DataProvider.GetAllSearchTypes()); var results = new List <SearchContentSource>(); foreach (var crawler in searchTypes) { switch (crawler.SearchTypeName) { case "module": // module crawler // get searchable module definition list var portalId = int.Parse(cacheItem.CacheKey.Split('-')[1]); var moduleController = new ModuleController(); var modules = moduleController.GetSearchModules(portalId); var modDefIds = new HashSet <int>(); foreach (ModuleInfo module in modules) { if (!modDefIds.Contains(module.ModuleDefID)) { modDefIds.Add(module.ModuleDefID); } } var list = modDefIds.Select(ModuleDefinitionController.GetModuleDefinitionByID).ToList(); foreach (var def in list) { var text = Localization.Localization.GetSafeJSString("Module_" + def.DefinitionName, LocalizedResxFile); if (string.IsNullOrEmpty(text)) { text = def.FriendlyName; } var result = new SearchContentSource { SearchTypeId = crawler.SearchTypeId, SearchTypeName = crawler.SearchTypeName, IsPrivate = crawler.IsPrivate, ModuleDefinitionId = def.ModuleDefID, LocalizedName = text }; results.Add(result); } break; default: var localizedName = Localization.Localization.GetSafeJSString("Crawler_" + crawler.SearchTypeName, LocalizedResxFile); if (string.IsNullOrEmpty(localizedName)) { localizedName = crawler.SearchTypeName; } results.Add(new SearchContentSource { SearchTypeId = crawler.SearchTypeId, SearchTypeName = crawler.SearchTypeName, IsPrivate = crawler.IsPrivate, ModuleDefinitionId = 0, LocalizedName = localizedName }); break; } } return(results); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetWorkflowStatePermissionsCallBack gets a Dictionary of WorkflowStatePermissionCollections by /// WorkflowState from the the Database. /// </summary> /// <param name = "cacheItemArgs">The CacheItemArgs object that contains the parameters needed for the database call</param> /// ----------------------------------------------------------------------------- private static object GetWorkflowStatePermissionsCallBack(CacheItemArgs cacheItemArgs) { return(FillWorkflowStatePermissionDictionary(provider.GetWorkflowStatePermissions())); }
private static object GetAuthenticationServicesCallBack(CacheItemArgs cacheItemArgs) { return(CBO.FillCollection <AuthenticationInfo>(provider.GetAuthenticationServices())); }
private object GetListInfoDictionaryCallBack(CacheItemArgs cacheItemArgs) { var portalId = (int)cacheItemArgs.ParamList[0]; return(FillListInfoDictionary(DataProvider.Instance().GetLists(portalId))); }
/// ----------------------------------------------------------------------------- /// <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> /// ----------------------------------------------------------------------------- private static object GetModuleControlsCallBack(CacheItemArgs cacheItemArgs) { return(CBO.FillDictionary(key, dataProvider.GetModuleControls(), new Dictionary <int, ModuleControlInfo>())); }
private IFileInfo GetLogoFileInfoCallBack(CacheItemArgs itemArgs) { return(FileManager.Instance.GetFile(PortalSettings.PortalId, PortalSettings.LogoFile)); }
private IList <IRedirection> GetAllRedirectionsCallBack(CacheItemArgs cacheItemArgs) { return(CBO.FillCollection <Redirection>(DataProvider.Instance().GetAllRedirections()).Cast <IRedirection>().ToList()); }
private object GetVocabulariesCallBack(CacheItemArgs cacheItemArgs) { return(CBO.FillQueryable <Vocabulary>(this._DataService.GetVocabularies()).ToList()); }
private object GetPortalGroupsCallback(CacheItemArgs cacheItemArgs) { return(CBO.FillCollection <PortalGroupInfo>(_dataService.GetPortalGroups())); }
private static object GetSkinDefaultsCallback(CacheItemArgs cacheItemArgs) { var defaultType = (SkinDefaultType)cacheItemArgs.ParamList[0]; return(new SkinDefaults(defaultType)); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetDesktopModulesByPortalCallBack gets a Dictionary of Desktop Modules by /// Portal from the the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// ----------------------------------------------------------------------------- private static object GetDesktopModulesByPortalCallBack(CacheItemArgs cacheItemArgs) { var portalId = (int)cacheItemArgs.ParamList[0]; return(CBO.FillDictionary("DesktopModuleID", DataProvider.GetDesktopModulesByPortal(portalId), new Dictionary <int, DesktopModuleInfo>())); }
private object GetScopeTypesCallBack(CacheItemArgs cacheItemArgs) { return(CBO.FillQueryable <ScopeType>(_DataService.GetScopeTypes()).ToList()); }
private Dictionary <int, BaseResultController> GetSearchResultControllers() { var cachArg = new CacheItemArgs(SeacrchContollersCacheKey, 120, CacheItemPriority.Default); return(CBO.GetCachedObject <Dictionary <int, BaseResultController> >(cachArg, GetSearchResultsControllersCallBack)); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetWorkFlowStatesCallback retrieves a collection of WorkflowStateInfo objects for the Workflow from the database /// </summary> /// <remarks> /// </remarks> /// <param name = "cacheItemArgs">Arguments passed by the GetWorkflowStates method</param> /// ----------------------------------------------------------------------------- public object GetWorkflowStatesCallBack(CacheItemArgs cacheItemArgs) { var WorkflowID = (int)(cacheItemArgs.ParamList[0]); return(CBO.FillCollection(DataProvider.Instance().GetWorkflowStates(WorkflowID), typeof(WorkflowStateInfo))); }
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> /// 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)); }
private static object GetPortalDesktopModulesByPortalIDCallBack(CacheItemArgs cacheItemArgs) { var portalId = (int)cacheItemArgs.ParamList[0]; return(CBO.FillDictionary("PortalDesktopModuleID", DataProvider.Instance().GetPortalDesktopModules(portalId, Null.NullInteger), new Dictionary <int, PortalDesktopModuleInfo>())); }
private IList <IRedirection> GetRedirectionsByPortalCallBack(CacheItemArgs cacheItemArgs) { int portalId = (int)cacheItemArgs.ParamList[0]; return(CBO.FillCollection <Redirection>(DataProvider.Instance().GetRedirections(portalId)).Cast <IRedirection>().ToList()); }
private object GetTermsCallBack(CacheItemArgs cacheItemArgs) { var vocabularyId = (int)cacheItemArgs.ParamList[0]; return(CBO.FillQueryable <Term>(_DataService.GetTermsByVocabulary(vocabularyId)).ToList()); }