Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
68848027
Commit
68848027
authored
Jul 09, 2019
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SqlServer options bug
parent
7021dc65
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
20 deletions
+25
-20
CAP.EFOptions.cs
src/DotNetCore.CAP.SqlServer/CAP.EFOptions.cs
+1
-1
ICollectProcessor.SqlServer.cs
src/DotNetCore.CAP.SqlServer/ICollectProcessor.SqlServer.cs
+3
-2
IMonitoringApi.SqlServer.cs
src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs
+3
-2
IStorage.SqlServer.cs
src/DotNetCore.CAP.SqlServer/IStorage.SqlServer.cs
+11
-10
IStorageConnection.SqlServer.cs
src/DotNetCore.CAP.SqlServer/IStorageConnection.SqlServer.cs
+6
-3
IStorageTransaction.SqlServer.cs
...DotNetCore.CAP.SqlServer/IStorageTransaction.SqlServer.cs
+0
-1
SqlServerStorageConnectionTest.cs
...Core.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs
+1
-1
No files found.
src/DotNetCore.CAP.SqlServer/CAP.EFOptions.cs
View file @
68848027
...
...
@@ -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
;
}
...
...
src/DotNetCore.CAP.SqlServer/ICollectProcessor.SqlServer.cs
View file @
68848027
...
...
@@ -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
;
...
...
src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs
View file @
68848027
...
...
@@ -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
));
}
...
...
src/DotNetCore.CAP.SqlServer/IStorage.SqlServer.cs
View file @
68848027
...
...
@@ -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
)
{
...
...
src/DotNetCore.CAP.SqlServer/IStorageConnection.SqlServer.cs
View file @
68848027
...
...
@@ -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
;
}
...
...
src/DotNetCore.CAP.SqlServer/IStorageTransaction.SqlServer.cs
View file @
68848027
...
...
@@ -13,7 +13,6 @@ namespace DotNetCore.CAP.SqlServer
public
class
SqlServerStorageTransaction
:
IStorageTransaction
{
private
readonly
IDbConnection
_dbConnection
;
private
readonly
string
_schema
;
public
SqlServerStorageTransaction
(
SqlServerStorageConnection
connection
)
...
...
test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs
View file @
68848027
...
...
@@ -14,7 +14,7 @@ namespace DotNetCore.CAP.SqlServer.Test
public
SqlServerStorageConnectionTest
()
{
_storage
=
new
SqlServerStorageConnection
(
SqlSeverOptions
.
Value
,
CapOptions
.
Value
);
_storage
=
new
SqlServerStorageConnection
(
SqlSeverOptions
,
CapOptions
);
}
[
Fact
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment