Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Assignment2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bad
Assignment2
Compare revisions
72c042f2886223adf461c7692e24cc265d05b5b7 to ac5af842c5dbb4ecd4565add9b8658f105d031d4
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
bad1/assignment2
Select target project
No results found
ac5af842c5dbb4ecd4565add9b8658f105d031d4
Select Git revision
Swap
Target
bad1/assignment2
Select target project
bad1/assignment2
1 result
72c042f2886223adf461c7692e24cc265d05b5b7
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Fixed dat shit
· a4dc5f82
BigDude
authored
2 weeks ago
a4dc5f82
Merge branch 'main' of
https://gitlab.au.dk/bad1/assignment2
· ac5af842
BigDude
authored
2 weeks ago
ac5af842
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Interfaces/ILogService.cs
+1
-0
1 addition, 0 deletions
Interfaces/ILogService.cs
Models/LogEntry.cs
+1
-2
1 addition, 2 deletions
Models/LogEntry.cs
Services/LogsService.cs
+9
-18
9 additions, 18 deletions
Services/LogsService.cs
with
11 additions
and
20 deletions
Interfaces/ILogService.cs
View file @
ac5af842
...
@@ -2,6 +2,7 @@ using System;
...
@@ -2,6 +2,7 @@ using System;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
assignment1.Models
;
using
assignment2.Models
;
using
assignment2.Models
;
namespace
assignment2.Interfaces
namespace
assignment2.Interfaces
...
...
This diff is collapsed.
Click to expand it.
Models/LogEntry.cs
View file @
ac5af842
...
@@ -6,9 +6,8 @@ namespace assignment2.Models
...
@@ -6,9 +6,8 @@ namespace assignment2.Models
[
BsonIgnoreExtraElements
]
[
BsonIgnoreExtraElements
]
public
class
LogEntry
public
class
LogEntry
{
{
[
BsonId
]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
public
int
Id
{
get
;
set
;
}
public
string
?
Id
{
get
;
set
;
}
[
BsonElement
(
"Level"
)]
[
BsonElement
(
"Level"
)]
public
int
Level
{
get
;
set
;
}
public
int
Level
{
get
;
set
;
}
...
...
This diff is collapsed.
Click to expand it.
Services/LogsService.cs
View file @
ac5af842
...
@@ -2,6 +2,7 @@ using System;
...
@@ -2,6 +2,7 @@ using System;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
assignment1.Models
;
using
assignment2.Interfaces
;
using
assignment2.Interfaces
;
using
assignment2.Models
;
using
assignment2.Models
;
using
Microsoft.Extensions.Options
;
using
Microsoft.Extensions.Options
;
...
@@ -13,7 +14,7 @@ namespace assignment2.Services
...
@@ -13,7 +14,7 @@ namespace assignment2.Services
{
{
public
class
LogsService
:
ILogService
public
class
LogsService
:
ILogService
{
{
private
readonly
IMongoCollection
<
Log
>
_logsCollection
;
private
readonly
IMongoCollection
<
Log
Entry
>
_logsCollection
;
private
readonly
MongoClient
_mongoClient
;
private
readonly
MongoClient
_mongoClient
;
private
readonly
IMongoDatabase
_database
;
private
readonly
IMongoDatabase
_database
;
...
@@ -26,39 +27,29 @@ namespace assignment2.Services
...
@@ -26,39 +27,29 @@ namespace assignment2.Services
_database
=
_mongoClient
.
GetDatabase
(
_database
=
_mongoClient
.
GetDatabase
(
logsDatabaseSettings
.
Value
.
DatabaseName
);
logsDatabaseSettings
.
Value
.
DatabaseName
);
//BsonClassMap.RegisterClassMap<Log>(cm =>
_logsCollection
=
_database
.
GetCollection
<
LogEntry
>(
//{
// cm.AutoMap();
// cm.MapMember(c => c.User).SetElementName("Properties.Log.User");
// cm.MapMember(c => c.Operation).SetElementName("Properties.Log.Operation");
// cm.MapMember(c => c.Timestamp).SetElementName("Properties.Log.Timestamp");
// cm.SetIgnoreExtraElements(true);
//});
_logsCollection
=
_database
.
GetCollection
<
Log
>(
logsDatabaseSettings
.
Value
.
LogsCollectionName
);
logsDatabaseSettings
.
Value
.
LogsCollectionName
);
}
}
public
async
Task
<
IEnumerable
<
Log
>>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
)
public
async
Task
<
IEnumerable
<
Log
Entry
>>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
)
{
{
var
builder
=
Builders
<
Log
>.
Filter
;
var
builder
=
Builders
<
Log
Entry
>.
Filter
;
var
filters
=
new
List
<
FilterDefinition
<
Log
>>();
var
filters
=
new
List
<
FilterDefinition
<
Log
Entry
>>();
if
(!
string
.
IsNullOrEmpty
(
user
))
if
(!
string
.
IsNullOrEmpty
(
user
))
filters
.
Add
(
builder
.
Eq
(
u
=>
u
.
User
,
user
));
filters
.
Add
(
builder
.
Eq
(
u
=>
u
.
Properties
.
LogInfo
.
User
,
user
));
if
(!
string
.
IsNullOrEmpty
(
operation
))
if
(!
string
.
IsNullOrEmpty
(
operation
))
filters
.
Add
(
builder
.
Eq
(
u
=>
u
.
Operation
,
operation
));
filters
.
Add
(
builder
.
Eq
(
u
=>
u
.
Properties
.
LogInfo
.
Operation
,
operation
));
if
(
startDate
.
HasValue
&&
endTime
.
HasValue
)
if
(
startDate
.
HasValue
&&
endTime
.
HasValue
)
filters
.
Add
(
builder
.
And
(
builder
.
Gte
(
u
=>
u
.
Timestamp
,
startDate
),
builder
.
Lte
(
u
=>
u
.
Timestamp
,
endTime
)));
filters
.
Add
(
builder
.
And
(
builder
.
Gte
(
u
=>
u
.
Properties
.
LogInfo
.
Timestamp
,
startDate
),
builder
.
Lte
(
u
=>
u
.
Properties
.
LogInfo
.
Timestamp
,
endTime
)));
var
filter
=
filters
.
Count
>
0
?
builder
.
And
(
filters
)
:
builder
.
Empty
;
var
filter
=
filters
.
Count
>
0
?
builder
.
And
(
filters
)
:
builder
.
Empty
;
return
await
_logsCollection
.
Find
(
filter
).
ToListAsync
();
return
await
_logsCollection
.
Find
(
filter
).
ToListAsync
();
}
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.