Switched to standard MonIn library
This commit is contained in:
@ -23,21 +23,30 @@ public class ECNService : IECNService {
|
||||
try {
|
||||
_logger.LogInformation("Attempting to get all TECNs expired in the last day");
|
||||
|
||||
string today = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
string yesterday = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
DateTime today = DateTime.Now.Date;
|
||||
DateTime tomorrow = DateTime.Now.Date.AddDays(1);
|
||||
|
||||
StringBuilder queryBuilder = new StringBuilder();
|
||||
queryBuilder.Append("select ECNNumber, IsTECN, ExpirationDate, ExtensionDate, OriginatorID, Title ");
|
||||
queryBuilder.Append($"from ECN where IsTECN = 1 and ");
|
||||
queryBuilder.Append($"ExpirationDate between '{yesterday}' ");
|
||||
queryBuilder.Append($"and '{today}'");
|
||||
queryBuilder.Append("Cancelled = 0 and Deleted = 0 ");
|
||||
queryBuilder.Append("and (CloseDate IS NULL or CloseDate = '');");
|
||||
|
||||
IEnumerable<ECN> expiredTecns = (await _dalService.QueryAsync<ECN>(queryBuilder.ToString()));
|
||||
IEnumerable<ECN> activeTecns = await _dalService.QueryAsync<ECN>(queryBuilder.ToString());
|
||||
|
||||
_logger.LogInformation($"There are {activeTecns.Count()} active TECNs");
|
||||
|
||||
IEnumerable<ECN> expiredTecns = activeTecns.Where(e => ((e.ExpirationDate < tomorrow) && (e.ExpirationDate >= today)) ||
|
||||
((e.ExtensionDate < tomorrow) && (e.ExtensionDate >= today)));
|
||||
|
||||
_logger.LogInformation($"There are {expiredTecns.Count()} TECNs with an expiration date or extension date today");
|
||||
|
||||
IEnumerable<ECN> expiredTecnsNotExtended = expiredTecns
|
||||
.Where(e => e.ExtensionDate < DateTime.Now)
|
||||
.Where(e => !(e.ExtensionDate >= tomorrow))
|
||||
.ToList();
|
||||
|
||||
_logger.LogInformation($"There are {expiredTecnsNotExtended.Count()} TECNs expiring today");
|
||||
|
||||
return expiredTecnsNotExtended;
|
||||
} catch (Exception ex) {
|
||||
StringBuilder errMsgBuilder = new();
|
||||
@ -52,21 +61,30 @@ public class ECNService : IECNService {
|
||||
try {
|
||||
_logger.LogInformation("Attempting to get all TECNs expiring in the next five days");
|
||||
|
||||
string today = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
string fiveDaysFromToday = DateTime.Now.AddDays(5).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
DateTime tomorrow = DateTime.Now.AddDays(1).Date;
|
||||
DateTime fiveDaysFromToday = DateTime.Now.AddDays(5).Date;
|
||||
|
||||
StringBuilder queryBuilder = new StringBuilder();
|
||||
queryBuilder.Append("select * from ECN ");
|
||||
queryBuilder.Append($"where IsTECN = 1 and ");
|
||||
queryBuilder.Append($"ExpirationDate between '{today}' ");
|
||||
queryBuilder.Append($"and '{fiveDaysFromToday}';");
|
||||
queryBuilder.Append("Cancelled = 0 and Deleted = 0 ");
|
||||
queryBuilder.Append("and (CloseDate IS NULL or CloseDate = '');");
|
||||
|
||||
IEnumerable<ECN> expiringTecns = (await _dalService.QueryAsync<ECN>(queryBuilder.ToString()));
|
||||
IEnumerable<ECN> activeTecns = (await _dalService.QueryAsync<ECN>(queryBuilder.ToString()));
|
||||
|
||||
_logger.LogInformation($"There are {activeTecns.Count()} active TECNs");
|
||||
|
||||
IEnumerable<ECN> expiringTecns = activeTecns.Where(e => ((e.ExpirationDate >= tomorrow) && (e.ExpirationDate <= fiveDaysFromToday)) ||
|
||||
((e.ExtensionDate >= tomorrow) && (e.ExtensionDate <= fiveDaysFromToday)));
|
||||
|
||||
_logger.LogInformation($"There are {expiringTecns.Count()} TECNs with an expiration date or extension date in the next 5 days");
|
||||
|
||||
IEnumerable<ECN> expiringTecnsNotExtended = expiringTecns
|
||||
.Where(e => e.ExtensionDate <= DateTime.Now.AddDays(5))
|
||||
.Where(e => !(e.ExtensionDate > fiveDaysFromToday))
|
||||
.ToList();
|
||||
|
||||
_logger.LogInformation($"There are {expiringTecnsNotExtended.Count()} TECNs expiring in the next five days");
|
||||
|
||||
return expiringTecnsNotExtended;
|
||||
} catch (Exception ex) {
|
||||
StringBuilder errMsgBuilder = new();
|
||||
|
Reference in New Issue
Block a user