Umbraco uBlogsy(webforms)PostService在登录页上未显示帖子

Umbraco uBlogsy(webforms)PostService在登录页上未显示帖子,umbraco,umbraco6,Umbraco,Umbraco6,我正在使用uBlogsy WebForms 3.0.2在Umbraco 6.1.5上 登录页上的帖子也没有显示出来 函数PostService.Instance.GetPosts返回0篇文章,即使在正确的位置有文章 当我尝试替换此内容时,仍收到0篇帖子: var posts = PostService.Instance .GetPosts( IPublishedContentHelper.GetN

我正在使用uBlogsy WebForms 3.0.2在Umbraco 6.1.5上

登录页上的帖子也没有显示出来

函数
PostService.Instance.GetPosts
返回0篇文章,即使在正确的位置有文章

当我尝试替换此内容时,仍收到0篇帖子:

var posts = PostService.Instance
                       .GetPosts(
                           IPublishedContentHelper.GetNode((int)Model.Id)
                       ).ToIPublishedContent(true);
int postCount = posts.Count();

有人知道为什么邮政服务不起作用吗?或者,发生了什么事?

我在Ublogsy上也遇到过几次同样的问题。因此,我决定编写自己的代码,如下所示:

(有点长)

//从查询字符串中获取标记、标签或作者
var tag=Request.QueryString[“tag”]??"";
var label=Request.QueryString[“label”]??"";
var author=Request.QueryString[“author”]??"";
var searchTerm=Request.QueryString[“search”]??"";
var commenter=Request.QueryString[“commenter”]??"";
int page=int.TryParse(Request.QueryString[“page”]、out page)?页码:1;
变量年份=请求。查询字符串[“年份”]??"";
var month=Request.QueryString[“month”]??"";
var day=Request.QueryString[“day”]??"";
国际邮政计数;
IEnumerable posts=new BlockingCollection();
var filterResults=this.FilterAgainstPosts(this.Model.Content、标记、标签、作者、搜索词、评论员、年份、月份);
如果(filterResults!=null)
{
posts=可枚举的.Take(filterResults.Skip((第1页)*itemsPerPage),itemsPerPage);
}
@渲染预览(立柱)
我的FilterAgainstPosts方法如下:

@functions
{
private IEnumerable<IPublishedContent> FilterAgainstPosts(IPublishedContent landing, string tag, string label, string author, string searchTerm, string commenter, string year, string month)
    {
        IEnumerable<IPublishedContent> filteredPosts = landing.DescendantsOrSelf("uBlogsyPost").Where(x => x.GetProperty("umbracoNaviHide").Value.ToString() != "1");

        if (!String.IsNullOrEmpty(searchTerm))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterAgainstTerm(i, searchTerm));
        }

        if (!String.IsNullOrEmpty(tag))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponTag(i, i.GetProperty("uBlogsyPostTags").Value.ToString(), tag));
        }

        if (!String.IsNullOrEmpty(label))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponLabel(i, i.GetProperty("uBlogsyPostLabels").Value.ToString(), label));
        }

        if (!String.IsNullOrEmpty(author))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponAuthor(i, i.GetProperty("uBlogsyPostAuthor").Value.ToString(), author));
        }

        //
        //TODO: Coomenter search needs to added
        //

        if (!string.IsNullOrEmpty(year))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponYear(i, i.GetProperty("uBlogsyPostDate").Value.ToString(), year));
        }

        if (!string.IsNullOrEmpty(month))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponMonth(i, i.GetProperty("uBlogsyPostDate").Value.ToString(), month));
        }

        return filteredPosts.WhereNotNull();
    }

private IPublishedContent FilterUponMonth(IPublishedContent currentNode, string postDate, string month)
    {
        DateTime postedDate;
        if (DateTime.TryParse(postDate, out postedDate) && postedDate.Month.ToString() == month) return currentNode;

        return null;
    }

