Exemplo n.º 1
0
        public async Task <ArticleTaskResult> ProcessItem(UnexpandedArticle item)
        {
            var response = new ArticleTaskResult {
                Article = item
            };

            var card = await _cardService.CardByName(item.Title);

            if (card != null)
            {
                var tipSections = new List <CardTipSection>();

                var articleCardTips = await _wikiArticle.Simple(item.Id);

                foreach (var cardTipSection in articleCardTips.Sections)
                {
                    var tipSection = new CardTipSection
                    {
                        Name = cardTipSection.Title,
                        Tips = SectionHelper.GetSectionContentList(cardTipSection)
                    };


                    if (cardTipSection.Title.Equals("List", StringComparison.OrdinalIgnoreCase) ||
                        cardTipSection.Title.Equals("Lists", StringComparison.OrdinalIgnoreCase))
                    {
                        tipSection.Name = tipSection.Tips.First();
                        tipSection.Tips.Clear();
                        _tipRelatedWebPage.GetTipRelatedCards(tipSection, item);
                    }

                    tipSections.Add(tipSection);
                }

                await _cardTipService.Update(card.Id, tipSections);
            }

            return(response);
        }
        public async Task <ArticleTaskResult> ProcessItem(Article article)
        {
            var response = new ArticleTaskResult {
                Article = article
            };

            var tipSections = new List <CardSection>();

            var articleCardTips = await _wikiArticle.Simple(article.Id);

            foreach (var cardTipSection in articleCardTips.Sections)
            {
                var tipSection = new CardSection
                {
                    Name        = cardTipSection.Title,
                    ContentList = SectionHelper.GetSectionContentList(cardTipSection)
                };

                if (cardTipSection.Title.Equals("List", StringComparison.OrdinalIgnoreCase) ||
                    cardTipSection.Title.Equals("Lists", StringComparison.OrdinalIgnoreCase))
                {
                    tipSection.Name = tipSection.ContentList.First();
                    tipSection.ContentList.Clear();
                    _tipRelatedWebPage.GetTipRelatedCards(tipSection, article);
                }

                tipSections.Add(tipSection);
            }

            var cardSectionMessage = new CardSectionMessage {
                Name = article.Title, CardSections = tipSections
            };

            await _queues.Single(q => q.Handles(ArticleCategory.CardTips)).Publish(cardSectionMessage);

            return(response);
        }