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,14 +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 ExpiredTECNWorker : IJob {
|
||||
private readonly ILogger<ExpiredTECNWorker> _logger;
|
||||
@ -24,7 +23,8 @@ public class ExpiredTECNWorker : IJob {
|
||||
ITrainingService trainingService,
|
||||
IUserService userService,
|
||||
ISmtpService smtpService,
|
||||
IMonInClient monInClient) {
|
||||
IMonInClient monInClient,
|
||||
AppSettings appSettings) {
|
||||
_logger = logger ??
|
||||
throw new ArgumentNullException("ILogger not injected");
|
||||
_ecnService = ecnService ??
|
||||
@ -37,8 +37,7 @@ public class ExpiredTECNWorker : IJob {
|
||||
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) {
|
||||
@ -61,14 +60,14 @@ public class ExpiredTECNWorker : IJob {
|
||||
|
||||
foreach (ECN ecn in expiredEcns) {
|
||||
List<int> trainingIds = (await _trainingService.GetTrainingIdsForECN(ecn.ECNNumber)).ToList();
|
||||
|
||||
|
||||
foreach (int trainingId in trainingIds) {
|
||||
await _trainingService.DeleteTrainingAssignmentsByTrainingId(trainingId);
|
||||
|
||||
List<int> trainingAssignmentIds =
|
||||
|
||||
List<int> trainingAssignmentIds =
|
||||
(await _trainingService.GetTrainingAssignmentIdsForTraining(trainingId)).ToList();
|
||||
|
||||
foreach (int assignmentId in trainingAssignmentIds) {
|
||||
foreach (int assignmentId in trainingAssignmentIds) {
|
||||
await _trainingService.DeleteDocAssignment(assignmentId);
|
||||
}
|
||||
|
||||
@ -76,8 +75,8 @@ public class ExpiredTECNWorker : IJob {
|
||||
}
|
||||
|
||||
string recipientEmail = await _userService.GetUserEmail(ecn.OriginatorID);
|
||||
List<MailAddress> recipientEamils = new List<MailAddress>() {
|
||||
new MailAddress(recipientEmail)
|
||||
List<MailAddress> recipientEamils = new List<MailAddress>() {
|
||||
new MailAddress(recipientEmail)
|
||||
};
|
||||
|
||||
string subject = "Notice of Expired TECN";
|
||||
@ -108,4 +107,4 @@ public class ExpiredTECNWorker : IJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user