public HttpKeepAliveService(IWatchDog watchDog, HttpSettings httpSettings) { Validation.RequireValidHttpSettings(httpSettings); _watchDog = watchDog ?? throw new ArgumentNullException(nameof(watchDog)); _httpSettings = httpSettings; _watchedConnections = new Dictionary <IDisposable, IWatchDogSession>(); }
public WebSocketDeviceConnectedHandler( IHandler <IWebSocketRemoteDevice, string> commandHandler, IWatchDog watchDog) { _commandHandler = commandHandler ?? throw new ArgumentNullException(nameof(commandHandler)); _watchDog = watchDog ?? throw new ArgumentNullException(nameof(watchDog)); }
public int CreateWatchDogsFromFile(string filename) { lock (m_Dogs) { m_Dogs.Clear(); //获取应用程序运行路径 string path = System.AppDomain.CurrentDomain.BaseDirectory; path = path.Substring(0, path.LastIndexOf("\\") + 1); DataSet DBds = new DataSet(); //读入数据库连接参数 DBds = MD5Encrypt.DES.instance().DecryptXML2DS(path + filename, 1); if (DBds.Tables["SysDB"].Rows.Count == 0) { throw new Exception("未定义数据库连接,请检查配置文件"); } Dictionary <string, string> sysdb = new Dictionary <string, string>(); Dictionary <string, string> paras = new Dictionary <string, string>(); foreach (DataRow r in DBds.Tables["SysDB"].Rows) { string conn = "Persist Security Info=False;"; conn += "server=" + r["hostname"].ToString() + ";"; conn += "user id=" + r["username"] + ";"; conn += "pwd =" + r["userpass"].ToString() + ";"; conn += "database=" + r["database"].ToString(); sysdb[r["dbname"].ToString()] = conn; } if (!sysdb.ContainsKey("WatchDogDB")) { throw new Exception("未定义系统数据库, 请检查配置文件"); } foreach (DataRow r in DBds.Tables["Parameters"].Rows) { paras.Add(r["paraname"].ToString(), r["value"].ToString()); } m_DBStr = sysdb["WatchDogDB"].ToString(); m_TableName = paras["WatchDog Table"]; foreach (DataRow r in DBds.Tables["HostDB"].Rows) { IWatchDog dog = CreateWatchDog( r["host"].ToString(), r["component"].ToString(), Convert.ToInt32(r["refresh_interval"]), Convert.ToInt32(r["timeout"])); m_Dogs[dog.Host][dog.Component] = dog as WatchDog; } return(m_Dogs.Count); } }
public TcpClientHandler( ISslService sslService, ITcpSessionFactory tcpSessionFactory, IWatchDog tcpWatchDog, TcpSettings tcpSettings) { Validation.RequireValidTcpSettings(tcpSettings); _sslService = sslService ?? throw new ArgumentNullException(nameof(sslService)); _tcpSessionFactory = tcpSessionFactory ?? throw new ArgumentNullException(nameof(tcpSessionFactory)); _tcpWatchDog = tcpWatchDog ?? throw new ArgumentNullException(nameof(tcpWatchDog)); _tcpWatchDog.MaxSessionDuration = tcpSettings.IdleTimeout; _tcpSettings = tcpSettings; }
public int CompareTo(IWatchDog other) { int i = m_Host.CompareTo(other.Host); if (i < 0) return -1; else if (i > 0) return 1; i = m_Component.CompareTo(other.Component); if (i < 0) return -1; else if (i > 0) return 1; else return 0; }
static void Main(string[] args) { ConfigureContainer(); var pathToStorage = @"C:\zdir\backup\remote\storage"; var pathToTempStorage = @"C:\zdir\backup\remote\tempstorage"; WatchDog = Container.Resolve <IWatchDog>(); var comminicator = new Communicator(13001, new NetworkClient("TestServer", new TcpClient()), new NetworkListener()); var fileServer = new RemoteFileServer(comminicator, pathToStorage, pathToTempStorage); var backupService = new BackupServiceModule(fileServer); WatchDog.RegisterModule(backupService); WatchDog.Start(); Console.WriteLine("Press any key to stop backup server"); Console.ReadKey(); WatchDog.Stop(); }