예제 #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)));
 }
예제 #2
0
    private static ObjectQuery <DocumentAliasInfo> GetAliasesQuery(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize)
    {
        var columnList = GetColumns(columns);

        var where = SqlHelper.AddWhereCondition(completeWhere, "AliasSiteID = " + SiteContext.CurrentSiteID);
        return(DocumentAliasInfoProvider.GetDocumentAliasesWithNodesDataQuery()
               .Where(where)
               .OrderBy(currentOrder)
               .TopN(currentTopN)
               .Page(currentOffset / currentPageSize, currentPageSize)
               .Columns(columnList));
    }
    private static ObjectQuery <DocumentAliasInfo> GetAliasesQuery(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize)
    {
        var columnList = GetColumns(columns);

        var where = SqlHelper.AddWhereCondition(completeWhere, "AliasSiteID = " + SiteContext.CurrentSiteID);
        var query = DocumentAliasInfoProvider.GetDocumentAliasesWithNodesDataQuery()
                    .Source(s => s.InnerJoin <DataClassInfo>("NodeClassID", "ClassID"))
                    .Where(where)
                    .OrderBy(currentOrder)
                    .TopN(currentTopN)
                    .Columns(columnList);

        query.Offset     = currentOffset;
        query.MaxRecords = currentPageSize;

        return(query);
    }