예제 #1
0
 /// <summary>
 /// Gets the TreeNode for the corresponding path, can be either the NodeAliasPath or a URL Alias
 /// </summary>
 /// <param name="Path"></param>
 /// <returns></returns>
 public static TreeNode GetNodeByAliasPath(string Path, string ClassName = null, string CultureCode = null)
 {
     return(CacheHelper.Cache <TreeNode>(cs =>
     {
         List <string> CacheDependencies = new List <string>();
         TreeNode FoundNode = DocumentQueryHelper.RepeaterQuery(Path: Path, ClassNames: ClassName, CultureCode: CultureCode).GetTypedResult().Items.FirstOrDefault();
         if (FoundNode == null)
         {
             // Check Url Aliases
             var FoundNodeByAlias = DocumentAliasInfoProvider.GetDocumentAliasesWithNodesDataQuery().WhereEquals("AliasUrlPath", Path).Or().Where(string.Format("'{0}' like AliasWildCardRule", SqlHelper.EscapeQuotes(Path))).FirstOrDefault();
             if (FoundNodeByAlias != null && FoundNodeByAlias.AliasNodeID > 0)
             {
                 CacheDependencies.Add("cms.documentalias|all");
                 CacheDependencies.Add(string.Format("node|{0}|{1}", SiteContext.CurrentSiteName, Path));
                 FoundNode = DocumentQueryHelper.RepeaterQuery(NodeID: FoundNodeByAlias.AliasNodeID, ClassNames: ClassName, CultureCode: (!string.IsNullOrWhiteSpace(FoundNodeByAlias.AliasCulture) ? FoundNodeByAlias.AliasCulture : CultureCode)).GetTypedResult().Items.FirstOrDefault();
             }
         }
         if (FoundNode != null)
         {
             CacheDependencies.Add("documentid|" + FoundNode.DocumentID);
         }
         if (cs.Cached)
         {
             cs.CacheDependency = CacheHelper.GetCacheDependency(CacheDependencies.ToArray());
         }
         return FoundNode;
     }, new CacheSettings(CacheHelper.CacheMinutes(SiteContext.CurrentSiteName), Path, ClassName, CultureCode)));
 }
 /// <summary>
 /// Gets the TreeNode for the corresponding path, can be either the NodeAliasPath or a URL Alias
 /// </summary>
 /// <param name="Path"></param>
 /// <returns></returns>
 public static TreeNode GetNodeByAliasPath(string Path, string ClassName = null, string CultureCode = null)
 {
     return(CacheHelper.Cache <TreeNode>(cs =>
     {
         List <string> CacheDependencies = new List <string>();
         TreeNode FoundNode = DocumentQueryHelper.RepeaterQuery(Path: Path, ClassNames: ClassName, CultureCode: CultureCode).GetTypedResult().Items.FirstOrDefault();
         if (FoundNode != null)
         {
             CacheDependencies.Add("documentid|" + FoundNode.DocumentID);
         }
         if (cs.Cached)
         {
             cs.CacheDependency = CacheHelper.GetCacheDependency(CacheDependencies.ToArray());
         }
         return FoundNode;
     }, new CacheSettings((EnvironmentHelper.PreviewEnabled ? 0 : CacheHelper.CacheMinutes(SiteContext.CurrentSiteName)), Path, ClassName, CultureCode, SiteContext.CurrentSiteName)));
 }