Exemple #1
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            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("现在不是选课时间!");
                    return;
                }
                else if (rHtmlp.IndexOf("该门课程已选") > 0)
                {
                    MessageBox.Show("该门课程已选,请谢谢我qq50595531");
                    return;
                }
            } while (rHtmlp.IndexOf("请重新登陆,如无法解决,请稍后再试") > 0 || rHtmlp.IndexOf("该门课程已选") < 0);
        }
Exemple #2
0
        /// <summary>
        /// 初始化viewStatue的值
        /// </summary>
        private void init()
        {
            //向服务器请求登录页面的地址并获取viewState和TagCode
            string loginAddress = SimilateSendPostDate.SimilateGetLoginAddress("http://" + SimilateSendPostDate.host);

            Txb_StuNum.ItemsSource   = saveUserNameAndPassword.GetAllUserId();
            Txb_StuNum.SelectedIndex = 0;
            loginStatus = LoginStatus.Default;
        }
Exemple #3
0
        private static string viewState;//控件提交的状态码
        /// <summary>
        /// 构造函数,当传入学年,学期,课程性质时,初始化各门科目的分数
        /// </summary>
        /// <param name="schoolYear">学年</param>
        /// <param name="term">学期</param>
        /// <param name="courseProperties">课程性质</param>
        public Grade(string schoolYear, string term, string courseProperties)
        {
            //refer之前的字符串
            string refer_str = "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xscjcx.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121605";
            //post请求的数据
            string requestData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" + viewState + "&hidLanguage=&ddlXN=" + schoolYear + "&ddlXQ=" + term + "&ddl_kcxz=" + courseProperties + (term == "" ? "&btn_xn=%D1%A7%C4%EA%B3%C9%BC%A8" : "&btn_xq=%D1%A7%C6%DA%B3%C9%BC%A8");

            //错误检测,从配置文件读取最大错误次数数据,然后进行检测,没出错时跳出循环
            int    maxErrorTimes     = 1000; //最大错误次数
            int    errorTimeCount    = 0;    //当前错误次数
            string htmlResponseGrade = "";   //接收课程表的数据

            while (errorTimeCount++ < maxErrorTimes)
            {
                //response接收回滚的正文
                htmlResponseGrade = SimilateSendPostDate.SimilateAndGetDataWithRefer(requestData, refer_str, "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xscjcx.aspx?xh=" + Student.StuNum + "&xm=" + Student.StuName + "&gnmkdm=N121605");
                if (htmlResponseGrade.IndexOf("出错啦") < 0)
                {
                    break;
                }
            }

            //用正则表达式数组来接收返回来的数组
            MatchCollection grade_match = new Regex("<td>(?<text1>\\d{8})</td><td>(?<text2>[\\w]*?)</td><td>(?<text3>[\\w]*?)</td><td>(?<text4>.*?)</td><td>(?<text5>[\\d\\.]*?)</td><td>(?<text6>[\\d\\.]*?)</td><td>(?<text7>[\\d\\.]*?)</td><td>(?<text8>.*?)</td><td>(?<text9>.*?)</td><td>(?<text10>.*?)</td><td>(?<text11>[\\w]*?)</td><td></td><td></td>").Matches(htmlResponseGrade);

            if (grade_match.Count > 0)
            {
                for (int i = 0; i < grade_match.Count; i++)
                {
                    GradeMessage gradeMsg = new GradeMessage();
                    gradeMsg.kcdm = grade_match[i].Groups["text1"].Value.ToString();
                    gradeMsg.kcmc = grade_match[i].Groups["text2"].Value.ToString();
                    gradeMsg.kcxz = grade_match[i].Groups["text3"].Value.ToString();
                    gradeMsg.kcgs = grade_match[i].Groups["text4"].Value.ToString() == "&nbsp;" ? "" : grade_match[i].Groups["text4"].Value.ToString();
                    gradeMsg.xf   = grade_match[i].Groups["text5"].Value.ToString();
                    gradeMsg.jd   = grade_match[i].Groups["text6"].Value.ToString();
                    gradeMsg.cj   = grade_match[i].Groups["text7"].Value.ToString();
                    gradeMsg.fxbj = grade_match[i].Groups["text8"].Value.ToString() == "&nbsp;" ? "" : grade_match[i].Groups["text8"].Value.ToString();
                    gradeMsg.bkcj = grade_match[i].Groups["text9"].Value.ToString() == "&nbsp;" ? "没补考" : grade_match[i].Groups["text9"].Value.ToString();
                    gradeMsg.cxcj = grade_match[i].Groups["text10"].Value.ToString() == "&nbsp;" ? "没重修" : grade_match[i].Groups["text9"].Value.ToString();
                    gradeMsg.kkxy = grade_match[i].Groups["text11"].Value.ToString();
                    GradeMessage_list.Add(gradeMsg);
                }
            }
        }
