public ProfessionChoose()
        {
            InitializeComponent();

            this.Title = "欢迎你:" + Student.StuName + "同学!";
            string refer_str = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + Student.StuNum;

            requestUriString = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsyxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuNum, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121110";
            //post请求的数据
            string html = SimilateSendPostDate.SimilateAndGetDataWithRefer("", refer_str, requestUriString);
            //向服务器请求登录页面的信息,获取ViewStae控制状态记录,然后用正则表达式提取
            Regex regex = new Regex("name=\"__VIEWSTATE\" value=\".*\"\\s*/>");
            Match match = regex.Match(html);

            viewState = System.Web.HttpUtility.UrlEncode(match.Value.Replace("name=\"__VIEWSTATE\" value=\"", "").Replace("\"", "").Replace("/>", "").Trim());
            MatchCollection matches = new Regex("id=\"kcmcGrid__(?<text>.*?)_jc\"([\\s\\S]*?)<a [\\w\\W]*?>(?<text1>.*?)</a>").Matches(html);

            if (matches.Count > 0)
            {
                for (int i = 0; i < matches.Count; i++)
                {
                    string key   = matches[i].Groups["text"].Value;
                    string value = matches[i].Groups["text1"].Value;
                    dic_Course.Add(key, value);
                }
            }
            cbo_Course.ItemsSource   = dic_Course.Values;
            cbo_Course.SelectedIndex = 1;
        }
        public void Choose()
        {
            string html = "";

            Dispatcher.Invoke((Action) delegate
            {
                do
                {
                    string key              = dic_Course.FirstOrDefault(x => x.Value.ToString() == cbo_Course.SelectedValue.ToString()).Key.ToString();
                    string postData         = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_ywyl=&ddl_kcgs=&ddl_sksj=&ddl_xqbs=1&kcmcGrid%3A_" + key + "%3Axk=on&Button1=+%CC%E1+%BD%BB+";
                    string referRequest_str = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsyxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121110";
                    html = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referRequest_str, referRequest_str);
                    if (html.IndexOf("现在不是选课时间!") > 0)
                    {
                        status         += "现在还不是选课时间\n";
                        Txb_Status.Text = status;
                        MessageBox.Show("现在不是选课时间,请耐心等候!");
                        progressbar.Visibility = Visibility.Collapsed;
                        return;
                    }
                }while (html.IndexOf("请重新登陆,如无法解决,请稍后再试") > 0 || html.IndexOf("该门课程已选") < 0);
                if (html.IndexOf("该门课程已选") > 0)
                {
                    MessageBox.Show("选课成功!");
                }
                else
                {
                    MessageBox.Show("好像没选成功!");
                }
                progressbar.Visibility = Visibility.Collapsed;
            });
        }
Exemple #3
0
        private void ChooseLesson()
        {
            string postData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_kcxz=&ddl_ywyl=%D3%D0&ddl_kcgs=&ddl_xqbs=1&ddl_sksj=&TextBox1=";

            foreach (CourseMsg item in list_courseMsg)
            {
                postData += "&kcmcGrid%3A_ct" + item.CourseId + "%3Ajcnr=%7C%7C%7C";
                if (item.IsChecked != "False")
                {
                    postData += "&kcmcGrid%3A_ct" + item.CourseId + "%3Axk=on";
                }
            }
            postData += "&dpkcmcGrid%3AtxtChoosePage=1&dpkcmcGrid%3AtxtPageSize=6&Button1=++%CC%E1%BD%BB++";
            string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109";
            string rHtmlp   = "";

            do
            {
                rHtmlp = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referStr, referStr);
                if (rHtmlp.IndexOf("现在不是选课时间") > 0)
                {
                    MessageBox.Show("现在不是选课时间!");
                    tip.Visibility = Visibility.Collapsed;
                    return;
                }
                else if (rHtmlp.IndexOf("该门课程已选") > 0)
                {
                    MessageBox.Show("该门课程已选,请谢谢我qq50595531");
                    tip.Visibility = Visibility.Collapsed;
                    return;
                }
            } while (rHtmlp.IndexOf("请重新登陆,如无法解决,请稍后再试") > 0 || rHtmlp.IndexOf("该门课程已选") < 0);

            //while (rHtmlp.IndexOf("请重新登陆,如无法解决,请稍后再试") > 0 || rHtmlp.IndexOf("该门课程已选") < 0 || rHtmlp.IndexOf("现在还不是选课时间") > 0);
        }
Exemple #4
0
 private void btn_SearchAll_Click(object sender, RoutedEventArgs e)
 {
     do
     {
         string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109";
         string postData = "__EVENTTARGET=dpkcmcGrid%3AtxtPageSize&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_kcxz=&ddl_ywyl=%D3%D0&ddl_kcgs=&ddl_xqbs=1&ddl_sksj=&TextBox1=&kcmcGrid%3A_ctl2%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl3%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl4%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl5%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl6%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl7%3Ajcnr=%7C%7C%7C&dpkcmcGrid%3AtxtChoosePage=1&dpkcmcGrid%3AtxtPageSize=1000";
         responseHtml = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referStr, requestStr);
     } while (responseHtml.IndexOf("出错啦!") > 0 || responseHtml.IndexOf("三秒防刷") > 0);
     BindCourse();
 }
