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
24dcba90
Commit
24dcba90
authored
Dec 12, 2019
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mongodb dashboard query bugs
parent
c08808c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
10 deletions
+21
-10
IClientSessionHandle.CAP.cs
src/DotNetCore.CAP.MongoDB/IClientSessionHandle.CAP.cs
+12
-1
IDataStorage.MongoDB.cs
src/DotNetCore.CAP.MongoDB/IDataStorage.MongoDB.cs
+2
-2
IMonitoringApi.MongoDB.cs
src/DotNetCore.CAP.MongoDB/IMonitoringApi.MongoDB.cs
+7
-7
No files found.
src/DotNetCore.CAP.MongoDB/IClientSessionHandle.CAP.cs
View file @
24dcba90
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP
;
...
...
@@ -18,7 +19,7 @@ namespace MongoDB.Driver
public
CapMongoDbClientSessionHandle
(
ICapTransaction
transaction
)
{
_transaction
=
transaction
;
_sessionHandle
=
(
IClientSessionHandle
)
_transaction
.
DbTransaction
;
_sessionHandle
=
(
IClientSessionHandle
)
_transaction
.
DbTransaction
;
}
public
void
Dispose
()
...
...
@@ -76,5 +77,15 @@ namespace MongoDB.Driver
{
return
_sessionHandle
.
Fork
();
}
public
TResult
WithTransaction
<
TResult
>(
Func
<
IClientSessionHandle
,
CancellationToken
,
TResult
>
callback
,
TransactionOptions
transactionOptions
=
null
,
CancellationToken
cancellationToken
=
default
)
{
return
_sessionHandle
.
WithTransaction
(
callback
,
transactionOptions
,
cancellationToken
);
}
public
Task
<
TResult
>
WithTransactionAsync
<
TResult
>(
Func
<
IClientSessionHandle
,
CancellationToken
,
Task
<
TResult
>>
callbackAsync
,
TransactionOptions
transactionOptions
=
null
,
CancellationToken
cancellationToken
=
default
)
{
return
_sessionHandle
.
WithTransactionAsync
(
callbackAsync
,
transactionOptions
,
cancellationToken
);
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.MongoDB/IDataStorage.MongoDB.cs
View file @
24dcba90
...
...
@@ -52,7 +52,7 @@ namespace DotNetCore.CAP.MongoDB
public
async
Task
ChangeReceiveStateAsync
(
MediumMessage
message
,
StatusName
state
)
{
var
collection
=
_database
.
GetCollection
<
ReceivedMessage
>(
_options
.
Value
.
Publish
edCollection
);
var
collection
=
_database
.
GetCollection
<
ReceivedMessage
>(
_options
.
Value
.
Receiv
edCollection
);
var
updateDef
=
Builders
<
ReceivedMessage
>.
Update
.
Set
(
x
=>
x
.
Retries
,
message
.
Retries
)
...
...
@@ -161,7 +161,7 @@ namespace DotNetCore.CAP.MongoDB
{
if
(
collection
==
_options
.
Value
.
PublishedCollection
)
{
Builders
<
PublishedMessage
>.
Filter
.
Lt
(
x
=>
x
.
ExpiresAt
,
timeout
);
//
Builders<PublishedMessage>.Filter.Lt(x => x.ExpiresAt, timeout);
var
publishedCollection
=
_database
.
GetCollection
<
PublishedMessage
>(
_options
.
Value
.
PublishedCollection
);
var
ret
=
await
publishedCollection
.
DeleteManyAsync
(
x
=>
x
.
ExpiresAt
<
timeout
,
cancellationToken
);
...
...
src/DotNetCore.CAP.MongoDB/IMonitoringApi.MongoDB.cs
View file @
24dcba90
...
...
@@ -63,12 +63,12 @@ namespace DotNetCore.CAP.MongoDB
var
statistics
=
new
StatisticsDto
{
PublishedSucceeded
=
(
int
)
publishedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Succeeded
)),
(
int
)
publishedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Succeeded
)),
PublishedFailed
=
(
int
)
publishedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Failed
)),
(
int
)
publishedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Failed
)),
ReceivedSucceeded
=
(
int
)
receivedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Succeeded
)),
ReceivedFailed
=
(
int
)
receivedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Failed
))
(
int
)
receivedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Succeeded
)),
ReceivedFailed
=
(
int
)
receivedCollection
.
CountDocuments
(
x
=>
x
.
StatusName
==
nameof
(
StatusName
.
Failed
))
};
return
statistics
;
}
...
...
@@ -93,7 +93,7 @@ namespace DotNetCore.CAP.MongoDB
var
builder
=
Builders
<
MessageDto
>.
Filter
;
var
filter
=
builder
.
Empty
;
if
(!
string
.
IsNullOrEmpty
(
queryDto
.
StatusName
))
filter
&=
builder
.
Eq
(
x
=>
x
.
StatusName
,
queryDto
.
StatusName
);
filter
&=
builder
.
Where
(
x
=>
x
.
StatusName
.
ToLower
()
==
queryDto
.
StatusName
);
if
(!
string
.
IsNullOrEmpty
(
queryDto
.
Name
))
filter
&=
builder
.
Eq
(
x
=>
x
.
Name
,
queryDto
.
Name
);
...
...
@@ -135,7 +135,7 @@ namespace DotNetCore.CAP.MongoDB
private
int
GetNumberOfMessage
(
string
collectionName
,
string
statusName
)
{
var
collection
=
_database
.
GetCollection
<
BsonDocument
>(
collectionName
);
var
count
=
collection
.
CountDocuments
(
new
BsonDocument
{
{
"StatusName"
,
statusName
}
});
var
count
=
collection
.
CountDocuments
(
new
BsonDocument
{
{
"StatusName"
,
statusName
}
});
return
int
.
Parse
(
count
.
ToString
());
}
...
...
@@ -194,7 +194,7 @@ namespace DotNetCore.CAP.MongoDB
}
};
var
pipeline
=
new
[]
{
match
,
groupby
};
var
pipeline
=
new
[]
{
match
,
groupby
};
var
collection
=
_database
.
GetCollection
<
BsonDocument
>(
collectionName
);
var
result
=
collection
.
Aggregate
<
BsonDocument
>(
pipeline
).
ToList
();
...
...
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