This commit is contained in:
Zeeshaun
2026-03-17 09:53:09 -05:00
parent cdcba54aa4
commit 1a0702a79a
590 changed files with 62058 additions and 0 deletions
@@ -0,0 +1,187 @@
using LCU.API.Internal.Operations.IncentiveApi.Configuration;
using LCU.API.Internal.Operations.IncentiveApi.DataAccess;
using LCU.Library.Internal.IncentiveApiModels.Entities;
using NewAtmCheckCardActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewAtmCheckCardActivity;
using NewCheckingAccountActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewCheckingAccountActivity;
using NewLoanSaleActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewLoanSaleActivity;
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Activity;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
using System.Web;
using LCU.Library.Internal.Exceptions;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices;
public class CoreApiWrapperService : ICoreApiWrapperService
{
private readonly ICoreApiWrapperDao _coreApiWrapperDao;
private readonly CoreApiWrapperConfiguration _coreApiWrapperConfiguration;
public CoreApiWrapperService(CoreApiWrapperConfiguration coreApiWrapperConfiguration, ICoreApiWrapperDao coreApiWrapperDao)
{
_coreApiWrapperDao = coreApiWrapperDao;
_coreApiWrapperConfiguration = coreApiWrapperConfiguration;
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingAccountSalesActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewCheckingAccountSalesActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Checking Account Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingDigitalBankingAccountSalesActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewCheckingDigitalBankingAccountSalesActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Digital Banking Checking Account Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardSalesActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewAtmCheckCardSalesActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New ATM and Check Card Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewActivityManagerReferral>> GetNewActivityManagerReferralsActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewActivityManagerReferralsActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Activity Manager Referrals from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewMortgageSaleActivities(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewMortgageSaleActivities(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Mortgage Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewVehicleSaleActivities(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewVehicleSaleActivities(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Vehicle Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewDpEligibleSaleActivities(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewDpEligibleSaleActivities(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New DP Eligible Sales and Actvities from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<ActivityAccountDetails>> GetUpdatedAccountInformation(List<long> accountNumbers)
{
try
{
return await _coreApiWrapperDao.GetUpdatedAccountInformation(accountNumbers);
}
catch (Exception ex)
{
var error = $"Failed to get Updated Account Information from DNA after: {string.Join(",", accountNumbers)}" + $"Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewActivityManagerReferral>> GetActivityManagerActivities(ActivityQueryRequest request)
{
try
{
return await _coreApiWrapperDao.GetActivityManagerActivities(request);
}
catch (Exception ex)
{
var error = $"Failed to get Activity Manager Activities from DNA after: {request.ActivityIds} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<TransactionHistory>> GetTransactionHistory(string accountNumber, DateTime startDate, DateTime endDate, List<string> transactionCodes)
{
try
{
return await _coreApiWrapperDao.GetTransactionHistory(accountNumber, startDate, endDate, transactionCodes);
}
catch (Exception ex)
{
var error = $"Failed to get Transaction History for Account Number: {accountNumber} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public string DateTimeToUrlString(DateTime dateTime)
{
var dtstring = dateTime.ToString("yyyy-MM-ddTHH:mm:ss");
return HttpUtility.UrlEncode(dtstring);
}
public async Task<IReadOnlyCollection<EStatementDeliveryMethod>> GetEStatmentDeliveryMethods(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetEStatmentDeliveryMethods(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get EStatement Delivery Methods from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
}
@@ -0,0 +1,43 @@
using LCU.API.Internal.Operations.IncentiveApi.DataAccess;
using LCU.Library.Internal.Exceptions;
using LCU.Library.Internal.FileOperationsModels.Models;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices;
public class FileOperationsApiService : IFileOperationsApiService
{
private readonly IFileOperationsApiDao _fileOperationDao;
public FileOperationsApiService(IFileOperationsApiDao fileOperationDao)
{
_fileOperationDao = fileOperationDao;
}
public async Task<string[]> BuildDynamicFileList(DynamicFileListRequest dynamicFileRequest)
{
try
{
return await _fileOperationDao.BuildDynamicFileList(dynamicFileRequest);
}
catch (Exception exception)
{
var message = $"Error to BuildDynamicFileList. FilePath: {dynamicFileRequest.Path}.";
Log.Error(exception, message);
throw new ServiceException($"{message} Exception Message:{exception.Message}");
}
}
public async Task<string> GetFileContent(string filePath)
{
try
{
return await _fileOperationDao.GetFileContent(filePath);
}
catch (Exception exception)
{
var message = $"Failure to GetFileContent. FilePath: {filePath}.";
Log.Error(exception, message);
throw new ServiceException($"{message} Exception Message: {exception.Message}");
}
}
}
@@ -0,0 +1,25 @@
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Activity;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
using NewAtmCheckCardActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewAtmCheckCardActivity;
using NewCheckingAccountActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewCheckingAccountActivity;
using NewLoanSaleActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewLoanSaleActivity;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices;
public interface ICoreApiWrapperService
{
public Task<IReadOnlyCollection<EStatementDeliveryMethod>> GetEStatmentDeliveryMethods(DateTime activityDt);
public Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingDigitalBankingAccountSalesActivity(DateTime activityDt);
public Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingAccountSalesActivity(DateTime activityDt);
public Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardSalesActivity(DateTime activityDt);
public Task<IReadOnlyCollection<NewActivityManagerReferral>> GetNewActivityManagerReferralsActivity(DateTime activityDt);
public Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewMortgageSaleActivities(DateTime activityDt);
public Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewVehicleSaleActivities(DateTime activityDt);
public Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewDpEligibleSaleActivities(DateTime activityDt);
public Task<IReadOnlyCollection<ActivityAccountDetails>> GetUpdatedAccountInformation(List<long> activityIds);
public Task<IReadOnlyCollection<NewActivityManagerReferral>> GetActivityManagerActivities(ActivityQueryRequest request);
public Task<IReadOnlyCollection<TransactionHistory>> GetTransactionHistory(string accountNumber, DateTime startDate, DateTime endDate, List<string> transactionCodes);
}
@@ -0,0 +1,9 @@
using LCU.Library.Internal.FileOperationsModels.Models;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices;
public interface IFileOperationsApiService
{
Task<string[]> BuildDynamicFileList(DynamicFileListRequest dynamicFileRequest);
Task<string> GetFileContent(string filePath);
}
@@ -0,0 +1,13 @@
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.API.Internal.Operations.IncentiveApi.Models.Dayforce;
using LCU.API.Internal.Operations.IncentiveApi.Models.GoalDispersal;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices;
public interface INotificationApiService
{
public Task SendMonthStartGoalDispersalReceipt(Dictionary<string, GoalDispersalReceipt> receipts, List<string> recipients);
public Task SendMissingRoleNotification(IEnumerable<AppUser> usersMissingRole, List<string> recipients);
public Task SendTerminatedEmployeeNotification(IEnumerable<TerminatedEmployeeReceipt> terminated, List<string> recipients);
public Task SendTransferRequestInitiatedNotification(ActivityTransferAction transferAction, List<string> recipients);
}
@@ -0,0 +1,312 @@
using LCU.API.Internal.Operations.IncentiveApi.Configuration;
using LCU.API.Internal.Operations.IncentiveApi.DataAccess;
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.API.Internal.Operations.IncentiveApi.Models.Dayforce;
using LCU.API.Internal.Operations.IncentiveApi.Models.GoalDispersal;
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
using LCU.API.Internal.NotificationsApiLib.Models;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices;
public class NotificationApiService : INotificationApiService
{
private readonly EmailRecipientsConfiguration _emailRecipientsConfig;
private readonly INotificationApiDao _notificationsDao;
private readonly ApiConfiguration _incentiveApiConfig;
public NotificationApiService(EmailRecipientsConfiguration emailRecipientsConfig, ApiConfiguration incentiveApiConfig, INotificationApiDao notificationsDao,
IUserService userService)
{
_emailRecipientsConfig = emailRecipientsConfig;
_notificationsDao = notificationsDao;
_incentiveApiConfig = incentiveApiConfig;
}
public async Task SendMonthStartGoalDispersalReceipt(Dictionary<string, GoalDispersalReceipt> receipts, List<string> recipients)
{
try
{
#region Body HTML Boilerplate
string body =
@"<style>
.report {
border:1px solid #C0C0C0;
border-collapse:collapse;
padding:5px;
}
.report th {
border:1px solid #C0C0C0;
padding:5px;
background:#F0F0F0;
}
.report td {
border:1px solid #C0C0C0;
padding:5px;
}
</style>
<table class='report'>
<tbody>
<tr>
<td><h3>Department</h3></td>
<td><h3>Strategy</h3></td>
<td><h3>Alerts</h3></td>
</tr>";
#endregion
foreach (var (departmentName, receipt) in receipts)
{
if (receipt == null)
{
body += $@"
<tr>
<td><b>{departmentName}</b></td>
<td>&nbsp;<i>FAILED</i></td>
<td>&nbsp;No Receipt Data, Failed to Run Dispersal.</td>
</tr>";
}
else if (receipt.GoalDispersalErrors.Any())
{
body += $@"
<tr>
<td><b>{departmentName}</b></td>
<td>&nbsp;<i>{receipt.Strategy}</i></td>
<td>&nbsp;{FormatReceiptItems(receipt.GoalDispersalErrors)}</td>
</tr>";
}
}
body += @"</tbody> </table>";
var emailRequest = new EmailRequest
{
Recipient = recipients,
Subject = "Month Start Personnel Dispersal Report",
Body = body
};
await _notificationsDao.SendMessageAsync(emailRequest);
}
catch (Exception ex)
{
Log.Error(ex, "Failed to Send Month Start Dispersal Report");
}
}
public async Task SendMissingRoleNotification(IEnumerable<AppUser> usersMissingRole, List<string> recipients)
{
try
{
#region Body HTML Boilerplate
string body =
@"<style>
.report {
border:1px solid #C0C0C0;
border-collapse:collapse;
padding:5px;
}
.report th {
border:1px solid #C0C0C0;
padding:5px;
background:#F0F0F0;
}
.report td {
border:1px solid #C0C0C0;
padding:5px;
}
</style>
<table class='report'>
<tbody>
<tr>
<td><h3>Name</h3></td>
<td><h3>Employee ID</h3></td>
<td><h3>Department</h3></td>
<td><h3>Missing Role</h3></td>
</tr>";
#endregion
foreach (var user in usersMissingRole)
{
body += $@"
<tr>
<td>{user.FullName}</td>
<td>{user.EmployeeId}</td>
<td>{user.HomeDepartment}</td>
<td>{user.BaseRole}</td>
</tr>";
}
body += @"</tbody> </table>";
var emailRequest = new EmailRequest
{
Recipient = recipients,
Subject = $"Users missing Dayforce role",
Body = body
};
await _notificationsDao.SendMessageAsync(emailRequest);
}
catch (Exception ex)
{
Log.Error(ex, "Failed to send missing role notification");
}
}
public async Task SendTerminatedEmployeeNotification(IEnumerable<TerminatedEmployeeReceipt> terminated, List<string> recipients)
{
try
{
#region Body HTML Boilerplate
string body =
@"<style>
.report {
border:1px solid #C0C0C0;
border-collapse:collapse;
padding:5px;
}
.report th {
border:1px solid #C0C0C0;
padding:5px;
background:#F0F0F0;
}
.report td {
border:1px solid #C0C0C0;
padding:5px;
}
</style>
<table class='report'>
<tbody>
<tr>
<td><h3>Name</h3></td>
<td><h3>Employee ID</h3></td>
<td><h3>Department</h3></td>
<td><h3>Terminated</h3></td>
<td><h3>Manager</h3></td>
<td><h3>Prev Month Payout</h3></td>
<td><h3>This Month Payout</h3></td>
</tr>";
#endregion
foreach (var receipt in terminated)
{
var manager = receipt.Manager != null ? receipt.Manager.FullName : "Not Found";
body += $@"
<tr>
<td>{receipt.Terminated.FullName}</td>
<td>{receipt.Terminated.EmployeeId}</td>
<td>{receipt.Terminated.HomeDepartment}</td>
<td>{receipt.Terminated.Terminated.Value:MM/dd/yyyy}</td>
<td>{manager}</td>
<td>${receipt.LastMonthPayout.PayoutTotal}.00</td>
<td>${receipt.ThisMonthPayout.PayoutTotal}.00</td>
</tr>";
}
body += @"</tbody> </table>";
var emailRequest = new EmailRequest
{
Recipient = recipients,
Subject = $"Users terminated in Dayforce",
Body = body
};
await _notificationsDao.SendMessageAsync(emailRequest);
}
catch (Exception ex)
{
Log.Error(ex, "Failed to send terminated employee notification");
}
}
private string FormatReceiptItems(List<GoalDispersalReceiptItem> receiptErrors)
{
string orderedList = @"<ol>";
foreach (var error in receiptErrors)
{
orderedList += $@"<li> <b>{error.EmployeeName}</b> - {error.EmployeeId}: {error.Message}<br><br></li>";
}
orderedList += @"</ol>";
return orderedList;
}
public async Task SendTransferRequestInitiatedNotification(ActivityTransferAction transferAction,
List<string> recipients)
{
try
{
#region Body HTML Boilerplate
string body =
@"<style>
.report {
border:1px solid #C0C0C0;
border-collapse:collapse;
padding:5px;
}
.report th {
border:1px solid #C0C0C0;
padding:5px;
background:#F0F0F0;
}
.report td {
border:1px solid #C0C0C0;
padding:5px;
}
</style>";
#endregion
body += @"
<p>A transfer request has been initiated for the following activity:</p>
<table class='report'>
<tbody>
<tr>
<td><h3>Product</h3></td>
<td><h3>Activity Type</h3></td>
<td><h3>Requested by</h3></td>
<td><h3>Transfer to Employee</h3></td>
<td><h3>Transfer to Department</h3></td>
</tr>";
body += $@"
<tr>
<td>{transferAction.RequestedActivity.Product}</td>
<td>{transferAction.RequestedActivity.Type}</td>
<td>{transferAction.CreatedBy}</td>
<td>{transferAction.NewActivityEmployeeId}</td>
<td>{transferAction.NewActivityDepartmentId}</td>
</tr>
</tbody>
</table>";
var webAppUrl = $@"{_incentiveApiConfig.IncentiveManagerClientUrl}/activity/{transferAction.RequestedActivityId}";
body += $@"
<p>
The request can be approved at <a href='{webAppUrl}'>{webAppUrl}</a>.
</p>";
if (_emailRecipientsConfig.OverrideRecipients)
{
body += $"<p>The original recipients have been overriden in this environment: {string.Join(", ", recipients)}</p>";
recipients = _emailRecipientsConfig.TransferRequestInitiatedNotification;
}
var emailRequest = new EmailRequest
{
Recipient = recipients,
Subject = "Activity transfer request initiated",
Body = body
};
await _notificationsDao.SendMessageAsync(emailRequest);
}
catch (Exception ex)
{
Log.Error(ex, "Failed to send transfer request initiated notification");
}
}
}