Skip to content

Commit 61af3a8

Browse files
authored
Add operation and table to EF (#42)
#41
1 parent 5eaddde commit 61af3a8

File tree

86 files changed

+1631
-1321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1631
-1321
lines changed

source/Diol/Diol.sln

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integration", "integration"
2121
EndProject
2222
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "functional", "functional", "{1528B197-7430-4831-87B1-747F6FB002C7}"
2323
EndProject
24-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Diol.applications.SignalrClient", "src\applications\Diol.applications.SignalrClient\Diol.applications.SignalrClient.csproj", "{B4B281E3-CA30-498C-81EA-CC5962D47EC7}"
25-
EndProject
2624
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Diol.applications.WpfClient", "src\applications\Diol.applications.WpfClient\Diol.applications.WpfClient.csproj", "{747E725B-015C-4420-879E-B787704C7ABF}"
2725
EndProject
2826
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Diol.Wpf.Core", "src\Diol.Wpf.Core\Diol.Wpf.Core.csproj", "{7D2CED13-BC97-449D-A458-51F17F1B31B2}"
2927
EndProject
3028
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiolVSIX", "src\applications\DiolVSIX\DiolVSIX.csproj", "{E0468409-CC5D-4A75-BAB2-B174172B1599}"
3129
EndProject
32-
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "DiolBackendServiceSetup", "src\applications\DiolBackendServiceSetup\DiolBackendServiceSetup.vdproj", "{E25C1CD6-16B7-4DED-8996-8B1322840750}"
33-
EndProject
3430
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiolBackendService", "src\applications\DiolBackendService\DiolBackendService.csproj", "{8BE6480C-E801-43D5-95FE-5EED9F7B0A74}"
3531
EndProject
3632
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Diol.Aspnet", "src\Diol.Aspnet\Diol.Aspnet.csproj", "{A8F6119D-7D26-4E19-BB59-4F8BAAE27F8B}"
3733
EndProject
34+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diol.Tests.Units", "tests\unit\Diol.Tests.Units\Diol.Tests.Units.csproj", "{CDBE6EB7-D224-4ED4-8103-0A36D4354699}"
35+
EndProject
3836
Global
3937
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4038
Debug|Any CPU = Debug|Any CPU
@@ -67,14 +65,6 @@ Global
6765
{2A1DA117-7632-4434-92A2-19151A460AD6}.Release|Any CPU.Build.0 = Release|Any CPU
6866
{2A1DA117-7632-4434-92A2-19151A460AD6}.Release|x86.ActiveCfg = Release|x86
6967
{2A1DA117-7632-4434-92A2-19151A460AD6}.Release|x86.Build.0 = Release|x86
70-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
72-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Debug|x86.ActiveCfg = Debug|x86
73-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Debug|x86.Build.0 = Debug|x86
74-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
75-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Release|Any CPU.Build.0 = Release|Any CPU
76-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Release|x86.ActiveCfg = Release|x86
77-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7}.Release|x86.Build.0 = Release|x86
7868
{747E725B-015C-4420-879E-B787704C7ABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
7969
{747E725B-015C-4420-879E-B787704C7ABF}.Debug|Any CPU.Build.0 = Debug|Any CPU
8070
{747E725B-015C-4420-879E-B787704C7ABF}.Debug|x86.ActiveCfg = Debug|x86
@@ -99,10 +89,6 @@ Global
9989
{E0468409-CC5D-4A75-BAB2-B174172B1599}.Release|Any CPU.Build.0 = Release|Any CPU
10090
{E0468409-CC5D-4A75-BAB2-B174172B1599}.Release|x86.ActiveCfg = Release|x86
10191
{E0468409-CC5D-4A75-BAB2-B174172B1599}.Release|x86.Build.0 = Release|x86
102-
{E25C1CD6-16B7-4DED-8996-8B1322840750}.Debug|Any CPU.ActiveCfg = Debug
103-
{E25C1CD6-16B7-4DED-8996-8B1322840750}.Debug|x86.ActiveCfg = Debug
104-
{E25C1CD6-16B7-4DED-8996-8B1322840750}.Release|Any CPU.ActiveCfg = Release
105-
{E25C1CD6-16B7-4DED-8996-8B1322840750}.Release|x86.ActiveCfg = Release
10692
{8BE6480C-E801-43D5-95FE-5EED9F7B0A74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10793
{8BE6480C-E801-43D5-95FE-5EED9F7B0A74}.Debug|Any CPU.Build.0 = Debug|Any CPU
10894
{8BE6480C-E801-43D5-95FE-5EED9F7B0A74}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -119,6 +105,14 @@ Global
119105
{A8F6119D-7D26-4E19-BB59-4F8BAAE27F8B}.Release|Any CPU.Build.0 = Release|Any CPU
120106
{A8F6119D-7D26-4E19-BB59-4F8BAAE27F8B}.Release|x86.ActiveCfg = Release|Any CPU
121107
{A8F6119D-7D26-4E19-BB59-4F8BAAE27F8B}.Release|x86.Build.0 = Release|Any CPU
108+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Debug|Any CPU.Build.0 = Debug|Any CPU
110+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Debug|x86.ActiveCfg = Debug|Any CPU
111+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Debug|x86.Build.0 = Debug|Any CPU
112+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Release|Any CPU.ActiveCfg = Release|Any CPU
113+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Release|Any CPU.Build.0 = Release|Any CPU
114+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Release|x86.ActiveCfg = Release|Any CPU
115+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699}.Release|x86.Build.0 = Release|Any CPU
122116
EndGlobalSection
123117
GlobalSection(SolutionProperties) = preSolution
124118
HideSolutionNode = FALSE
@@ -131,13 +125,12 @@ Global
131125
{F686F4B3-FBCF-4FC3-9DD0-B52D65C4D7FB} = {82EF7528-27F3-4E33-8CBD-871D75BFE740}
132126
{039544AD-135F-4B0D-B202-57A99ED7AE92} = {82EF7528-27F3-4E33-8CBD-871D75BFE740}
133127
{1528B197-7430-4831-87B1-747F6FB002C7} = {82EF7528-27F3-4E33-8CBD-871D75BFE740}
134-
{B4B281E3-CA30-498C-81EA-CC5962D47EC7} = {EA282770-C145-4DDB-8394-A3D1FAF6890A}
135128
{747E725B-015C-4420-879E-B787704C7ABF} = {EA282770-C145-4DDB-8394-A3D1FAF6890A}
136129
{7D2CED13-BC97-449D-A458-51F17F1B31B2} = {B9685848-670D-40C5-A0F6-D195370594E7}
137130
{E0468409-CC5D-4A75-BAB2-B174172B1599} = {EA282770-C145-4DDB-8394-A3D1FAF6890A}
138-
{E25C1CD6-16B7-4DED-8996-8B1322840750} = {EA282770-C145-4DDB-8394-A3D1FAF6890A}
139131
{8BE6480C-E801-43D5-95FE-5EED9F7B0A74} = {EA282770-C145-4DDB-8394-A3D1FAF6890A}
140132
{A8F6119D-7D26-4E19-BB59-4F8BAAE27F8B} = {B9685848-670D-40C5-A0F6-D195370594E7}
133+
{CDBE6EB7-D224-4ED4-8103-0A36D4354699} = {F686F4B3-FBCF-4FC3-9DD0-B52D65C4D7FB}
141134
EndGlobalSection
142135
GlobalSection(ExtensibilityGlobals) = postSolution
143136
SolutionGuid = {4D583379-3FA0-4D41-9B6A-DDF00ED79751}

source/Diol/src/Diol.Aspnet/BackgroundWorkers/BackgroundTaskQueue.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66

77
namespace Diol.Aspnet.BackgroundWorkers
88
{
9+
/// <summary>
10+
/// Represents a queue for background tasks.
11+
/// </summary>
912
public class BackgroundTaskQueue
1013
{
1114
private readonly Channel<Func<EventPipeEventSourceBuilder, CancellationToken, ValueTask>> _queue;
1215
private readonly IHubContext<LogsHub> hubContext;
1316
private readonly ILogger<BackgroundTaskQueue> logger;
1417

18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="BackgroundTaskQueue"/> class.
20+
/// </summary>
21+
/// <param name="hubContext">The hub context.</param>
22+
/// <param name="logger">The logger.</param>
23+
/// <param name="capacity">The capacity of the queue. Default is 5.</param>
1524
public BackgroundTaskQueue(
1625
IHubContext<LogsHub> hubContext,
1726
ILogger<BackgroundTaskQueue> logger,
@@ -32,13 +41,18 @@ public BackgroundTaskQueue(
3241
_queue = Channel.CreateBounded<Func<EventPipeEventSourceBuilder, CancellationToken, ValueTask>>(options);
3342
}
3443

44+
/// <summary>
45+
/// Queues a background work item for execution.
46+
/// </summary>
47+
/// <param name="workItem">The work item to be executed.</param>
48+
/// <returns>A <see cref="ValueTask"/> representing the asynchronous operation.</returns>
3549
public async ValueTask QueueBackgroundWorkItemAsync(
3650
Func<EventPipeEventSourceBuilder, CancellationToken, ValueTask> workItem)
3751
{
3852
if (workItem == null)
3953
{
4054
this.logger.LogError(
41-
"QueueBackgroundWorkItemAsync args is null: {argName}",
55+
"QueueBackgroundWorkItemAsync args is null: {argName}",
4256
nameof(workItem));
4357

4458
throw new ArgumentNullException(nameof(workItem));
@@ -47,6 +61,11 @@ public async ValueTask QueueBackgroundWorkItemAsync(
4761
await _queue.Writer.WriteAsync(workItem);
4862
}
4963

64+
/// <summary>
65+
/// Queues logs processing for a specific process ID.
66+
/// </summary>
67+
/// <param name="processId">The process ID.</param>
68+
/// <returns>A <see cref="ValueTask"/> representing the asynchronous operation.</returns>
5069
public async ValueTask QueueLogsProcessing(int processId)
5170
{
5271
await this.QueueBackgroundWorkItemAsync(
@@ -67,7 +86,7 @@ await this.QueueBackgroundWorkItemAsync(
6786
executor.Stop();
6887

6988
this.logger.LogInformation(
70-
"Processing stopped. ProcessId: {processId}",
89+
"Processing stopped. ProcessId: {processId}",
7190
processId);
7291

7392
return Task.CompletedTask;
@@ -77,26 +96,26 @@ await this.QueueBackgroundWorkItemAsync(
7796
Task processing = Task.Run(() =>
7897
{
7998
this.logger.LogInformation(
80-
"Processing started. ProcessId: {processId}",
99+
"Processing started. ProcessId: {processId}",
81100
processId);
82101

83102
executor.Start();
84103

85104
this.logger.LogInformation(
86-
"Processing finished. ProcessId: {processId}",
105+
"Processing finished. ProcessId: {processId}",
87106
processId);
88107

89108
executor.Dispose();
90109
});
91110

92111
this.logger.LogInformation(
93-
"General processing being. ProcessId: {processId}",
112+
"General processing being. ProcessId: {processId}",
94113
processId);
95114

96115
Task.WaitAny(finish, processing);
97116

98117
this.logger.LogInformation(
99-
"General processing finished. ProcessId: {processId}",
118+
"General processing finished. ProcessId: {processId}",
100119
processId);
101120

102121
await this.hubContext.Clients
@@ -105,6 +124,11 @@ await this.hubContext.Clients
105124
});
106125
}
107126

127+
/// <summary>
128+
/// Dequeues a work item from the queue.
129+
/// </summary>
130+
/// <param name="cancellationToken">The cancellation token.</param>
131+
/// <returns>A <see cref="Func{T1, T2, TResult}"/> representing the work item.</returns>
108132
public async ValueTask<Func<EventPipeEventSourceBuilder, CancellationToken, ValueTask>> DequeueAsync(
109133
CancellationToken cancellationToken)
110134
{

source/Diol/src/Diol.Aspnet/BackgroundWorkers/LogsBackgroundWorker.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
using Diol.Aspnet.Consumers;
2-
using Diol.Core.DiagnosticClients;
3-
using Diol.Core.TraceEventProcessors;
4-
using Diol.Share.Features.Aspnetcores;
5-
using Diol.Share.Features.Httpclients;
1+
using Diol.Core.DiagnosticClients;
62
using Microsoft.Extensions.Hosting;
73
using Microsoft.Extensions.Logging;
84

95
namespace Diol.Aspnet.BackgroundWorkers
106
{
7+
/// <summary>
8+
/// Represents a background worker for processing logs.
9+
/// </summary>
1110
public class LogsBackgroundWorker : BackgroundService
1211
{
1312
private readonly BackgroundTaskQueue taskQueue;
1413
private EventPipeEventSourceBuilder builder;
1514
private readonly ILogger<LogsBackgroundWorker> logger;
1615

16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="LogsBackgroundWorker"/> class.
18+
/// </summary>
19+
/// <param name="taskQueue">The background task queue.</param>
20+
/// <param name="builder">The event pipe event source builder.</param>
21+
/// <param name="logger">The logger.</param>
1722
public LogsBackgroundWorker(
1823
BackgroundTaskQueue taskQueue,
1924
EventPipeEventSourceBuilder builder,
@@ -24,6 +29,11 @@ public LogsBackgroundWorker(
2429
this.logger = logger;
2530
}
2631

32+
/// <summary>
33+
/// Executes the background worker asynchronously.
34+
/// </summary>
35+
/// <param name="stoppingToken">The cancellation token to stop the execution.</param>
36+
/// <returns>A task representing the asynchronous operation.</returns>
2737
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2838
{
2939
this.logger.LogInformation("LogsBackgroundWorker Execution started");
@@ -41,15 +51,25 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
4151
this.logger.LogInformation("LogsBackgroundWorker Execution finished");
4252
}
4353

54+
/// <summary>
55+
/// Starts the background worker asynchronously.
56+
/// </summary>
57+
/// <param name="cancellationToken">The cancellation token to stop the execution.</param>
58+
/// <returns>A task representing the asynchronous operation.</returns>
4459
public override Task StartAsync(CancellationToken cancellationToken)
4560
{
4661
this.logger.LogInformation("LogsBackgroundWorker started");
4762
return base.StartAsync(cancellationToken);
4863
}
4964

65+
/// <summary>
66+
/// Stops the background worker asynchronously.
67+
/// </summary>
68+
/// <param name="cancellationToken">The cancellation token to stop the execution.</param>
69+
/// <returns>A task representing the asynchronous operation.</returns>
5070
public override Task StopAsync(CancellationToken cancellationToken)
5171
{
52-
this.logger.LogInformation("LogsBackgroundWorker started");
72+
this.logger.LogInformation("LogsBackgroundWorker stopped");
5373
return base.StopAsync(cancellationToken);
5474
}
5575
}

source/Diol/src/Diol.Aspnet/Consumers/SignalRConsumer.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77

88
namespace Diol.Aspnet.Consumers
99
{
10+
/// <summary>
11+
/// Represents a consumer that sends log messages to SignalR clients.
12+
/// </summary>
1013
public class SignalRConsumer : IConsumer
1114
{
1215
private readonly IHubContext<LogsHub> hubContext;
1316
private readonly ILogger<SignalRConsumer> logger;
1417

18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="SignalRConsumer"/> class.
20+
/// </summary>
21+
/// <param name="hubContext">The SignalR hub context.</param>
22+
/// <param name="logger">The logger.</param>
1523
public SignalRConsumer(
1624
IHubContext<LogsHub> hubContext,
1725
ILogger<SignalRConsumer> logger)
@@ -20,15 +28,22 @@ public SignalRConsumer(
2028
this.logger = logger;
2129
}
2230

31+
/// <summary>
32+
/// Called when the IObservable has completed.
33+
/// </summary>
2334
public void OnCompleted()
2435
{
2536
// IObservable has finished.
2637
this.logger.LogInformation(
27-
"{className} | {methodName}",
28-
nameof(SignalRConsumer),
38+
"{className} | {methodName}",
39+
nameof(SignalRConsumer),
2940
nameof(OnCompleted));
3041
}
3142

43+
/// <summary>
44+
/// Called when an error occurs in the IObservable.
45+
/// </summary>
46+
/// <param name="error">The error that occurred.</param>
3247
public void OnError(Exception error)
3348
{
3449
// write log
@@ -38,6 +53,10 @@ public void OnError(Exception error)
3853
nameof(OnError));
3954
}
4055

56+
/// <summary>
57+
/// Called when a new log message is received.
58+
/// </summary>
59+
/// <param name="value">The log message.</param>
4160
public void OnNext(BaseDto value)
4261
{
4362
var valueAsJson = JsonSerializer.Serialize(

source/Diol/src/Diol.Aspnet/Hubs/LogsHub.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55

66
namespace Diol.Aspnet.Hubs
77
{
8+
/// <summary>
9+
/// Represents a SignalR hub for managing logs.
10+
/// </summary>
811
public class LogsHub : Hub
912
{
1013
private readonly BackgroundTaskQueue taskQueue;
1114
private readonly DotnetProcessesService dotnetProcessesService;
1215
private readonly ILogger<LogsHub> logger;
1316

17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="LogsHub"/> class.
19+
/// </summary>
20+
/// <param name="taskQueue">The background task queue.</param>
21+
/// <param name="dotnetProcessesService">The DotnetProcessesService instance.</param>
22+
/// <param name="logger">The logger instance.</param>
1423
public LogsHub(
1524
BackgroundTaskQueue taskQueue,
1625
DotnetProcessesService dotnetProcessesService,
@@ -21,6 +30,11 @@ public LogsHub(
2130
this.logger = logger;
2231
}
2332

33+
/// <summary>
34+
/// Gets the processes.
35+
/// </summary>
36+
/// <param name="message">The message.</param>
37+
/// <returns>A task representing the asynchronous operation.</returns>
2438
public async Task GetProcesses(string message)
2539
{
2640
var processes = this.dotnetProcessesService.GetCollection();
@@ -29,6 +43,11 @@ await this.Clients.Caller
2943
.SendAsync("ProcessesReceived", processes);
3044
}
3145

46+
/// <summary>
47+
/// Subscribes to a process.
48+
/// </summary>
49+
/// <param name="processId">The process ID.</param>
50+
/// <returns>A task representing the asynchronous operation.</returns>
3251
public async Task Subscribe(int processId)
3352
{
3453
await this.Groups.AddToGroupAsync(
@@ -41,6 +60,10 @@ await this.Clients.Caller
4160
await this.taskQueue.QueueLogsProcessing(processId);
4261
}
4362

63+
/// <summary>
64+
/// Called when a client is connected.
65+
/// </summary>
66+
/// <returns>A task representing the asynchronous operation.</returns>
4467
public override async Task OnConnectedAsync()
4568
{
4669
this.logger.LogInformation(

0 commit comments

Comments
 (0)