Util - Add IsValidIPAddress
This commit is contained in:
parent
2c559d26b9
commit
6d7125511c
|
@ -27,7 +27,7 @@ namespace AIParkingApplication
|
|||
this.configOnWeb = configOnWeb;
|
||||
|
||||
ReadAccessControlDeviceIPConfiguration();
|
||||
if (string.IsNullOrEmpty(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);
|
||||
Application.Exit();
|
||||
|
@ -56,8 +56,6 @@ namespace AIParkingApplication
|
|||
MessageBox.Show("Cấu hình API Plate Recognize lỗi!", "Cấu hình API Engine lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void InitAllLanes()
|
||||
|
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -143,6 +144,16 @@ namespace AIParkingApplication
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsValidIPAddress(string ipAddress)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ipAddress))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool isValidIPAddress = IPAddress.TryParse(ipAddress, out IPAddress ip);
|
||||
return isValidIPAddress;
|
||||
}
|
||||
|
||||
public static bool IsUrlValid(string url)
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user