StatusBar - Check file engine.bat exist

This commit is contained in:
DucDangAnh 2020-07-06 09:41:54 +07:00
parent b441c2d70a
commit 3d08edea71
2 changed files with 12 additions and 4 deletions

View File

@ -13,7 +13,6 @@ namespace AIParkingApplication
private StatusBar statusBar; private StatusBar statusBar;
private Statistic statistic; private Statistic statistic;
public AIParkingApplicationForm() public AIParkingApplicationForm()
{ {
InitializeComponent(); InitializeComponent();

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
@ -11,6 +12,7 @@ namespace AIParkingApplication
private string webServerIP; private string webServerIP;
private string doorAccessControlDeviceIP; private string doorAccessControlDeviceIP;
private TimeSpan updateInterval; private TimeSpan updateInterval;
private const string engineFilePath = @"\engine.bat";
public StatusBar(string webServerIP, string doorAccessControlDeviceIP, TimeSpan updateInterval) public StatusBar(string webServerIP, string doorAccessControlDeviceIP, TimeSpan updateInterval)
{ {
@ -39,9 +41,16 @@ namespace AIParkingApplication
if (Process.GetProcessesByName("tmux").Length == 0) if (Process.GetProcessesByName("tmux").Length == 0)
{ {
string engineBatFilePath = Application.StartupPath + @"\engine.bat"; if (File.Exists(engineFilePath))
Util.ExecuteCommand(engineBatFilePath); {
lblEngineStatus.UpdateLabel("DỪNG HOẠT ĐỘNG", Color.Red); string engineBatFilePath = Application.StartupPath + engineFilePath;
Util.ExecuteCommand(engineBatFilePath);
lblEngineStatus.UpdateLabel("DỪNG HOẠT ĐỘNG", Color.Red);
}
else
{
lblEngineStatus.UpdateLabel("KHÔNG TÌM THẤY FILE", Color.Red);
}
} }
else else
{ {