internal static Dictionary<int, List<ParameterReplaceAction>> GetParameterReplacements(FriendlyUrlSettings settings, int portalId, ref List<string> messages) { string replaceActionKey = "replaceActions:" + portalId.ToString(); var replaceActions = (Dictionary<int, List<ParameterReplaceAction>>)DataCache.GetCache(replaceActionKey); if (messages == null) { messages = new List<string>(); } if (replaceActions == null) { replaceActions = new Dictionary<int, List<ParameterReplaceAction>>(); try { bool portalSpecific; string fileName = FindFriendlyUrlParmsConfigFilePath(portalId, out portalSpecific); if (!string.IsNullOrEmpty(fileName)) { replaceActions.LoadFromXmlFile(fileName, portalId, portalSpecific, ref messages); } CacheDependency cacheDependency = null; if (replaceActions.Count > 0) { //only set filename dependency if file exists cacheDependency = new CacheDependency(fileName); } DateTime expiration = DateTime.MaxValue; DataCache.SetCache(replaceActionKey, replaceActions, new DNNCacheDependency(cacheDependency), expiration, settings.CacheTime); } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); messages.Add("Exception: " + ex.Message + "\n" + ex.StackTrace); } } return replaceActions; }
internal static Dictionary<int, SharedList<ParameterRewriteAction>> GetParameterRewrites(int portalId, ref List<string> messages, Guid parentTraceId) { string rewriteActionKey = string.Format(RewriteActionsKey, portalId.ToString()); if (messages == null) { messages = new List<string>(); } var rewriteActions = (Dictionary<int, SharedList<ParameterRewriteAction>>)DataCache.GetCache(rewriteActionKey); if (rewriteActions == null) { try { rewriteActions = new Dictionary<int, SharedList<ParameterRewriteAction>>(); bool portalSpecific; //807 : new change to look for portal rule files in portal specific locations string filename = FindFriendlyUrlParmsConfigFilePath(portalId, out portalSpecific); if (!string.IsNullOrEmpty(filename)) { rewriteActions.LoadFromXmlFile(filename, portalId, portalSpecific, ref messages); } CacheDependency fileDependency = null; if (File.Exists(filename)) { fileDependency = new CacheDependency(filename); } DataCache.SetCache(rewriteActionKey, rewriteActions, new DNNCacheDependency(fileDependency)); } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); messages.Add("Exception: " + ex.Message + "\n" + ex.StackTrace); } } return rewriteActions; }
internal static Dictionary<int, List<ParameterRedirectAction>> GetParameterRedirects(FriendlyUrlSettings settings, int portalId, ref List<string> messages) { string redirectActionKey = string.Format(RedirectActionsKey, portalId); //cached one portal at a time if (messages == null) { messages = new List<string>(); } var redirectActions = (Dictionary<int, List<ParameterRedirectAction>>)DataCache.GetCache(redirectActionKey); if (redirectActions == null) { try { redirectActions = new Dictionary<int, List<ParameterRedirectAction>>(); //807 : look for portal specific files bool portalSpecific; string fileName = FindFriendlyUrlParmsConfigFilePath(portalId, out portalSpecific); if (fileName != "") { redirectActions.LoadFromXmlFile(fileName, portalId, portalSpecific, ref messages); } CacheDependency fileDependency = null; if (File.Exists(fileName)) { fileDependency = new CacheDependency(fileName); } if (settings != null) { DateTime absoluteExpiration = DateTime.Now.Add(settings.CacheTime); DataCache.SetCache(redirectActionKey, redirectActions, new DNNCacheDependency(fileDependency), absoluteExpiration, Cache.NoSlidingExpiration); } else { DataCache.SetCache(redirectActionKey, redirectActions, new DNNCacheDependency(fileDependency)); } } catch (Exception ex) { //log the exception Services.Exceptions.Exceptions.LogException(ex); messages.Add("Exception: " + ex.Message + "\n" + ex.StackTrace); } } return redirectActions; }