|
|
@@ -2163,14 +2163,20 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
|
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(EIS_URL);
|
|
|
request.Method = "POST";
|
|
|
- request.ContentType = "application/json";
|
|
|
request.Timeout = 30 * 1000;
|
|
|
request.Headers.Add("Accesskey", EIS_ACCESSKEY);
|
|
|
request.Headers.Add("Requestid", requestId);
|
|
|
request.Headers.Add("AccessSecret", EIS_ACCESSSECRET);
|
|
|
request.Headers.Add("Signature", signature);
|
|
|
request.Headers.Add("Timestamp", timestamp);
|
|
|
- byte[] data = Encoding.UTF8.GetBytes(postData);
|
|
|
+ //接口按 form-data 方式接收:字段名固定为 data,值为上面的 JSON 字符串(与 Postman form-data 一致)
|
|
|
+ string boundary = "----Boundary" + System.DateTime.Now.Ticks.ToString("x");
|
|
|
+ request.ContentType = "multipart/form-data; boundary=" + boundary;
|
|
|
+ string formBody = "--" + boundary + "\r\n"
|
|
|
+ + "Content-Disposition: form-data; name=\"data\"\r\n\r\n"
|
|
|
+ + postData + "\r\n"
|
|
|
+ + "--" + boundary + "--\r\n";
|
|
|
+ byte[] data = Encoding.UTF8.GetBytes(formBody);
|
|
|
request.ContentLength = data.Length;
|
|
|
using (Stream rs = request.GetRequestStream())
|
|
|
{
|
|
|
@@ -2182,6 +2188,24 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
return sr.ReadToEnd();
|
|
|
}
|
|
|
}
|
|
|
+ catch (WebException wex)
|
|
|
+ {
|
|
|
+ //非 200 响应时尽量把服务端返回的报文带出来,便于排查
|
|
|
+ string respText = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (wex.Response != null)
|
|
|
+ {
|
|
|
+ using (StreamReader sr = new StreamReader(wex.Response.GetResponseStream(), Encoding.UTF8))
|
|
|
+ {
|
|
|
+ respText = sr.ReadToEnd();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ iErrorMessage = "请求EIS接口失败:" + wex.Message + (respText == "" ? "" : ",接口返回:" + respText);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
iErrorMessage = "请求EIS接口失败:" + ex.Message;
|
|
|
@@ -2272,6 +2296,21 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// MDM 注册前置校验:SN 存在于 MDMREGISTRATIONLOG 表 MRL_SNCODE 字段中时,才调用 CheckMDMRegistration 接口校验
|
|
|
+ /// 未登记或接口校验通过返回 true;接口校验不通过返回 false 并给出接口实际错误信息
|
|
|
+ /// </summary>
|
|
|
+ public static bool CheckMDMRegistrationLog(string iSN, string iMakeCode, out string oErrorMessage)
|
|
|
+ {
|
|
|
+ oErrorMessage = "";
|
|
|
+ //SN 不在 MDMREGISTRATIONLOG 中登记,无需调接口校验
|
|
|
+ if (dh.getFieldDataByCondition("MDMREGISTRATIONLOG", "count(1)", "MRL_SNCODE='" + iSN + "'").ToString() == "0")
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return CheckMDMRegistration(iSN, iMakeCode, User.UserSourceCode, User.UserCode, out oErrorMessage);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 取 JSON 对象里的字符串值(键不存在或值为 null 时返回空串)
|
|
|
/// </summary>
|