Exemple #5
0
        private void BindTtile()
        {
            string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + Student.StuNum;

            requestStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109";
            do
            {
                responseHtml = SimilateSendPostDate.SimilateAndGetDataWithRefer("", referStr, requestStr);
            }while (responseHtml.IndexOf("出错啦!") > 0 || responseHtml.IndexOf("三秒防刷") > 0);
            //课程属性提取
            Regex CBregex = new Regex("<select name=\"ddl_kcgs\"[\\w\\W]*?id=\"ddl_kcgs\">(?<text>[\\w\\W]*?)</select> ");
            Match CBmatch = CBregex.Match(responseHtml);

            if (CBmatch.Success)
            {
                string str = CBmatch.Groups["text"].Value.Trim();
                CourseBelong = str.Split(new string[] { "</option>" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < CourseBelong.Length; i++)
                {
                    CourseBelong[i] = CourseBelong[i].Remove(0, CourseBelong[i].IndexOf(">") + 1);
                }
                cbx_CourseBelong.ItemsSource = CourseBelong;
            }
            //上课时间提取
            Regex TCTregex = new Regex("<select name=\"ddl_sksj\"[\\w\\W]*?id=\"ddl_sksj\">(?<text>[\\w\\W]*?)</select> ");
            Match TCYmatch = TCTregex.Match(responseHtml);

            if (CBmatch.Success)
            {
                string str = TCYmatch.Groups["text"].Value.Trim();
                TakeCourseTime = str.Split(new string[] { "</option>" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < TakeCourseTime.Length; i++)
                {
                    TakeCourseTime[i] = TakeCourseTime[i].Remove(0, TakeCourseTime[i].IndexOf(">") + 1);
                }
                cbx_TakeCourseTime.ItemsSource = TakeCourseTime;
            }
            BindCourse();

            //向服务器请求登录页面的信息,获取ViewStae控制状态记录,然后用正则表达式提取
            Regex regex = new Regex("name=\"__VIEWSTATE\" value=\".*\"\\s*/>");
            Match match = regex.Match(responseHtml);

            viewState = System.Web.HttpUtility.UrlEncode(match.Value.Replace("name=\"__VIEWSTATE\" value=\"", "").Replace("\"", "").Replace("/>", "").Trim());


            cbx_CourseBelong.SelectedValue   = "";
            cbx_TakeCourseTime.SelectedValue = "";

            isPostBack = false;
        }
Exemple #6
0
 private void SearchData(object sender, RoutedEventArgs e)
 {
     do
     {
         if (requestStr == "")
         {
             return;
         }
         string referStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xf_xsqxxxk.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121109";
         string postData = "__EVENTTARGET=dpkcmcGrid%3AtxtPageSize&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&ddl_kcxz=&ddl_ywyl=" + System.Web.HttpUtility.UrlEncode(IsHave, Encoding.GetEncoding("GB2312")) + "&ddl_kcgs=" + System.Web.HttpUtility.UrlEncode(courseBelongs, Encoding.GetEncoding("GB2312")) + "&ddl_xqbs=1&ddl_sksj=" + System.Web.HttpUtility.UrlEncode(courserTime, Encoding.GetEncoding("GB2312")) + "&TextBox1=" + System.Web.HttpUtility.UrlEncode(courseName, Encoding.GetEncoding("GB2312")) + "&Button2=%C8%B7%B6%A8&kcmcGrid%3A_ctl2%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl3%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl4%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl5%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl6%3Ajcnr=%7C%7C%7C&kcmcGrid%3A_ctl7%3Ajcnr=%7C%7C%7C&dpkcmcGrid%3AtxtChoosePage=1&dpkcmcGrid%3AtxtPageSize=1000";
         responseHtml = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, referStr, requestStr);
     } while (responseHtml.IndexOf("出错啦!") > 0);
     BindCourse();
 }
Exemple #7
0
        /// <summary>
        /// 绑定课程名称和任课老师数据
        /// </summary>
        private void BindClassAndTeacher()
        {
            string referStr   = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + Student.StuNum;
            string requestStr = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xsjxpj2.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlDecode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121901";
            string htmlData   = SimilateSendPostDate.SimilateAndGetDataWithRefer("", referStr, requestStr);

            Regex           regex           = new Regex("<td>(?<className>.*?)</td><td><a href='#' onclick=\"window.open\\('(?<url>[\\w\\W]*?)','xsjxpj','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1'\\)\">&nbsp;&nbsp;(?<teacherName>.*?)&nbsp;&nbsp;</a></td>");
            MatchCollection matchCollection = regex.Matches(htmlData);

            dic_ClassAndTeacher.Clear();
            for (int i = 0; i < matchCollection.Count; i++)
            {
                dic_ClassAndTeacher.Add(matchCollection[i].Groups["className"].Value.ToString().Replace("【课堂教学】", ""), matchCollection[i].Groups["teacherName"].Value.ToString().Replace("</font>", "").Replace("<font color='#FF0000'>", ""));
                list_Url.Add(matchCollection[i].Groups["url"].Value.ToString());
            }
            cmb_ClassName.ItemsSource   = dic_ClassAndTeacher.Keys;
            cmb_TeacherName.ItemsSource = dic_ClassAndTeacher.Values;
        }