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 ApprovalNotificationWorker : IJob {
|
||||
@ -31,7 +31,8 @@ public class ApprovalNotificationWorker : IJob {
|
||||
IPCRBService pcrbService,
|
||||
ISmtpService smtpService,
|
||||
IMonInClient monInClient,
|
||||
IUserService userService) {
|
||||
IUserService userService,
|
||||
AppSettings appSettings) {
|
||||
_logger = logger ?? throw new ArgumentNullException("ILogger not injected");
|
||||
_approvalService = approvalService ?? throw new ArgumentNullException("IApprovalService not injected");
|
||||
_ecnService = ecnService ?? throw new ArgumentNullException("IECNService not injected");
|
||||
@ -41,10 +42,8 @@ public class ApprovalNotificationWorker : IJob {
|
||||
_smtpService = smtpService ?? throw new ArgumentNullException("ISmtpService not injected");
|
||||
_monInClient = monInClient ?? throw new ArgumentNullException("IMonInClient not injected");
|
||||
_userService = userService ?? throw new ArgumentNullException("IUserService not injected");
|
||||
_oldFabApprovalBaseUrl = Environment.GetEnvironmentVariable("OldFabApprovalUrl") ??
|
||||
throw new ArgumentNullException("OldFabApprovalUrl environment variable not found");
|
||||
_newFabApprovalBaseUrl = Environment.GetEnvironmentVariable("NewFabApprovalBaseUrl") ??
|
||||
throw new ArgumentNullException("NewFabApprovalBaseUrl environment variable not found");
|
||||
_oldFabApprovalBaseUrl = appSettings.OldBaseUrl;
|
||||
_newFabApprovalBaseUrl = appSettings.NewBaseUrl;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context) {
|
||||
@ -116,8 +115,8 @@ public class ApprovalNotificationWorker : IJob {
|
||||
if (issueAndUserIds.Contains($"{approval.IssueID}{approval.UserID}")) {
|
||||
approval.NotifyDate = DateTime.Now;
|
||||
await _approvalService.UpdateApproval(approval);
|
||||
} else if ((isEcn || isCa || isMrb || isPcrb) &&
|
||||
!string.IsNullOrWhiteSpace(title) &&
|
||||
} else if ((isEcn || isCa || isMrb || isPcrb) &&
|
||||
!string.IsNullOrWhiteSpace(title) &&
|
||||
!string.IsNullOrWhiteSpace(url) &&
|
||||
!issueAndUserIds.Contains($"{approval.IssueID}{approval.UserID}")) {
|
||||
|
||||
@ -167,4 +166,4 @@ public class ApprovalNotificationWorker : IJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 CAFollowUpWorker : IJob {
|
||||
@ -22,14 +22,14 @@ public class CAFollowUpWorker : IJob {
|
||||
ICorrectiveActionService caService,
|
||||
IUserService userService,
|
||||
ISmtpService smtpService,
|
||||
IMonInClient monInClient) {
|
||||
IMonInClient monInClient,
|
||||
AppSettings appSettings) {
|
||||
_logger = logger ?? throw new ArgumentNullException("ILogger not injected");
|
||||
_caService = caService ?? throw new ArgumentNullException("ICorrectiveActionService not injected");
|
||||
_userService = userService ?? throw new ArgumentNullException("IUserService 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) {
|
||||
@ -45,7 +45,7 @@ public class CAFollowUpWorker : IJob {
|
||||
.ToList();
|
||||
foreach (CorrectiveAction ca in followUpCAs) {
|
||||
await _caService.CreateCorrectiveActionFollowUpApproval(ca.CANo, ca.QAID);
|
||||
|
||||
|
||||
string qaEmail = await _userService.GetUserEmail(ca.QAID);
|
||||
IEnumerable<MailAddress> recipients = new List<MailAddress>() {
|
||||
new MailAddress(qaEmail)
|
||||
@ -84,4 +84,4 @@ public class CAFollowUpWorker : IJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
using System.Text;
|
||||
|
||||
using FabApprovalWorkerService.Models;
|
||||
using FabApprovalWorkerService.Services;
|
||||
|
||||
@ -5,14 +7,12 @@ using Infineon.Monitoring.MonA;
|
||||
|
||||
using Quartz;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace FabApprovalWorkerService.Workers;
|
||||
|
||||
public class CertificationTrainingGroupWorker : IJob {
|
||||
private static readonly int MAX_RETRIES = 3;
|
||||
private static readonly int BACKOFF_SECONDS = 30;
|
||||
|
||||
|
||||
private readonly ILogger<CertificationTrainingGroupWorker> _logger;
|
||||
private readonly ITrainingService _trainingService;
|
||||
private readonly IUserService _userService;
|
||||
@ -26,25 +26,20 @@ public class CertificationTrainingGroupWorker : IJob {
|
||||
private readonly string _packagingAndLabelingTrainingGroupName;
|
||||
|
||||
public CertificationTrainingGroupWorker(ILogger<CertificationTrainingGroupWorker> logger,
|
||||
ITrainingService trainingService,
|
||||
IUserService userService,
|
||||
IMonInClient monInClient) {
|
||||
ITrainingService trainingService,
|
||||
IUserService userService,
|
||||
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");
|
||||
_monInClient = monInClient ?? throw new ArgumentNullException("IMonInClient not injected");
|
||||
_siProductionGroupName = Environment.GetEnvironmentVariable("SiProductionTrainingGroupName") ??
|
||||
throw new ArgumentNullException("SiProductionTrainingGroupName environment variable not found");
|
||||
_asmHtrTrainingGroupName = Environment.GetEnvironmentVariable("AsmHtrTrainingGroupName") ??
|
||||
throw new ArgumentNullException("AsmHtrTrainingGroupName environment variable not found");
|
||||
_cleansTrainingGroupName = Environment.GetEnvironmentVariable("CleansTrainingGroupName") ??
|
||||
throw new ArgumentNullException("CleansTrainingGroupName environment variable not found");
|
||||
_epiProTrainingGroupName = Environment.GetEnvironmentVariable("EpiProTrainingGroupName") ??
|
||||
throw new ArgumentNullException("EpiProTrainingGroupName environment variable not found");
|
||||
_fqaTrainingGroupName = Environment.GetEnvironmentVariable("FqaTrainingGroupName") ??
|
||||
throw new ArgumentNullException("FqaTrainingGroupName environment variable not found");
|
||||
_packagingAndLabelingTrainingGroupName = Environment.GetEnvironmentVariable("PackagingAndLabelingTrainingGroupName") ??
|
||||
throw new ArgumentNullException("PackagingAndLabelingTrainingGroupName environment variable not found");
|
||||
_fqaTrainingGroupName = appSettings.FqaTrainingGroupName;
|
||||
_asmHtrTrainingGroupName = appSettings.AsmHtrTrainingGroupName;
|
||||
_cleansTrainingGroupName = appSettings.CleansTrainingGroupName;
|
||||
_epiProTrainingGroupName = appSettings.EpiProTrainingGroupName;
|
||||
_siProductionGroupName = appSettings.SiProductionTrainingGroupName;
|
||||
_packagingAndLabelingTrainingGroupName = appSettings.PackagingAndLabelingTrainingGroupName;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context) {
|
||||
@ -93,10 +88,11 @@ public class CertificationTrainingGroupWorker : IJob {
|
||||
_logger.LogInformation($"Processing cert record {{{record}}}");
|
||||
|
||||
if (record is not null) {
|
||||
User user = null;
|
||||
User? user;
|
||||
try {
|
||||
user = await _userService.GetUserByEmail(record.Email);
|
||||
} catch (Exception ex) {
|
||||
user = null;
|
||||
StringBuilder errMsgBuilder = new();
|
||||
errMsgBuilder.Append($"An exception occurred when attempting to get user for email {record.Email}. ");
|
||||
errMsgBuilder.Append($"Exception: {ex.Message}");
|
||||
|
@ -1,12 +1,12 @@
|
||||
using FabApprovalWorkerService.Models;
|
||||
using System.Text;
|
||||
|
||||
using FabApprovalWorkerService.Models;
|
||||
using FabApprovalWorkerService.Services;
|
||||
|
||||
using Infineon.Monitoring.MonA;
|
||||
|
||||
using Quartz;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace FabApprovalWorkerService.Workers;
|
||||
|
||||
public sealed class ExpiredOOOStatusWorker : IJob {
|
||||
@ -43,7 +43,7 @@ public sealed class ExpiredOOOStatusWorker : IJob {
|
||||
List<User> expiredOOOUsers = await _userService.GetAllExpiredOOOUsersAsync();
|
||||
|
||||
_logger.LogInformation($"There are {expiredOOOUsers.Count()} OOO users expiring");
|
||||
|
||||
|
||||
foreach (User user in expiredOOOUsers) {
|
||||
bool approvalsRemoved = await _userService.RemoveDelegatedApprovalsForUser(user.UserID, user.DelegatedTo);
|
||||
bool subRolesRemoved = await _userService.RemoveDelegatedUserSubRoles(user.UserID, user.DelegatedTo);
|
||||
@ -61,7 +61,7 @@ public sealed class ExpiredOOOStatusWorker : IJob {
|
||||
errMsgBuilder.Append($"OOO flag removed: {oooFlagRemoved}");
|
||||
throw new Exception(errMsgBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
StringBuilder errMsgBuilder = new();
|
||||
errMsgBuilder.Append("An exception occurred when attempting to remove OOO status for users with OOO expired ");
|
||||
@ -80,4 +80,4 @@ public sealed class ExpiredOOOStatusWorker : IJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 ExpiringTECNWorker : IJob {
|
||||
@ -22,7 +22,8 @@ public class ExpiringTECNWorker : IJob {
|
||||
IMonInClient monInClient,
|
||||
IUserService userService,
|
||||
IECNService ecnService,
|
||||
ISmtpService smtpService) {
|
||||
ISmtpService smtpService,
|
||||
AppSettings appSettings) {
|
||||
_logger = logger ??
|
||||
throw new ArgumentNullException("ILogger not injected");
|
||||
_monInClient = monInClient ??
|
||||
@ -33,8 +34,7 @@ public class ExpiringTECNWorker : IJob {
|
||||
throw new ArgumentNullException("IECNService not injected");
|
||||
_smtpService = smtpService ??
|
||||
throw new ArgumentNullException("ISmtpService not injected");
|
||||
_baseUrl = Environment.GetEnvironmentVariable("FabApprovalBaseUrl") ??
|
||||
throw new ArgumentNullException("FabApprovalBaseUrl environment variable not found");
|
||||
_baseUrl = appSettings.BaseUrl;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context) {
|
||||
@ -57,8 +57,8 @@ public class ExpiringTECNWorker : IJob {
|
||||
foreach (ECN eCN in expiringTECNs) {
|
||||
string recipientEmail = await _userService.GetUserEmail(eCN.OriginatorID);
|
||||
MailAddress recipientAddress = new MailAddress(recipientEmail);
|
||||
List<MailAddress> recipientList = new () { recipientAddress };
|
||||
|
||||
List<MailAddress> recipientList = new() { recipientAddress };
|
||||
|
||||
List<MailAddress> ccRecipientList = new();
|
||||
foreach (string email in tecnNotificationUserEmails) {
|
||||
ccRecipientList.Add(new MailAddress(email));
|
||||
@ -94,4 +94,4 @@ public class ExpiringTECNWorker : IJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
using FabApprovalWorkerService.Models;
|
||||
using System.Text;
|
||||
|
||||
using FabApprovalWorkerService.Models;
|
||||
using FabApprovalWorkerService.Services;
|
||||
|
||||
using Infineon.Monitoring.MonA;
|
||||
|
||||
using Quartz;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace FabApprovalWorkerService.Workers;
|
||||
|
||||
public sealed class PendingOOOStatusWorker : IJob {
|
||||
@ -43,7 +43,7 @@ public sealed class PendingOOOStatusWorker : IJob {
|
||||
List<OOOTemp> pendingOOOUsers = await _userService.GetAllPendingOOOUsersAsync();
|
||||
|
||||
_logger.LogInformation($"There are {pendingOOOUsers.Count()} pending OOO users");
|
||||
|
||||
|
||||
foreach (OOOTemp oooTemp in pendingOOOUsers) {
|
||||
bool userAlreadyOOO = await _userService.IsUserAlreadyOOO(oooTemp.OOOUserID);
|
||||
bool delegateAlreadyADelegate = await _userService.IsDelegatorAlreadyDelegatedTo(oooTemp.DelegatedTo);
|
||||
@ -84,4 +84,4 @@ public sealed class PendingOOOStatusWorker : IJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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