private async Task RefreshGuid()
        {
            HttpMessage resp = await SelectCourseHelper.GetValiGuid(token);

            switch (resp.statusCode)
            {
            case HttpStatusCode.OK:
                string guid = resp.data as string;
                if (guid != null)
                {
                    Debug.WriteLine(guid);
                    tbx_tip.Text = "正在加载验证码";
                    string      url_login_vali = SelectCourseHelper.GetValiPicUrl(guid);
                    BitmapImage image          = await HttpHelper.GetPicAsync(url_login_vali);

                    if (image != null)
                    {
                        tbx_tip.Visibility = Visibility.Hidden;
                        img_vali.Source    = image;
                    }
                    else
                    {
                        tbx_tip.Text = "验证码加载失败,点击刷新";
                    }
                }
                break;

            default:
                MessageBox.Show(resp.data.ToString(), "异常错误!");
                break;
            }
        }
示例#2
0
        private async Task <string> AutoAddCourse(string TeachClassId, bool showMessage)
        {
            LoadingWindow loadingWindow = new LoadingWindow("正在获取验证码");

            if (showMessage)
            {
                loadingWindow.Show();
            }
            HttpMessage resp = await SelectCourseHelper.GetValiGuid(loginData.access_token);

            switch (resp.statusCode)
            {
            case HttpStatusCode.OK:
                string guid = resp.data as string;
                if (guid != null)
                {
                    Debug.WriteLine(guid);
                    string url_login_vali = SelectCourseHelper.GetValiPicUrl(guid);
                    loadingWindow.StatusText = "正在识别验证码";
                    Debug.WriteLine("正在识别验证码");
                    byte[] pic = await HttpHelper.GetPicBytesAsync(url_login_vali);

                    if (pic != null)
                    {
                        var valicode = await Vercode(pic);

                        if (valicode != null)
                        {
                            loadingWindow.StatusText = "识别成功,正在选课";
                            var result = await AddCourse(TeachClassId, valicode, showMessage);

                            loadingWindow.Close();
                            return(result);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }

            default:
                Debug.WriteLine(resp.data.ToString(), "异常错误!");
                return(null);
            }
        }