Пример #1
0
        private async void GetCourseByDean()
        {
            BitmapImage bmp    = new BitmapImage();
            Stream      stream = await WebConnection.Connect_for_stream("http://dean.pku.edu.cn/student/yanzheng.php?act=init");

            if (stream == null)
            {
                Constants.BoxPage.ShowMessage("获取验证码失败!");
                return;
            }
            var ran_stream = await Util.StreamToRandomAccessStream(stream);

            bmp.SetSource(ran_stream);
            IMGverify.Source = bmp;
            PRGRScourse.ProgressStart();
            ContentDialogResult res = await DLGverify.ShowAsync();

            if (res != ContentDialogResult.Primary)
            {
                this.IsEnabled = true;
                PRGRScourse.ProgressEnd();
                return;
            }
            String str = await Dean.get_session_id(VerifyCode);

            if (str == "")
            {
                return;
            }

            /**
             * 下面这段注释的代码可能是用来获取自选课程的,不是dean
             */
            //List<Parameters> list = new List<Parameters>();
            //list.Add(new Parameters("token", Constants.token));
            //list.Add(new Parameters("phpsessid", str));
            //Parameters parameter = await WebConnection.Connect(Constants.domain + "/services/pkuhelper/course.php", list);
            Parameters parameter = await WebConnection.Connect("http://dean.pku.edu.cn/student/newXkInfo_1105.php?PHPSESSID=" + str, null);

            if (parameter != null && parameter.name == "200")
            {
                CourseUtil.DecodeDeanHtml(parameter.value);
                CourseUtil.SaveCourses("DeanCourses", CourseUtil.DeanCourses);
                if (Constants.CourseUseCustom)
                {
                    await CourseUtil.GetCustomCourses(str);
                }
                ShowCourse();
                this.IsEnabled = true;
                PRGRScourse.ProgressEnd();
            }
            else
            {
                Util.DealWithDisconnect(parameter);
                this.IsEnabled = true;
                PRGRScourse.ProgressEnd();
            }
        }
Пример #2
0
        private async void LSTVWinfo_ItemClick(object sender, ItemClickEventArgs e)
        {
            switch ((e.ClickedItem as UsualItemData).ID)
            {
            case 0:
            {
                FRAMEdetail.Navigate(typeof(ImageShowPage), new Parameters("北大地图", "ms-appx:///Assets/pkumap.jpg"));
                if (VSGinfo.CurrentState == narrow)
                {
                    UpdateVisualState(narrow, null);
                }
            } break;

            case 1:
            {
                FRAMEdetail.Navigate(typeof(ImageShowPage), new Parameters("北京地铁图", "ms-appx:///Assets/subwaymap.jpg"));
                if (VSGinfo.CurrentState == narrow)
                {
                    UpdateVisualState(narrow, null);
                }
            } break;

            case 2:
            {
                PRGRSinfo.ProgressStart();
                await InfoUtil.GetCardAmount();

                PRGRSinfo.ProgressEnd();
            } break;

            case 3:
            {
                first : BitmapImage bmp = new BitmapImage();
                Stream stream = await WebConnection.Connect_for_stream("http://dean.pku.edu.cn/student/yanzheng.php?act=init");

                if (stream == null)
                {
                    Constants.BoxPage.ShowMessage("获取验证码失败!");
                    return;
                }
                var ran_stream = await Util.StreamToRandomAccessStream(stream);

                bmp.SetSource(ran_stream);

                IMGverify.Source = bmp;
                if (DLGshowing)
                {
                    return;
                }
                ContentDialogResult res = await DLGverify.ShowAsync();

                if (res == ContentDialogResult.Primary)
                {
                    String phpsessid = await Dean.get_session_id(verifyCode);

                    if (phpsessid == "")
                    {
                        goto first;
                    }
                    PRGRSinfo.ProgressStart();
                    Parameters parameters = await WebConnection.Connect(Constants.domain + "/services/pkuhelper/allGrade.php?phpsessid=" + phpsessid, null);

                    if (parameters.name != "200")
                    {
                        Util.DealWithDisconnect(parameters);
                        PRGRSinfo.ProgressEnd();
                    }
                    else
                    {
                        PRGRSinfo.ProgressEnd();
                        FRAMEdetail.Navigate(typeof(GradePage), parameters.value);
                        if (VSGinfo.CurrentState == narrow)
                        {
                            UpdateVisualState(narrow, null);
                        }
                    }
                }
            } break;

            case 4:
            {
                FRAMEdetail.Navigate(typeof(SchoolCalendarPage));
                if (VSGinfo.CurrentState == narrow)
                {
                    UpdateVisualState(narrow, null);
                }
            }
            break;

            case 5:
            {
                FRAMEdetail.Navigate(typeof(PhoneList));
                if (VSGinfo.CurrentState == narrow)
                {
                    UpdateVisualState(narrow, null);
                }
            }
            break;
            }
        }