From 2187fcbff389c2a7cc799845410580b37abfe921 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 21 十月 2024 10:31:19 +0800
Subject: [PATCH] mom交互

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs
index b06c608..0800faf 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs
@@ -13,7 +13,7 @@
     private static readonly LogFactory LogFactory = new LogFactory();
 
     // 灏佽涓�涓敤HttpClient鍙戦�丟ET璇锋眰鐨勬柟娉曟湁鍙傛暟
-    public static async Task<string> GetAsync(string url, Dictionary<string, string> parameters)
+    public static async Task<string> GetAsync(string url, Dictionary<string, object> parameters)
     {
         // 璁板綍璇锋眰鍙傛暟
         LogRequestParameters(parameters);
@@ -43,7 +43,7 @@
     }
 
     // 灏佽涓�涓敤HttpClient鍙戦�丳ost璇锋眰鐨勬柟娉曟湁鍙傛暟
-    public static async Task<string> PostAsync(string url, Dictionary<string, string> parameters)
+    public static async Task<string> PostAsync(string url, Dictionary<string, object> parameters)
     {
         // 璁板綍璇锋眰鍙傛暟
         LogRequestParameters(parameters);
@@ -52,7 +52,7 @@
         using (HttpClient client = new HttpClient())
         {
             // 灏嗗弬鏁拌浆鎹负FormUrlEncodedContent
-            FormUrlEncodedContent content = new FormUrlEncodedContent(parameters);
+            var content = new FormUrlEncodedContent(ConvertToKeyValuePairs(parameters));
 
             // 鍙戦�丳OST璇锋眰骞惰幏鍙栧搷搴�
             HttpResponseMessage response = await client.PostAsync(url, content);
@@ -71,7 +71,7 @@
         }
     }
 
-    private static void LogRequestParameters(Dictionary<string, string> parameters)
+    private static void LogRequestParameters(Dictionary<string, object> parameters)
     {
         LogFactory.GetLog("API鎺ュ彛").Info(true, "璇锋眰鍙傛暟: " + JsonConvert.SerializeObject(parameters));
     }
@@ -80,4 +80,13 @@
     {
         LogFactory.GetLog("API鎺ュ彛").Info(true, "鍝嶅簲鍙傛暟: " + responseBody);
     }
+
+    private static IEnumerable<KeyValuePair<string, string>> ConvertToKeyValuePairs(Dictionary<string, object> parameters)
+    {
+        foreach (var kvp in parameters)
+        {
+            yield return new KeyValuePair<string, string>(kvp.Key, kvp.Value?.ToString());
+        }
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3