Skip to content

Commit 16da40a

Browse files
authored
Merge pull request #19 from DEFRA/feature/ulitp-2683
Feature/ulitp 2683
2 parents 898e6dc + 812db72 commit 16da40a

File tree

19 files changed

+469
-1
lines changed

19 files changed

+469
-1
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ ENV BUILD_CONFIGURATION=${BUILD_CONFIGURATION}
1818
WORKDIR /src
1919

2020
COPY ["src/KeeperData.Bridge/KeeperData.Bridge.csproj", "KeeperData.Bridge/"]
21+
COPY ["src/KeeperData.Bridge.Worker/KeeperData.Bridge.Worker.csproj", "KeeperData.Bridge.Worker/"]
2122
COPY ["src/KeeperData.Infrastructure/KeeperData.Infrastructure.csproj", "KeeperData.Infrastructure/"]
2223
COPY ["src/KeeperData.Application/KeeperData.Application.csproj", "KeeperData.Application/"]
2324
COPY ["src/KeeperData.Core/KeeperData.Core.csproj", "KeeperData.Core/"]
2425

2526
RUN dotnet restore "KeeperData.Bridge/KeeperData.Bridge.csproj" -r linux-x64 -v n
27+
RUN dotnet restore "KeeperData.Bridge.Worker/KeeperData.Bridge.Worker.csproj" -r linux-x64 -v n
2628
RUN dotnet restore "KeeperData.Infrastructure/KeeperData.Infrastructure.csproj" -r linux-x64 -v n
2729
RUN dotnet restore "KeeperData.Application/KeeperData.Application.csproj" -r linux-x64 -v n
2830
RUN dotnet restore "KeeperData.Core/KeeperData.Core.csproj" -r linux-x64 -v n

