Compare commits
6 Commits
646449b4ba
...
2c60eebda1
Author | SHA1 | Date | |
---|---|---|---|
2c60eebda1 | |||
7c03df5229 | |||
c9b65ba883 | |||
a835ed626b | |||
79eca30267 | |||
87e3a7418a |
|
@ -63,6 +63,18 @@ namespace AIParkingApplication
|
||||||
MessageBox.Show("Cấu hình API Plate Recognize lỗi!", "Cấu hình API Engine lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Cấu hình API Plate Recognize lỗi!", "Cấu hình API Engine lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
Application.ThreadException += Application_ThreadException;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
appLogger.Log(LogLevel.Error, $"Application.ThreadException. ex:{e.Exception.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
appLogger.Log(LogLevel.Error, $"AppDomain.CurrentDomain.UnhandledException. ex:{(e.ExceptionObject as Exception).Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitAllLanes()
|
private void InitAllLanes()
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace AIParkingApplication
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Login Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
Console.WriteLine($"Login Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
||||||
|
appLogger.Log(LogLevel.Error, $"Login lỗi. exMessage: {ex.Message}");
|
||||||
return new LoginDataModel
|
return new LoginDataModel
|
||||||
{
|
{
|
||||||
IsLoginSuccess = false,
|
IsLoginSuccess = false,
|
||||||
|
@ -74,7 +75,7 @@ namespace AIParkingApplication
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"GetStatisticInfo Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
Console.WriteLine($"GetStatisticInfo Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
||||||
appLogger.Log(LogLevel.Info, $"Query dữ liệu thống kê bãi xe lỗi. exMessage: {ex.Message}");
|
appLogger.Log(LogLevel.Error, $"Query dữ liệu thống kê bãi xe lỗi. exMessage: {ex.Message}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,17 +85,13 @@ namespace AIParkingApplication
|
||||||
int requestCounter = 1;
|
int requestCounter = 1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var request = new CardModel()
|
|
||||||
{
|
|
||||||
CardNumber = cardNumber
|
|
||||||
};
|
|
||||||
HttpResponseMessage response;
|
HttpResponseMessage response;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
response = await httpClient.PostAsJsonAsync("/api/check-card", new CardModel { CardNumber = cardNumber });
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
requestCounter += 1;
|
requestCounter += 1;
|
||||||
await Task.Delay(100);
|
await Task.Delay(800);
|
||||||
}
|
}
|
||||||
while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
|
while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
|
||||||
|
|
||||||
|
@ -104,12 +101,11 @@ namespace AIParkingApplication
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
||||||
appLogger.Log(LogLevel.Info, $"Query thông tin thẻ lỗi. Thẻ số: {cardNumber} | số lần thử lại: {requestCounter} | exMessage: {ex.Message}");
|
appLogger.Log(LogLevel.Error, $"Query thông tin thẻ lỗi. Thẻ số: {cardNumber} | số lần thử lại: {requestCounter} | exMessage: {ex.Message}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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 plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
|
||||||
|
@ -141,7 +137,7 @@ namespace AIParkingApplication
|
||||||
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
|
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
requestCounter += 1;
|
requestCounter += 1;
|
||||||
await Task.Delay(100);
|
await Task.Delay(800);
|
||||||
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
|
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
|
||||||
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
|
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
|
||||||
return saveLogRespone;
|
return saveLogRespone;
|
||||||
|
@ -149,7 +145,7 @@ namespace AIParkingApplication
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"SaveLog Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
Console.WriteLine($"SaveLog Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
|
||||||
appLogger.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));
|
appLogger.Log(LogLevel.Error, 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 null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
<add key="DOOR_ACCESS_DEVICE_CONTROL_IP" value="192.168.1.200" />
|
<add key="DOOR_ACCESS_DEVICE_CONTROL_IP" value="192.168.1.200" />
|
||||||
<add key="DEFAULT_USERNAME" value="cong1vao" />
|
<add key="DEFAULT_USERNAME" value="cong1vao" />
|
||||||
<add key="DEFAULT_PASSWORD" value="123456a@" />
|
<add key="DEFAULT_PASSWORD" value="123456a@" />
|
||||||
<add key="CURRENT_LANE_SETTING" value="OUT-OUT" />
|
<add key="CURRENT_LANE_SETTING" value="IN-OUT" />
|
||||||
|
<add key="AUTO_LOGIN" value="false" />
|
||||||
|
<add key="USE_PRINTER" value="false" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -69,14 +70,14 @@ namespace AIParkingApplication
|
||||||
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Ệ");
|
appLogger.Log(LogLevel.Info, $"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");
|
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: XE ĐÃ Ở TRONG BÃI");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,21 +149,24 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var starTime = DateTime.Now;
|
||||||
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
||||||
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||||
|
|
||||||
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
|
||||||
{
|
{
|
||||||
Console.WriteLine("ProcessFrameImage Retry Mode");
|
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
overviewCamera.RequestCaptureOneFrame();
|
overviewCamera.RequestCaptureOneFrame();
|
||||||
finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||||
|
Console.WriteLine("ProcessFrameImage Retry Mode");
|
||||||
}
|
}
|
||||||
|
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: {(DateTime.Now - starTime).TotalMilliseconds} ms");
|
||||||
return finalPlateResult;
|
return finalPlateResult;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"ProcessFrameImage\texMessage: {ex.Message}");
|
Console.WriteLine($"ProcessFrameImage\texMessage: {ex.Message}");
|
||||||
|
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: ex: {ex.Message}");
|
||||||
return new FinalPlateResult
|
return new FinalPlateResult
|
||||||
{
|
{
|
||||||
PlateImage = frame,
|
PlateImage = frame,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -24,6 +25,7 @@ namespace AIParkingApplication
|
||||||
private ApiController apiController;
|
private ApiController apiController;
|
||||||
private Printer printer;
|
private Printer printer;
|
||||||
private Logger appLogger;
|
private Logger appLogger;
|
||||||
|
private bool isUsePrinter;
|
||||||
|
|
||||||
public LaneOut(int doorId,
|
public LaneOut(int doorId,
|
||||||
string cameraId,
|
string cameraId,
|
||||||
|
@ -52,6 +54,7 @@ namespace AIParkingApplication
|
||||||
this.doorControlAccess = doorControlAccess;
|
this.doorControlAccess = doorControlAccess;
|
||||||
printer = new Printer(appLogger);
|
printer = new Printer(appLogger);
|
||||||
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
|
||||||
|
ReadUsePrinterConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
||||||
|
@ -72,14 +75,14 @@ namespace AIParkingApplication
|
||||||
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Ệ");
|
appLogger.Log(LogLevel.Info, $"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");
|
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: XE ĐÃ Ở TRONG BÃI");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +124,9 @@ namespace AIParkingApplication
|
||||||
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");
|
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | biển số: {result.PlateString} | Đã mở cửa");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isUsePrinter)
|
||||||
|
{
|
||||||
PrinterData printerData = new PrinterData
|
PrinterData printerData = new PrinterData
|
||||||
{
|
{
|
||||||
PlateString = result.PlateString,
|
PlateString = result.PlateString,
|
||||||
|
@ -130,6 +136,7 @@ namespace AIParkingApplication
|
||||||
};
|
};
|
||||||
printer.DoPrint(printerData);
|
printer.DoPrint(printerData);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: LƯU BẢN GHI LỖI");
|
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: LƯU BẢN GHI LỖI");
|
||||||
|
@ -137,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)
|
private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame)
|
||||||
{
|
{
|
||||||
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
|
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
|
||||||
|
@ -161,9 +181,11 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private void OpenDoor(int doorId)
|
private void OpenDoor(int doorId)
|
||||||
{
|
{
|
||||||
if (doorControlAccess.OpenDoor(doorId).HasError)
|
var openDoorResult = doorControlAccess.OpenDoor(doorId);
|
||||||
|
if (openDoorResult.HasError)
|
||||||
{
|
{
|
||||||
lblStatusInfo.UpdateLabel("KHÔNG THỂ MỞ CỬA", Color.Red);
|
lblStatusInfo.UpdateLabel("KHÔNG THỂ MỞ CỬA", Color.Red);
|
||||||
|
appLogger.Log(LogLevel.Error, $"Không thể mở cửa {doorId}. Lỗi: {openDoorResult.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +193,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var starTime = DateTime.Now;
|
||||||
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
|
||||||
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||||
|
|
||||||
|
@ -181,6 +204,7 @@ namespace AIParkingApplication
|
||||||
overviewCamera.RequestCaptureOneFrame();
|
overviewCamera.RequestCaptureOneFrame();
|
||||||
finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
finalPlateResult = await plateProcessor.ProcessPlate(frame);
|
||||||
}
|
}
|
||||||
|
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: {(DateTime.Now - starTime).TotalMilliseconds} ms");
|
||||||
return finalPlateResult;
|
return finalPlateResult;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace AIParkingApplication
|
namespace AIParkingApplication
|
||||||
|
@ -11,12 +12,14 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
private ApiController apiController;
|
private ApiController apiController;
|
||||||
private Logger applicationLogger;
|
private Logger applicationLogger;
|
||||||
|
private bool isAutoLogin;
|
||||||
|
|
||||||
public LoginForm()
|
public LoginForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
applicationLogger = LogManager.GetLogger(AppConstant.APPLICATION_LOGGER_NAME);
|
applicationLogger = LogManager.GetLogger(AppConstant.APPLICATION_LOGGER_NAME);
|
||||||
applicationLogger.Log(LogLevel.Info, new string('-', 20));
|
applicationLogger.Log(LogLevel.Info, new string('-', 20));
|
||||||
|
isAutoLogin = false;
|
||||||
if (File.Exists(AppConstant.DEFAULT_LOGO_IMAGE))
|
if (File.Exists(AppConstant.DEFAULT_LOGO_IMAGE))
|
||||||
{
|
{
|
||||||
pictureBoxImageLogo.Image = new Bitmap(AppConstant.DEFAULT_LOGO_IMAGE);
|
pictureBoxImageLogo.Image = new Bitmap(AppConstant.DEFAULT_LOGO_IMAGE);
|
||||||
|
@ -34,7 +37,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
lblLoginStatus.Text = "Địa chỉ server không được để trống! \r\n ví dụ: 192.168.1.2:80";
|
lblLoginStatus.Text = "Địa chỉ server không được để trống! \r\n ví dụ: 192.168.1.2:80";
|
||||||
btnLogin.Enabled = true;
|
btnLogin.Enabled = true;
|
||||||
applicationLogger.Log(LogLevel.Error, "Địa chỉ server không được để trống");
|
applicationLogger.Log(LogLevel.Info, "Địa chỉ server không được để trống");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +47,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
lblLoginStatus.Text = "Địa chỉ server không đúng định dạng: \r\n ví dụ: 192.168.1.122:80";
|
lblLoginStatus.Text = "Địa chỉ server không đúng định dạng: \r\n ví dụ: 192.168.1.122:80";
|
||||||
btnLogin.Enabled = true;
|
btnLogin.Enabled = true;
|
||||||
applicationLogger.Log(LogLevel.Error, "Địa chỉ server không đúng định dạng");
|
applicationLogger.Log(LogLevel.Info, "Địa chỉ server không đúng định dạng");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,9 +57,9 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
applicationLogger.Log(LogLevel.Error, $"Cấu máy chủ lỗi - Kiểm tra lại tên máy chủ, kết nối máy chủ! Không thể khởi tạo API Webserver. ex: {ex.Message}");
|
||||||
MessageBox.Show($"Cấu máy chủ lỗi - Kiểm tra lại tên máy chủ, kết nối máy chủ! \r\n {ex.Message}", "Lỗi khởi tạo API!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show($"Cấu máy chủ lỗi - Kiểm tra lại tên máy chủ, kết nối máy chủ! \r\n {ex.Message}", "Lỗi khởi tạo API!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
btnLogin.Enabled = true;
|
btnLogin.Enabled = true;
|
||||||
applicationLogger.Log(LogLevel.Error, "Cấu máy chủ lỗi - Kiểm tra lại tên máy chủ, kết nối máy chủ! Không thể khởi tạo API Webserver");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +70,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
lblLoginStatus.Text = "Tên tài khoản hoặc mật khẩu không được để trống";
|
lblLoginStatus.Text = "Tên tài khoản hoặc mật khẩu không được để trống";
|
||||||
btnLogin.Enabled = true;
|
btnLogin.Enabled = true;
|
||||||
applicationLogger.Log(LogLevel.Error, "Tên tài khoản hoặc mật khẩu không được để trống");
|
applicationLogger.Log(LogLevel.Info, "Tên tài khoản hoặc mật khẩu không được để trống");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +82,7 @@ namespace AIParkingApplication
|
||||||
if (execeptioMessage.Contains("Error converting value"))
|
if (execeptioMessage.Contains("Error converting value"))
|
||||||
{
|
{
|
||||||
lblLoginStatus.UpdateLabel("Sai tên tài khoản hoặc mật khẩu!", Color.Red);
|
lblLoginStatus.UpdateLabel("Sai tên tài khoản hoặc mật khẩu!", Color.Red);
|
||||||
applicationLogger.Log(LogLevel.Error, "Sai tên tài khoản hoặc mật khẩu");
|
applicationLogger.Log(LogLevel.Info, "Sai tên tài khoản hoặc mật khẩu");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,12 +120,34 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void DoAutoLogin()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("AUTO_LOGIN", string.Empty);
|
||||||
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
||||||
|
applicationLogger.Log(LogLevel.Error, "Không thể đọc cấu hình tài khoản mặc định: DEFAULT_USERNAME, DEFAULT_PASSWORD");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ReadAppConfigurationFromFile()
|
private void ReadAppConfigurationFromFile()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
txtUsername.Text = ConfigurationManager.AppSettings["DEFAULT_USERNAME"];
|
txtUsername.Text = ConfigurationManager.AppSettings["DEFAULT_USERNAME"];
|
||||||
txtPassword.Text = ConfigurationManager.AppSettings["DEFAULT_PASSWORD"];
|
txtPassword.Text = ConfigurationManager.AppSettings["DEFAULT_PASSWORD"];
|
||||||
|
bool.TryParse(ConfigurationManager.AppSettings["AUTO_LOGIN"], out isAutoLogin);
|
||||||
|
Thread.Sleep(500);
|
||||||
|
if (isAutoLogin)
|
||||||
|
{
|
||||||
|
lblLoginStatus.UpdateLabel("Đang đăng nhập", Color.Green, Color.White);
|
||||||
|
Login();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -130,6 +155,7 @@ namespace AIParkingApplication
|
||||||
txtPassword.Text = string.Empty;
|
txtPassword.Text = string.Empty;
|
||||||
Util.AddOrUpdateAppSettings("DEFAULT_USERNAME", string.Empty);
|
Util.AddOrUpdateAppSettings("DEFAULT_USERNAME", string.Empty);
|
||||||
Util.AddOrUpdateAppSettings("DEFAULT_PASSWORD", string.Empty);
|
Util.AddOrUpdateAppSettings("DEFAULT_PASSWORD", string.Empty);
|
||||||
|
Util.AddOrUpdateAppSettings("AUTO_LOGIN", "false");
|
||||||
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
||||||
applicationLogger.Log(LogLevel.Error, "Không thể đọc cấu hình tài khoản mặc định: DEFAULT_USERNAME, DEFAULT_PASSWORD");
|
applicationLogger.Log(LogLevel.Error, "Không thể đọc cấu hình tài khoản mặc định: DEFAULT_USERNAME, DEFAULT_PASSWORD");
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace AIParkingApplication
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"ProcessingString\texMessage:{ex.Message}");
|
Console.WriteLine($"ProcessingString\texMessage:{ex.Message}");
|
||||||
appLogger.Log(LogLevel.Info, $"Lỗi khi In hóa đơn: {ex.Message}");
|
appLogger.Log(LogLevel.Error, $"Lỗi khi In hóa đơn: {ex.Message}");
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user