Ejemplo n.º 1
0
        private IEnumerable <IListable> GetRelatedArticles(IArticle article)
        {
            var relatedArticles = article.Related_Articles.Concat(article.Referenced_Articles).Take(10).ToList();

            if (relatedArticles.Count < 10)
            {
                var filter = Searcher.CreateFilter();
                filter.ReferencedArticle = article._Id;
                filter.PageSize          = 10 - relatedArticles.Count;

                var results = Searcher.Search(filter);
                relatedArticles.AddRange(results.Articles);
            }
            return(relatedArticles.Where(r => r != null).Select(x => ArticleListableFactory.Create(GlobalService.GetItem <IArticle>(x._Id))).Cast <IListable>().OrderByDescending(x => x.ListableDate));
        }
Ejemplo n.º 2
0
        private IEnumerable <IListableViewModel> GetLatestNews(Guid datasourceId, IEnumerable <Guid> subjectIds, IEnumerable <string> publicationNames,
                                                               IEnumerable <string> authorGuids, IEnumerable <string> companyRecordNumbers, int itemsToDisplay)
        {
            Stopwatch sw = Stopwatch.StartNew();

            StringExtensions.WriteSitecoreLogs("Reading GetLatestNews at:", sw, "Latest News");

            var manuallyCuratedContent = ItemManuallyCuratedContent.Get(datasourceId);
            var filter = ArticleSearch.CreateFilter();

            filter.Page     = 1;
            filter.PageSize = itemsToDisplay;
            if (manuallyCuratedContent != null)
            {
                filter.ExcludeManuallyCuratedItems.AddRange(manuallyCuratedContent);
            }
            if (subjectIds != null)
            {
                filter.TaxonomyIds.AddRange(subjectIds);
            }
            if (publicationNames != null)
            {
                filter.PublicationNames.AddRange(publicationNames);
            }
            if (authorGuids != null)
            {
                filter.AuthorGuids.AddRange(authorGuids);
            }
            if (companyRecordNumbers != null)
            {
                filter.CompanyRecordNumbers.AddRange(companyRecordNumbers);
            }

            var results  = ArticleSearch.Search(filter);
            var articles =
                results.Articles.Where(a => a != null)
                .Select(a => ArticleListableFactory.Create(a).Alter(l => l.DisplayImage = false));

            if (IsAuthorPage) // articles pages are wildcard and don't have a title
            {
                articles = articles.Select(a => a.Alter(b => b.PageTitle = CurrentAuthorName));
            }

            StringExtensions.WriteSitecoreLogs("Reading GetLatestNews ends at:", sw, "Latest News");
            return(articles);
        }