Exemple #1
0
        protected override void Login()
        {
            string loginUrl = "https://service.htsc.com.cn/service/loginAction.do?method=login";

            this.httpClient.DownloadString(loginUrl);

            string verifyCode = this.GetVerifyCode();

            if (verifyCode == "")
            {
                MessageBox.Show("获取验证码失败");
            }

            LoginPostInfo t = new LoginPostInfo
            {
                // TODO: 自动获取MAC, HDD INFO
                macaddr = "00:0C:29:1A:B4:32",
                hddInfo = "CVCV434102MF120BGN++",

                servicePwd = fivc.txtServicePwd.Text,
                trdpwd     = fivc.txtTrdpwd.GetEncPswAes(),
                trdpwdEns  = fivc.txtTrdpwd.GetEncPswAes(),
                userName   = fivc.txtUsername.Text,
                vcode      = verifyCode
            };

            string postString = URLHelper.GetData <LoginPostInfo>(t, this.encoding);

            byte[] postData = Encoding.UTF8.GetBytes(postString);
            this.httpClient.Encoding = this.encoding;

            // string str4 = this.httpClient.UploadString(address, data);
            httpClient.Timeout = 0xea90;
            byte[] responseData = this.httpClient.UploadData(loginUrl, "POST", postData);
            string resp         = Encoding.UTF8.GetString(responseData);//解码

            if (resp.IndexOf("上次登录时间") != -1)
            {
                string input   = this.httpClient.DownloadString("https://service.htsc.com.cn/service/flashbusiness_new3.jsp?etfCode=");
                String infoStr = StockUtil.Base64Decode(this.GetData(input), this.GB2312);
                Console.WriteLine(infoStr);
                resAccountInfo = JsonConvert.DeserializeObject <RespAccountInfo>(infoStr);
            }
            else if (resp.IndexOf("系统升级中") != -1)
            {
                MessageBox.Show("系统升级中");
                return;
            }
            else
            {
                Login();
            }
        }
Exemple #2
0
        private T getResp <T, R>(R request)
        {
            string    queryParams = StockUtil.Base64Encode(URLHelper.GetDataWithOutEncode <R>(request), this.GB2312);
            string    sellUrl     = "https://tradegw.htsc.com.cn/?" + queryParams;
            Stopwatch watch       = new Stopwatch();

            watch.Start();
            string strResp = this.httpClient.DownloadString(sellUrl);

            Console.WriteLine("请求耗时:{0}ms", watch.ElapsedMilliseconds);
            string resp = StockUtil.Base64Decode(strResp, this.GB2312);

            Console.WriteLine("Web操作返回结果", resp);
            T ret = JsonConvert.DeserializeObject <T>(resp);

            return(ret);
        }