Skip to content

Commit 90c07b9

Browse files
committed
MMI-3382 Replace CHES
Update all services Add DB migration 1.5 Update DevOps
1 parent 33cff1f commit 90c07b9

248 files changed

Lines changed: 11595 additions & 6534 deletions

File tree

Some content is hidden

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

.vscode/launch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,18 @@
294294
// Use IntelliSense to find out which attributes exist for C# debugging
295295
// Use hover for the description of the existing attributes
296296
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
297-
"name": "Run Ches Retry Service",
297+
"name": "Run SMTP Retry Service",
298298
"type": "coreclr",
299299
"request": "launch",
300-
"preLaunchTask": "build-ches-retry",
300+
"preLaunchTask": "build-smtp-retry",
301301
// If you have changed target frameworks, make sure to update the program path.
302-
"program": "${workspaceFolder}/services/net/ches-retry/bin/Debug/net9.0/TNO.Services.ChesRetry.dll",
302+
"program": "${workspaceFolder}/services/net/smtp-retry/bin/Debug/net9.0/MMI.Services.SMTPRetry.dll",
303303
"args": [],
304-
"cwd": "${workspaceFolder}/services/net/ches-retry",
304+
"cwd": "${workspaceFolder}/services/net/smtp-retry",
305305
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
306306
"console": "internalConsole",
307307
"stopAtEntry": false,
308-
"envFile": "${workspaceFolder}/services/net/ches-retry/.env"
308+
"envFile": "${workspaceFolder}/services/net/smtp-retry/.env"
309309
},
310310
{
311311
// Use IntelliSense to find out which attributes exist for C# debugging

.vscode/tasks.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,38 +645,38 @@
645645
"problemMatcher": "$msCompile"
646646
},
647647
{
648-
"label": "build-ches-retry",
648+
"label": "build-smtp-retry",
649649
"command": "dotnet",
650650
"type": "process",
651651
"args": [
652652
"build",
653-
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj",
653+
"${workspaceFolder}/services/net/smtp-retry/MMI.Services.SMTPRetry.csproj",
654654
"/property:GenerateFullPaths=true",
655655
"/consoleloggerparameters:NoSummary"
656656
],
657657
"problemMatcher": "$msCompile"
658658
},
659659
{
660-
"label": "publish-ches-retry",
660+
"label": "publish-smtp-retry",
661661
"command": "dotnet",
662662
"type": "process",
663663
"args": [
664664
"publish",
665-
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj",
665+
"${workspaceFolder}/services/net/smtp-retry/MMI.Services.SMTPRetry.csproj",
666666
"/property:GenerateFullPaths=true",
667667
"/consoleloggerparameters:NoSummary"
668668
],
669669
"problemMatcher": "$msCompile"
670670
},
671671
{
672-
"label": "watch-ches-retry",
672+
"label": "watch-smtp-retry",
673673
"command": "dotnet",
674674
"type": "process",
675675
"args": [
676676
"watch",
677677
"run",
678678
"--project",
679-
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj"
679+
"${workspaceFolder}/services/net/smtp-retry/MMI.Services.SMTPRetry.csproj"
680680
],
681681
"problemMatcher": "$msCompile"
682682
},