private IPublishedContent FilterUponYear(IPublishedContent currentNode, string postDate, string year)
    {
        DateTime postedDate;
        if (DateTime.TryParse(postDate, out postedDate) && postedDate.Year.ToString() == year) return currentNode;

        return null;
    }

private IPublishedContent FilterUponAuthor(IPublishedContent currentNode, string authorId, string author)
    {
        if (String.IsNullOrEmpty(authorId)) return null;
        //Loads relevant node
        int authorNodeId = -1;
        if (!Int32.TryParse(authorId, out authorNodeId)) return null;
        Node authorNode = new Node(authorNodeId);

        //Trims the author name and search for given name
        if (authorNode.GetProperty("uBlogsyAuthorName") != null && authorNode.GetProperty("uBlogsyAuthorName").Value.ToUpper().Trim().Contains(author.ToUpper())) return currentNode;

        return null;
    }


private Boolean FilterUponAuthor(string authorId, string author)
    {
        if (String.IsNullOrEmpty(authorId)) return false;

        int authorNodeId = -1;
        if (!Int32.TryParse(authorId, out authorNodeId)) return false;
        Node authorNode = new Node(authorNodeId);

        if (authorNode.GetProperty("uBlogsyAuthorName") != null && authorNode.GetProperty("uBlogsyAuthorName").Value.ToUpper().Trim().Contains(author.ToUpper())) return true;

        return false;
    }

private Boolean FilterUponCategories(string categoryIds, string category)
    {
        if (String.IsNullOrEmpty(categoryIds)) return false;

        int categoryNodeID = -1;

        foreach (string catID in categoryIds.Split(','))
        {
            if (!Int32.TryParse(catID, out categoryNodeID)) continue;
            Node categoryNode = new Node(categoryNodeID);

            if (categoryNode.GetProperty("uBlogsyLabelName") != null && categoryNode.GetProperty("uBlogsyLabelName").Value.ToUpper().Trim().Contains(category.ToUpper())) return true;
        }
        return false;
    }

private Boolean FilterUponTags(string tagIds, string tag)
    {
        if (String.IsNullOrEmpty(tagIds)) return false;

        int tagNodeID = -1;

        foreach (string tagID in tagIds.Split(','))
        {
            if (!Int32.TryParse(tagID, out tagNodeID)) continue;
            Node tagNode = new Node(tagNodeID);

            if (tagNode.GetProperty("uTagsyTagName") != null && tagNode.GetProperty("uTagsyTagName").Value.ToUpper().Trim().Contains(tag.ToUpper())) return true;
        }
        return false;
    }

private IPublishedContent FilterUponLabel(IPublishedContent currentNode, string nodeIDs, string label)
    {
        if (String.IsNullOrEmpty(nodeIDs)) return null;


        foreach (string nodeId in nodeIDs.Split(','))
        {
            int labelNodeId = -1;
            if (!Int32.TryParse(nodeId, out labelNodeId))
                continue;
            //Loads relevant node
            Node labelNode = new Node(labelNodeId);
            if (labelNode.GetProperty("uBlogsyLabelName") != null && labelNode.GetProperty("uBlogsyLabelName").Value.ToUpper().Trim().Contains(label.ToUpper())) return currentNode;
        }

        return null;
    }

private IPublishedContent FilterAgainstTerm(IPublishedContent currentNode, string searchTerm)
    {
        if (String.IsNullOrEmpty(searchTerm)) return currentNode;

        if (currentNode.GetProperty("uBlogsyContentTitle").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsyContentSummary").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsyContentBody").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsySeoKeywords").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsySeoDescription").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsyNavigationTitle").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) ||
            FilterUponAuthor(currentNode.GetProperty("uBlogsyPostAuthor").Value.ToString(), searchTerm.ToUpper()) ||
            FilterUponCategories(currentNode.GetProperty("uBlogsyPostLabels").Value.ToString(), searchTerm.ToUpper()) ||
            FilterUponTags(currentNode.GetProperty("uBlogsyPostTags").Value.ToString(), searchTerm.ToUpper())
            ) 
                return currentNode;
        return null;
    }

