コード例 #1
0
        private async Task <DialogTurnResult> TimeTableViewAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (LoginRequest.LoginInfoFlag)
            {
                var dd = (HttpWebRequest)WebRequest.Create("https://info.hansung.ac.kr/fuz/sugang/dae_sigan_main_data.jsp");
                dd.Method = "post";
                string h = $"as_hakbun={LoginRequest.UserId}";
                dd.ContentLength = h.Length;
                dd.ContentType   = "application/x-www-urlencoded";
                TextWriter wd = (TextWriter) new StreamWriter(dd.GetRequestStream());
                wd.Write(h);
                wd.Close();
                dd.CookieContainer = LoginRequest.InfoCookie;

                var ddf = (HttpWebResponse)dd.GetResponse();
                using (var r = new StreamReader(ddf.GetResponseStream(), Encoding.GetEncoding("euc-kr"), true))
                {
                    var ee            = r.ReadToEnd();
                    var siganpyo      = TimeTableRemake(ee);
                    var cardGenerator = new CardGenerator();
                    await cardGenerator.AttachTimeTableCardAsync(stepContext.Context, siganpyo, cancellationToken);
                }
                return(await stepContext.EndDialogAsync(cancellationToken));
            }
            else
            {
                return(await stepContext.BeginDialogAsync(nameof(LoginDialog), "timeTable", cancellationToken));
            }
        }