v1.2.1
This commit is contained in:
40
Mip/AppOptions.cs
Normal file
40
Mip/AppOptions.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace Mip
|
||||
{
|
||||
public class AppOptions
|
||||
{
|
||||
public string Host { get; set; }
|
||||
public string Port { get; set; }
|
||||
public string LoginName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Database { get; set; }
|
||||
public bool Connetable { get; set; }
|
||||
|
||||
public AppOptions(string host, string port, string loginName, string password, string database)
|
||||
{
|
||||
Host = host;
|
||||
Port = port;
|
||||
LoginName = loginName;
|
||||
Password = password;
|
||||
Database = database;
|
||||
Connetable = CheckConnectivity();
|
||||
}
|
||||
|
||||
private bool CheckConnectivity()
|
||||
{
|
||||
Ping pingIP = new Ping();
|
||||
try
|
||||
{
|
||||
var pingReply = pingIP.Send(Host);
|
||||
|
||||
return pingReply.Status.ToString() == "Success";
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user