コード例 #1
0
ファイル: FormLogin.cs プロジェクト: Fall-Rain/timetable
        private void btnlogin_Click(object sender, EventArgs e)
        {
            Global.userid = GUI_User_Name.Text;
            Dictionary <string, FeildDetail> formdata = new Dictionary <string, FeildDetail>()
            {
                { "__VIEWSTATE", new FeildDetail()
                  {
                      Xpath = "//*[@id='__VIEWSTATE']", ContentType = ContentType.AttributeValue, AttributeKey = "value"
                  } },
                { "__EVENTVALIDATION", new FeildDetail()
                  {
                      Xpath = "//*[@id='__EVENTVALIDATION']", ContentType = ContentType.AttributeValue, AttributeKey = "value"
                  } },
            };

            HtmlHelp.GetBodyInfo(() => login, formdata, null, "/html/body", "", out Dictionary <string, string> rootvalues, out List <Dictionary <string, string> > rangeValues);
            Dictionary <string, string> pams = new Dictionary <string, string>()
            {
                { "__VIEWSTATE", rootvalues["__VIEWSTATE"] },
                { "__EVENTVALIDATION", rootvalues["__EVENTVALIDATION"] },
                { "Account", Global.userid },
                { "PWD", GUI_User_Pwd.Text },
                { "CheckCode", GUI_verfyCode.Text },
                { "cmdok", "" }
            };

            Global.aspxauth = HttpHelp.LoginGetSessin("http://jw.jltc.edu.cn/login.aspx", pams, cookie: Global.Cookie);
            if (string.IsNullOrEmpty(Global.LoginCookie))
            {
                MessageBox.Show("用户名/密码/验证码错误");
                return;
            }
            UserSecret userSecret = new UserSecret
            {
                UserName = GUI_User_Name.Text,
                //PassWord = GUI_User_Pwd.Text?.EncryptDES(),
                PassWord         = GUI_rememberpassword.Checked ? GUI_User_Pwd.Text?.EncryptDES() : "",
                RememberPassword = GUI_rememberpassword.Checked ? true : false
            };
            string jsonstr = userSecret.ToJson();

            File.Delete(Global.FileUrl);
            using (FileStream fs = new FileStream(Global.FileUrl, FileMode.CreateNew))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.Write(jsonstr);
                }
            }
            Hide();

            //FormMain fm = new FormMain();
            //var result = fm.ShowDialog();
            //if (result == DialogResult.Cancel)
            //{
            //    Application.Exit();
            //}
        }
コード例 #2
0
        private void GUI_refresh_Click(object sender, EventArgs e)
        {
            int key = 0;


            key = Global.semester.FirstOrDefault(q => q.Value == GUI_semester.Text).Key;

            if (GUI_week.Text == "")
            {
                GUI_week.Text = "1";
            }

            if (key == 0 || GUI_week.Text == "")
            {
                ShowTimeTable(timetable);
                return;
            }


            string ddlxnxqh = "20" + Convert.ToString(Global.year + (key / 10) - 1) + "-20" +
                              Convert.ToString(Global.year + (key / 10)) + "-" + Convert.ToString(key % 10);
            Dictionary <string, FeildDetail> formdata = new Dictionary <string, FeildDetail>()
            {
                {
                    "__VIEWSTATE",
                    new FeildDetail()
                    {
                        Xpath        = "//*[@id='__VIEWSTATE']", ContentType = ContentType.AttributeValue,
                        AttributeKey = "value"
                    }
                },
                //   { "__EVENTVALIDATION",new FeildDetail() { Xpath="//*[@id='__EVENTVALIDATION']", ContentType=ContentType.AttributeValue, AttributeKey="value" } },
            };

            HtmlHelp.GetBodyInfo(() => timetable, formdata, null, "/html/body", "",
                                 out Dictionary <string, string> rootvalues, out List <Dictionary <string, string> > rangeValues);
            string __VIEWSTATE = rootvalues["__VIEWSTATE"];
            Dictionary <string, string> pams = new Dictionary <string, string>()
            {
                { "__EVENTTARGET", "zc" },
                { "__EVENTARGUMENT", "" },
                { "__LASTFOCUS", "" },
                { "__VIEWSTATE", rootvalues["__VIEWSTATE"] },
                { "ddlxnxqh", ddlxnxqh },
                { "mx", "on" },
                { "zc", GUI_week.Text }
            };
            string html = HttpHelp.HttpPost("http://jw.jltc.edu.cn/JWXS/pkgl/XsKB_List.aspx", Global.LoginCookie, pams);

            ShowTimeTable(html);
        }