コード例 #1
0
ファイル: MainFrm.cs プロジェクト: chfism/AuctionConsole
        private void btnLogon_Click(object sender, EventArgs e)
        {
            _imagenumber = txtImageNumber.Text;
            var request = (HttpWebRequest)WebRequest.Create("https://paimai.alltobid.com/webwcf/BidCmd.svc/WebCmd");

            _timestamp = gettimestamp_JS();
            _requestid = getrequestid_JS();
            var dto = new LoginDto
            {
                version   = _version,
                timestamp = _timestamp,
                bidnumber = _bidnumber,
                requestid = _requestid,
                checkcode = EncryptWithMD5(EncryptWithMD5(_bidnumber + _bidpassword) + _bidnumber + _imagenumber + _idcard + _requestid + _uniqueid + _version),
                request   = new LoginRequestDto
                {
                    info        = _info,
                    uniqueid    = _uniqueid,
                    bidnumber   = _bidnumber,
                    bidpassword = EncryptWithMD5(_bidnumber + _bidpassword),
                    imagenumber = _imagenumber,
                    idcard      = _idcard,
                    clientId    = _clientId,
                    idtype      = _idtype
                }
            };

            var json        = JsonConvert.SerializeObject(dto);
            var encodedJson = HttpUtility.UrlEncode(json);

            var postData = new WebCmdDto
            {
                method = "login",
                cmd    = encodedJson
            };

            var postDataJson = JsonConvert.SerializeObject(postData);

            var data = Encoding.ASCII.GetBytes(postDataJson);

            request.Method        = "POST";
            request.ContentType   = "application/json";
            request.ContentLength = data.Length;
            request.Referer       = "https://paimai2.alltobid.com/bid/2017111801/login.htm";


            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            var response       = (HttpWebResponse)request.GetResponse();
            var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();

            SetCookie(JsonConvert.DeserializeObject(responseString));
        }
コード例 #2
0
ファイル: MainFrm.cs プロジェクト: chfism/AuctionConsole
        private void btnGetImageCode_Click(object sender, EventArgs e)
        {
            _bidnumber   = txtBidNumber.Text;
            _bidpassword = txtPassword.Text;
            _idcard      = txtidcard.Text;
            _timestamp   = gettimestamp_JS();
            _requestid   = _timestamp;

            //var request = (HttpWebRequest)WebRequest.Create("https://paimai2.alltobid.com/webwcf/BidCmd.svc/WebCmd");
            var request = (HttpWebRequest)WebRequest.Create("https://paimai.alltobid.com/webwcf/BidCmd.svc/WebCmd");

            var dto = new ImageCodeDto
            {
                version   = _version,
                timestamp = _timestamp,
                requestid = _requestid,
                request   = { }, //request={}
                checkcode = EncryptWithMD5(_timestamp + _requestid + _version)
            };

            var json        = JsonConvert.SerializeObject(dto);
            var encodedJson = HttpUtility.UrlEncode(json);

            var postData = new WebCmdDto
            {
                method = "getimagecode",
                cmd    = encodedJson
            };

            var postDataJson = JsonConvert.SerializeObject(postData);

            var data = Encoding.ASCII.GetBytes(postDataJson);

            request.Method        = "POST";
            request.ContentType   = "application/json";
            request.ContentLength = data.Length;
            request.Referer       = "https://paimai.alltobid.com/pubbid/2017112001/login.htm";


            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            var response       = (HttpWebResponse)request.GetResponse();
            var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            var imagedata      = responseString.Substring(responseString.IndexOf("data") + 9, 36);

            _uniqueid = imagedata;
            var imgurl = responseString.Substring(responseString.IndexOf("data") + 9 + 36 + 1, 81).Replace("\\", "");

            pictureBoxLogin.Load(imgurl);
        }