From dc1a2cac65d1abadabda8b5fb3977199100d2cb3 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期四, 25 十二月 2025 08:55:24 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs |   52 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 17 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs"
index 659a98c..0ee3520 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs"
@@ -8,6 +8,8 @@
 using System.Text.Json;
 using System.Threading;
 using System.Threading.Tasks;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.LogHelper;
 using WIDESEA_DTO.Basic;
 using WIDESEA_IBasicService;
 
@@ -66,6 +68,8 @@
                 var result = await PostAsync<TaskModel, ApiResponse<TasksData>>(url, request);
                 if (result != null && result.Code == 0)
                 {
+                    _logger.LogInformation(result.Serialize());
+
                     return true;
                 }
                 return false;
@@ -76,31 +80,45 @@
                 return false;
             }
         }
- 
+
 
 
         private async Task<TResponse> PostAsync<TRequest, TResponse>(string url, TRequest request)
         {
-
-            string json = JsonConvert.SerializeObject(request, new JsonSerializerSettings
+            TResponse response1 = (TResponse)Activator.CreateInstance(typeof(TResponse));
+            try
             {
-                ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
-            });
-            var content = new StringContent(json, Encoding.UTF8, "application/json");
-            var _client = _httpClientFactory.CreateClient("ESSUrl");
-            _client.DefaultRequestHeaders.Clear();
+                string json = JsonConvert.SerializeObject(request, new JsonSerializerSettings
+                {
+                    ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
+                });
+                var content = new StringContent(json, Encoding.UTF8, "application/json");
+                var _client = _httpClientFactory.CreateClient("ESSUrl");
+                _client.DefaultRequestHeaders.Clear();
 
-            _client.DefaultRequestHeaders.Add("Accept", "application/json");
+                _client.DefaultRequestHeaders.Add("Accept", "application/json");
 
-            using var response = await _client.PostAsync(url, content);
-            string body = await response.Content.ReadAsStringAsync();
-            _logger.LogInformation($"ESSAPI post :  {_client.BaseAddress}  {url}   {body}");
-            if (!response.IsSuccessStatusCode)
-            {
-                throw new HttpRequestException(body);
+                using var response = await _client.PostAsync(url, content);
+                string body = await response.Content.ReadAsStringAsync();
+                _logger.LogInformation($"ESSAPI post :  {_client.BaseAddress}  {url}   {body}");
+                if (!response.IsSuccessStatusCode)
+                {
+                    throw new HttpRequestException(body);
+                }
+
+                response1 = JsonConvert.DeserializeObject<TResponse>(body);
+
+                return response1;
             }
-
-            return JsonConvert.DeserializeObject<TResponse>(body);
+            catch (Exception ex)
+            {
+                Logger.Add(request == null ? "" : JsonConvert.SerializeObject(request), response1 == null ? ex.ToString() : JsonConvert.SerializeObject(response1));
+                throw new Exception(ex.Message);
+            }
+            finally
+            {
+                Logger.Add(request == null ? "" : JsonConvert.SerializeObject(request), response1 == null ? "" : JsonConvert.SerializeObject(response1));
+            }
 
         }
     }

--
Gitblit v1.9.3