private IPublishedContent FilterUponTag(IPublishedContent currentNode, string nodeIDs, string tag)
    {
        if (String.IsNullOrEmpty(nodeIDs)) return null;

        foreach (string nodeId in nodeIDs.Split(','))
        {
            int tagNodeId = -1;
            if (!Int32.TryParse(nodeId, out tagNodeId))
                continue;
            // Loads relevant TagNode
            Node tagNode = new Node(tagNodeId);
            if (tagNode.GetProperty("uTagsyTagName") != null && tagNode.GetProperty("uTagsyTagName").Value.ToUpper().Contains(tag.ToUpper())) return currentNode;
        }

        return null;
    }

}
@函数
{
私有IEnumerable FilterAgainstPosts(IPPublishedContent登录、字符串标记、字符串标签、字符串作者、字符串搜索词、字符串注释器、字符串年、字符串月)
{
IEnumerable filteredPosts=landing.genderantsorself(“uBlogsyPost”)。其中(x=>x.GetProperty(“umbracanaviHide”)。Value.ToString()!=“1”);
如果(!String.IsNullOrEmpty(searchTerm))
{
filteredPosts=filteredPosts.ForEach(i=>this.filteragainsterm(i,searchTerm));
}
如果(!String.IsNullOrEmpty(标记))
{
filteredPosts=filteredPosts.ForEach(i=>this.FilterUponTag(i,i.GetProperty(“uBlogsyPostTags”).Value.ToString(),tag));
}
如果(!String.IsNullOrEmpty(标签))
{
filteredPosts=filteredPosts.ForEach(i=>this.FilterUponLabel(i,i.GetProperty(“ublogsypostlables”).Value.ToString(),label));
}
如果(!String.IsNullOrEmpty(作者))
{
filteredPosts=filteredPosts.ForEach(i=>this.FilterUponAuthor(i,i.GetProperty(“ublogsyposauthor”).Value.ToString(),author));
}
//
//TODO:需要添加Coomenter搜索
//
如果(!string.IsNullOrEmpty(年))
{
filteredPosts=filteredPosts.ForEach(i=>this.FilterUponYear(i,i.GetProperty(“uBlogsyPostDate”).Value.ToString(),year));
}
如果(!string.IsNullOrEmpty(月))
{
filteredPosts=filteredPosts.ForEach(i=>this.FilterUponMonth(i,i.GetProperty(“uBlogsyPostDate”).Value.ToString(),month));
}
返回filteredPosts.WhereNotNull();
}
private IPPublishedContent FilterUponMonth(IPPublishedContent currentNode、字符串postDate、字符串month)
{
日期时间后置;
if(DateTime.TryParse(postDate,out postedDate)和&postedDate.Month.ToString()==Month)返回currentNode;
返回null;
}
私有IPPublishedContent筛选器年份(IPPublishedContent currentNode、字符串postDate、字符串年份)
{
日期时间后置;
if(DateTime.TryParse(postDate,out postedDate)和&postedDate.Year.ToString()==Year)返回currentNode;
返回null;
}
私有IPPublishedContent筛选器OnAuthor(IPPublishedContent currentNode、字符串作者、字符串作者)
{
if(String.IsNullOrEmpty(authorId))返回null;
//加载相关节点
int authorNodeId=-1;
如果(!Int32.TryParse(authord,out authorNodeId))返回null;
节点authorNode=新节点(authorNodeId);
//修剪作者姓名并搜索给定姓名
if(authorNode.GetProperty(“uBlogsyAuthorName”)!=null&&authorNode.GetProperty(“uBlogsyAuthorName”).Value.ToUpper().Trim()包含(author.ToUpper())返回currentNode;
返回null;
}
私有布尔筛选器编写器(字符串编写器、字符串编写器)
{
if(String.IsNullOrEmpty(authorId))返回false;
int authorNodeId=-1;
如果(!Int32.TryParse(authord,out authorNodeId))返回false;
节点authorNode=新节点(authorNodeId);
如果(authorNode.GetProperty(“uBlogsyAuthorName”)!=null&&authorNode.GetProperty(“uBlogsyAuthorName”).Value.ToUpper().Trim().Contains(author.ToUpper())返回true;
返回false;
}
私有布尔过滤器的类别(字符串类别ID、字符串类别)
{
if(String.IsNullOrEmpty(categoryId))返回false;
int categoryNodeID=-1;
foreach(categoryId.Split(',')中的字符串catID)
{
如果(!Int32.TryParse(catID,out categoryNodeID))继续;
节点categoryNode=新节点(categoryNodeID);
if(categoryNode.GetProperty(“uBlogsyLabelName”)!=null和&categoryNode.GetProperty(“uBlogsyLabelName”).Value.ToUpper().Trim()包含(category.ToUpper())返回true;
}
返回false;
}
私有布尔过滤器(字符串标记ID、字符串标记)
{
if(String.IsNullOrEmpty(tagId))返回false;
int tagNodeID=-1;
foreach(tagID.Split(',')中的字符串tagID)
{
如果(!Int32.TryParse(tagID,out tagNodeID))继续;
节点tagNode=新节点(tagNodeID);
如果(tagNode.GetProperty(“uTagsyTagName”)!=null&&tagNode.GetProperty(“uTagsyTagName”).Value.ToUpper().Trim().Contains(tag.ToUpper())返回true;
}
返回false;
}
专用IPPublishedContent筛选器标签(IP
@functions
{
private IEnumerable<IPublishedContent> FilterAgainstPosts(IPublishedContent landing, string tag, string label, string author, string searchTerm, string commenter, string year, string month)
    {
        IEnumerable<IPublishedContent> filteredPosts = landing.DescendantsOrSelf("uBlogsyPost").Where(x => x.GetProperty("umbracoNaviHide").Value.ToString() != "1");

        if (!String.IsNullOrEmpty(searchTerm))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterAgainstTerm(i, searchTerm));
        }

        if (!String.IsNullOrEmpty(tag))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponTag(i, i.GetProperty("uBlogsyPostTags").Value.ToString(), tag));
        }

        if (!String.IsNullOrEmpty(label))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponLabel(i, i.GetProperty("uBlogsyPostLabels").Value.ToString(), label));
        }

        if (!String.IsNullOrEmpty(author))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponAuthor(i, i.GetProperty("uBlogsyPostAuthor").Value.ToString(), author));
        }

        //
        //TODO: Coomenter search needs to added
        //

        if (!string.IsNullOrEmpty(year))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponYear(i, i.GetProperty("uBlogsyPostDate").Value.ToString(), year));
        }

        if (!string.IsNullOrEmpty(month))
        {
            filteredPosts = filteredPosts.ForEach(i => this.FilterUponMonth(i, i.GetProperty("uBlogsyPostDate").Value.ToString(), month));
        }

        return filteredPosts.WhereNotNull();
    }