TNO.sln

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.FFmpeg", "serv
8181
EndProject
8282
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.EventHandler", "services\net\event-handler\TNO.Services.EventHandler.csproj", "{6F1F9B85-B155-4A5A-BB36-10F734F96A12}"
8383
EndProject
84-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.ChesRetry", "services\net\ches-retry\TNO.Services.ChesRetry.csproj", "{067EA7C3-A816-406B-B36A-09FC05A427A1}"
85-
EndProject
8684
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.AutoClipper", "services\net\auto-clipper\TNO.Services.AutoClipper.csproj", "{7B8BF924-36BA-422E-85FD-1C590B092F7B}"
8785
EndProject
86+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMI.SmtpEmail", "libs\net\smtp\MMI.SmtpEmail.csproj", "{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}"
87+
EndProject
88+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.NLP", "services\net\nlp\TNO.Services.NLP.csproj", "{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}"
89+
EndProject
90+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MMI.Services.SmtpRetry", "services\net\smtp-retry\MMI.Services.SmtpRetry.csproj", "{66BC5554-D360-450A-A529-97EAB4D56637}"
91+
EndProject
8892
Global
8993
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9094
Debug|Any CPU = Debug|Any CPU
@@ -218,14 +222,22 @@ Global
218222
{6F1F9B85-B155-4A5A-BB36-10F734F96A12}.Debug|Any CPU.Build.0 = Debug|Any CPU
219223
{6F1F9B85-B155-4A5A-BB36-10F734F96A12}.Release|Any CPU.ActiveCfg = Release|Any CPU
220224
{6F1F9B85-B155-4A5A-BB36-10F734F96A12}.Release|Any CPU.Build.0 = Release|Any CPU
221-
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
222-
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
223-
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
224-
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Release|Any CPU.Build.0 = Release|Any CPU
225225
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
226226
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
227227
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
228228
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Release|Any CPU.Build.0 = Release|Any CPU
229+
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
230+
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Debug|Any CPU.Build.0 = Debug|Any CPU
231+
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Release|Any CPU.ActiveCfg = Release|Any CPU
232+
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C}.Release|Any CPU.Build.0 = Release|Any CPU
233+
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
234+
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
235+
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
236+
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4}.Release|Any CPU.Build.0 = Release|Any CPU
237+
{66BC5554-D360-450A-A529-97EAB4D56637}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
238+
{66BC5554-D360-450A-A529-97EAB4D56637}.Debug|Any CPU.Build.0 = Debug|Any CPU
239+
{66BC5554-D360-450A-A529-97EAB4D56637}.Release|Any CPU.ActiveCfg = Release|Any CPU
240+
{66BC5554-D360-450A-A529-97EAB4D56637}.Release|Any CPU.Build.0 = Release|Any CPU
229241
EndGlobalSection
230242
GlobalSection(NestedProjects) = preSolution
231243
{16EA028B-B4C8-416D-BE54-D73D75483668} = {F627B24A-217D-4BF1-BC77-E1A92DBCD07F}
@@ -263,7 +275,9 @@ Global
263275
{E7444ADF-0137-439B-8E20-917CF2FAFA45} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
264276
{2D455400-0E86-476E-8C42-532D32C10107} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
265277
{6F1F9B85-B155-4A5A-BB36-10F734F96A12} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
266-
{067EA7C3-A816-406B-B36A-09FC05A427A1} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
267278
{7B8BF924-36BA-422E-85FD-1C590B092F7B} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
279+
{ED18F7E1-BFC4-4126-8FD6-ABE5CFDA581C} = {890D13F9-A1ED-4B00-8E69-A1AB620F31A9}
280+
{7DDD3D18-E89A-4297-A5CD-D2FFF72503F4} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
281+
{66BC5554-D360-450A-A529-97EAB4D56637} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
268282
EndGlobalSection
269283
EndGlobal

api/net/Areas/Admin/Controllers/NotificationInstanceController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public IActionResult FindById(long id)
8080
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
8181
public IActionResult Add([FromBody] NotificationInstanceModel model)
8282
{
83-
var result = _service.AddAndSave(model.ToEntity(_serializerOptions));
83+
var result = _service.AddAndSave((Entities.NotificationInstance)model);
8484
return CreatedAtAction(nameof(FindById), new { id = result.Id }, new NotificationInstanceModel(result, _serializerOptions));
8585
}
8686

@@ -96,7 +96,7 @@ public IActionResult Add([FromBody] NotificationInstanceModel model)
9696
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
9797
public async Task<IActionResult> UpdateAsync([FromBody] NotificationInstanceModel model)
9898
{
99-
var notificationInstance = model.ToEntity(_serializerOptions);
99+
var notificationInstance = (Entities.NotificationInstance)model;
100100
// TODO: This shouldn't occur, but if it does we want to know.
101101
if (notificationInstance.Notification != null)
102102
await _watch.AlertNotificationSubscriptionChangedAsync(notificationInstance.Notification, this.User, "API Admin Notification Instance Controller Update endpoint.");
@@ -116,7 +116,7 @@ public async Task<IActionResult> UpdateAsync([FromBody] NotificationInstanceMode
116116
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
117117
public IActionResult Delete([FromBody] NotificationInstanceModel model)
118118
{
119-
_service.DeleteAndSave(model.ToEntity(_serializerOptions));
119+
_service.DeleteAndSave((Entities.NotificationInstance)model);
120120
return new JsonResult(model);
121121
}
122122
#endregion

api/net/Areas/Editor/Controllers/ContentController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public async Task<IActionResult> AttachFileAsync([FromRoute] long contentId, [Fr
721721
public IActionResult GetNotificationsFor(long id)
722722
{
723723
var notifications = _contentService.GetNotificationsFor(id);
724-
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n, _serializerOptions)));
724+
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n)));
725725
}
726726
#endregion
727727
#endregion

