public ArticleItemWrapper(ArticleItem articleItem, ArticleLengthEstimator estimator) { _estimator = estimator; Database masterDb = Factory.GetDatabase("master"); Item articleBaseItem = masterDb.GetItem(articleItem.ID.ToString()); IArticle article = articleBaseItem.GlassCast<IArticle>(inferType: true); InnerItem = articleBaseItem; //var pubRoot = _globalService.GetSiteRootAncestor(source._Id); var siteRootItem = getSiteRoot(articleBaseItem); string pubName = string.Empty; if (siteRootItem != null && siteRootItem.Fields["Publication Name"] != null) pubName = siteRootItem.Fields["Publication Name"].Value; //TODO PreviewUrl = GetPreviewUrl(article._Id.ToString()); ArticleNumber = article.Article_Number; if (ArticleNumber == null) { ArticleNumber = ""; } PublicationName = pubName; //Title = article.Title + " : " + article._Path; Title = article.Title; if (article.Authors != null) { Authors = article.Authors.Select(a => a.First_Name + " " + a.Last_Name); } if (article.Created_Date == DateTime.MinValue) { ArticleCreation = articleBaseItem.Statistics.Created.ToServerTimeZone(); } else { ArticleCreation = article.Created_Date.ToServerTimeZone(); } if (string.IsNullOrEmpty(article.Word_Count)) { WordCount = 0; } else { int parsedCount = 0; if (Int32.TryParse(article.Word_Count, out parsedCount)) { WordCount = parsedCount; } else { WordCount = 0; } } var ra = (article.Referenced_Articles != null) ? article.Referenced_Articles.Select(a => ((IArticle)a).Article_Number).Where(b => !string.IsNullOrEmpty(b)) : Enumerable.Empty<string>(); if (ra.Any()) SidebarArticleNumbers.AddRange(ra); SidebarArticleNumbers.Sort(); TaxonomyString = (article.Taxonomies != null) ? string.Join(",", article.Taxonomies.Select(t => t.Item_Name)) : string.Empty; ContentType = ""; if (article.Content_Type != null) { ContentType = article.Content_Type.Item_Name; } MediaType = ""; if (article.Media_Type != null) { MediaType = article.Media_Type.Item_Name; } EmailPriority = ""; EmailPriority = article.Sort_Order.ToString(); NotesToEditorial = article.Editorial_Notes; Embargoed = article.Embargoed; EmbargoDate = articleBaseItem.Publishing.PublishDate.ToServerTimeZone(); SAPDateTime = article.Planned_Publish_Date.ToServerTimeZone(); WebPublicationDateTime = article.Actual_Publish_Date.ToServerTimeZone(); }
public ArticleItemWrapper(ArticleItem articleItem) : this(articleItem, new ArticleLengthEstimator()) { }