From e998e67f3b017d41b4f1c322301c1e8a4bc7c241 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 18 十二月 2024 17:53:57 +0800
Subject: [PATCH] 截取返回金蝶报错信息
---
CLOUDWEB/Model/KingdeeResponse.cs | 53 ++++++++++++++++++++++++++
CLOUDWEB/CLOUDWEB.csproj | 1
CLOUDWEB/WebService1.asmx.cs | 13 ++++++
3 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/CLOUDWEB/CLOUDWEB.csproj b/CLOUDWEB/CLOUDWEB.csproj
index 3ee1257..fd08476 100644
--- a/CLOUDWEB/CLOUDWEB.csproj
+++ b/CLOUDWEB/CLOUDWEB.csproj
@@ -318,6 +318,7 @@
</Compile>
<Compile Include="Log.cs" />
<Compile Include="LogService.cs" />
+ <Compile Include="Model\KingdeeResponse.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Site.Master.cs">
<DependentUpon>Site.Master</DependentUpon>
diff --git a/CLOUDWEB/Model/KingdeeResponse.cs b/CLOUDWEB/Model/KingdeeResponse.cs
new file mode 100644
index 0000000..5afd452
--- /dev/null
+++ b/CLOUDWEB/Model/KingdeeResponse.cs
@@ -0,0 +1,53 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CLOUDWEB
+{
+ public class KingdeeResponse
+ {
+ public _Result Result { get; set; }
+ }
+
+ public class _Result
+ {
+ public _ResponseStatus ResponseStatus { get; set; }
+ }
+
+ public class _ResponseStatus
+ {
+ public int ErrorCode { get; set; }
+ public bool IsSuccess { get; set; }
+
+ private List<_Error> _errors;
+ public List<_Error> Errors
+ {
+ get; set;
+ } = new List<_Error>();
+
+ private List<_SuccessEntity> _successEntitys;
+ public List<_SuccessEntity> SuccessEntitys
+ {
+ get; set;
+ }
+ public int MsgCode { get; set; }
+ }
+
+ public class _Error
+ {
+ public string FieldName { get; set; }
+ public string Message { get; set; }
+ public int DIndex { get; set; }
+ //閿欒鐨勫崟鎹紪鍙�
+ public string FNumber { get; set; }
+ }
+
+ public class _SuccessEntity
+ {
+ public int Id { get; set; }
+ public string Number { get; set; }
+ public int DIndex { get; set; }
+ }
+}
diff --git a/CLOUDWEB/WebService1.asmx.cs b/CLOUDWEB/WebService1.asmx.cs
index 1ce2a15..90f9de0 100644
--- a/CLOUDWEB/WebService1.asmx.cs
+++ b/CLOUDWEB/WebService1.asmx.cs
@@ -7,6 +7,7 @@
using System.Web.Services;
using System.Data.SqlClient;
using System.Globalization;
+using Newtonsoft.Json;
namespace CLOUDWEB
{
@@ -32937,7 +32938,17 @@
if (HReturn.Contains("\"IsSuccess\":false") == true)
{
- sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + HReturn;
+ //鍙嶅簭鍒楀寲json鏁版嵁
+ var retModel = JsonConvert.DeserializeObject<KingdeeResponse>(result);
+ //鎺ユ敹閲戣澏鎶ラ敊淇℃伅
+ var strErrorMsg = string.Empty;
+ //閬嶅巻鑾峰彇鎶ラ敊淇℃伅
+ foreach (var item in retModel.Result.ResponseStatus.Errors)
+ {
+ strErrorMsg += item.Message + "\r\n";
+ };
+
+ sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + strErrorMsg;
LogService.Write("鐢熸垚鐢熶骇鍏ュ簱鍗曪紙婧愬崟锛氱敓浜т换鍔″崟锛夊け璐ワ紒" + HReturn + sJson); //鍐欏叆txt鏂囨湰
oCn.RollBack();
return false;
--
Gitblit v1.9.1