Compare commits
3 Commits
e006ea75e4
...
56e6ef249d
Author | SHA1 | Date | |
---|---|---|---|
56e6ef249d | |||
34d0054b01 | |||
85ec2e8559 |
|
@ -23,12 +23,16 @@ namespace AIParkingApplication
|
|||
InitializeComponent();
|
||||
this.apiController = apiController;
|
||||
this.configOnWeb = configOnWeb;
|
||||
c3Device = new C3DeviceController("192.168.1.200");
|
||||
|
||||
sidebar = new Sidebar(apiController);
|
||||
sidebar.Location = new Point(0, 0);
|
||||
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
|
||||
{
|
||||
|
@ -40,11 +44,6 @@ namespace AIParkingApplication
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,17 +13,15 @@ namespace AIParkingApplication
|
|||
private const int MAX_REQUEST = 3;
|
||||
private HttpClient httpClient;
|
||||
private bool isHttpClientDisposabled;
|
||||
private int numberOfRetry;
|
||||
|
||||
public ApiController(string baseAddress, int numberOfRetry = 5)
|
||||
{
|
||||
httpClient = new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri(baseAddress),
|
||||
Timeout = TimeSpan.FromSeconds(5)
|
||||
Timeout = TimeSpan.FromSeconds(1)
|
||||
};
|
||||
isHttpClientDisposabled = false;
|
||||
this.numberOfRetry = numberOfRetry;
|
||||
}
|
||||
|
||||
~ApiController()
|
||||
|
@ -91,7 +89,7 @@ namespace AIParkingApplication
|
|||
{
|
||||
response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
||||
requestCounter += 1;
|
||||
Thread.Sleep(100);
|
||||
await Task.Delay(100);
|
||||
}
|
||||
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
||||
|
||||
|
@ -102,7 +100,7 @@ namespace AIParkingApplication
|
|||
catch (Exception ex)
|
||||
{
|
||||
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);
|
||||
requestCounter += 1;
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
||||
await Task.Delay(100);
|
||||
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
|
||||
response.EnsureSuccessStatusCode();
|
||||
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
|
||||
return saveLogRespone;
|
||||
|
|
|
@ -56,6 +56,11 @@ namespace AIParkingApplication
|
|||
}
|
||||
ClearPlateAndOverviewImage();
|
||||
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)
|
||||
{
|
||||
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
|
||||
|
|
|
@ -59,6 +59,11 @@ namespace AIParkingApplication
|
|||
ClearPlateAndOverviewImage();
|
||||
ClearPlateAndOverviewImageIn();
|
||||
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)
|
||||
{
|
||||
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
|
||||
|
|
Loading…
Reference in New Issue
Block a user