public bool init() { initOK = false; try { logger = Logging.LogService.Instance(); if (!System.IO.File.Exists(pathConigFile)) { LogEntry(System.Diagnostics.EventLogEntryType.Error, "Receiver.init failed: " + pathConigFile + " does not exist"); return(false); } Logging.IniFile ini = new Logging.IniFile(pathConigFile); DataBaseDriver.DBAddress = ini.Read("Address", "DATABASE"); DataBaseDriver.DBName = ini.Read("DBName", "DATABASE"); DataBaseDriver.DBUserName = ini.Read("DBUser", "DATABASE"); DataBaseDriver.DBPassword = ini.Read("DBPwd", "DATABASE"); listenPort = Int32.Parse(ini.Read("ListenPort", "SERVICE")); Logging.LogService.LogPath = ini.Read("LogPath", "PATH"); String daysToZipLog = ini.Read("DaysToZip", "HOUSEKEEPING"); String daysToDeleteLog = ini.Read("DaysToDelete", "HOUSEKEEPING"); dbDriver = DataBaseDriver.Instance(); tcpServer = new TCPServer(listenPort); tcpServer.OnClientMessage += handleDataMessage; houseKeepingAgent = new FileZipAgent(Logging.LogService.LogPath, daysToZipLog, daysToDeleteLog); if (!houseKeepingAgent.init()) { LogEntry(System.Diagnostics.EventLogEntryType.Error, "Receiver.init failed: Check paramaeter for housekeeping"); return(false); } LogEntry(System.Diagnostics.EventLogEntryType.Information, "Receiver.init ok"); initOK = true; return(true); } catch (Exception ex) { LogEntry(System.Diagnostics.EventLogEntryType.Error, "Receiver.init failed: " + ex.Message); } return(false); }
private void init() { try { logger = LogService.Instance(); workerSynch = new object(); workerIsBusy = false; tiWorker = new System.Timers.Timer(); tiWorker.Interval = 10000; tiWorker.Elapsed += TiWorker_Elapsed; if (!File.Exists(configFolder)) { initOK = false; logEntry(System.Diagnostics.EventLogEntryType.Error, "DataClient.init failed: " + configFolder + " does not exist"); return; } IniFile ini = new IniFile(configFolder); LogService.LogPath = ini.Read("LogPath", "PATH"); Location = ini.Read("Location", "GENERAL"); workerInterval = Int32.Parse(ini.Read("ScanIntervalMinutes", "GENERAL")) * 1000 * 60; aliveInterval = Int32.Parse(ini.Read("AliveIntervalMinutes", "GENERAL")) * 1000 * 60; scanFolder = ini.Read("ScanFolder", "PATH"); workingFolder = ini.Read("WorkingFolder", "PATH"); queueFolder = ini.Read("QueueFolder", "PATH"); suspectFolder = ini.Read("SuspectFolder", "PATH"); DataManager.Network.TCPClient.ServerAddress = ini.Read("ServiceAddress", "CONNECTION"); DataManager.Network.TCPClient.ServerPort = Int32.Parse(ini.Read("ServicePort", "CONNECTION")); DataFile.FileNameRegEx = ini.Read("FileNameRegEx", "FORMAT"); DataFile.FileContentHeaderRegEx = ini.Read("ContentHeaderRegEx", "FORMAT"); DataFile.DateTimeFormat = ini.Read("ContentDateTimeFormat", "FORMAT"); aliveAgent = new AliveAgent(aliveInterval, Location); String daysToZipLog = ini.Read("DaysToZip", "HOUSEKEEPING"); String daysToDeleteLog = ini.Read("DaysToDelete", "HOUSEKEEPING"); houseKeepingAgent = new FileZipAgent(LogService.LogPath, daysToZipLog, daysToDeleteLog); if (!houseKeepingAgent.init()) { logEntry(System.Diagnostics.EventLogEntryType.Error, "DataClient.init failed: Check housekeeping parameter"); initOK = false; return; } initOK = true; logEntry(System.Diagnostics.EventLogEntryType.Information, "DataClient.init ok"); } catch (Exception ex) { initOK = false; logEntry(System.Diagnostics.EventLogEntryType.Error, "DataClient.init failed: " + ex.Message); } }