From 7d6194cf002b8f54d41cdc50b7f1b1843c1da636 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期四, 15 一月 2026 13:14:21 +0800
Subject: [PATCH] MES接口

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs"
index c020a67..26edc82 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs"
@@ -13,6 +13,7 @@
 {
     public class HttpHelper
     {
+        private const int Timeout = 60 * 1000;
         public static async Task<string> GetAsync(string serviceAddress, Dictionary<string, string>? headers = null)
         {
             string result = string.Empty;
@@ -132,5 +133,61 @@
                 Logger.Add(serviceAddress, requestJson, result, beginDate);
             }
         }
+
+        /// <summary>
+        /// post璇锋眰
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="parm">鍙傛暟</param>
+        /// <param name="rquestName">鎺ュ彛鍚嶇О,鐢ㄤ簬鏃ュ織鍒嗙被</param>
+        /// <returns></returns>
+        public static T Post<T>(string url, object parm, string rquestName = "") where T : class
+        {
+            HttpWebResponse response = null;
+            StreamReader resultReader = null;
+            string responseContent = string.Empty;
+            try
+            {
+                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+                request.Timeout = Timeout;
+                request.Method = "POST";
+                request.ContentType = "application/json; charset=UTF-8";
+                parm = parm ?? "";
+                byte[] data = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(parm));
+                request.ContentLength = data.Length;
+                using (Stream newStream = request.GetRequestStream())
+                {
+                    newStream.Write(data, 0, data.Length);
+                }
+                ;
+
+                response = (HttpWebResponse)request.GetResponse();
+                Stream webStream = response.GetResponseStream();
+                if (webStream == null)
+                {
+                    throw new Exception("Network error");
+                }
+
+                int statsCode = (int)response.StatusCode;
+                resultReader = new StreamReader(webStream, Encoding.UTF8);
+                responseContent = resultReader.ReadToEnd();
+
+                if (response != null)
+                    response.Close();
+                if (resultReader != null)
+                    resultReader.Close();
+
+                if (statsCode != 200)
+                {
+                    throw new Exception("寮傚父锛屽搷搴旂爜锛�" + statsCode.ToString());
+                }
+
+                return JsonConvert.DeserializeObject<T>(responseContent);
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
     }
 }

--
Gitblit v1.9.3