Created CA follow up worker
This commit is contained in:
@ -6,9 +6,10 @@ namespace FabApprovalWorkerService.Services;
|
||||
|
||||
public interface IECNService {
|
||||
Task<IEnumerable<ECN>> GetExpiringTECNs();
|
||||
Task<IEnumerable<ECN>> GetExpiredTECNs();
|
||||
Task<IEnumerable<ECN>> GetExpiredTECNsInPastDay();
|
||||
Task<IEnumerable<string>> GetTECNNotificationUserEmails();
|
||||
Task<ECN> GetEcnByNumber(int ecnNumber);
|
||||
bool EcnIsExpired(ECN ecn);
|
||||
}
|
||||
|
||||
public class ECNService : IECNService {
|
||||
@ -20,6 +21,31 @@ public class ECNService : IECNService {
|
||||
_dalService = dalService ?? throw new ArgumentNullException("IDalService not injected");
|
||||
}
|
||||
|
||||
public bool EcnIsExpired(ECN ecn) {
|
||||
try {
|
||||
_logger.LogInformation("Attempting to determine if ECN is expired");
|
||||
|
||||
if (ecn is null) throw new ArgumentNullException("ECN cannot be null");
|
||||
|
||||
if (!ecn.IsTECN) return false;
|
||||
if (ecn.CloseDate <= DateTime.Now) return false;
|
||||
|
||||
DateTime tomorrow = DateTime.Now.Date.AddDays(1);
|
||||
|
||||
bool isExpired = (ecn.ExpirationDate < tomorrow) && (ecn.ExtensionDate < tomorrow);
|
||||
|
||||
_logger.LogInformation($"ECN {ecn.ECNNumber} expired: {isExpired}");
|
||||
|
||||
return isExpired;
|
||||
} catch (Exception ex) {
|
||||
StringBuilder errMsgBuilder = new();
|
||||
errMsgBuilder.Append($"An exception occurred when attempting to determine if ECN is expired. ");
|
||||
errMsgBuilder.Append($"Exception: {ex.Message}");
|
||||
_logger.LogError(errMsgBuilder.ToString());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ECN> GetEcnByNumber(int ecnNumber) {
|
||||
try {
|
||||
_logger.LogInformation($"Attempting to get ECN {ecnNumber}");
|
||||
@ -42,7 +68,7 @@ public class ECNService : IECNService {
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ECN>> GetExpiredTECNs() {
|
||||
public async Task<IEnumerable<ECN>> GetExpiredTECNsInPastDay() {
|
||||
try {
|
||||
_logger.LogInformation("Attempting to get all TECNs expired in the last day");
|
||||
|
||||
|
Reference in New Issue
Block a user