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
a65fe37d
Commit
a65fe37d
authored
Sep 30, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix postgre sql bug.
parent
5e432a94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
17 deletions
+16
-17
CAP.PostgreSqlCapOptionsExtension.cs
...tCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs
+1
-1
PostgreSqlMonitoringApi.cs
src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs
+13
-14
IConsumerHandler.Default.cs
src/DotNetCore.CAP/IConsumerHandler.Default.cs
+2
-2
No files found.
src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs
View file @
a65fe37d
...
...
@@ -34,7 +34,7 @@ namespace DotNetCore.CAP
using
(
var
scope
=
x
.
CreateScope
())
{
var
provider
=
scope
.
ServiceProvider
;
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
postgreSqlOptions
.
DbContextType
);
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
postgreSqlOptions
.
DbContextType
);
postgreSqlOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
postgreSqlOptions
;
}
...
...
src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs
View file @
a65fe37d
...
...
@@ -24,12 +24,12 @@ namespace DotNetCore.CAP.PostgreSql
public
StatisticsDto
GetStatistics
()
{
var
sql
=
string
.
Format
(
@"
select count(
Id
) from ""{0}"".""published"" where ""StatusName"" = N'Succeeded';
select count(
Id
) from ""{0}"".""received"" where ""StatusName"" = N'Succeeded';
select count(
Id
) from ""{0}"".""published"" where ""StatusName"" = N'Failed';
select count(
Id
) from ""{0}"".""received"" where ""StatusName"" = N'Failed';
select count(
Id
) from ""{0}"".""published"" where ""StatusName"" in (N'Processing',N'Scheduled',N'Enqueued');
select count(
Id
) from ""{0}"".""received"" where ""StatusName"" in (N'Processing',N'Scheduled',N'Enqueued');"
,
select count(
""Id""
) from ""{0}"".""published"" where ""StatusName"" = N'Succeeded';
select count(
""Id""
) from ""{0}"".""received"" where ""StatusName"" = N'Succeeded';
select count(
""Id""
) from ""{0}"".""published"" where ""StatusName"" = N'Failed';
select count(
""Id""
) from ""{0}"".""received"" where ""StatusName"" = N'Failed';
select count(
""Id""
) from ""{0}"".""published"" where ""StatusName"" in (N'Processing',N'Scheduled',N'Enqueued');
select count(
""Id""
) from ""{0}"".""received"" where ""StatusName"" in (N'Processing',N'Scheduled',N'Enqueued');"
,
_options
.
Schema
);
var
statistics
=
UseConnection
(
connection
=>
...
...
@@ -130,10 +130,10 @@ select count(Id) from ""{0}"".""received"" where ""StatusName"" in (N'Processin
private
int
GetNumberOfMessage
(
IDbConnection
connection
,
string
tableName
,
string
statusName
)
{
var
sqlQuery
=
statusName
==
StatusName
.
Processing
?
$"select count(
Id
) from \"
{
_options
.
Schema
}
\".\"
{
tableName
}
\" where \"StatusName\" in (N'Processing',N'Scheduled',N'Enqueued')"
:
$"select count(
Id
) from \"
{
_options
.
Schema
}
\".\"
{
tableName
}
\" where \"StatusName\" = @state"
;
?
$"select count(
\"Id\"
) from \"
{
_options
.
Schema
}
\".\"
{
tableName
}
\" where \"StatusName\" in (N'Processing',N'Scheduled',N'Enqueued')"
:
$"select count(
\"Id\"
) from \"
{
_options
.
Schema
}
\".\"
{
tableName
}
\" where \"StatusName\" = @state"
;
var
count
=
connection
.
ExecuteScalar
<
int
>(
sqlQuery
,
new
{
state
=
statusName
});
var
count
=
connection
.
ExecuteScalar
<
int
>(
sqlQuery
,
new
{
state
=
statusName
});
return
count
;
}
...
...
@@ -174,12 +174,11 @@ with aggr as (
where ""StatusName"" = N'Processing'
group by to_char(""Added"", 'yyyy-MM-dd-HH')
)
select ""Key"",""Count"" from aggr where ""Key""
in @keys
;"
;
select ""Key"",""Count"" from aggr where ""Key""
=Any(@keys)
;"
;
var
valuesMap
=
connection
.
Query
(
sqlQuery
,
new
{
keys
=
keyMaps
.
Keys
,
statusName
})
.
ToDictionary
(
x
=>
(
string
)
x
.
Key
,
x
=>
(
int
)
x
.
Count
);
var
valuesMap
=
connection
.
Query
(
sqlQuery
,
new
{
keys
=
keyMaps
.
Keys
.
ToList
(),
statusName
})
.
ToList
()
.
ToDictionary
(
x
=>
(
string
)
x
.
Key
,
x
=>
(
int
)
x
.
Count
);
foreach
(
var
key
in
keyMaps
.
Keys
)
if
(!
valuesMap
.
ContainsKey
(
key
))
valuesMap
.
Add
(
key
,
0
);
...
...
src/DotNetCore.CAP/IConsumerHandler.Default.cs
View file @
a65fe37d
...
...
@@ -40,9 +40,9 @@ namespace DotNetCore.CAP
public
void
Start
()
{
var
groupingMatchs
=
_selector
.
GetCandidatesMethodsOfGroupNameGrouped
();
var
groupingMatch
e
s
=
_selector
.
GetCandidatesMethodsOfGroupNameGrouped
();
foreach
(
var
matchGroup
in
groupingMatchs
)
foreach
(
var
matchGroup
in
groupingMatch
e
s
)
Task
.
Factory
.
StartNew
(()
=>
{
using
(
var
client
=
_consumerClientFactory
.
Create
(
matchGroup
.
Key
))
...
...
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