From 75e3bca44b111c167b9389e4e51b2ce577a9f9e0 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期日, 10 八月 2025 10:35:50 +0800
Subject: [PATCH] 优化更新
---
WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs b/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs
index adbae83..275eeae 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs
@@ -78,19 +78,26 @@
return null;
}
- public static string Post(string serviceAddress, string requestJson = null, string contentType = "application/json", Dictionary<string, string>? headers = null)
+ public static string Post(string serviceAddress, string requestJson = "", string contentType = "application/json", Dictionary<string, string>? headers = null)
{
+ string result = string.Empty;
+ DateTime beginDate = DateTime.Now;
try
{
- string result = string.Empty;
using (HttpContent httpContent = new StringContent(requestJson))
{
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
using HttpClient httpClient = new HttpClient();
httpClient.Timeout = new TimeSpan(0, 0, 60);
-
- foreach (var header in headers)
- httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
+ if (serviceAddress.Contains("cimforce/AtomJsonService"))
+ {
+ httpClient.Timeout = new TimeSpan(0, 0, 30);
+ }
+ if (headers != null)
+ {
+ foreach (var header in headers)
+ httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
+ }
result = httpClient.PostAsync(serviceAddress, httpContent).Result.Content.ReadAsStringAsync().Result;
}
@@ -98,9 +105,12 @@
}
catch (Exception e)
{
- Console.WriteLine(e.Message);
+ throw new Exception(e.Message);
}
- return null;
+ finally
+ {
+ //Logger.Add(serviceAddress, requestJson, result, beginDate);
+ }
}
/// <summary>
/// post璇锋眰
--
Gitblit v1.9.3