api/net/Areas/Helpers/WatchSubscriptionChange.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
using System.Net.Mail;
12
using System.Security.Claims;
23
using System.Text;
34
using Microsoft.EntityFrameworkCore;
45
using Microsoft.Extensions.Options;
5-
using TNO.Ches;
6+
using MMI.SmtpEmail;
67
using TNO.Core.Exceptions;
78
using TNO.Core.Extensions;
89
using TNO.DAL.Services;
@@ -21,8 +22,7 @@ public class WatchSubscriptionChange
2122
private readonly IReportService _reportService;
2223
private readonly IProductService _productService;
2324
private readonly INotificationService _notificationService;
24-
private readonly IChesService _chesService;
25-
private readonly Ches.Configuration.ChesOptions _chesOptions;
25+
private readonly IEmailService _emailService;
2626

2727
/// <summary>
2828
/// SubscriptionChange enum, identifies the type of change.
@@ -132,26 +132,23 @@ public class WatchOptions
132132
/// <param name="reportService"></param>
133133
/// <param name="productService"></param>
134134
/// <param name="notificationService"></param>
135-
/// <param name="chesService"></param>
136-
/// <param name="chesOptions"></param>
135+
/// <param name="emailService"></param>
137136
/// <param name="watchOptions"></param>
138137
/// <param name="logger"></param>
139138
public WatchSubscriptionChange(
140139
IUserService userService,
141140
IReportService reportService,
142141
IProductService productService,
143142
INotificationService notificationService,
144-
IChesService chesService,
145-
IOptions<Ches.Configuration.ChesOptions> chesOptions,
143+
IEmailService emailService,
146144
IOptions<WatchOptions> watchOptions,
147145
ILogger<WatchSubscriptionChange> logger)
148146
{
149147
_userService = userService;
150148
_reportService = reportService;
151149
_productService = productService;
152150
_notificationService = notificationService;
153-
_chesService = chesService;
154-
_chesOptions = chesOptions.Value;
151+
_emailService = emailService;
155152
this.Options = watchOptions.Value;
156153
_logger = logger;
157154
}
@@ -165,7 +162,7 @@ public WatchSubscriptionChange(
165162
/// <param name="changeSource">The source of the change, generally the user who made the change.</param>
166163
/// <param name="traceInformation">The location or other details to help trace the source of the change.</param>
167164
/// <returns></returns>
168-
public Ches.Models.EmailModel GenerateEmail(SubscriptionChange[] changes, string changeSource, string traceInformation)
165+
public MailMessage GenerateEmail(SubscriptionChange[] changes, string changeSource, string traceInformation)
169166
{
170167
var body = new StringBuilder($"""
171168
<div>This is an alert to identify changes to user subscriptions.</div>
@@ -234,7 +231,7 @@ public Ches.Models.EmailModel GenerateEmail(SubscriptionChange[] changes, string
234231
}
235232

236233
var to = this.Options.SendTo.Split(',');
237-
return new Ches.Models.EmailModel(_chesOptions.From, to, "MMI - User Subscription Change Alert", body.ToString());
234+
return _emailService.CreateMailMessage("MMI - User Subscription Change Alert", body.ToString(), to, null, null, null, isHtml: true);
238235
}
239236

240237
#region Users
@@ -285,7 +282,7 @@ public async Task AlertUserSubscriptionChangedAsync(Entities.User user, string c
285282
if (changes.Length > 0)
286283
{
287284
var email = GenerateEmail(changes, changeSource, traceInformation);
288-
await _chesService.SendEmailAsync(email);
285+
await _emailService.SendAsync(email);
289286
}
290287
}
291288
#endregion
@@ -335,7 +332,7 @@ public async Task AlertProductSubscriptionChangedAsync(Entities.Product product,
335332
if (changes.Length > 0)
336333
{
337334
var email = GenerateEmail(changes, changeSource, traceInformation);
338-
await _chesService.SendEmailAsync(email);
335+
await _emailService.SendAsync(email);
339336
}
340337
}
341338
#endregion
@@ -385,7 +382,7 @@ public async Task AlertReportSubscriptionChangedAsync(Entities.Report report, st
385382
if (changes.Length > 0)
386383
{
387384
var email = GenerateEmail(changes, changeSource, traceInformation);
388-
await _chesService.SendEmailAsync(email);
385+
await _emailService.SendAsync(email);
389386
}
390387
}
391388
#endregion
@@ -435,7 +432,7 @@ public async Task AlertNotificationSubscriptionChangedAsync(Entities.Notificatio
435432
if (changes.Length > 0)
436433
{
437434
var email = GenerateEmail(changes, changeSource, traceInformation);
438-
await _chesService.SendEmailAsync(email);
435+
await _emailService.SendAsync(email);
439436
}
440437
}
441438
#endregion

api/net/Areas/Services/Controllers/AVOverviewController.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ public IActionResult Update([FromBody] AVOverviewInstanceModel model)
9191
return new JsonResult(new AVOverviewInstanceModel(instance, _serializerOptions));
9292
}
9393

94+
/// <summary>
95+
/// Get all user report instances for the specified instance 'id'.
96+
/// </summary>
97+
/// <param name="id"></param>
98+
/// <param name="userId"></param>
99+
/// <returns></returns>
100+
[HttpGet("{id}/users/{userId}")]
101+
[Produces(MediaTypeNames.Application.Json)]
102+
[ProducesResponseType(typeof(UserAVOverviewInstanceModel), (int)HttpStatusCode.OK)]
103+
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
104+
[SwaggerOperation(Tags = new[] { "Evening Overview" })]
105+
public IActionResult GetUserAVOverviewInstanceAsync(long id, int userId)
106+
{
107+
var result = _overviewInstanceService.GetUserAVOverviewInstance(id, userId) ?? throw new NoContentException();
108+
return new JsonResult(new UserAVOverviewInstanceModel(result));
109+
}
110+
94111
/// <summary>
95112
/// Get all user report instances for the specified instance 'id'.
96113
/// </summary>
@@ -103,8 +120,8 @@ public IActionResult Update([FromBody] AVOverviewInstanceModel model)
103120
[SwaggerOperation(Tags = new[] { "Evening Overview" })]
104121
public IActionResult GetUserAVOverviewInstancesAsync(long id)
105122
{
106-
var content = _overviewInstanceService.GetUserAVOverviewInstances(id);
107-
return new JsonResult(content.Select(c => new UserAVOverviewInstanceModel(c)));
123+
var result = _overviewInstanceService.GetUserAVOverviewInstances(id);
124+
return new JsonResult(result.Select(c => new UserAVOverviewInstanceModel(c)));
108125
}
109126

110127
/// <summary>

api/net/Areas/Services/Controllers/ContentController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public async Task<IActionResult> GetImageFile(long id)
511511
public IActionResult GetNotificationsFor(long id)
512512
{
513513
var notifications = _contentService.GetNotificationsFor(id);
514-
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n, _serializerOptions)));
514+
return new JsonResult(notifications.Select(n => new NotificationInstanceModel(n)));
515515
}
516516

517517
/// <summary>

api/net/Areas/Services/Controllers/NotificationController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ public async Task<IActionResult> FindContentForNotificationIdAsync(int id, int?
123123
/// <returns></returns>
124124
[HttpGet("sent/{status}")]
125125
[Produces(MediaTypeNames.Application.Json)]
126-
[ProducesResponseType(typeof(IEnumerable<ChesNotificationMessagesModel>), (int)HttpStatusCode.OK)]
126+
[ProducesResponseType(typeof(IEnumerable<SmtpNotificationMessagesModel>), (int)HttpStatusCode.OK)]
127127
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
128128
[SwaggerOperation(Tags = new[] { "Notification" })]
129-
public IActionResult GetChesMessages(Entities.NotificationStatus status, [FromQuery] DateTime cutOff)
129+
public IActionResult GetSmtpMessages(Entities.NotificationStatus status, [FromQuery] DateTime cutOff)
130130
{
131-
var messages = _service.GetChesMessageIds(status, cutOff);
131+
var messages = _service.GetSmtpMessages(status, cutOff);
132132
return new JsonResult(messages);
133133
}
134134
#endregion

api/net/Areas/Services/Controllers/NotificationInstanceController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public IActionResult FindById(long id)
6161
{
6262
var result = _service.FindById(id);
6363
if (result == null) return NoContent();
64-
return new JsonResult(new NotificationInstanceModel(result, _serializerOptions));
64+
return new JsonResult(new NotificationInstanceModel(result));
6565
}
6666

6767
/// <summary>
@@ -76,8 +76,8 @@ public IActionResult FindById(long id)
7676
[SwaggerOperation(Tags = new[] { "NotificationInstance" })]
7777
public IActionResult Add([FromBody] NotificationInstanceModel model)
7878
{
79-
var result = _service.AddAndSave(model.ToEntity(_serializerOptions));
80-
return CreatedAtAction(nameof(FindById), new { id = result.Id }, new NotificationInstanceModel(result, _serializerOptions));
79+
var result = _service.AddAndSave((Entities.NotificationInstance)model);
80+
return CreatedAtAction(nameof(FindById), new { id = result.Id }, new NotificationInstanceModel(result));
8181
}
8282

8383
/// <summary>
@@ -97,7 +97,7 @@ public IActionResult UpdateNotificationInstanceStatus(long id, Entities.Notifica
9797
instance.Status = status;
9898
_service.UpdateAndSave(instance);
9999

100-
return new JsonResult(new NotificationInstanceModel(instance, _serializerOptions));
100+
return new JsonResult(new NotificationInstanceModel(instance));
101101
}
102102
#endregion
103103
}

0 commit comments

Comments
 (0)