private static string BaseInvoiceValideCodeOrc(WebClient wc, string url) { Stream stream = null; MemoryStream ms = null; byte[] bytes = null; int bytesConter = 0; try { stream = wc.OpenRead(url); ms = new MemoryStream(); bytes = new byte[4096]; int actual = stream.Read(bytes, 0, bytes.Length); if (actual > 0) { ms.Write(bytes, 0, actual); bytesConter += actual; } ms.Position = 0; } catch (Exception e) { } finally { ms.Close(); stream.Close(); } string user = "******"; string psw = NetRecognizePic.MD5String("y123456"); string lpSoftId = "96001"; string lpCodeType = "1902"; string str = NetRecognizePic.CJY_RecognizeBytes(bytes, bytesConter, user, psw, lpSoftId, lpCodeType, "0", "0", ""); string strerr = GetTextByKey(str, "err_str"); if (strerr != "OK") { return(strerr); } else { return(GetTextByKey(str, "pic_str")); } }
private string JxHandWritingValideCodeOrc(string randomT, WebClient wc) { string url = "http://117.40.128.134:7002/fpcx//Validate?t=" + randomT; Stream stream = null; MemoryStream ms = null; byte[] bytes = null; int bytesConter = 0; try { //var wc = new WebClient { Encoding = Encoding.UTF8 }; //wc.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); stream = wc.OpenRead(url); ms = new MemoryStream(); bytes = new byte[4096]; int actual = stream.Read(bytes, 0, bytes.Length); if (actual > 0) { ms.Write(bytes, 0, actual); bytesConter += actual; } ms.Position = 0; } catch (Exception e) { throw e; } //try //{ // WebRequest req = WebRequest.Create(url); // stream = req.GetResponse().GetResponseStream(); // ms = new MemoryStream(); // //using (var ms = new MemoryStream()) // //{ // // await stream..CopyToAsync(ms); // // //... // //} // bytes = new byte[4096]; // int actual = stream.Read(bytes, 0, bytes.Length); // if (actual > 0) // { // ms.Write(bytes, 0, actual); // bytesConter += actual; // } // ms.Position = 0; // //stream.Read(bytes, 0, (int)stream.Length); //} finally { ms.Close(); stream.Close(); } string user = "******"; string psw = NetRecognizePic.MD5String("y123456"); string lpSoftId = "96001"; string lpCodeType = "1004"; string str = NetRecognizePic.CJY_RecognizeBytes(bytes, bytesConter, user, psw, lpSoftId, lpCodeType, "0", "0", ""); string strerr = GetTextByKey(str, "err_str"); if (strerr != "OK") { //this.richTextBox1.Text += "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + strerr + "\r\n"; //MessageBox.Show(strerr); return(strerr); } else { return(GetTextByKey(str, "pic_str")); } //string strpic_id = GetTextByKey(str, "pic_id"); //this.txtPicID.Text = strpic_id; //string strpic_str = GetTextByKey(str, "pic_str"); //this.txtshibie.Text = strpic_str; //this.richTextBox1.Text += "[" + DateTime.Now.ToString("HH:mm:ss") + "]识别结果:" + strpic_str + "\r\n"; }