Compare commits

...

4 Commits

3 changed files with 36 additions and 51 deletions

View File

@ -69,20 +69,20 @@ namespace AIParkingApplication
if (cardInfoResult == null)
{
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");
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | lỗi: KHÔNG THỂ KẾT NỐI TỚI SERVER");
return;
}
if (!cardInfoResult.IsValid)
{
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
appLogger.Log(LogLevel.Info, $"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} ra | số thẻ : {cardNumber} | lỗi: THẺ KHÔNG HỢP LỆ");
return;
}
if (cardInfoResult.Direction != "out")
{
lblStatusInfo.UpdateLabel("CHƯA NHẬN THẺ VÀO", Color.Red);
appLogger.Log(LogLevel.Info, $"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} ra | số thẻ : {cardNumber} | lỗi: CHƯA NHẬN THẺ VÀO");
return;
}
@ -95,7 +95,7 @@ namespace AIParkingApplication
plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | Chụp ảnh camera");
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | Chụp ảnh camera");
var plateVideoFrame = plateCamera.CurrentFrame;
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
@ -111,7 +111,7 @@ namespace AIParkingApplication
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");
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | lỗi: KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ - KHÔNG LƯU ĐƯỢC LOG");
return;
}
@ -122,7 +122,7 @@ namespace AIParkingApplication
if (isAutoOpenDoor)
{
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} ra | số thẻ : {cardNumber} | biển số: {result.PlateString} | Đã mở cửa");
}
if (isUsePrinter)
@ -139,7 +139,7 @@ namespace AIParkingApplication
}
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} ra | số thẻ : {cardNumber} | lỗi: LƯU BẢN GHI LỖI");
lblStatusInfo.UpdateLabel("LƯU BẢN GHI LỖI", Color.Red);
}
}
@ -153,7 +153,7 @@ namespace AIParkingApplication
catch (Exception ex)
{
Util.AddOrUpdateAppSettings("USE_PRINTER", "false");
appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: USE_PRINTER");
appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: USE_PRINTER. ex: {ex.Message }");
}
}

View File

@ -37,8 +37,8 @@
this.txtServerAddress = new System.Windows.Forms.TextBox();
this.lblServerAddress = new System.Windows.Forms.Label();
this.btnLogin = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.lblLoginStatus = new System.Windows.Forms.Label();
this.chkAutoLogin = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).BeginInit();
this.SuspendLayout();
//
@ -70,7 +70,7 @@
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(294, 52);
this.txtPassword.Location = new System.Drawing.Point(294, 45);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(227, 20);
@ -80,7 +80,7 @@
// lblPassword
//
this.lblPassword.AutoSize = true;
this.lblPassword.Location = new System.Drawing.Point(214, 55);
this.lblPassword.Location = new System.Drawing.Point(214, 48);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(52, 13);
this.lblPassword.TabIndex = 2;
@ -88,7 +88,7 @@
//
// txtServerAddress
//
this.txtServerAddress.Location = new System.Drawing.Point(294, 90);
this.txtServerAddress.Location = new System.Drawing.Point(294, 77);
this.txtServerAddress.Name = "txtServerAddress";
this.txtServerAddress.Size = new System.Drawing.Size(227, 20);
this.txtServerAddress.TabIndex = 1;
@ -97,7 +97,7 @@
// lblServerAddress
//
this.lblServerAddress.AutoSize = true;
this.lblServerAddress.Location = new System.Drawing.Point(214, 93);
this.lblServerAddress.Location = new System.Drawing.Point(214, 80);
this.lblServerAddress.Name = "lblServerAddress";
this.lblServerAddress.Size = new System.Drawing.Size(48, 13);
this.lblServerAddress.TabIndex = 2;
@ -105,42 +105,44 @@
//
// btnLogin
//
this.btnLogin.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnLogin.Location = new System.Drawing.Point(294, 162);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(101, 37);
this.btnLogin.Size = new System.Drawing.Size(227, 37);
this.btnLogin.TabIndex = 3;
this.btnLogin.Text = "Đăng nhập";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(421, 162);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(101, 37);
this.btnExit.TabIndex = 3;
this.btnExit.Text = "Thoát";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// lblLoginStatus
//
this.lblLoginStatus.AutoSize = true;
this.lblLoginStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLoginStatus.ForeColor = System.Drawing.SystemColors.ControlLight;
this.lblLoginStatus.Location = new System.Drawing.Point(294, 117);
this.lblLoginStatus.Location = new System.Drawing.Point(291, 100);
this.lblLoginStatus.Name = "lblLoginStatus";
this.lblLoginStatus.Size = new System.Drawing.Size(90, 18);
this.lblLoginStatus.TabIndex = 4;
this.lblLoginStatus.Text = "Login Status";
//
// chkAutoLogin
//
this.chkAutoLogin.AutoSize = true;
this.chkAutoLogin.Location = new System.Drawing.Point(295, 142);
this.chkAutoLogin.Name = "chkAutoLogin";
this.chkAutoLogin.Size = new System.Drawing.Size(122, 17);
this.chkAutoLogin.TabIndex = 5;
this.chkAutoLogin.Text = "Tự động đăng nhập";
this.chkAutoLogin.UseVisualStyleBackColor = true;
this.chkAutoLogin.CheckedChanged += new System.EventHandler(this.chkAutoLogin_CheckedChanged);
//
// LoginForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(534, 211);
this.Controls.Add(this.chkAutoLogin);
this.Controls.Add(this.lblLoginStatus);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.lblServerAddress);
this.Controls.Add(this.lblPassword);
@ -173,7 +175,7 @@
private System.Windows.Forms.TextBox txtServerAddress;
private System.Windows.Forms.Label lblServerAddress;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Label lblLoginStatus;
private System.Windows.Forms.CheckBox chkAutoLogin;
}
}

View File

@ -111,30 +111,6 @@ namespace AIParkingApplication
Login();
}
private void btnExit_Click(object sender, EventArgs e)
{
if (DialogResult.OK == MessageBox.Show("AIParking - Bạn muốn thoát ứng dụng?", "Cảnh báo!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
{
applicationLogger.Log(LogLevel.Info, "Login - Thoát ứng dụng");
Application.Exit();
}
}
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()
{
try
@ -145,6 +121,7 @@ namespace AIParkingApplication
Thread.Sleep(500);
if (isAutoLogin)
{
chkAutoLogin.Checked = true;
lblLoginStatus.UpdateLabel("Đang đăng nhập", Color.Green, Color.White);
Login();
}
@ -156,6 +133,7 @@ namespace AIParkingApplication
Util.AddOrUpdateAppSettings("DEFAULT_USERNAME", string.Empty);
Util.AddOrUpdateAppSettings("DEFAULT_PASSWORD", string.Empty);
Util.AddOrUpdateAppSettings("AUTO_LOGIN", "false");
chkAutoLogin.Checked = false;
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");
}
@ -165,5 +143,10 @@ namespace AIParkingApplication
{
ReadAppConfigurationFromFile();
}
private void chkAutoLogin_CheckedChanged(object sender, EventArgs e)
{
Util.AddOrUpdateAppSettings("AUTO_LOGIN", (sender as CheckBox).Checked.ToString().ToLower());
}
}
}