示例#1
0
 /// <summary>
 /// Construct a sink posting to the specified database.
 /// </summary>
 /// <param name="connectionString">Connection string to access the database.</param>
 /// <param name="sinkOptions">Supplies additional options for the sink</param>
 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
 /// <param name="columnOptions">Options that pertain to columns</param>
 /// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
 public MSSqlServerSink(
     string connectionString,
     MSSqlServerSinkOptions sinkOptions,
     IFormatProvider formatProvider   = null,
     ColumnOptions columnOptions      = null,
     ITextFormatter logEventFormatter = null)
     : this(sinkOptions, SinkDependenciesFactory.Create(connectionString, sinkOptions, formatProvider, columnOptions, logEventFormatter))
 {
 }
 private static void CreateTable(MSSqlServerSinkOptions sinkOptions, SinkDependencies sinkDependencies)
 {
     if (sinkOptions.AutoCreateSqlTable)
     {
         using (var eventTable = sinkDependencies.DataTableCreator.CreateDataTable())
         {
             sinkDependencies.SqlTableCreator.CreateTable(eventTable);
         }
     }
 }
        // Internal constructor with injectable dependencies for better testability
        internal MSSqlServerAuditSink(
            MSSqlServerSinkOptions sinkOptions,
            ColumnOptions columnOptions,
            SinkDependencies sinkDependencies)
        {
            ValidateParameters(sinkOptions, columnOptions);
            CheckSinkDependencies(sinkDependencies);

            _sqlLogEventWriter = sinkDependencies.SqlLogEventWriter;

            CreateTable(sinkOptions, sinkDependencies);
        }
        private static void ValidateParameters(MSSqlServerSinkOptions sinkOptions, ColumnOptions columnOptions)
        {
            if (sinkOptions?.TableName == null)
            {
                throw new InvalidOperationException("Table name must be specified!");
            }

            if (columnOptions.DisableTriggers)
            {
                throw new NotSupportedException($"The {nameof(ColumnOptions.DisableTriggers)} option is not supported for auditing.");
            }
        }
示例#5
0
        // Internal constructor with injectable dependencies for better testability
        internal MSSqlServerSink(
            MSSqlServerSinkOptions sinkOptions,
            SinkDependencies sinkDependencies)
        {
            ValidateParameters(sinkOptions);
            CheckSinkDependencies(sinkDependencies);

            _sqlBulkBatchWriter = sinkDependencies.SqlBulkBatchWriter;
            _eventTable         = sinkDependencies.DataTableCreator.CreateDataTable();

            CreateTable(sinkOptions, sinkDependencies);
        }
示例#6
0
 public MSSqlServerSinkOptions ConfigureSinkOptions(MSSqlServerSinkOptions sinkOptions, IConfigurationSection config) =>
 _sinkOptionsProvider.ConfigureSinkOptions(sinkOptions, config);
 public MSSqlServerSinkOptions ConfigureSinkOptions(MSSqlServerConfigurationSection config, MSSqlServerSinkOptions sinkOptions) =>
 _sinkOptionsProvider.ConfigureSinkOptions(config, sinkOptions);