Pārlūkot izejas kodu

Fix SqlServer options bug

master
Savorboard pirms 5 gadiem
vecāks
revīzija
6884802770
7 mainītis faili ar 25 papildinājumiem un 20 dzēšanām
  1. +1
    -1
      src/DotNetCore.CAP.SqlServer/CAP.EFOptions.cs
  2. +3
    -2
      src/DotNetCore.CAP.SqlServer/ICollectProcessor.SqlServer.cs
  3. +3
    -2
      src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs
  4. +11
    -10
      src/DotNetCore.CAP.SqlServer/IStorage.SqlServer.cs
  5. +6
    -3
      src/DotNetCore.CAP.SqlServer/IStorageConnection.SqlServer.cs
  6. +0
    -1
      src/DotNetCore.CAP.SqlServer/IStorageTransaction.SqlServer.cs
  7. +1
    -1
      test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs

+ 1
- 1
src/DotNetCore.CAP.SqlServer/CAP.EFOptions.cs Parādīt failu

@@ -17,7 +17,7 @@ namespace DotNetCore.CAP
public string Schema { get; set; } = DefaultSchema;

/// <summary>
/// EF dbcontext type.
/// EF DbContext
/// </summary>
internal Type DbContextType { get; set; }



+ 3
- 2
src/DotNetCore.CAP.SqlServer/ICollectProcessor.SqlServer.cs Parādīt failu

@@ -20,12 +20,13 @@ namespace DotNetCore.CAP.SqlServer
"Published", "Received"
};

private readonly TimeSpan _delay = TimeSpan.FromSeconds(1);
private readonly ILogger _logger;
private readonly SqlServerOptions _options;
private readonly TimeSpan _delay = TimeSpan.FromSeconds(1);
private readonly TimeSpan _waitingInterval = TimeSpan.FromMinutes(5);

public SqlServerCollectProcessor(ILogger<SqlServerCollectProcessor> logger,
public SqlServerCollectProcessor(
ILogger<SqlServerCollectProcessor> logger,
IOptions<SqlServerOptions> sqlServerOptions)
{
_logger = logger;


+ 3
- 2
src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs Parādīt failu

@@ -10,6 +10,7 @@ using DotNetCore.CAP.Dashboard;
using DotNetCore.CAP.Dashboard.Monitoring;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using Microsoft.Extensions.Options;

namespace DotNetCore.CAP.SqlServer
{
@@ -18,9 +19,9 @@ namespace DotNetCore.CAP.SqlServer
private readonly SqlServerOptions _options;
private readonly SqlServerStorage _storage;

public SqlServerMonitoringApi(IStorage storage, SqlServerOptions options)
public SqlServerMonitoringApi(IStorage storage, IOptions<SqlServerOptions> options)
{
_options = options ?? throw new ArgumentNullException(nameof(options));
_options = options.Value ?? throw new ArgumentNullException(nameof(options));
_storage = storage as SqlServerStorage ?? throw new ArgumentNullException(nameof(storage));
}



+ 11
- 10
src/DotNetCore.CAP.SqlServer/IStorage.SqlServer.cs Parādīt failu

@@ -17,21 +17,22 @@ namespace DotNetCore.CAP.SqlServer
{
public class SqlServerStorage : IStorage
{
private readonly CapOptions _capOptions;
private readonly DiagnosticProcessorObserver _diagnosticProcessorObserver;
private readonly IDbConnection _existingConnection = null;
private readonly ILogger _logger;
private readonly SqlServerOptions _options;
private readonly IOptions<CapOptions> _capOptions;
private readonly IOptions<SqlServerOptions> _options;
private readonly IDbConnection _existingConnection = null;
private readonly DiagnosticProcessorObserver _diagnosticProcessorObserver;

public SqlServerStorage(ILogger<SqlServerStorage> logger,
public SqlServerStorage(
ILogger<SqlServerStorage> logger,
IOptions<CapOptions> capOptions,
IOptions<SqlServerOptions> options,
DiagnosticProcessorObserver diagnosticProcessorObserver)
{
_options = options.Value;
_options = options;
_diagnosticProcessorObserver = diagnosticProcessorObserver;
_logger = logger;
_capOptions = capOptions.Value;
_capOptions = capOptions;
}

public IStorageConnection GetConnection()
@@ -51,9 +52,9 @@ namespace DotNetCore.CAP.SqlServer
return;
}

var sql = CreateDbTablesScript(_options.Schema);
var sql = CreateDbTablesScript(_options.Value.Schema);

using (var connection = new SqlConnection(_options.ConnectionString))
using (var connection = new SqlConnection(_options.Value.ConnectionString))
{
await connection.ExecuteAsync(sql);
}
@@ -128,7 +129,7 @@ END;";

internal IDbConnection CreateAndOpenConnection()
{
var connection = _existingConnection ?? new SqlConnection(_options.ConnectionString);
var connection = _existingConnection ?? new SqlConnection(_options.Value.ConnectionString);

if (connection.State == ConnectionState.Closed)
{


+ 6
- 3
src/DotNetCore.CAP.SqlServer/IStorageConnection.SqlServer.cs Parādīt failu

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Dapper;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using Microsoft.Extensions.Options;

namespace DotNetCore.CAP.SqlServer
{
@@ -15,10 +16,12 @@ namespace DotNetCore.CAP.SqlServer
{
private readonly CapOptions _capOptions;

public SqlServerStorageConnection(SqlServerOptions options, CapOptions capOptions)
public SqlServerStorageConnection(
IOptions<SqlServerOptions> options,
IOptions<CapOptions> capOptions)
{
_capOptions = capOptions;
Options = options;
_capOptions = capOptions.Value;
Options = options.Value;
}

public SqlServerOptions Options { get; }


+ 0
- 1
src/DotNetCore.CAP.SqlServer/IStorageTransaction.SqlServer.cs Parādīt failu

@@ -13,7 +13,6 @@ namespace DotNetCore.CAP.SqlServer
public class SqlServerStorageTransaction : IStorageTransaction
{
private readonly IDbConnection _dbConnection;

private readonly string _schema;

public SqlServerStorageTransaction(SqlServerStorageConnection connection)


+ 1
- 1
test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs Parādīt failu

@@ -14,7 +14,7 @@ namespace DotNetCore.CAP.SqlServer.Test

public SqlServerStorageConnectionTest()
{
_storage = new SqlServerStorageConnection(SqlSeverOptions.Value, CapOptions.Value);
_storage = new SqlServerStorageConnection(SqlSeverOptions, CapOptions);
}

[Fact]


Notiek ielāde…
Atcelt
Saglabāt