You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
using HybirdFrameworkCore.Entity;
|
|
using log4net;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Service.Execute.Model;
|
|
|
|
namespace Service.Execute.Api;
|
|
/// <summary>
|
|
/// chargeApi
|
|
/// </summary>
|
|
public class ChargeApi
|
|
{
|
|
private static readonly ILog Log = LogManager.GetLogger("ChargeApi");
|
|
|
|
private static readonly string BASE_URL = "http://localhost:5035";
|
|
|
|
private static readonly HttpClient _httpClient = new HttpClient()
|
|
{
|
|
Timeout = TimeSpan.FromSeconds(60)
|
|
};
|
|
|
|
public static async Task<bool> StopCharge(string binNo)
|
|
{
|
|
Log.Info($" ChargeApi StopCharge binNo={binNo}");
|
|
string url = BASE_URL + "/api/Charge/StopChargeByBinNo/" + binNo;
|
|
try
|
|
{
|
|
string s = await _httpClient.GetStringAsync(url);
|
|
if (!String.IsNullOrWhiteSpace(s))
|
|
{
|
|
Result<bool>? succ = JsonConvert.DeserializeObject<Result<bool>>(s);
|
|
Log.Info($" ChargeApi StopCharge binNo={binNo} resp={succ.IsSuccess}");
|
|
|
|
if (succ.IsSuccess)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error($" ChargeApi StopCharge binNo={binNo} ,e={e}");
|
|
return false;
|
|
}
|
|
}
|
|
} |