Compare commits
6 Commits
74855b6467
...
daf755949a
Author | SHA1 | Date | |
---|---|---|---|
daf755949a | |||
92d95236c8 | |||
06dc6957ce | |||
5773b6d48e | |||
73e353b99e | |||
9d25ac394b |
|
@ -26,7 +26,7 @@ namespace AIParkingApplication
|
||||||
this.apiController = apiController;
|
this.apiController = apiController;
|
||||||
this.configOnWeb = configOnWeb;
|
this.configOnWeb = configOnWeb;
|
||||||
|
|
||||||
ReadAccessControlDeviceIPConfiguration();
|
ReadAccessControlDeviceIPConfigurationFile();
|
||||||
if (string.IsNullOrEmpty(doorAccessControlDeviceIP) || !Util.IsValidIPAddress(doorAccessControlDeviceIP))
|
if (string.IsNullOrEmpty(doorAccessControlDeviceIP) || !Util.IsValidIPAddress(doorAccessControlDeviceIP))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Kiểm tra lại cấu hình IP thiết bị mở cửa! (C3200)", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Kiểm tra lại cấu hình IP thiết bị mở cửa! (C3200)", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
@ -135,6 +135,7 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e)
|
private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "IN-IN");
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneInIn();
|
UpdateLaneInIn();
|
||||||
|
@ -142,6 +143,7 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
|
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "IN-OUT");
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneInOut();
|
UpdateLaneInOut();
|
||||||
|
@ -149,6 +151,7 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
|
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "OUT-IN");
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneOutIn();
|
UpdateLaneOutIn();
|
||||||
|
@ -156,6 +159,7 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
|
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "OUT-OUT");
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneOutOut();
|
UpdateLaneOutOut();
|
||||||
|
@ -196,7 +200,51 @@ namespace AIParkingApplication
|
||||||
laneOut78?.Hide();
|
laneOut78?.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadAccessControlDeviceIPConfiguration()
|
private void InitLaneFirstTime()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string lanesConfig = ConfigurationManager.AppSettings["CURRENT_LANE_SETTING"];
|
||||||
|
if (!string.IsNullOrEmpty(lanesConfig))
|
||||||
|
{
|
||||||
|
string[] lanes = lanesConfig.Split('-');
|
||||||
|
if (lanes.Length == 2)
|
||||||
|
{
|
||||||
|
string lane0 = lanes[0].ToLower();
|
||||||
|
string lane1 = lanes[1].ToLower();
|
||||||
|
if (lane0 == "in" && lane1 == "in")
|
||||||
|
{
|
||||||
|
UpdateLaneInIn();
|
||||||
|
}
|
||||||
|
if (lane0 == "in" && lane1 == "out")
|
||||||
|
{
|
||||||
|
UpdateLaneInOut();
|
||||||
|
}
|
||||||
|
if (lane0 == "out" && lane1 == "in")
|
||||||
|
{
|
||||||
|
UpdateLaneOutIn();
|
||||||
|
}
|
||||||
|
if (lane0 == "out" && lane1 == "out")
|
||||||
|
{
|
||||||
|
UpdateLaneOutOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "IN-OUT");
|
||||||
|
UpdateLaneInOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "IN-OUT");
|
||||||
|
UpdateLaneInOut();
|
||||||
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReadAccessControlDeviceIPConfigurationFile()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -209,14 +257,23 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
||||||
{
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AIParkingApplicationForm_Load(object sender, EventArgs e)
|
private void AIParkingApplicationForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
InitAllLanes();
|
InitAllLanes();
|
||||||
|
InitLaneFirstTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult closeAppDialog = MessageBox.Show("Bạn chắc chắn thoát phần mềm quản lý bãi xe?", "Cảnh báo đóng ứng dụng: AIParking - Hệ thống quản lý bãi đỗ xe", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
|
||||||
|
if (closeAppDialog == DialogResult.OK)
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Cancel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<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="congvao1" />
|
||||||
|
<add key="DEFAULT_PASSWORD" value="123456a@" />
|
||||||
|
<add key="CURRENT_LANE_SETTING" value="OUT-OUT" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
|
5
AIParkingApplication/LoginForm.Designer.cs
generated
5
AIParkingApplication/LoginForm.Designer.cs
generated
|
@ -126,9 +126,11 @@
|
||||||
// lblLoginStatus
|
// lblLoginStatus
|
||||||
//
|
//
|
||||||
this.lblLoginStatus.AutoSize = true;
|
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(294, 117);
|
||||||
this.lblLoginStatus.Name = "lblLoginStatus";
|
this.lblLoginStatus.Name = "lblLoginStatus";
|
||||||
this.lblLoginStatus.Size = new System.Drawing.Size(66, 13);
|
this.lblLoginStatus.Size = new System.Drawing.Size(90, 18);
|
||||||
this.lblLoginStatus.TabIndex = 4;
|
this.lblLoginStatus.TabIndex = 4;
|
||||||
this.lblLoginStatus.Text = "Login Status";
|
this.lblLoginStatus.Text = "Login Status";
|
||||||
//
|
//
|
||||||
|
@ -154,6 +156,7 @@
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "AIParking - Hệ thống quản lý bãi đỗ xe - Đăng nhập";
|
this.Text = "AIParking - Hệ thống quản lý bãi đỗ xe - Đăng nhập";
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
|
this.Load += new System.EventHandler(this.LoginForm_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using OpenCvSharp;
|
||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -69,7 +71,7 @@ namespace AIParkingApplication
|
||||||
var execeptioMessage = loginResult.Exception.Message;
|
var execeptioMessage = loginResult.Exception.Message;
|
||||||
if (execeptioMessage.Contains("Error converting value"))
|
if (execeptioMessage.Contains("Error converting value"))
|
||||||
{
|
{
|
||||||
lblLoginStatus.UpdateLabel("Tên tài khoản hoặc mật khẩu không đúng!", Color.Red);
|
lblLoginStatus.UpdateLabel("Sai tên tài khoản hoặc mật khẩu!", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,13 +85,13 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
if (loginResult.IsLoginSuccess)
|
if (loginResult.IsLoginSuccess)
|
||||||
{
|
{
|
||||||
|
Util.AddOrUpdateAppSettings("DEFAULT_USERNAME", txtUsername.Text);
|
||||||
|
Util.AddOrUpdateAppSettings("DEFAULT_PASSWORD", txtPassword.Text);
|
||||||
new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData).Show();
|
new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData).Show();
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void btnLogin_Click(object sender, EventArgs e)
|
private void btnLogin_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Login();
|
Login();
|
||||||
|
@ -102,5 +104,25 @@ namespace AIParkingApplication
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ReadAppConfigurationFromFile()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
txtUsername.Text = ConfigurationManager.AppSettings["DEFAULT_USERNAME"];
|
||||||
|
txtPassword.Text = ConfigurationManager.AppSettings["DEFAULT_PASSWORD"];
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
||||||
|
txtUsername.Text = string.Empty;
|
||||||
|
txtPassword.Text = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoginForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ReadAppConfigurationFromFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -174,6 +175,29 @@ namespace AIParkingApplication
|
||||||
hostName = hostParts[0];
|
hostName = hostParts[0];
|
||||||
int.TryParse(hostParts[1], out port);
|
int.TryParse(hostParts[1], out port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddOrUpdateAppSettings(string key, string value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||||
|
var settings = configFile.AppSettings.Settings;
|
||||||
|
if (settings[key] == null)
|
||||||
|
{
|
||||||
|
settings.Add(key, value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settings[key].Value = value;
|
||||||
|
}
|
||||||
|
configFile.Save(ConfigurationSaveMode.Modified);
|
||||||
|
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
|
||||||
|
}
|
||||||
|
catch (ConfigurationErrorsException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tAddOrUpdateAppSettings\t{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlateRequestEngineModel
|
public class PlateRequestEngineModel
|
||||||
|
|
Loading…
Reference in New Issue
Block a user