From 1fd3d68af8a566e01b9593db0361e53647e686bc Mon Sep 17 00:00:00 2001 From: "nodyang@aliyun.com" Date: Thu, 12 Dec 2024 12:33:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86json=20=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiParam/CsbResult.cs | 26 ++++++++++++++++--- .../SelectRouterWindow.xaml.cs | 6 +++-- .../ContainerTransferOrderViewModel.cs | 4 +-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs b/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs index 4cf6939..d76d2e3 100644 --- a/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs +++ b/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs @@ -1,6 +1,10 @@ -using System; +using Newtonsoft.Json.Linq; + +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Text; +using Newtonsoft.Json; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -32,9 +36,25 @@ namespace SlnMesnac.RfidUpload.Model.apiParam public string msg { get; set; } - public List @object { get; set; } + // public List @object { get; set; } + + public bool IsSuccess => code == "200"; + + public List ToObjectList() + { + JObject job = JObject.Parse(body); + string str = job["retBody"]?["object"]?.ToString(); + if (!string.IsNullOrEmpty(str)) + { + List institutionList = JsonConvert.DeserializeObject>(str); + return institutionList; + + } + + return new List(); + } - public string body { get; set; } + public string body { get; set; } public string code { get; set; } public string csbCode { get; set; } diff --git a/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs b/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs index bf2c8ce..0368f28 100644 --- a/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs +++ b/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs @@ -72,9 +72,11 @@ namespace SlnMesnac.RfidUpload.UI CsbResult res = csbHandleBusiness.findStationSequenceByCsb(_transferOrderInfo.ffjhNo, opBatch); if (res.code == "200") { - if (res.@object != null && res.@object.Count > 0) + if (res.IsSuccess) { - List institutionList = res.@object.ConvertAll(item => JsonConvert.DeserializeObject(item.ToString())); + List institutionList = res.ToObjectList(); + + // res.@object.ConvertAll(item => JsonConvert.DeserializeObject(item.ToString())); int count = 1; Console.WriteLine("机构信息:"); foreach (var institution in institutionList) diff --git a/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs b/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs index 2695eb6..6beee74 100644 --- a/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs +++ b/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs @@ -139,9 +139,9 @@ namespace SlnMesnac.RfidUpload.UI.viewModel MessageBox.Show(res.message); if (res.code == "200") { - if (res.@object != null && res.@object.Count > 0) + if (res.IsSuccess) { - List institutionList = res.@object.ConvertAll(item => JsonConvert.DeserializeObject(item.ToString())); + List institutionList = res.ToObjectList(); TransferOrderInfoItems = new ObservableCollection(institutionList); } }