public CincronBackend(IConfigurationSection config, FMSSettings cfg) { try { string msgFile; #if DEBUG var path = System.Reflection.Assembly.GetExecutingAssembly().Location; msgFile = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(path), "..\\..\\..\\test\\Cincron\\parker-example-messages"); #else msgFile = config.GetValue <string>("Message File"); #endif Log.Information("Starting cincron backend with message file {file}", msgFile); if (!System.IO.File.Exists(msgFile)) { Log.Error("Message file {file} does not exist", msgFile); } _log = new JobLogDB(cfg); _log.Open( System.IO.Path.Combine(cfg.DataDirectory, "log.db"), startingSerial: cfg.StartingSerial ); _msgWatcher = new MessageWatcher(msgFile, _log, cfg); _msgWatcher.Start(); } catch (Exception ex) { Log.Error(ex, "Unhandled exception when initializing cincron backend"); } }
public void Dispose() { if (_msgWatcher != null) { _msgWatcher.Halt(); } if (_log != null) { _log.Close(); } _msgWatcher = null; _log = null; }