Compare commits
No commits in common. "56e6ef249dbb6dd9b36054af98dd3b36f01e38eb" and "e006ea75e4d5e527f96cb6e7e55b1947b383d9d5" have entirely different histories.
56e6ef249d
...
e006ea75e4
|
@ -23,16 +23,12 @@ namespace AIParkingApplication
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.apiController = apiController;
|
this.apiController = apiController;
|
||||||
this.configOnWeb = configOnWeb;
|
this.configOnWeb = configOnWeb;
|
||||||
c3Device = new C3DeviceController("192.168.1.200");
|
|
||||||
|
|
||||||
sidebar = new Sidebar(apiController);
|
sidebar = new Sidebar(apiController);
|
||||||
sidebar.Location = new Point(0, 0);
|
sidebar.Location = new Point(0, 0);
|
||||||
Controls.Add(sidebar);
|
Controls.Add(sidebar);
|
||||||
|
|
||||||
statusBar = new StatusBar("192.168.1.122", "192.168.1.200", TimeSpan.FromSeconds(1));
|
c3Device = new C3DeviceController("192.168.1.200");
|
||||||
statusBar.Location = new Point(0, sidebar.Location.Y + sidebar.Height + 26);
|
|
||||||
statusBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
Controls.Add(statusBar);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -44,6 +40,11 @@ namespace AIParkingApplication
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statusBar = new StatusBar("192.168.1.122", "192.168.1.200", TimeSpan.FromSeconds(1));
|
||||||
|
statusBar.Location = new Point(0, sidebar.Location.Y + sidebar.Height + 26);
|
||||||
|
statusBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
Controls.Add(statusBar);
|
||||||
|
|
||||||
InitAllLanes();
|
InitAllLanes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,17 @@ namespace AIParkingApplication
|
||||||
private const int MAX_REQUEST = 3;
|
private const int MAX_REQUEST = 3;
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
private bool isHttpClientDisposabled;
|
private bool isHttpClientDisposabled;
|
||||||
|
private int numberOfRetry;
|
||||||
|
|
||||||
public ApiController(string baseAddress, int numberOfRetry = 5)
|
public ApiController(string baseAddress, int numberOfRetry = 5)
|
||||||
{
|
{
|
||||||
httpClient = new HttpClient
|
httpClient = new HttpClient
|
||||||
{
|
{
|
||||||
BaseAddress = new Uri(baseAddress),
|
BaseAddress = new Uri(baseAddress),
|
||||||
Timeout = TimeSpan.FromSeconds(1)
|
Timeout = TimeSpan.FromSeconds(5)
|
||||||
};
|
};
|
||||||
isHttpClientDisposabled = false;
|
isHttpClientDisposabled = false;
|
||||||
|
this.numberOfRetry = numberOfRetry;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ApiController()
|
~ApiController()
|
||||||
|
@ -89,7 +91,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
||||||
requestCounter += 1;
|
requestCounter += 1;
|
||||||
await Task.Delay(100);
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
||||||
|
|
||||||
|
@ -100,7 +102,7 @@ namespace AIParkingApplication
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
||||||
return null;
|
return new CardInformation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,8 +135,9 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
|
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
|
||||||
requestCounter += 1;
|
requestCounter += 1;
|
||||||
await Task.Delay(100);
|
Thread.Sleep(100);
|
||||||
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
}
|
||||||
|
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
|
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
|
||||||
return saveLogRespone;
|
return saveLogRespone;
|
||||||
|
|
|
@ -56,11 +56,6 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
ClearPlateAndOverviewImage();
|
ClearPlateAndOverviewImage();
|
||||||
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
|
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
|
||||||
if (cardInfoResult == null)
|
|
||||||
{
|
|
||||||
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!cardInfoResult.IsValid)
|
if (!cardInfoResult.IsValid)
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
|
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
|
||||||
|
|
|
@ -59,11 +59,6 @@ namespace AIParkingApplication
|
||||||
ClearPlateAndOverviewImage();
|
ClearPlateAndOverviewImage();
|
||||||
ClearPlateAndOverviewImageIn();
|
ClearPlateAndOverviewImageIn();
|
||||||
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
|
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
|
||||||
if (cardInfoResult == null)
|
|
||||||
{
|
|
||||||
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!cardInfoResult.IsValid)
|
if (!cardInfoResult.IsValid)
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
|
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user