C# – Network Monitor Class Library Design Pattern
Monitor.cs |
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NetworkMonitor { public class Monitor { private string HostName; private Ping ping; private WindowsService service; private SQLConnection sqlconn; private DNS dns; private Notification notify; private Library lib; public Monitor(string HostName) { this.HostName = HostName; this.ping = new Ping(HostName); this.service = new WindowsService(HostName); this.sqlconn = new SQLConnection(HostName); this.dns = new DNS(HostName); this.notify = new Notification(); this.lib = new Library(); } public bool IsReachable() { return this.ping.IsReachable(); } public void pingTest() { this.ping.pingTest(); } public void WindowsServiceValidate(string loginname, string password) { this.service.WindowsServiceValidate(loginname, password); } public string getIPAddrbyDomainName() { return this.dns.getIPbyHostName(); } public bool ValidateSQLServerAlive(string InstanceName, string DatabaseName, string UserName, string Password) { return this.sqlconn.ValidateSQLServerAlive(InstanceName, DatabaseName, UserName, Password); } } } |