Ejemplo n.º 1
0
        public async Task <CardSectionMessage> ProcessItem(Article article)
        {
            var cardSections = new List <CardSection>();

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

            foreach (var section in contentResult.Sections)
            {
                if (section.Title.Equals("References", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                var rulingSection = new CardSection
                {
                    Name        = section.Title,
                    ContentList = SectionHelper.GetSectionContentList(section)
                };

                cardSections.Add(rulingSection);
            }

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

            return(cardSectionMessage);
        }
Ejemplo n.º 2
0
        static void notifyTeamsPlanner(Messages value)
        {
            List <MessageValue> val = value.value;

            //List<CardSection> cardSection = new List<CardSection>();
            MessageCard card = new MessageCard();


            foreach (var item in val)
            {
                List <Message> msg = new List <Message>();
                msg = item.Messages;

                List <CardFacts> facts = new List <CardFacts>();

                foreach (var ite in msg)
                {
                    CardFacts fa = new CardFacts()
                    {
                        name  = ite.PublishedTime.ToString(),
                        value = ite.MessageText
                    };
                    facts.Add(fa);
                }
                List <CardSection> cardSection = new List <CardSection>();

                CardSection cardS = new CardSection()
                {
                    facts            = facts,
                    text             = item.WorkloadDisplayName,
                    activityTitle    = item.FeatureDisplayName,
                    activitySubtitle = item.Id + " " + item.ImpactDescription
                };

                cardSection.Add(cardS);

                card = new MessageCard()
                {
                    sections = cardSection,
                    summary  = item.Status,
                    title    = item.Title
                };

                // My Teams LInk
                var client  = new RestClient(teamsWebhook);
                var request = new RestRequest(Method.POST);
                request.AddHeader("cache-control", "no-cache");
                request.AddHeader("Connection", "keep-alive");
                request.AddHeader("accept-encoding", "gzip, deflate");
                request.AddHeader("Host", "outlook.office.com");
                request.AddHeader("Cache-Control", "no-cache");
                request.AddHeader("Accept", "*/*");
                request.AddHeader("Content-Type", "application/json");
                request.AddParameter(JsonConvert.SerializeObject(card), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
            }
        }
Ejemplo n.º 3
0
        public void GetTipRelatedCards(CardSection section, string tipRelatedCardListUrl, HtmlNode tipRelatedCardListTable)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            if (!string.IsNullOrEmpty(tipRelatedCardListUrl))
            {
                var cardsFromUrl = _semanticSearch.CardsByUrl(tipRelatedCardListUrl);
                section.ContentList.AddRange(cardsFromUrl.Select(c => c.Name));
            }
            else if (tipRelatedCardListTable != null)
            {
                var cardsFromTable = _tipRelatedCardList.ExtractCardsFromTable(tipRelatedCardListTable);
                section.ContentList.AddRange(cardsFromTable);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Возвращает секцию с указанным псевдонимом в виде коллекции строк этой секции
        /// </summary>
        /// <param name="card">Карточка, для которой запрашивается получение секции</param>
        /// <param name="sectionAlias">Псевдоним запрашиваемой секции</param>
        /// <returns>Коллекция строк, представляющих секцию в случае успешности её получения; иначе null</returns>
        public static IList GetSection(this BaseCard card, string sectionAlias)
        {
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }
            if (string.IsNullOrEmpty(sectionAlias))
            {
                throw new ArgumentOutOfRangeException("sectionAlias");
            }

            CardSection section = card.CardType.GetSectionByAlias(sectionAlias);

            if (section != null)
            {
                return(card.GetSection(section.Id));
            }

            return(null);
        }
Ejemplo n.º 5
0
        public void GetTipRelatedCards(CardSection section, Article item)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var tipWebPage = new HtmlWeb().Load(item.Url);

            //Get tip related card list url
            var cardListUrl = _tipRelatedHtmlDocument.GetUrl(tipWebPage);

            //get tips related card list table
            var cardListTable = _tipRelatedHtmlDocument.GetTable(tipWebPage);

            GetTipRelatedCards(section, cardListUrl, cardListTable);
        }
        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);
        }
Ejemplo n.º 7
0
        public static IList GetSectionRows(this BaseCard card, string sectionAlias)
        {
            if (card == null)
            {
                throw new ArgumentNullException("card", "Card can't be null.");
            }
            if (string.IsNullOrEmpty(sectionAlias))
            {
                throw new ArgumentNullException("sectionAlias", "Section alias can't be null or empty.");
            }

            CardSection section = card.CardType.GetSectionByAlias(sectionAlias);

            if (section != null)
            {
                IList sectionData = card.GetSection(section.Id);
                if (sectionData.Count == 0)
                {
                    sectionData.Add(new BaseCardSectionRow());
                }
                return(sectionData);
            }
            return(null);
        }
 protected void OnDeleteSection(CardSection section)
 {
     CardSections.Remove(section);
     StateHasChanged();
 }
Ejemplo n.º 9
0
 public static void UpdateFrom(this CardSection cardSection, CardSectionUpdate update)
 {
     cardSection.Title = update.Title;
 }