using HybirdFrameworkCore.Entity; using log4net; using Newtonsoft.Json; namespace Service.Execute.Api; /// /// chargeApi /// 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 StopCharge(string? binNo) { Log.Info($" ChargeApi StopCharge binNo={binNo}"); if (string.IsNullOrWhiteSpace(binNo)) { return false; } string url = BASE_URL + "/api/Charge/StopChargeByBinNo/" + binNo; try { string s = await _httpClient.GetStringAsync(url); if (!String.IsNullOrWhiteSpace(s)) { Result? succ = JsonConvert.DeserializeObject>(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; } } }