Compare commits

..

No commits in common. "d97908a22b9df207799f9bcaa15274189425c109" and "59208674e0f1a5b8f757296f2842377679328f51" have entirely different histories.

10 changed files with 62 additions and 108 deletions

View File

@ -9,6 +9,8 @@ namespace AIParkingApplication
{ {
public partial class AIParkingApplicationForm : Form public partial class AIParkingApplicationForm : Form
{ {
private const string CURRENT_LANE_SETTING_KEY = "CURRENT_LANE_SETTING";
private ApiController apiController; private ApiController apiController;
private IDoorControlAccess c3Device; private IDoorControlAccess c3Device;
private LaneIn laneIn12; private LaneIn laneIn12;
@ -152,7 +154,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e)
{ {
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-IN"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-IN");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneInIn(); UpdateLaneInIn();
@ -161,7 +163,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
{ {
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneInOut(); UpdateLaneInOut();
@ -170,7 +172,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
{ {
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "OUT-IN"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-IN");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneOutIn(); UpdateLaneOutIn();
@ -179,7 +181,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
{ {
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "OUT-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-OUT");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneOutOut(); UpdateLaneOutOut();
@ -225,7 +227,7 @@ namespace AIParkingApplication
{ {
try try
{ {
string lanesConfig = ConfigurationManager.AppSettings[AppConstant.CURRENT_LANE_SETTING]; string lanesConfig = ConfigurationManager.AppSettings[CURRENT_LANE_SETTING_KEY];
if (!string.IsNullOrEmpty(lanesConfig)) if (!string.IsNullOrEmpty(lanesConfig))
{ {
string[] lanes = lanesConfig.Split('-'); string[] lanes = lanesConfig.Split('-');
@ -260,7 +262,7 @@ namespace AIParkingApplication
} }
else else
{ {
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
UpdateLaneInOut(); UpdateLaneInOut();
toolStripMenuItemSwitchLaneInOut.DisableSelected(); toolStripMenuItemSwitchLaneInOut.DisableSelected();
appLogger.Log(LogLevel.Info, $"Khởi động App đọc config không đủ 2 param: IN-OUT"); appLogger.Log(LogLevel.Info, $"Khởi động App đọc config không đủ 2 param: IN-OUT");
@ -269,7 +271,7 @@ namespace AIParkingApplication
} }
catch (Exception ex) catch (Exception ex)
{ {
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
UpdateLaneInOut(); UpdateLaneInOut();
toolStripMenuItemSwitchLaneInOut.DisableSelected(); toolStripMenuItemSwitchLaneInOut.DisableSelected();
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}"); Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}");
@ -281,13 +283,13 @@ namespace AIParkingApplication
{ {
try try
{ {
doorAccessControlDeviceIP = ConfigurationManager.AppSettings[AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP].Trim(); doorAccessControlDeviceIP = ConfigurationManager.AppSettings["DOOR_ACCESS_DEVICE_CONTROL_IP"].Trim();
} }
catch (Exception ex) catch (Exception ex)
{ {
doorAccessControlDeviceIP = string.Empty; doorAccessControlDeviceIP = string.Empty;
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}"); Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
appLogger.Log(LogLevel.Error, $"Cấu hình IP thiết bị mở cửa lỗi({AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP})!\texMessage: {ex.Message}"); appLogger.Log(LogLevel.Error, $"Cấu hình IP thiết bị mở cửa lỗi(DOOR_ACCESS_DEVICE_CONTROL_IP)!\texMessage: {ex.Message}");
} }
} }

View File

@ -6,25 +6,11 @@
public const string ERROR_TITLE = "Lỗi"; public const string ERROR_TITLE = "Lỗi";
public const string DATETIME_FORMAT = "HH:mm:ss dd/MM/yyyy"; public const string DATETIME_FORMAT = "HH:mm:ss dd/MM/yyyy";
public const string CAMERA_FAILED_IMAGE_PATH = @".\Images\CantConnectCamera.jpg"; public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg";
public const string DEFAULT_LOGO_IMAGE = @".\Images\ApplicationLogo.ico"; public const string DEFAULT_LOGO_IMAGE = @".\Images\ApplicationLogo.ico";
public const string APPLICATION_LOGGER_NAME = "ApplicationLogger"; public const string APPLICATION_LOGGER_NAME = "ApplicationLogger";
public const string PING_SERVER_LOGGER_NAME = "PingServerLogger"; public const string PING_SERVER_LOGGER_NAME = "PingServerLogger";
public const string PING_DOOR_DEVICE_CONTROL_ACCESS_LOGGER_NAME = "PingDoorDeviceControlAccessLogger"; public const string PING_DOOR_DEVICE_CONTROL_ACCESS_LOGGER_NAME = "PingDoorDeviceControlAccessLogger";
#region App Config Key
public const string DOOR_ACCESS_DEVICE_CONTROL_IP = "DOOR_ACCESS_DEVICE_CONTROL_IP";
public const string DEFAULT_USERNAME = "DEFAULT_USERNAME";
public const string DEFAULT_PASSWORD = "DEFAULT_PASSWORD";
public const string DEFAULT_WEB_SERVER = "DEFAULT_WEB_SERVER";
public const string CURRENT_LANE_SETTING = "CURRENT_LANE_SETTING";
public const string AUTO_LOGIN = "AUTO_LOGIN";
public const string USE_PRINTER = "USE_PRINTER";
public const string AUTO_OPEN_DOOR_1 = "AUTO_OPEN_DOOR_1";
public const string AUTO_OPEN_DOOR_2 = "AUTO_OPEN_DOOR_2";
public const string ALLOW_CHANGE_ROI_RECT = "ALLOW_CHANGE_ROI_RECT";
public const string AUTO_RUN_AT_STARTUP = "AUTO_RUN_AT_STARTUP";
#endregion
} }
} }

View File

@ -1,6 +1,5 @@
using OpenCvSharp; using OpenCvSharp;
using System.Threading; using System.Threading;
using System.Windows.Forms;
namespace AIParkingApplication namespace AIParkingApplication
{ {
@ -51,7 +50,7 @@ namespace AIParkingApplication
{ {
if (!videoCapture.Open(streamUrl)) if (!videoCapture.Open(streamUrl))
{ {
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(Application.StartupPath + AppConstant.CAMERA_FAILED_IMAGE_PATH)); OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
return; return;
} }
@ -73,7 +72,7 @@ namespace AIParkingApplication
} }
else else
{ {
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(Application.StartupPath + AppConstant.CAMERA_FAILED_IMAGE_PATH)); OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
} }
} }
} }

View File

@ -28,7 +28,7 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.lblDoorDeviceControlAccessIPStatus = new System.Windows.Forms.Label(); this.txtDoorDeviceControlAccessIPStatus = new System.Windows.Forms.Label();
this.btnCheckDoorDeviceControlAccessIP = new System.Windows.Forms.Button(); this.btnCheckDoorDeviceControlAccessIP = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.btnSaveSettings = new System.Windows.Forms.Button(); this.btnSaveSettings = new System.Windows.Forms.Button();
@ -50,14 +50,14 @@
this.statusStrip.SuspendLayout(); this.statusStrip.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// lblDoorDeviceControlAccessIPStatus // txtDoorDeviceControlAccessIPStatus
// //
this.lblDoorDeviceControlAccessIPStatus.AutoSize = true; this.txtDoorDeviceControlAccessIPStatus.AutoSize = true;
this.lblDoorDeviceControlAccessIPStatus.Location = new System.Drawing.Point(412, 9); this.txtDoorDeviceControlAccessIPStatus.Location = new System.Drawing.Point(412, 9);
this.lblDoorDeviceControlAccessIPStatus.Name = "lblDoorDeviceControlAccessIPStatus"; this.txtDoorDeviceControlAccessIPStatus.Name = "txtDoorDeviceControlAccessIPStatus";
this.lblDoorDeviceControlAccessIPStatus.Size = new System.Drawing.Size(58, 13); this.txtDoorDeviceControlAccessIPStatus.Size = new System.Drawing.Size(58, 13);
this.lblDoorDeviceControlAccessIPStatus.TabIndex = 17; this.txtDoorDeviceControlAccessIPStatus.TabIndex = 17;
this.lblDoorDeviceControlAccessIPStatus.Text = "Trạng thái:"; this.txtDoorDeviceControlAccessIPStatus.Text = "Trạng thái:";
// //
// btnCheckDoorDeviceControlAccessIP // btnCheckDoorDeviceControlAccessIP
// //
@ -67,7 +67,6 @@
this.btnCheckDoorDeviceControlAccessIP.TabIndex = 2; this.btnCheckDoorDeviceControlAccessIP.TabIndex = 2;
this.btnCheckDoorDeviceControlAccessIP.Text = "Kiểm tra"; this.btnCheckDoorDeviceControlAccessIP.Text = "Kiểm tra";
this.btnCheckDoorDeviceControlAccessIP.UseVisualStyleBackColor = true; this.btnCheckDoorDeviceControlAccessIP.UseVisualStyleBackColor = true;
this.btnCheckDoorDeviceControlAccessIP.Click += new System.EventHandler(this.btnCheckDoorDeviceControlAccessIP_Click);
// //
// btnClose // btnClose
// //
@ -234,7 +233,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(646, 281); this.ClientSize = new System.Drawing.Size(646, 281);
this.Controls.Add(this.statusStrip); this.Controls.Add(this.statusStrip);
this.Controls.Add(this.lblDoorDeviceControlAccessIPStatus); this.Controls.Add(this.txtDoorDeviceControlAccessIPStatus);
this.Controls.Add(this.btnCheckDoorDeviceControlAccessIP); this.Controls.Add(this.btnCheckDoorDeviceControlAccessIP);
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnSaveSettings); this.Controls.Add(this.btnSaveSettings);
@ -267,7 +266,7 @@
#endregion #endregion
private System.Windows.Forms.Label lblDoorDeviceControlAccessIPStatus; private System.Windows.Forms.Label txtDoorDeviceControlAccessIPStatus;
private System.Windows.Forms.Button btnCheckDoorDeviceControlAccessIP; private System.Windows.Forms.Button btnCheckDoorDeviceControlAccessIP;
private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSaveSettings; private System.Windows.Forms.Button btnSaveSettings;

View File

@ -29,19 +29,13 @@ namespace AIParkingApplication
private void btnSaveSettings_Click(object sender, EventArgs e) private void btnSaveSettings_Click(object sender, EventArgs e)
{ {
bool isValidIPAddress = Util.IsValidIPAddress(txtDoorDeviceControlAccessIP.Text); Util.UpsertAppSettings("DOOR_ACCESS_DEVICE_CONTROL_IP", txtDoorDeviceControlAccessIP.Text);
if (!isValidIPAddress) Util.UpsertAppSettings("AUTO_OPEN_DOOR_1", chkAllowAutoDoor1.Checked.ToString().ToLower());
{ Util.UpsertAppSettings("AUTO_OPEN_DOOR_2", chkAllowAutoDoor2.Checked.ToString().ToLower());
MessageBox.Show("Nhập đúng IP thiết bị mở cửa!"); Util.UpsertAppSettings("USE_PRINTER", chkAllowUsePrinter.Checked.ToString().ToLower());
return; Util.UpsertAppSettings("ALLOW_CHANGE_ROI_RECT", chkAllowChangeROIRect.Checked.ToString().ToLower());
} Util.UpsertAppSettings("AUTO_LOGIN", chkAllowAutoLogin.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP, txtDoorDeviceControlAccessIP.Text); Util.UpsertAppSettings("AUTO_RUN_AT_STARTUP", chkAllowAutoRunAtStartUp.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.AUTO_OPEN_DOOR_1, chkAllowAutoDoor1.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.AUTO_OPEN_DOOR_2, chkAllowAutoDoor2.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.USE_PRINTER, chkAllowUsePrinter.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.ALLOW_CHANGE_ROI_RECT, chkAllowChangeROIRect.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, chkAllowAutoLogin.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.AUTO_RUN_AT_STARTUP, chkAllowAutoRunAtStartUp.Checked.ToString().ToLower());
if (chkAllowAutoRunAtStartUp.Checked) if (chkAllowAutoRunAtStartUp.Checked)
{ {
Util.AddApplicationToStartup(); Util.AddApplicationToStartup();
@ -67,13 +61,13 @@ namespace AIParkingApplication
private void LoadConfiguration() private void LoadConfiguration()
{ {
doorAccessControlDeviceIP = ReadConfigurationFromAppSettings(AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP, string.Empty); doorAccessControlDeviceIP = ReadConfigurationFromAppSettings("DOOR_ACCESS_DEVICE_CONTROL_IP", string.Empty);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_OPEN_DOOR_1, "false"), out allowAutoOpenDoor1); bool.TryParse(ReadConfigurationFromAppSettings("AUTO_OPEN_DOOR_1", "false"), out allowAutoOpenDoor1);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_OPEN_DOOR_2, "false"), out allowAutoOpenDoor2); bool.TryParse(ReadConfigurationFromAppSettings("AUTO_OPEN_DOOR_2", "false"), out allowAutoOpenDoor2);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.USE_PRINTER, "false"), out allowUsePrinter); bool.TryParse(ReadConfigurationFromAppSettings("USE_PRINTER", "false"), out allowUsePrinter);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.ALLOW_CHANGE_ROI_RECT, "false"), out allowChangeROIRect); bool.TryParse(ReadConfigurationFromAppSettings("ALLOW_CHANGE_ROI_RECT", "false"), out allowChangeROIRect);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_LOGIN, "false"), out allowAutoLogin); bool.TryParse(ReadConfigurationFromAppSettings("AUTO_LOGIN", "false"), out allowAutoLogin);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_RUN_AT_STARTUP, "false"), out allowAutoRunAtStartUp); bool.TryParse(ReadConfigurationFromAppSettings("AUTO_RUN_AT_STARTUP", "false"), out allowAutoRunAtStartUp);
} }
private string ReadConfigurationFromAppSettings(string configurationKey, string defaultValueIfReadFailed) private string ReadConfigurationFromAppSettings(string configurationKey, string defaultValueIfReadFailed)
@ -90,19 +84,5 @@ namespace AIParkingApplication
return defaultValueIfReadFailed; return defaultValueIfReadFailed;
} }
} }
private void btnCheckDoorDeviceControlAccessIP_Click(object sender, EventArgs e)
{
lblDoorDeviceControlAccessIPStatus.Text = string.Empty;
bool isValidIPAddress = Util.IsValidIPAddress(txtDoorDeviceControlAccessIP.Text);
if (!isValidIPAddress)
{
lblDoorDeviceControlAccessIPStatus.Text = "Không đúng định dạng IP";
}
else
{
lblDoorDeviceControlAccessIPStatus.Text = "OK";
}
}
} }
} }