private IPublishedContent FilterUponMonth(IPublishedContent currentNode, string postDate, string month)
    {
        DateTime postedDate;
        if (DateTime.TryParse(postDate, out postedDate) && postedDate.Month.ToString() == month) return currentNode;

        return null;
    }

private IPublishedContent FilterUponYear(IPublishedContent currentNode, string postDate, string year)
    {
        DateTime postedDate;
        if (DateTime.TryParse(postDate, out postedDate) && postedDate.Year.ToString() == year) return currentNode;

        return null;
    }

private IPublishedContent FilterUponAuthor(IPublishedContent currentNode, string authorId, string author)
    {
        if (String.IsNullOrEmpty(authorId)) return null;
        //Loads relevant node
        int authorNodeId = -1;
        if (!Int32.TryParse(authorId, out authorNodeId)) return null;
        Node authorNode = new Node(authorNodeId);

        //Trims the author name and search for given name
        if (authorNode.GetProperty("uBlogsyAuthorName") != null && authorNode.GetProperty("uBlogsyAuthorName").Value.ToUpper().Trim().Contains(author.ToUpper())) return currentNode;

        return null;
    }


private Boolean FilterUponAuthor(string authorId, string author)
    {
        if (String.IsNullOrEmpty(authorId)) return false;

        int authorNodeId = -1;
        if (!Int32.TryParse(authorId, out authorNodeId)) return false;
        Node authorNode = new Node(authorNodeId);

        if (authorNode.GetProperty("uBlogsyAuthorName") != null && authorNode.GetProperty("uBlogsyAuthorName").Value.ToUpper().Trim().Contains(author.ToUpper())) return true;

        return false;
    }

