diff --git a/AIParkingApplication/App.config b/AIParkingApplication/App.config index b4557ab..78684e9 100644 --- a/AIParkingApplication/App.config +++ b/AIParkingApplication/App.config @@ -6,6 +6,7 @@ + diff --git a/AIParkingApplication/LaneOut.cs b/AIParkingApplication/LaneOut.cs index a0496a8..3b923e3 100644 --- a/AIParkingApplication/LaneOut.cs +++ b/AIParkingApplication/LaneOut.cs @@ -1,4 +1,5 @@ using System; +using System.Configuration; using System.Drawing; using System.Threading; using System.Threading.Tasks; @@ -24,6 +25,7 @@ namespace AIParkingApplication private ApiController apiController; private Printer printer; private Logger appLogger; + private bool isUsePrinter; public LaneOut(int doorId, string cameraId, @@ -52,6 +54,7 @@ namespace AIParkingApplication this.doorControlAccess = doorControlAccess; printer = new Printer(appLogger); plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate); + ReadUsePrinterConfig(); } private async void C3Device_OnNewCardReceived(int doorId, string cardNumber) @@ -121,7 +124,8 @@ namespace AIParkingApplication OpenDoor(doorId); appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | biển số: {result.PlateString} | Đã mở cửa"); } - if (false) + + if (isUsePrinter) { PrinterData printerData = new PrinterData { @@ -140,6 +144,19 @@ namespace AIParkingApplication } } + private void ReadUsePrinterConfig() + { + try + { + bool.TryParse(ConfigurationManager.AppSettings["USE_PRINTER"], out isUsePrinter); + } + catch (Exception ex) + { + Util.AddOrUpdateAppSettings("USE_PRINTER", "false"); + appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: USE_PRINTER"); + } + } + private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame) { pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());