| | |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Text; |
| | | using Newtonsoft.Json.Linq; |
| | | |
| | | namespace HH.WCS.Mobox3.NFLZ.util { |
| | | public class HttpHelper { |
| | | public string WebPost(string url, string postData, string cotentType = "application/json",string AppKey="",string ReqTime="",string ReqVerify="") { |
| | | public string WebPost(string url, string postData, string cotentType = "application/json",string AppKey="",string ReqTime="",string ReqVerify="", bool Extend = false) { |
| | | Console.WriteLine(url); |
| | | WebRequest request = WebRequest.Create(url); |
| | | request.Method = "POST"; |
| | | |
| | | if (!string.IsNullOrEmpty(AppKey) && !string.IsNullOrEmpty(ReqTime) && !string.IsNullOrEmpty(ReqVerify)) |
| | | if (Settings.ProjectName == "农夫林芝") |
| | | { |
| | | request.Headers.Set("AppKey", AppKey); |
| | | request.Headers.Set("ReqTime", ReqTime); |
| | | request.Headers.Set("ReqVerify", ReqVerify); |
| | | if (!string.IsNullOrEmpty(AppKey) && (!string.IsNullOrEmpty(ReqTime))) |
| | | { |
| | | request.Headers.Set("token", AppKey);//MD5加密后Token值 |
| | | request.Headers.Set("from", "MOBOX");//来源系统号 |
| | | request.Headers.Set("timestamp", ReqTime);//时间戳 |
| | | if (Extend) request.Headers.Set("proxyInterfaceCode", Settings.OneSign);//MES任务回报接口添加 唯一标识 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!string.IsNullOrEmpty(AppKey) && !string.IsNullOrEmpty(ReqTime) && !string.IsNullOrEmpty(ReqVerify)) |
| | | { |
| | | request.Headers.Set("AppKey", AppKey); |
| | | request.Headers.Set("ReqTime", ReqTime); |
| | | request.Headers.Set("ReqVerify", ReqVerify); |
| | | } |
| | | } |
| | | |
| | | //string postData = JsonConvert.SerializeObject(data); ; |
| | | byte[] byteArray = Encoding.UTF8.GetBytes(postData); |
| | | request.ContentType = cotentType; |