Pull Request 33523 suggestions
Pull Request 33520 suggestions Injected AppSettings instead of using GetEnvironmentVariable at Services level When debugging only app.Services.GetRequiredService<IPCRBService>(); Get ready to use VSCode IDE Align .editorconfig files
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
using FabApprovalWorkerService.Models;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
|
||||
using FabApprovalWorkerService.Models;
|
||||
using FabApprovalWorkerService.Services;
|
||||
|
||||
using Infineon.Monitoring.MonA;
|
||||
|
||||
using Quartz;
|
||||
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
|
||||
namespace FabApprovalWorkerService.Workers;
|
||||
|
||||
public class TrainingNotificationWorker : IJob {
|
||||
@ -24,15 +24,15 @@ public class TrainingNotificationWorker : IJob {
|
||||
IUserService userService,
|
||||
IECNService ecnService,
|
||||
ISmtpService smtpService,
|
||||
IMonInClient monInClient) {
|
||||
IMonInClient monInClient,
|
||||
AppSettings appSettings) {
|
||||
_logger = logger ?? throw new ArgumentNullException("ILogger not injected");
|
||||
_trainingService = trainingService ?? throw new ArgumentNullException("ITrainingService not injected");
|
||||
_userService = userService ?? throw new ArgumentNullException("IUserService not injected");
|
||||
_ecnService = ecnService ?? throw new ArgumentNullException("IECNService not injected");
|
||||
_smtpService = smtpService ?? throw new ArgumentNullException("ISmtpService not injected");
|
||||
_monInClient = monInClient ?? throw new ArgumentNullException("IMonInClient not injected");
|
||||
_baseUrl = Environment.GetEnvironmentVariable("FabApprovalBaseUrl") ??
|
||||
throw new ArgumentNullException("FabApprovalBaseUrl environment variable not found");
|
||||
_baseUrl = appSettings.BaseUrl;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context) {
|
||||
@ -67,7 +67,7 @@ public class TrainingNotificationWorker : IJob {
|
||||
_logger.LogInformation($"User {user.UserID} is inactive. Cancelling all training.");
|
||||
|
||||
IEnumerable<int> userTrainingAssignmentIds = await _trainingService.GetTrainingAssignmentIdsByUserId(user.UserID);
|
||||
|
||||
|
||||
foreach (int trainingAssignmentId in userTrainingAssignmentIds) {
|
||||
await _trainingService.DeleteTrainingAssignmentById(trainingAssignmentId);
|
||||
await _trainingService.DeleteDocAssignment(trainingAssignmentId);
|
||||
@ -124,7 +124,7 @@ public class TrainingNotificationWorker : IJob {
|
||||
};
|
||||
|
||||
IEnumerable<MailAddress> ccRecipients = new List<MailAddress>();
|
||||
|
||||
|
||||
StringBuilder bodyBuilder = new();
|
||||
bodyBuilder.Append("Hello, you have open training assignments in Fab Approval. This is a reminder to ");
|
||||
bodyBuilder.Append("finish your training assignments. <br /> View your open training assignments ");
|
||||
@ -134,4 +134,4 @@ public class TrainingNotificationWorker : IJob {
|
||||
|
||||
await _smtpService.SendEmail(recipients, ccRecipients, subject, bodyBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user