Browse Source

添加try

Lishi
xxe 2 years ago
parent
commit
b590abad72
2 changed files with 46 additions and 18 deletions
  1. +44
    -18
      HKCardIN/Logic/BaseLogic.cs
  2. +2
    -0
      HKCardIN/ViewModels/RootViewModel.cs

+ 44
- 18
HKCardIN/Logic/BaseLogic.cs View File

@@ -1,6 +1,7 @@
using HandyControl.Controls; using HandyControl.Controls;
using HKCardIN.Helper; using HKCardIN.Helper;
using HKCardIN.Logic.Model; using HKCardIN.Logic.Model;
using HKLog;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -22,12 +23,20 @@ namespace HKCardIN.Logic
/// <returns></returns> /// <returns></returns>
public UserAndCardInfo PullUserAndCardInfo(string CardNo) 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<JObject>()["data"].ToJson().ToModel<UserAndCardInfo>();
try
{
return IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PullUserAndCardInfo;
t.ReqType = MultiType.POST;
t.JsonParam = (new { cardNum = CardNo }).ToJson();
}).Build().RunStringFirst().ToModel<JObject>()["data"].ToJson().ToModel<UserAndCardInfo>();
}
catch (Exception ex)
{
HKLogImport.WriteError(ex);
return null;
}
} }
/// <summary> /// <summary>
/// 同步充值记录 /// 同步充值记录
@@ -36,13 +45,22 @@ namespace HKCardIN.Logic
/// <returns></returns> /// <returns></returns>
public bool PushMoneyToServer(string CardNo, decimal Money) 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<JObject>()["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<JObject>()["data"].ToString());
HKLogImport.WriteError(ex);
return false;
}
} }
/// <summary> /// <summary>
/// 根据会员手机获取卡号 /// 根据会员手机获取卡号
@@ -51,12 +69,20 @@ namespace HKCardIN.Logic
/// <returns></returns> /// <returns></returns>
public UserAndCardInfo GetCardNoByPhone(string Phone) 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<JObject>()["data"].ToJson().ToModel<UserAndCardInfo>();
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<JObject>()["data"].ToJson().ToModel<UserAndCardInfo>();
}
catch (Exception ex)
{
HKLogImport.WriteError(ex);
return null;
}
} }
} }
} }

+ 2
- 0
HKCardIN/ViewModels/RootViewModel.cs View File

@@ -156,6 +156,8 @@ namespace HKCardIN.ViewModels
} }
private void MainThread() private void MainThread()
{ {
CardView view = new CardView();
view.Show();
ThreadManage.GetInstance().StartLong(new Action(() => ThreadManage.GetInstance().StartLong(new Action(() =>
{ {
try try


Loading…
Cancel
Save