示例#1
0
        private async Task <DialogTurnResult> NoticeViewAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var notice = stepContext.Context.Activity.Text;
            var index  = NOTICENAME.IndexOf(notice);

            var client   = new HttpClient();
            var response = await client.GetAsync(URIS[index]);

            if (response.IsSuccessStatusCode)
            {
                var result = await response.Content.ReadAsStringAsync();

                var html = new HtmlDocument();
                html.LoadHtml(result);

                var htmlNode = html.DocumentNode.Descendants("table").Where(x => x.GetAttributeValue("class", "").Equals("bbs-list")).First().ChildNodes[7];

                var notices       = NoticeDivider(htmlNode.ChildNodes);
                var cardGenerator = new CardGenerator();
                await cardGenerator.AttachNoticeCard(stepContext.Context, notices, notice, URIS[index], cancellationToken);
            }
            else
            {
                await stepContext.Context.SendActivityAsync("공지사항을 불러오는데 실패했습니다");
            }
            return(await stepContext.EndDialogAsync(cancellationToken));
        }