Exemple #4
0
        /// <summary>
        ///登陆判断
        /// </summary>
        void loginJudge()
        {
            Dispatcher.Invoke((Action) delegate
            {
                //模拟请求验证码,并识别
                string reconizeNum      = "0";
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage             = SimilateSendPostDate.SimilateRequestPicture("http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/CheckCode.aspx");
                if (bitmapImage != null)
                {
                    Bitmap bitmap = new Bitmap(bitmapImage.StreamSource);
                    Class.IdentifyCheckCode identifyCheckCode = new Class.IdentifyCheckCode(bitmap);
                    reconizeNum = identifyCheckCode.Recognite();
                }


                //模拟提交表单数据,并接收Response 的正文
                string requestStr   = "__VIEWSTATE=" + SimilateSendPostDate.viewState + "&TextBox1=" + Txb_StuNum.Text.ToString() + "&TextBox2=" + Txb_Password.Password.ToString() + "&TextBox3=" + reconizeNum + "&RadioButtonList1=%D1%A7%C9%FA&Button1=&lbLanguage=";
                string ResponseHtml = SimilateSendPostDate.SimilateGetDataByPost(requestStr, "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/default2.aspx");

                //根据系统返回的信息判断是否成功登录,并记录状态
                if (ResponseHtml.IndexOf("密码错误") > 0)
                {
                    loginStatus = LoginStatus.WrongPassword;
                    return;
                }
                //当出现出错啦的时候继续刷进去
                else if (ResponseHtml.IndexOf("出错啦!") > 0)
                {
                }
                else if (ResponseHtml.IndexOf("xhxm") > 0)
                {
                    saveUserNameAndPassword.SaveUserIdAndPwd(Txb_StuNum.Text, Txb_Password.Password);
                    //保存学号,姓名信息
                    Match match     = new Regex("<span id=\"xhxm\">(.*?)</span></em>").Match(ResponseHtml);
                    Student.StuName = match.Value.Replace("<span id=\"xhxm\">" + Txb_StuNum.Text.ToString(), "").Replace("同学</span></em>", "").Trim();
                    Student.StuNum  = Txb_StuNum.Text.ToString();
                    loginStatus     = LoginStatus.Succeed;
                    return;
                }
            });
        }
