ApiController - Update Method: SaveLog. LaneIn, LaneOut - Add log
This commit is contained in:
parent
153eba219f
commit
e8fae43c1d
|
@ -150,7 +150,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
Console.WriteLine($"SaveLog Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
Console.WriteLine($"SaveLog Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
||||||
applicationLogger.Log(LogLevel.Info, string.Format("Không thể lưu log gửi xe. Làn: {0} | Mã thẻ: {1} | cameraID: {2} | Thời gian: {3} | Biển số: {4} | LogID: {5} | exMessage: ", direction == LaneDirection.In ? "IN" : "OUT", cardID, cameraID, timestamp, plateString, logID, ex.Message));
|
applicationLogger.Log(LogLevel.Info, string.Format("Không thể lưu log gửi xe. Làn: {0} | Mã thẻ: {1} | cameraID: {2} | Thời gian: {3} | Biển số: {4} | LogID: {5} | exMessage: ", direction == LaneDirection.In ? "IN" : "OUT", cardID, cameraID, timestamp, plateString, logID, ex.Message));
|
||||||
return new SaveLogRespone();
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,23 +63,27 @@ namespace AIParkingApplication
|
||||||
if (cardInfoResult == null)
|
if (cardInfoResult == null)
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
|
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: KHÔNG THỂ KẾT NỐI TỚI SERVER");
|
||||||
return;
|
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);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: THẺ KHÔNG HỢP LỆ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cardInfoResult.Direction != "in")
|
if (cardInfoResult.Direction != "in")
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("XE ĐÃ Ở TRONG BÃI", Color.Red);
|
lblStatusInfo.UpdateLabel("XE ĐÃ Ở TRONG BÃI", Color.Red);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: XE ĐÃ Ở TRONG BÃI");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plateCamera.RequestCaptureOneFrame();
|
plateCamera.RequestCaptureOneFrame();
|
||||||
overviewCamera.RequestCaptureOneFrame();
|
overviewCamera.RequestCaptureOneFrame();
|
||||||
await Task.Delay(200);
|
await Task.Delay(200);
|
||||||
|
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | Chụp ảnh camera");
|
||||||
|
|
||||||
var plateVideoFrame = plateCamera.CurrentFrame;
|
var plateVideoFrame = plateCamera.CurrentFrame;
|
||||||
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
|
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
|
||||||
|
@ -92,6 +96,13 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), cameraId, result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
|
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), cameraId, result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
|
||||||
|
|
||||||
|
if (saveLogResult == null)
|
||||||
|
{
|
||||||
|
lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ - KHÔNG LƯU ĐƯỢC LOG");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.GetTimeFormatted());
|
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.GetTimeFormatted());
|
||||||
|
|
||||||
if (saveLogResult.Status)
|
if (saveLogResult.Status)
|
||||||
|
@ -99,11 +110,13 @@ namespace AIParkingApplication
|
||||||
if (isAutoOpenDoor && DoorId == doorId)
|
if (isAutoOpenDoor && DoorId == doorId)
|
||||||
{
|
{
|
||||||
OpenDoor(doorId);
|
OpenDoor(doorId);
|
||||||
|
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | biển số: {result.PlateString} | Đã mở cửa");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: LƯU BẢN GHI LỖI");
|
||||||
|
lblStatusInfo.UpdateLabel("LƯU BẢN GHI LỖI", Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +176,12 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
plateCamera.Stop();
|
plateCamera.Stop();
|
||||||
overviewCamera.Stop();
|
overviewCamera.Stop();
|
||||||
|
|
||||||
|
pictureBoxPlateImage.UpdateImage(null);
|
||||||
|
pictureBoxPlateVideo.UpdateImage(null);
|
||||||
|
|
||||||
|
pictureBoxOverviewImage.UpdateImage(null);
|
||||||
|
pictureBoxOverviewVideo.UpdateImage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
|
|
|
@ -66,17 +66,20 @@ namespace AIParkingApplication
|
||||||
if (cardInfoResult == null)
|
if (cardInfoResult == null)
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
|
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: KHÔNG THỂ KẾT NỐI TỚI SERVER");
|
||||||
return;
|
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);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: THẺ KHÔNG HỢP LỆ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cardInfoResult.Direction != "out")
|
if (cardInfoResult.Direction != "out")
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("CHƯA NHẬN THẺ VÀO", Color.Red);
|
lblStatusInfo.UpdateLabel("CHƯA NHẬN THẺ VÀO", Color.Red);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: XE ĐÃ Ở TRONG BÃI");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +92,7 @@ namespace AIParkingApplication
|
||||||
plateCamera.RequestCaptureOneFrame();
|
plateCamera.RequestCaptureOneFrame();
|
||||||
overviewCamera.RequestCaptureOneFrame();
|
overviewCamera.RequestCaptureOneFrame();
|
||||||
await Task.Delay(200);
|
await Task.Delay(200);
|
||||||
|
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | Chụp ảnh camera");
|
||||||
|
|
||||||
var plateVideoFrame = plateCamera.CurrentFrame;
|
var plateVideoFrame = plateCamera.CurrentFrame;
|
||||||
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
|
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
|
||||||
|
@ -101,6 +105,13 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
var saveLogResult = await apiController.SaveLog(LaneDirection.Out, cardInformation.CardRealID.ToString(), cameraId, result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame, cardInformation.LogID.ToString());
|
var saveLogResult = await apiController.SaveLog(LaneDirection.Out, cardInformation.CardRealID.ToString(), cameraId, result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame, cardInformation.LogID.ToString());
|
||||||
|
|
||||||
|
if (saveLogResult == null)
|
||||||
|
{
|
||||||
|
lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ - KHÔNG LƯU ĐƯỢC LOG");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.PlateString, cardInformation.CardType, cardInformation.TimeIn, DateTime.Now.GetTimeFormatted(), saveLogResult.Cost);
|
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.PlateString, cardInformation.CardType, cardInformation.TimeIn, DateTime.Now.GetTimeFormatted(), saveLogResult.Cost);
|
||||||
|
|
||||||
if (saveLogResult.Status)
|
if (saveLogResult.Status)
|
||||||
|
@ -108,6 +119,7 @@ namespace AIParkingApplication
|
||||||
if (isAutoOpenDoor)
|
if (isAutoOpenDoor)
|
||||||
{
|
{
|
||||||
OpenDoor(doorId);
|
OpenDoor(doorId);
|
||||||
|
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | biển số: {result.PlateString} | Đã mở cửa");
|
||||||
}
|
}
|
||||||
PrinterData printerData = new PrinterData
|
PrinterData printerData = new PrinterData
|
||||||
{
|
{
|
||||||
|
@ -120,7 +132,8 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: LƯU BẢN GHI LỖI");
|
||||||
|
lblStatusInfo.UpdateLabel("LƯU BẢN GHI LỖI", Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +199,12 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
plateCamera.Stop();
|
plateCamera.Stop();
|
||||||
overviewCamera.Stop();
|
overviewCamera.Stop();
|
||||||
|
|
||||||
|
pictureBoxPlateImage.UpdateImage(null);
|
||||||
|
pictureBoxPlateVideo.UpdateImage(null);
|
||||||
|
|
||||||
|
pictureBoxOverviewImage.UpdateImage(null);
|
||||||
|
pictureBoxOverviewVideo.UpdateImage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user