Tasks 184281, 184799, 184800, 184801 and 184802
Align .editorconfig files Move Controller logic to DMO classes GlobalVars.AppSettings = Models.AppSettings.GetFromConfigurationManager(); Question EditorConfig Project level editorconfig Format White Spaces AppSetting when EnvironmentVariable not set Corrective Actions Tests Schedule Actions Tests DMO Tests Controller Tests Get ready to use VSCode IDE
This commit is contained in:
@ -8,69 +8,61 @@ using Fab2ApprovalSystem.Utilities;
|
||||
|
||||
using Quartz;
|
||||
|
||||
namespace Fab2ApprovalSystem.Workers
|
||||
{
|
||||
public class OOOTrainingReportJob:IJob
|
||||
{
|
||||
UserAccountDMO userDMO = new UserAccountDMO();
|
||||
AdminDMO adminDMO = new AdminDMO();
|
||||
TrainingDMO trainingDMO = new TrainingDMO();
|
||||
ECN_DMO ecnDMO = new ECN_DMO();
|
||||
public EmailUtilities emailer = new EmailUtilities();
|
||||
namespace Fab2ApprovalSystem.Workers;
|
||||
|
||||
async Task IJob.Execute(IJobExecutionContext context)
|
||||
{
|
||||
await Task.Run(() => {
|
||||
public class OOOTrainingReportJob : IJob {
|
||||
|
||||
string emailBody = "<h1>Mesa Approval Open Training Assignments Report - OOO</h1> <br />";
|
||||
emailBody += "<p>The following contains open training assignments in the Mesa Approval system for out of office users.";
|
||||
emailBody += " Please ensure they complete their training assignments promptly upon their return.</p><br />";
|
||||
emailBody += "<style>table,th,td{border: 1px solid black;}</style>";
|
||||
//Get all users set up to receive the training report email.
|
||||
List<TrainingReportUser> trainingReportUsers = adminDMO.GetTrainingReportUsers();
|
||||
List<string> emailList = new List<string>();
|
||||
foreach (var user in trainingReportUsers)
|
||||
{
|
||||
string userEmail = userDMO.GetUserByID(user.UserId).Email;
|
||||
emailList.Add(userEmail);
|
||||
}
|
||||
//emailList.Add("Chase.Tucker@infineon.com");
|
||||
//Get a list of open trainings
|
||||
List<Training> openTrainings = trainingDMO.GetAllOpenTrainings();
|
||||
private readonly UserAccountDMO userDMO = new();
|
||||
private readonly AdminDMO adminDMO = new();
|
||||
private readonly TrainingDMO trainingDMO = new();
|
||||
private readonly ECN_DMO ecnDMO = new();
|
||||
|
||||
foreach (Training training in openTrainings)
|
||||
{
|
||||
string trainingSection = "";
|
||||
int trainingSectionUserCount = 0;
|
||||
string ecnTitle = ecnDMO.GetECN(training.ECN).Title;
|
||||
trainingSection += "<h3>" + training.ECN + " - " + ecnTitle + "</h3>";
|
||||
async Task IJob.Execute(IJobExecutionContext context) {
|
||||
await Task.Run(() => {
|
||||
string emailBody = "<h1>Mesa Approval Open Training Assignments Report - OOO</h1> <br />";
|
||||
emailBody += "<p>The following contains open training assignments in the Mesa Approval system for out of office users.";
|
||||
emailBody += " Please ensure they complete their training assignments promptly upon their return.</p><br />";
|
||||
emailBody += "<style>table,th,td{border: 1px solid black;}</style>";
|
||||
//Get all users set up to receive the training report email.
|
||||
List<TrainingReportUser> trainingReportUsers = adminDMO.GetTrainingReportUsers();
|
||||
List<string> emailList = new();
|
||||
foreach (TrainingReportUser user in trainingReportUsers) {
|
||||
string userEmail = userDMO.GetUserByID(user.UserId).Email;
|
||||
emailList.Add(userEmail);
|
||||
}
|
||||
//emailList.Add("Chase.Tucker@infineon.com");
|
||||
//Get a list of open trainings
|
||||
List<Training> openTrainings = trainingDMO.GetAllOpenTrainings();
|
||||
|
||||
trainingSection += "<table>";
|
||||
trainingSection += "<tr><th>Name</th><th>Date Assigned</th></tr>";
|
||||
List<TrainingAssignment> openAssignments = trainingDMO.GetOpenAssignmentsByTrainingID(training.TrainingID);
|
||||
foreach (TrainingAssignment assignment in openAssignments)
|
||||
{
|
||||
foreach (Training training in openTrainings) {
|
||||
string trainingSection = "";
|
||||
int trainingSectionUserCount = 0;
|
||||
string ecnTitle = ecnDMO.GetECN(training.ECN).Title;
|
||||
trainingSection += "<h3>" + training.ECN + " - " + ecnTitle + "</h3>";
|
||||
|
||||
if (userDMO.GetUserByID(assignment.UserID).OOO)
|
||||
{
|
||||
trainingSectionUserCount++;
|
||||
trainingSection += "<table>";
|
||||
trainingSection += "<tr><th>Name</th><th>Date Assigned</th></tr>";
|
||||
List<TrainingAssignment> openAssignments = trainingDMO.GetOpenAssignmentsByTrainingID(training.TrainingID);
|
||||
foreach (TrainingAssignment assignment in openAssignments) {
|
||||
if (userDMO.GetUserByID(assignment.UserID).OOO) {
|
||||
trainingSectionUserCount++;
|
||||
|
||||
DateTime? assignmentDate = assignment.DateAssigned;
|
||||
DateTime? assignmentDate = assignment.DateAssigned;
|
||||
|
||||
string DateAssigned = assignmentDate.HasValue ? assignmentDate.Value.ToString("MM/dd/yyyy") : "<not available>";
|
||||
string DateAssigned = assignmentDate.HasValue ? assignmentDate.Value.ToString("MM/dd/yyyy") : "<not available>";
|
||||
|
||||
trainingSection += "<tr><td>" + assignment.FullName + "</td><td>" + DateAssigned + "</td>";
|
||||
trainingSection += "<tr><td>" + assignment.FullName + "</td><td>" + DateAssigned + "</td>";
|
||||
|
||||
trainingSection += "</tr>";
|
||||
}
|
||||
trainingSection += "</tr>";
|
||||
}
|
||||
trainingSection += "</table>";
|
||||
if (trainingSectionUserCount > 0) emailBody += trainingSection;
|
||||
}
|
||||
string recipientEmail = "";
|
||||
List<string> ccRecipients = emailList;
|
||||
emailer.SendNotification("MesaFabApproval@infineon.com", ccRecipients, "Mesa Approval Open Training Report - OOO", emailBody, "Open Training Report - OOO");
|
||||
});
|
||||
}
|
||||
trainingSection += "</table>";
|
||||
if (trainingSectionUserCount > 0)
|
||||
emailBody += trainingSection;
|
||||
}
|
||||
string recipientEmail = "";
|
||||
List<string> ccRecipients = emailList;
|
||||
EmailUtilities.SendNotification("MesaFabApproval@infineon.com", ccRecipients, "Open Training Report - OOO", emailBody);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user