Exemple #5
0
        /// <summary>
        /// 无参数的构造函数,初始化学年,学期,课程性质里的选择项
        /// </summary>
        public Grade()
        {
            //请示的字符串
            string htmlResponse = SimilateSendPostDate.SimilateAndGetDataWithRefer("", "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + Student.StuNum, "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xscjcx.aspx?xh=" + Student.StuNum + "&xm=" + System.Web.HttpUtility.UrlEncode(Student.StuName, Encoding.GetEncoding("GB2312")) + "&gnmkdm=N121605");
            //匹配学年字符串,并提取出来
            MatchCollection gradeSchoolYear_Match = new Regex("\\d{4}\\-\\d{4}").Matches(htmlResponse);

            if (gradeSchoolYear_Match.Count > 0)
            {
                for (int i = 0; i < gradeSchoolYear_Match.Count; i += 2)
                {
                    SchoolYear_list.Add(gradeSchoolYear_Match[i].Value.ToString());
                }
            }
            //匹配学期字符串,并提取出来
            MatchCollection gradeTerm_Match = new Regex("<option value=\"\\d\">(?<text>\\d)</option>").Matches(htmlResponse);

            if (gradeTerm_Match.Count > 0)
            {
                Term_list.Add("");
                for (int term = 0; term < gradeTerm_Match.Count; term++)
                {
                    Term_list.Add(gradeTerm_Match[term].Groups["text"].Value.ToString());
                }
            }
            //匹配课程性质字符串,并提取出来保存
            MatchCollection gradeCourseProperties_Match = new Regex("<option value=\"\\d+\">(?<text>[.\\D]+?)</option>").Matches(htmlResponse);

            if (gradeCourseProperties_Match.Count > 0)
            {
                CourseProperties_list.Add("");
                for (int courseProperties = 0; courseProperties < gradeCourseProperties_Match.Count; courseProperties++)
                {
                    CourseProperties_list.Add(gradeCourseProperties_Match[courseProperties].Groups["text"].Value.ToString());
                }
            }
            //向服务器请求登录页面的信息,获取ViewStae控制状态记录,然后用正则表达式提取
            Regex regex = new Regex("name=\"__VIEWSTATE\" value=\".*\"\\s*/>");
            Match match = regex.Match(htmlResponse);

            viewState = System.Web.HttpUtility.UrlEncode(match.Value.Replace("name=\"__VIEWSTATE\" value=\"", "").Replace("\"", "").Replace("/>", "").Trim());
        }
Exemple #6
0
        /// <summary>
        /// 学生信息的构造函数,在其中初始化学生的基本信息
        /// </summary>
        public Student()
        {
            string str       = SimilateSendPostDate.SimilateAndGetDataWithRefer("", "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xs_main.aspx?xh=" + StuNum, "http://" + SimilateSendPostDate.host + "/(" + SimilateSendPostDate.TagCode + ")/xsgrxx.aspx?xh=" + StuNum + "&xm=" + StuName + "gnmkdm=N121501");
            String regex_str = "([\\s\\S]*)id=\"lbl_zyfx\">(?<text1>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_xb\">(?<text2>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_csrq\">(?<text3>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_byzx\">(?<text4>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_mz\">(?<text5>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_jg\">(?<text6>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_zzmm\">(?<text7>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_sfzh\">(?<text8>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_CC\">(?<text9>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_xy\">(?<text10>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_zymc\">(?<text11>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_xzb\">(?<text12>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_xz\">(?<text13>.*?)</span></TD>" +
                               "([\\s\\S]*)id=\"lbl_dqszj\">(?<text14>.*?)</span></TD>";
            Match majorField_match = new Regex(regex_str).Match(str);

            if (majorField_match.Success)
            {
                Gender                = majorField_match.Groups["text2"].Value.ToString();
                MajorField            = majorField_match.Groups["text1"].Value.ToString();
                Brithday              = majorField_match.Groups["text3"].Value.ToString();
                GraditionMiddleSchool = majorField_match.Groups["text4"].Value.ToString();
                Nation                = majorField_match.Groups["text5"].Value.ToString();
                NativePlace           = majorField_match.Groups["text6"].Value.ToString();
                PoliticsStatus        = majorField_match.Groups["text7"].Value.ToString();
                IdentityCard          = majorField_match.Groups["text8"].Value.ToString();
                QualificationLevels   = majorField_match.Groups["text9"].Value.ToString();
                Academy               = majorField_match.Groups["text10"].Value.ToString();
                MajorName             = majorField_match.Groups["text11"].Value.ToString();
                LengthOfSchool        = majorField_match.Groups["text13"].Value.ToString();
                ExamineeNum           = majorField_match.Groups["text14"].Value.ToString();
                ExecutiveCourses      = majorField_match.Groups["text12"].Value.ToString();
            }
        }
Exemple #7
0
        /// <summary>
        /// 课程表初始化函数
        /// </summary>
        private void init(string postData, string refer, string urlStr)
        {
            //错误检测,从配置文件读取最大错误次数数据,然后进行检测,没出错时跳出循环
            int    maxErrorTimes  = 1000; //最大错误次数
            int    errorTimeCount = 0;    //当前错误次数
            string responData     = "";   //接收课程表的数据

            while (++errorTimeCount < maxErrorTimes)
            {
                responData = SimilateSendPostDate.SimilateAndGetDataWithRefer(postData, refer, urlStr);
                if (responData.IndexOf("出错啦") < 0)
                {
                    break;
                }
                else if (errorTimeCount == maxErrorTimes)
                {
                    MessageBox.Show("系统出错啦!");
                    return;
                }
            }
            //向服务器请求登录页面的信息,获取ViewStae控制状态记录,然后用正则表达式提取
            Regex regex = new Regex("name=\"__VIEWSTATE\" value=\".*\"\\s*/>");
            Match match = regex.Match(responData);

            viewState = System.Web.HttpUtility.UrlEncode(match.Value.Replace("name=\"__VIEWSTATE\" value=\"", "").Replace("\"", "").Replace("/>", "").Trim());
            //初始化当前所在学期的课程
            for (int lesson = 0; lesson < 6; lesson++)
            {
                //正则表达式匹配数据
                //并保存课程表
                Regex courseRegex = new Regex("<td.*?>第" + (lesson * 2 + 1) + "节</td><td.*?>(?<text1>.*?)</td><td.*?>(?<text2>.*?)</td><td.*?>(?<text3>.*?)</td><td.*?>(?<text4>.*?)</td><td.*?>(?<text5>.*?)</td><td.*?>(?<text6>.*?)</td><td.*?>(?<text7>.*?)</td>");
                Match courseMatch = courseRegex.Match(responData);
                if (courseMatch.Success)
                {
                    weekCourse[0][lesson] = courseMatch.Groups["text1"].Value.ToString() == "&nbsp;" ? "" : courseMatch.Groups["text1"].Value.ToString();
                    weekCourse[1][lesson] = courseMatch.Groups["text2"].Value.ToString() == "&nbsp;" ? "" : courseMatch.Groups["text2"].Value.ToString();
                    weekCourse[2][lesson] = courseMatch.Groups["text3"].Value.ToString() == "&nbsp;" ? "" : courseMatch.Groups["text3"].Value.ToString();
                    weekCourse[3][lesson] = courseMatch.Groups["text4"].Value.ToString() == "&nbsp;" ? "" : courseMatch.Groups["text4"].Value.ToString();
                    weekCourse[4][lesson] = courseMatch.Groups["text5"].Value.ToString() == "&nbsp;" ? "" : courseMatch.Groups["text5"].Value.ToString();
                    weekCourse[5][lesson] = courseMatch.Groups["text6"].Value.ToString() == "&nbsp;" ? "" : courseMatch.Groups["text6"].Value.ToString();
                    weekCourse[6][lesson] = courseMatch.Groups["text7"].Value.ToString() == "&nbsp;" ? "" : courseMatch.Groups["text7"].Value.ToString();
                }
            }
            //课程表学年
            Regex           schoolYearRegex = new Regex("(?<text>\\d{4}\\-\\d{4})</option>");
            MatchCollection schoolMatch     = schoolYearRegex.Matches(responData);

            if (schoolMatch.Count > 0)
            {
                for (int i = 0; i < schoolMatch.Count; i += 2)
                {
                    CourseShoolYear_list.Add(schoolMatch[i].Groups["text"].Value.ToString());
                }
            }
            //课程表学期
            Regex           termRegex  = new Regex("value=\"(?<text>\\d)\"");
            MatchCollection termMatchs = termRegex.Matches(responData);

            if (termMatchs.Count > 0)
            {
                for (int j = 0; j < termMatchs.Count; j++)
                {
                    CourseTerm_list.Add(termMatchs[j].Groups["text"].ToString());
                }
            }
        }