View File

@ -156,12 +156,12 @@ namespace AIParkingApplication
{ {
try try
{ {
bool.TryParse(ConfigurationManager.AppSettings[AppConstant.USE_PRINTER], out isUsePrinter); bool.TryParse(ConfigurationManager.AppSettings["USE_PRINTER"], out isUsePrinter);
} }
catch (Exception ex) catch (Exception ex)
{ {
Util.UpsertAppSettings(AppConstant.USE_PRINTER, "false"); Util.UpsertAppSettings("USE_PRINTER", "false");
appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: {AppConstant.USE_PRINTER}. ex: {ex.Message }"); appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: USE_PRINTER. ex: {ex.Message }");
} }
} }

View File

@ -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
@ -19,10 +20,9 @@ namespace AIParkingApplication
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; isAutoLogin = false;
string defaultLogoImagePath = Application.StartupPath + AppConstant.DEFAULT_LOGO_IMAGE; if (File.Exists(AppConstant.DEFAULT_LOGO_IMAGE))
if (File.Exists(defaultLogoImagePath))
{ {
pictureBoxImageLogo.Image = new Bitmap(defaultLogoImagePath); pictureBoxImageLogo.Image = new Bitmap(AppConstant.DEFAULT_LOGO_IMAGE);
} }
txtUsername.Focus(); txtUsername.Focus();
lblLoginStatus.Text = string.Empty; lblLoginStatus.Text = string.Empty;
@ -98,9 +98,9 @@ namespace AIParkingApplication
if (loginResult.IsLoginSuccess) if (loginResult.IsLoginSuccess)
{ {
Util.UpsertAppSettings(AppConstant.DEFAULT_USERNAME, txtUsername.Text); Util.UpsertAppSettings("DEFAULT_USERNAME", txtUsername.Text);
Util.UpsertAppSettings(AppConstant.DEFAULT_PASSWORD, txtPassword.Text); Util.UpsertAppSettings("DEFAULT_PASSWORD", txtPassword.Text);
Util.UpsertAppSettings(AppConstant.DEFAULT_WEB_SERVER, txtServerAddress.Text); Util.UpsertAppSettings("DEFAULT_WEB_SERVER", txtServerAddress.Text);
new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData, applicationLogger).Show(); new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData, applicationLogger).Show();
Hide(); Hide();
applicationLogger.Log(LogLevel.Info, $"Đăng nhập thành công với tài khoản: {txtUsername.Text}"); applicationLogger.Log(LogLevel.Info, $"Đăng nhập thành công với tài khoản: {txtUsername.Text}");
@ -116,10 +116,10 @@ namespace AIParkingApplication
{ {
try try
{ {
txtUsername.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_USERNAME]; txtUsername.Text = ConfigurationManager.AppSettings["DEFAULT_USERNAME"];
txtPassword.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_PASSWORD]; txtPassword.Text = ConfigurationManager.AppSettings["DEFAULT_PASSWORD"];
txtServerAddress.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_WEB_SERVER]; txtServerAddress.Text = ConfigurationManager.AppSettings["DEFAULT_WEB_SERVER"];
bool.TryParse(ConfigurationManager.AppSettings[AppConstant.AUTO_LOGIN], out isAutoLogin); bool.TryParse(ConfigurationManager.AppSettings["AUTO_LOGIN"], out isAutoLogin);
if (isAutoLogin) if (isAutoLogin)
{ {
chkAutoLogin.Checked = true; chkAutoLogin.Checked = true;
@ -130,13 +130,13 @@ namespace AIParkingApplication
{ {
txtUsername.Text = string.Empty; txtUsername.Text = string.Empty;
txtPassword.Text = string.Empty; txtPassword.Text = string.Empty;
Util.UpsertAppSettings(AppConstant.DEFAULT_USERNAME, string.Empty); Util.UpsertAppSettings("DEFAULT_USERNAME", string.Empty);
Util.UpsertAppSettings(AppConstant.DEFAULT_PASSWORD, string.Empty); Util.UpsertAppSettings("DEFAULT_PASSWORD", string.Empty);
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, "false"); Util.UpsertAppSettings("AUTO_LOGIN", "false");
Util.UpsertAppSettings(AppConstant.DEFAULT_WEB_SERVER, "127.0.0.1:80"); Util.UpsertAppSettings("DEFAULT_WEB_SERVER", "127.0.0.1:80");
chkAutoLogin.Checked = false; chkAutoLogin.Checked = 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: {AppConstant.DEFAULT_USERNAME}, {AppConstant.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");
} }
} }
@ -147,7 +147,7 @@ namespace AIParkingApplication
private void chkAutoLogin_CheckedChanged(object sender, EventArgs e) private void chkAutoLogin_CheckedChanged(object sender, EventArgs e)
{ {
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, (sender as CheckBox).Checked.ToString().ToLower()); Util.UpsertAppSettings("AUTO_LOGIN", (sender as CheckBox).Checked.ToString().ToLower());
} }
} }
} }

