AIParkingApplicationForm - Add method: InitLaneFirstTime, save lanes configuration.
This commit is contained in:
parent
92d95236c8
commit
daf755949a
|
@ -26,7 +26,7 @@ namespace AIParkingApplication
|
|||
this.apiController = apiController;
|
||||
this.configOnWeb = configOnWeb;
|
||||
|
||||
ReadAccessControlDeviceIPConfiguration();
|
||||
ReadAccessControlDeviceIPConfigurationFile();
|
||||
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);
|
||||
|
@ -135,6 +135,7 @@ namespace AIParkingApplication
|
|||
|
||||
private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "IN-IN");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneInIn();
|
||||
|
@ -142,6 +143,7 @@ namespace AIParkingApplication
|
|||
|
||||
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "IN-OUT");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneInOut();
|
||||
|
@ -149,6 +151,7 @@ namespace AIParkingApplication
|
|||
|
||||
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "OUT-IN");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneOutIn();
|
||||
|
@ -156,6 +159,7 @@ namespace AIParkingApplication
|
|||
|
||||
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.AddOrUpdateAppSettings("CURRENT_LANE_SETTING", "OUT-OUT");
|
||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||
StopAllLanes();
|
||||
UpdateLaneOutOut();
|
||||
|
@ -196,7 +200,51 @@ namespace AIParkingApplication
|
|||
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
|
||||
{
|
||||
|
@ -212,6 +260,7 @@ namespace AIParkingApplication
|
|||
private void AIParkingApplicationForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
InitAllLanes();
|
||||
InitLaneFirstTime();
|
||||
}
|
||||
|
||||
private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<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>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user