protected override void Initialise(XElement configXML, GlobalData globalData, ILogger logger) { if (configXML == null) { throw new ConfigException("Missing Config"); } var tablename = configXML.Attribute("tablename")?.Value; if (tablename == null) { throw new ConfigException("Missing Table name"); } lock (_initialisationObject) { if (!globalData.CacheDataSet.Tables.Contains(tablename)) { logger.Debug(string.Format("Pipe {0}: {1} Already initailised", PipeNumber, nameof(CacheTableLoader))); return; } try { _loggingTable = DataTableBuilder.Build(configXML); } catch (Exception ex) { throw new ConfigException("Invalid Configuration: " + ex.Message); } globalData.CacheDataSet.Tables.Add(_loggingTable.Table); } }
protected override void Initialise(XElement configXML, GlobalData globalData, ILogger logger) { if (configXML == null) { throw new ConfigException("Missing Config"); } Interlocked.Increment(ref _activeInstances); lock (_initialisationObject) { if (_initailised) { logger.Debug(string.Format("Pipe {0}: {1} Already initailised", PipeNumber, nameof(SQLBulkLoader))); return; } _tablename = configXML.Attribute("tablename")?.Value; if (string.IsNullOrWhiteSpace(_tablename)) { throw new ConfigException("Missing table name"); } _connStr = configXML.Attribute("connection")?.Value ?? GlobalData.Data["connection"].ToString(); if (!string.IsNullOrWhiteSpace(configXML.Attribute("batchsize")?.Value) && !int.TryParse(configXML.Attribute("batchsize")?.Value, out _batchSize)) { throw new ConfigException("Invalid batch size"); } try { _loggingTable = DataTableBuilder.Build(configXML); } catch (Exception ex) { throw new ConfigException("Invalid Configuration: " + ex.Message); } _initailised = true; } }