Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public static DataBaseDriver Instance()
        {
            if (instance == null)
            {
                instance = new DataBaseDriver();
            }

            return(instance);
        }