Ejemplo n.º 1
0
        private async Task <DialogTurnResult> ReadingRoomSeatAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (LoginRequest.LoginHselFlag)
            {
                var req = (HttpWebRequest)WebRequest.Create("http://hsel.hansung.ac.kr/reading_reading_list.mir");
                req.CookieContainer = LoginRequest.HselCookie;

                var resp = (HttpWebResponse)req.GetResponse();

                using (var r = new StreamReader(resp.GetResponseStream()))
                {
                    var          str  = r.ReadToEnd();
                    HtmlDocument html = new HtmlDocument();
                    html.LoadHtml(str);

                    var htmlNode    = html.DocumentNode.Descendants("div").Where(x => x.GetAttributeValue("class", "").Equals("facility_box"));
                    var seatNumbers = new List <SeatNumber>();
                    foreach (var node in htmlNode)
                    {
                        seatNumbers.Add(SeatNumberClassfication(node));
                    }
                    var cardGenerator = new CardGenerator();
                    await cardGenerator.AttachSeatCardAsync(stepContext.Context, seatNumbers, cancellationToken);
                }

                return(await stepContext.EndDialogAsync(cancellationToken));
            }
            else
            {
                return(await stepContext.BeginDialogAsync(nameof(LoginDialog), "readingRoom", cancellationToken));
            }
        }