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.
46 lines
1.1 KiB
46 lines
1.1 KiB
using HybirdFrameworkCore.Entity;
|
|
using log4net;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Service.Execute.Model;
|
|
|
|
namespace Service.Execute.Api;
|
|
|
|
public class ChargeApi
|
|
{
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(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("StopCharge");
|
|
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);
|
|
if (succ.IsSuccess)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
return false;
|
|
}
|
|
}
|
|
} |