1.出库界面展示当前正在进行出库的单据
2.后台退出了入库模式 通知前台扫码枪退出入库 3.对接盟讯公司登录Mes接口 4.接口记录增加本地日志排查问题
This commit is contained in:
@ -312,5 +312,47 @@ namespace WCS.BLL.Tool
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public static T GetDataFromHttpShortTime<T>(string url, object dataObj, string httpMethod, bool isSaveLog = false)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
var data = dataObj == null ? string.Empty : JsonConvert.SerializeObject(dataObj);
|
||||
try
|
||||
{
|
||||
if (isSaveLog)
|
||||
Logs.Write($"【{guid}】开始请求调用接口 url:{url} 请求方式:{httpMethod} 数据:{data}", LogsType.Api);
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = httpMethod;
|
||||
request.ContentType = "application/json";
|
||||
request.Timeout = 2000;
|
||||
|
||||
if (!string.IsNullOrEmpty(data))
|
||||
{
|
||||
string strContent = data; //参数data
|
||||
using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
|
||||
{
|
||||
dataStream.Write(strContent);
|
||||
dataStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
string encoding = response.ContentEncoding;
|
||||
if (encoding == null || encoding.Length < 1)
|
||||
{
|
||||
encoding = "UTF-8"; //默认编码
|
||||
}
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
|
||||
string retString = reader.ReadToEnd();
|
||||
if (isSaveLog)
|
||||
Logs.Write($"【{guid}】请求调用接口结束 返回数据为{retString}", LogsType.Api);
|
||||
return JsonConvert.DeserializeObject<T>(retString);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"【{guid}】请求调用遇到异常 异常信息为{ex.Message}");
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user