Compare commits
3 Commits
e006ea75e4
...
56e6ef249d
Author | SHA1 | Date | |
---|---|---|---|
56e6ef249d | |||
34d0054b01 | |||
85ec2e8559 |
|
@ -23,12 +23,16 @@ 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);
|
||||||
|
|
||||||
c3Device = new C3DeviceController("192.168.1.200");
|
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);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -40,11 +44,6 @@ 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,17 +13,15 @@ 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(5)
|
Timeout = TimeSpan.FromSeconds(1)
|
||||||
};
|
};
|
||||||
isHttpClientDisposabled = false;
|
isHttpClientDisposabled = false;
|
||||||
this.numberOfRetry = numberOfRetry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~ApiController()
|
~ApiController()
|
||||||
|
@ -91,7 +89,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
||||||
requestCounter += 1;
|
requestCounter += 1;
|
||||||
Thread.Sleep(100);
|
await Task.Delay(100);
|
||||||
}
|
}
|
||||||
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
||||||
|
|
||||||
|
@ -102,7 +100,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 new CardInformation();
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,9 +133,8 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
|
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
|
||||||
requestCounter += 1;
|
requestCounter += 1;
|
||||||
Thread.Sleep(100);
|
await Task.Delay(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,6 +56,11 @@ 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,6 +59,11 @@ 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