LaneIn - Refactor C3Device_OnNewCardReceived

This commit is contained in:
DucDangAnh 2020-06-30 10:58:25 +07:00
parent 562cccc7d5
commit 19f9a4ed82

View File

@ -57,45 +57,43 @@ namespace AIParkingApplication
{ {
ClearPlateAndOverviewImage(); ClearPlateAndOverviewImage();
var cardInfoResult = await apiController.GetCardInformation(cardNumber); var cardInfoResult = await apiController.GetCardInformation(cardNumber);
if (cardInfoResult.IsValid) if (!cardInfoResult.IsValid)
{ {
if (cardInfoResult.Direction == "in") lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
return;
}
if (cardInfoResult.Direction != "in")
{
lblStatusInfo.UpdateLabel("THẺ ĐÃ ĐƯỢC SỬ DỤNG", Color.Red);
return;
}
plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200);
var plateVideoFrame = plateCamera.CurrentFrame;
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
pictureBoxPlateImage.UpdateImage(result.PlateImage.ToBitmap());
var overviewVideoFrame = overviewCamera.CurrentFrame;
pictureBoxOverviewImage.UpdateImage(overviewVideoFrame.ToBitmap());
var cardInformation = await apiController.GetCardInformation(cardNumber);
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
if (saveLogResult.Status)
{
if (isAutoOpenDoor && this.doorId == doorId)
{ {
plateCamera.RequestCaptureOneFrame(); OpenDoor(doorId);
overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200);
var plateVideoFrame = plateCamera.CurrentFrame;
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
pictureBoxPlateImage.UpdateImage(result.PlateImage.ToBitmap());
var overviewVideoFrame = overviewCamera.CurrentFrame;
pictureBoxOverviewImage.UpdateImage(overviewVideoFrame.ToBitmap());
var cardInformation = await apiController.GetCardInformation(cardNumber);
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
if (saveLogResult.Status)
{
if (isAutoOpenDoor && this.doorId == doorId)
{
OpenDoor(doorId);
}
}
else
{
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
}
}
else
{
lblStatusInfo.UpdateLabel("THẺ ĐÃ ĐƯỢC SỬ DỤNG", Color.Red);
} }
} }
else else
{ {
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple); lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
} }
} }