KeeperData.Bridge.sln

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,56 +35,173 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "util", "util", "{25784FFF-F
3535
EndProject
3636
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeeperData.Crypto.Tool", "src\KeeperData.Crypto.Tool\KeeperData.Crypto.Tool.csproj", "{92F51802-9BF8-42A8-98C9-C25B27163DF0}"
3737
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeeperData.Bridge.Worker", "src\KeeperData.Bridge.Worker\KeeperData.Bridge.Worker.csproj", "{C20E1970-BB6F-46BC-886E-7E856DAA763E}"
39+
EndProject
3840
Global
3941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4042
Debug|Any CPU = Debug|Any CPU
43+
Debug|x64 = Debug|x64
44+
Debug|x86 = Debug|x86
4145
Release|Any CPU = Release|Any CPU
46+
Release|x64 = Release|x64
47+
Release|x86 = Release|x86
4248
EndGlobalSection
4349
GlobalSection(ProjectConfigurationPlatforms) = postSolution
4450
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4551
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Debug|x64.ActiveCfg = Debug|Any CPU
53+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Debug|x64.Build.0 = Debug|Any CPU
54+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Debug|x86.ActiveCfg = Debug|Any CPU
55+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Debug|x86.Build.0 = Debug|Any CPU
4656
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Release|Any CPU.ActiveCfg = Release|Any CPU
4757
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Release|x64.ActiveCfg = Release|Any CPU
59+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Release|x64.Build.0 = Release|Any CPU
60+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Release|x86.ActiveCfg = Release|Any CPU
61+
{7D935959-D3BE-4EDC-BAEC-541C72741633}.Release|x86.Build.0 = Release|Any CPU
62+
4863
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4964
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Debug|Any CPU.Build.0 = Debug|Any CPU
65+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Debug|x64.ActiveCfg = Debug|Any CPU
66+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Debug|x64.Build.0 = Debug|Any CPU
67+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Debug|x86.ActiveCfg = Debug|Any CPU
68+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Debug|x86.Build.0 = Debug|Any CPU
5069
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Release|Any CPU.ActiveCfg = Release|Any CPU
5170
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Release|Any CPU.Build.0 = Release|Any CPU
71+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Release|x64.ActiveCfg = Release|Any CPU
72+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Release|x64.Build.0 = Release|Any CPU
73+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Release|x86.ActiveCfg = Release|Any CPU
74+
{4E96024E-0BCB-4C41-8EB2-876499B07311}.Release|x86.Build.0 = Release|Any CPU
75+
5276
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5377
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Debug|Any CPU.Build.0 = Debug|Any CPU
78+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Debug|x64.ActiveCfg = Debug|Any CPU
79+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Debug|x64.Build.0 = Debug|Any CPU
80+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Debug|x86.ActiveCfg = Debug|Any CPU
81+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Debug|x86.Build.0 = Debug|Any CPU
5482
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Release|Any CPU.ActiveCfg = Release|Any CPU
5583
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Release|Any CPU.Build.0 = Release|Any CPU
84+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Release|x64.ActiveCfg = Release|Any CPU
85+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Release|x64.Build.0 = Release|Any CPU
86+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Release|x86.ActiveCfg = Release|Any CPU
87+
{D5BA4CDF-AABC-4FE6-B41A-D32381CDFB32}.Release|x86.Build.0 = Release|Any CPU
88+
5689
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5790
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
91+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Debug|x64.ActiveCfg = Debug|Any CPU
92+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Debug|x64.Build.0 = Debug|Any CPU
93+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Debug|x86.ActiveCfg = Debug|Any CPU
94+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Debug|x86.Build.0 = Debug|Any CPU
5895
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
5996
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Release|Any CPU.Build.0 = Release|Any CPU
97+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Release|x64.ActiveCfg = Release|Any CPU
98+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Release|x64.Build.0 = Release|Any CPU
99+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Release|x86.ActiveCfg = Release|Any CPU
100+
{45E67021-5132-416B-92F0-AA2C1C7E65AD}.Release|x86.Build.0 = Release|Any CPU
101+
60102
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61103
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
104+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Debug|x64.ActiveCfg = Debug|Any CPU
105+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Debug|x64.Build.0 = Debug|Any CPU
106+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Debug|x86.ActiveCfg = Debug|Any CPU
107+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Debug|x86.Build.0 = Debug|Any CPU
62108
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
63109
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Release|Any CPU.Build.0 = Release|Any CPU
110+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Release|x64.ActiveCfg = Release|Any CPU
111+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Release|x64.Build.0 = Release|Any CPU
112+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Release|x86.ActiveCfg = Release|Any CPU
113+
{28DA1EFD-BB2E-4AF5-B9BD-AD3B6A139DBE}.Release|x86.Build.0 = Release|Any CPU
114+
64115
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65116
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Debug|Any CPU.Build.0 = Debug|Any CPU
117+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Debug|x64.ActiveCfg = Debug|Any CPU
118+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Debug|x64.Build.0 = Debug|Any CPU
119+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Debug|x86.ActiveCfg = Debug|Any CPU
120+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Debug|x86.Build.0 = Debug|Any CPU
66121
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Release|Any CPU.ActiveCfg = Release|Any CPU
67122
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Release|Any CPU.Build.0 = Release|Any CPU
123+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Release|x64.ActiveCfg = Release|Any CPU
124+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Release|x64.Build.0 = Release|Any CPU
125+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Release|x86.ActiveCfg = Release|Any CPU
126+
{324F5874-B7B9-4B87-9FAB-BDB970971919}.Release|x86.Build.0 = Release|Any CPU
127+
68128
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69129
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Debug|Any CPU.Build.0 = Debug|Any CPU
130+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Debug|x64.ActiveCfg = Debug|Any CPU
131+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Debug|x64.Build.0 = Debug|Any CPU
132+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Debug|x86.ActiveCfg = Debug|Any CPU
133+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Debug|x86.Build.0 = Debug|Any CPU
70134
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Release|Any CPU.ActiveCfg = Release|Any CPU
71135
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Release|Any CPU.Build.0 = Release|Any CPU
136+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Release|x64.ActiveCfg = Release|Any CPU
137+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Release|x64.Build.0 = Release|Any CPU
138+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Release|x86.ActiveCfg = Release|Any CPU
139+
{E2B6D37D-2D17-4B43-83DC-36F1C4961526}.Release|x86.Build.0 = Release|Any CPU
140+
72141
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73142
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
143+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Debug|x64.ActiveCfg = Debug|Any CPU
144+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Debug|x64.Build.0 = Debug|Any CPU
145+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Debug|x86.ActiveCfg = Debug|Any CPU
146+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Debug|x86.Build.0 = Debug|Any CPU
74147
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
75148
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Release|Any CPU.Build.0 = Release|Any CPU
149+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Release|x64.ActiveCfg = Release|Any CPU
150+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Release|x64.Build.0 = Release|Any CPU
151+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Release|x86.ActiveCfg = Release|Any CPU
152+
{16AA106D-B4F1-46C9-92F3-548AE89FDA3A}.Release|x86.Build.0 = Release|Any CPU
153+
76154
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
77155
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
156+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|x64.ActiveCfg = Debug|Any CPU
157+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|x64.Build.0 = Debug|Any CPU
158+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|x86.ActiveCfg = Debug|Any CPU
159+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|x86.Build.0 = Debug|Any CPU
78160
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
79161
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|Any CPU.Build.0 = Release|Any CPU
162+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|x64.ActiveCfg = Release|Any CPU
163+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|x64.Build.0 = Release|Any CPU
164+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|x86.ActiveCfg = Release|Any CPU
165+
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|x86.Build.0 = Release|Any CPU
166+
167+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
168+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Debug|Any CPU.Build.0 = Debug|Any CPU
169+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Debug|x64.ActiveCfg = Debug|Any CPU
170+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Debug|x64.Build.0 = Debug|Any CPU
171+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Debug|x86.ActiveCfg = Debug|Any CPU
172+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Debug|x86.Build.0 = Debug|Any CPU
173+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Release|Any CPU.ActiveCfg = Release|Any CPU
174+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Release|Any CPU.Build.0 = Release|Any CPU
175+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Release|x64.ActiveCfg = Release|Any CPU
176+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Release|x64.Build.0 = Release|Any CPU
177+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Release|x86.ActiveCfg = Release|Any CPU
178+
{C20E1970-BB6F-46BC-886E-7E856DAA763E}.Release|x86.Build.0 = Release|Any CPU
179+
80180
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81181
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Debug|Any CPU.Build.0 = Debug|Any CPU
182+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Debug|x64.ActiveCfg = Debug|Any CPU
183+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Debug|x64.Build.0 = Debug|Any CPU
184+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Debug|x86.ActiveCfg = Debug|Any CPU
185+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Debug|x86.Build.0 = Debug|Any CPU
82186
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Release|Any CPU.ActiveCfg = Release|Any CPU
83187
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Release|Any CPU.Build.0 = Release|Any CPU
188+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Release|x64.ActiveCfg = Release|Any CPU
189+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Release|x64.Build.0 = Release|Any CPU
190+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Release|x86.ActiveCfg = Release|Any CPU
191+
{389DD08B-1B37-4BF2-9F2B-3F4805B25A46}.Release|x86.Build.0 = Release|Any CPU
192+
84193
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85194
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
195+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Debug|x64.ActiveCfg = Debug|Any CPU
196+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Debug|x64.Build.0 = Debug|Any CPU
197+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Debug|x86.ActiveCfg = Debug|Any CPU
198+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Debug|x86.Build.0 = Debug|Any CPU
86199
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
87200
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Release|Any CPU.Build.0 = Release|Any CPU
201+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Release|x64.ActiveCfg = Release|Any CPU
202+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Release|x64.Build.0 = Release|Any CPU
203+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Release|x86.ActiveCfg = Release|Any CPU
204+
{92F51802-9BF8-42A8-98C9-C25B27163DF0}.Release|x86.Build.0 = Release|Any CPU
88205
EndGlobalSection
89206
GlobalSection(SolutionProperties) = preSolution
90207
HideSolutionNode = FALSE
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace KeeperData.Bridge.Worker.Configuration;
2+
3+
public class ScheduledJobConfiguration
4+
{
5+
public string JobType { get; set; } = string.Empty;
6+
public bool Enabled { get; set; }
7+
public string CronSchedule { get; set; } = string.Empty;
8+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using KeeperData.Bridge.Worker.Tasks;
2+
using Microsoft.Extensions.Logging;
3+
using Quartz;
4+
5+
namespace KeeperData.Bridge.Worker.Jobs;
6+
7+
[DisallowConcurrentExecution]
8+
public class ImportBulkFilesJob(
9+
ITaskProcessBulkFiles taskProcessBulkFiles,
10+
ILogger<ImportBulkFilesJob> logger) : IJob
11+
{
12+
public async Task Execute(IJobExecutionContext context)
13+
{
14+
logger.LogInformation("ImportBulkFilesJob started at {startTime}", DateTime.UtcNow);
15+
16+
try
17+
{
18+
await taskProcessBulkFiles.RunAsync(context.CancellationToken);
19+
20+
logger.LogInformation("ImportBulkFilesJob completed at {endTime}", DateTime.UtcNow);
21+
}
22+
catch (Exception ex)
23+
{
24+
logger.LogError(ex, "ImportBulkFilesJob failed.");
25+
throw;
26+
}
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using KeeperData.Bridge.Worker.Tasks;
2+
using Microsoft.Extensions.Logging;
3+
using Quartz;
4+
5+
namespace KeeperData.Bridge.Worker.Jobs;
6+
7+
[DisallowConcurrentExecution]
8+
public class ImportDeltaFilesJob(
9+
ITaskProcessDeltaFiles taskProcessDeltaFiles,
10+
ILogger<ImportDeltaFilesJob> logger) : IJob
11+
{
12+
public async Task Execute(IJobExecutionContext context)
13+
{
14+
logger.LogInformation("ImportDeltaFilesJob started at {startTime}", DateTime.UtcNow);
15+
16+
try
17+
{
18+
await taskProcessDeltaFiles.RunAsync(context.CancellationToken);
19+
20+
logger.LogInformation("ImportDeltaFilesJob completed at {endTime}", DateTime.UtcNow);
21+
}
22+
catch (Exception ex)
23+
{
24+
logger.LogError(ex, "ImportDeltaFilesJob failed.");
25+
throw;
26+
}
27+
}
28+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.15.0" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\KeeperData.Infrastructure\KeeperData.Infrastructure.csproj" />
15+
</ItemGroup>
16+
</Project>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using KeeperData.Bridge.Worker.Configuration;
2+
using KeeperData.Bridge.Worker.Jobs;
3+
using KeeperData.Bridge.Worker.Tasks;
4+
using KeeperData.Bridge.Worker.Tasks.Implementations;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Quartz;
8+
using System.Diagnostics.CodeAnalysis;
9+
10+
namespace KeeperData.Bridge.Worker.Setup;
11+
12+
[ExcludeFromCodeCoverage]
13+
public static class ServiceCollectionExtensions
14+
{
15+
public static void AddBackgroundJobDependencies(this IServiceCollection services, IConfiguration configuration)
16+
{
17+
services
18+
.AddQuartz(configuration)
19+
.AddJobs()
20+
.AddTasks();
21+
}
22+
23+
private static IServiceCollection AddQuartz(this IServiceCollection services, IConfiguration configuration)
24+
{
25+
var scheduledJobConfiguration = configuration.GetRequiredSection("Quartz:Jobs").Get<List<ScheduledJobConfiguration>>() ?? [];
26+
27+
services.AddQuartz(q =>
28+
{
29+
var importBulkFilesConfig = scheduledJobConfiguration.FirstOrDefault(x => x.JobType == nameof(ImportBulkFilesJob));
30+
if (importBulkFilesConfig?.CronSchedule != null)
31+
{
32+
q.AddJob<ImportBulkFilesJob>(opts => opts.WithIdentity(importBulkFilesConfig.JobType));
33+
34+
q.AddTrigger(opts => opts
35+
.ForJob(importBulkFilesConfig.JobType)
36+
.WithIdentity($"{importBulkFilesConfig.JobType}-trigger")
37+
.WithCronSchedule(importBulkFilesConfig.CronSchedule));
38+
}
39+
40+
var importDeltaFilesConfig = scheduledJobConfiguration.FirstOrDefault(x => x.JobType == nameof(ImportDeltaFilesJob));
41+
if (importDeltaFilesConfig?.CronSchedule != null)
42+
{
43+
q.AddJob<ImportDeltaFilesJob>(opts => opts.WithIdentity(importDeltaFilesConfig.JobType));
44+
45+
q.AddTrigger(opts => opts
46+
.ForJob(importDeltaFilesConfig.JobType)
47+
.WithIdentity($"{importDeltaFilesConfig.JobType}-trigger")
48+
.WithCronSchedule(importDeltaFilesConfig.CronSchedule));
49+
}
50+
});
51+
52+
services.AddQuartzHostedService(q =>
53+
{
54+
q.WaitForJobsToComplete = false;
55+
});
56+
57+
return services;
58+
}
59+
60+
private static IServiceCollection AddJobs(this IServiceCollection services)
61+
{
62+
services.AddScoped<ImportBulkFilesJob>();
63+
services.AddScoped<ImportDeltaFilesJob>();
64+
65+
return services;
66+
}
67+
68+
private static IServiceCollection AddTasks(this IServiceCollection services)
69+
{
70+
services.AddScoped<ITaskProcessBulkFiles, TaskProcessBulkFiles>();
71+
services.AddScoped<ITaskProcessDeltaFiles, TaskProcessDeltaFiles>();
72+
73+
return services;
74+
}
75+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace KeeperData.Bridge.Worker.Tasks;
2+
3+
public interface ITask
4+
{
5+
Task RunAsync(CancellationToken cancellationToken);
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace KeeperData.Bridge.Worker.Tasks;
2+
3+
public interface ITaskProcessBulkFiles : ITask { }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace KeeperData.Bridge.Worker.Tasks;
2+
3+
public interface ITaskProcessDeltaFiles : ITask { }

0 commit comments

Comments
 (0)