View File

@ -1,7 +1,6 @@
using OpenCvSharp; using OpenCvSharp;
using System; using System;
using System.Linq; using System.Linq;
using System.Windows.Forms;
namespace AIParkingApplication namespace AIParkingApplication
{ {
@ -21,8 +20,7 @@ namespace AIParkingApplication
this.maxSizePlate = maxSizePlate; this.maxSizePlate = maxSizePlate;
this.scaleFactor = scaleFactor; this.scaleFactor = scaleFactor;
this.minNeighbors = minNeighbors; this.minNeighbors = minNeighbors;
string plateWeightPath = Application.StartupPath + (this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME); plateCascadeClassifier = new CascadeClassifier(this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME);
plateCascadeClassifier = new CascadeClassifier(plateWeightPath);
} }
~PlateDetector() ~PlateDetector()
@ -89,8 +87,8 @@ namespace AIParkingApplication
public static class PlateDetectorConstant public static class PlateDetectorConstant
{ {
public const string SQUARE_PLATE_WEIGHT_FILENAME = @".\plate.xml"; public const string SQUARE_PLATE_WEIGHT_FILENAME = "plate.xml";
public const string LONG_PLATE_WEIGHT_FILENAME = @".\plateLong.xml"; public const string LONG_PLATE_WEIGHT_FILENAME = "plateLong.xml";
public const double SCALE_FACTOR_DEFAULT_SQUARE_PLATE = 1.03; public const double SCALE_FACTOR_DEFAULT_SQUARE_PLATE = 1.03;
public static int MIN_NEIGHBORS_DEFAULT_SQUARE_PLATE = 2; public static int MIN_NEIGHBORS_DEFAULT_SQUARE_PLATE = 2;

View File

@ -36,7 +36,6 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "Sidebar"; this.Name = "Sidebar";
this.Size = new System.Drawing.Size(192, 692); this.Size = new System.Drawing.Size(192, 692);
this.Load += new System.EventHandler(this.Sidebar_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
} }

View File

@ -8,20 +8,11 @@ namespace AIParkingApplication
public partial class Sidebar : UserControl public partial class Sidebar : UserControl
{ {
private Statistic statistic; private Statistic statistic;
private string logoImagePath;
private ApiController apiController;
public Sidebar(ApiController apiController, string logoImagePath = AppConstant.DEFAULT_LOGO_IMAGE) public Sidebar(ApiController apiController, string logoImagePath = AppConstant.DEFAULT_LOGO_IMAGE)
{ {
InitializeComponent(); InitializeComponent();
this.apiController = apiController; if (File.Exists(logoImagePath))
this.logoImagePath = logoImagePath;
}
private void Sidebar_Load(object sender, EventArgs e)
{
string defaultLogoImagePath = Application.StartupPath + logoImagePath;
if (File.Exists(defaultLogoImagePath))
{ {
PictureBox pictureBoxImageLogo; PictureBox pictureBoxImageLogo;
pictureBoxImageLogo = new PictureBox(); pictureBoxImageLogo = new PictureBox();