private Boolean FilterUponCategories(string categoryIds, string category)
    {
        if (String.IsNullOrEmpty(categoryIds)) return false;

        int categoryNodeID = -1;

        foreach (string catID in categoryIds.Split(','))
        {
            if (!Int32.TryParse(catID, out categoryNodeID)) continue;
            Node categoryNode = new Node(categoryNodeID);

            if (categoryNode.GetProperty("uBlogsyLabelName") != null && categoryNode.GetProperty("uBlogsyLabelName").Value.ToUpper().Trim().Contains(category.ToUpper())) return true;
        }
        return false;
    }

private Boolean FilterUponTags(string tagIds, string tag)
    {
        if (String.IsNullOrEmpty(tagIds)) return false;

        int tagNodeID = -1;

        foreach (string tagID in tagIds.Split(','))
        {
            if (!Int32.TryParse(tagID, out tagNodeID)) continue;
            Node tagNode = new Node(tagNodeID);

            if (tagNode.GetProperty("uTagsyTagName") != null && tagNode.GetProperty("uTagsyTagName").Value.ToUpper().Trim().Contains(tag.ToUpper())) return true;
        }
        return false;
    }

private IPublishedContent FilterUponLabel(IPublishedContent currentNode, string nodeIDs, string label)
    {
        if (String.IsNullOrEmpty(nodeIDs)) return null;


        foreach (string nodeId in nodeIDs.Split(','))
        {
            int labelNodeId = -1;
            if (!Int32.TryParse(nodeId, out labelNodeId))
                continue;
            //Loads relevant node
            Node labelNode = new Node(labelNodeId);
            if (labelNode.GetProperty("uBlogsyLabelName") != null && labelNode.GetProperty("uBlogsyLabelName").Value.ToUpper().Trim().Contains(label.ToUpper())) return currentNode;
        }

        return null;
    }

private IPublishedContent FilterAgainstTerm(IPublishedContent currentNode, string searchTerm)
    {
        if (String.IsNullOrEmpty(searchTerm)) return currentNode;

        if (currentNode.GetProperty("uBlogsyContentTitle").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsyContentSummary").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsyContentBody").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsySeoKeywords").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsySeoDescription").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) || 
            currentNode.GetProperty("uBlogsyNavigationTitle").Value.ToString().ToUpper().Contains(searchTerm.ToUpper()) ||
            FilterUponAuthor(currentNode.GetProperty("uBlogsyPostAuthor").Value.ToString(), searchTerm.ToUpper()) ||
            FilterUponCategories(currentNode.GetProperty("uBlogsyPostLabels").Value.ToString(), searchTerm.ToUpper()) ||
            FilterUponTags(currentNode.GetProperty("uBlogsyPostTags").Value.ToString(), searchTerm.ToUpper())
            ) 
                return currentNode;
        return null;
    }

private IPublishedContent FilterUponTag(IPublishedContent currentNode, string nodeIDs, string tag)
    {
        if (String.IsNullOrEmpty(nodeIDs)) return null;

        foreach (string nodeId in nodeIDs.Split(','))
        {
            int tagNodeId = -1;
            if (!Int32.TryParse(nodeId, out tagNodeId))
                continue;
            // Loads relevant TagNode
            Node tagNode = new Node(tagNodeId);
            if (tagNode.GetProperty("uTagsyTagName") != null && tagNode.GetProperty("uTagsyTagName").Value.ToUpper().Contains(tag.ToUpper())) return currentNode;
        }

        return null;
    }

}