From b590abad7231b78b22279fe9ef3633caebc91b25 Mon Sep 17 00:00:00 2001 From: xxe Date: Fri, 23 Sep 2022 11:19:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0try?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKCardIN/Logic/BaseLogic.cs | 62 ++++++++++++++++++++-------- HKCardIN/ViewModels/RootViewModel.cs | 2 + 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/HKCardIN/Logic/BaseLogic.cs b/HKCardIN/Logic/BaseLogic.cs index 06a5242..4ca3c2c 100644 --- a/HKCardIN/Logic/BaseLogic.cs +++ b/HKCardIN/Logic/BaseLogic.cs @@ -1,6 +1,7 @@ using HandyControl.Controls; using HKCardIN.Helper; using HKCardIN.Logic.Model; +using HKLog; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -22,12 +23,20 @@ namespace HKCardIN.Logic /// public UserAndCardInfo PullUserAndCardInfo(string CardNo) { - return IHttpMultiClient.HttpMulti.AddNode(t => - { - t.NodePath = ApiRoute.PullUserAndCardInfo; - t.ReqType = MultiType.POST; - t.JsonParam = (new { cardNum = CardNo }).ToJson(); - }).Build().RunStringFirst().ToModel()["data"].ToJson().ToModel(); + try + { + return IHttpMultiClient.HttpMulti.AddNode(t => + { + t.NodePath = ApiRoute.PullUserAndCardInfo; + t.ReqType = MultiType.POST; + t.JsonParam = (new { cardNum = CardNo }).ToJson(); + }).Build().RunStringFirst().ToModel()["data"].ToJson().ToModel(); + } + catch (Exception ex) + { + HKLogImport.WriteError(ex); + return null; + } } /// /// 同步充值记录 @@ -36,13 +45,22 @@ namespace HKCardIN.Logic /// public bool PushMoneyToServer(string CardNo, decimal Money) { - var data = IHttpMultiClient.HttpMulti.AddNode(t => + try + { + var data = IHttpMultiClient.HttpMulti.AddNode(t => + { + t.NodePath = ApiRoute.PushMoneyToServer; + t.ReqType = MultiType.POST; + t.JsonParam = (new { Money, Type = 1, CardNum = CardNo }).ToJson(); + }).Build().RunStringFirst(); + return bool.Parse(data.ToModel()["data"].ToString()); + } + catch (Exception ex) { - t.NodePath = ApiRoute.PushMoneyToServer; - t.ReqType = MultiType.POST; - t.JsonParam = (new { Money, Type = 1, CardNum = CardNo }).ToJson(); - }).Build().RunStringFirst(); - return bool.Parse(data.ToModel()["data"].ToString()); + HKLogImport.WriteError(ex); + return false; + } + } /// /// 根据会员手机获取卡号 @@ -51,12 +69,20 @@ namespace HKCardIN.Logic /// public UserAndCardInfo GetCardNoByPhone(string Phone) { - var data = IHttpMultiClient.HttpMulti.AddNode(t => { - t.NodePath = ApiRoute.GetCardNoByPhone; - t.ReqType = MultiType.POST; - t.JsonParam = (new { phone = Phone }).ToJson(); - }).Build().RunStringFirst().ToModel()["data"].ToJson().ToModel(); - return data; + try + { + var data = IHttpMultiClient.HttpMulti.AddNode(t => { + t.NodePath = ApiRoute.GetCardNoByPhone; + t.ReqType = MultiType.POST; + t.JsonParam = (new { phone = Phone }).ToJson(); + }).Build().RunStringFirst(); + return data.ToModel()["data"].ToJson().ToModel(); + } + catch (Exception ex) + { + HKLogImport.WriteError(ex); + return null; + } } } } diff --git a/HKCardIN/ViewModels/RootViewModel.cs b/HKCardIN/ViewModels/RootViewModel.cs index fc3a272..0a8ca1e 100644 --- a/HKCardIN/ViewModels/RootViewModel.cs +++ b/HKCardIN/ViewModels/RootViewModel.cs @@ -156,6 +156,8 @@ namespace HKCardIN.ViewModels } private void MainThread() { + CardView view = new CardView(); + view.Show(); ThreadManage.GetInstance().StartLong(new Action(() => { try