LoginForm - Catch exception to handle login status. (API needs to fixed same return data type: todo DongPD)
This commit is contained in:
parent
53f457b020
commit
5f7ac10f22
|
@ -42,7 +42,8 @@ namespace AIParkingApplication
|
|||
Console.WriteLine($"Login Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
||||
return new LoginDataModel
|
||||
{
|
||||
IsLoginSuccess = false
|
||||
IsLoginSuccess = false,
|
||||
Exception = ex
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +95,7 @@ namespace AIParkingApplication
|
|||
}
|
||||
|
||||
//Neu Dicrection la Out thi logID la logID lay ve khi check the
|
||||
public async Task<SaveLogRespone> SaveLog(LaneDirection direction, string cardID, string cameraID, PlateType plateType, string timestamp, string plateString, Mat plateImage, Mat plateImageResult, Mat plateFrameImage, Mat frameImage, string logID = "")
|
||||
public async Task<SaveLogRespone> SaveLog(LaneDirection direction, string cardID, string cameraID, PlateType plateType, string timestamp, string plateString, Mat plateImage, Mat plateImageResult, Mat plateFrameImage, Mat frameImage, string logID = "")
|
||||
{
|
||||
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
|
||||
string plateImageResultBase64 = Convert.ToBase64String(plateImageResult.ToBytes());
|
||||
|
@ -109,7 +110,7 @@ namespace AIParkingApplication
|
|||
CardID = cardID,
|
||||
TextPlate = plateString,
|
||||
CameraID = cameraID,
|
||||
ModePlate = plateType == PlateType.Square ? "1":"0",
|
||||
ModePlate = plateType == PlateType.Square ? "1" : "0",
|
||||
Timestamp = timestamp,
|
||||
PlateImage = plateImageBase64,
|
||||
PlateResultImage = plateImageResultBase64,
|
||||
|
@ -259,6 +260,8 @@ namespace AIParkingApplication
|
|||
|
||||
[JsonProperty("data")]
|
||||
public Config LoginData { get; set; }
|
||||
|
||||
public Exception Exception { get; set; }
|
||||
}
|
||||
|
||||
public class Config
|
||||
|
|
|
@ -55,15 +55,26 @@ namespace AIParkingApplication
|
|||
}
|
||||
|
||||
var loginResult = await apiController.Login(new LoginModel { Username = username, Password = password });
|
||||
if (loginResult.Exception != null)
|
||||
{
|
||||
var execeptioMessage = loginResult.Exception.Message;
|
||||
if (execeptioMessage.Contains("Error converting value"))
|
||||
{
|
||||
lblLoginStatus.UpdateLabel("Tên tài khoản hoặc mật khẩu không đúng!", Color.Red);
|
||||
}
|
||||
|
||||
if (execeptioMessage.Contains("An error occurred while sending the request"))
|
||||
{
|
||||
lblLoginStatus.UpdateLabel("Không có kết nối tới server!\r\nKiểm tra lại kết nối tới server!", Color.Red, Color.White);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (loginResult.IsLoginSuccess)
|
||||
{
|
||||
new AIParkingApplicationForm(apiController, loginResult.LoginData).Show();
|
||||
Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblLoginStatus.Text = "Tên tài khoản hoặc mật khẩu không đúng!";
|
||||
}
|
||||
}
|
||||
|
||||
private void btnLogin_Click(object sender, System.EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue
Block a user