Util - use static HttpClient httpClientEngine as field.
This commit is contained in:
parent
148896423f
commit
cc92f80a45
|
@ -10,6 +10,8 @@ namespace AIParkingApplication
|
|||
{
|
||||
public static class Util
|
||||
{
|
||||
private static HttpClient httpClientEngine = new HttpClient { BaseAddress = new Uri("http://localhost:8080/"), Timeout = TimeSpan.FromMilliseconds(5000) };
|
||||
|
||||
public static bool IsPingable(string destinationIPAddress, out long pingTime, int timeOut = UtilConstant.PING_TIMEOUT_MS)
|
||||
{
|
||||
var pingTask = Task.Factory.StartNew(async () =>
|
||||
|
@ -55,19 +57,16 @@ namespace AIParkingApplication
|
|||
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
|
||||
try
|
||||
{
|
||||
using (var client = new HttpClient { BaseAddress = new Uri("http://localhost:8080/"), Timeout = TimeSpan.FromMilliseconds(5000) })
|
||||
var request = new PlateRequestEngineModel
|
||||
{
|
||||
var request = new PlateRequestEngineModel
|
||||
{
|
||||
Img64 = plateImageBase64,
|
||||
Mode = plateType == PlateType.Square ? "square" : "long",
|
||||
Display = "full"
|
||||
};
|
||||
HttpResponseMessage response = await client.PostAsJsonAsync("/get-from-frame", request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var ocrResult = await response.Content.ReadAsAsync<OcrResult>();
|
||||
return ocrResult;
|
||||
}
|
||||
Img64 = plateImageBase64,
|
||||
Mode = plateType == PlateType.Square ? "square" : "long",
|
||||
Display = "full"
|
||||
};
|
||||
HttpResponseMessage response = await httpClientEngine.PostAsJsonAsync("/get-from-frame", request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var ocrResult = await response.Content.ReadAsAsync<OcrResult>();
|
||||
return ocrResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user