pUSH CHANGES

This commit is contained in:
ouellette
2022-11-17 14:32:36 -07:00
parent 580e90f6a2
commit 7e283d3d36
98 changed files with 561367 additions and 10 deletions

View File

@ -28,6 +28,7 @@ namespace Fab2ApprovalSystem.Controllers
UserUtilities userDMO = new UserUtilities();
UserAccountDMO originalUserDMO = new UserAccountDMO();
TrainingDMO trainingDMO = new TrainingDMO();
MiscDMO miscDMO = new MiscDMO();
/// <summary>
@ -700,6 +701,101 @@ namespace Fab2ApprovalSystem.Controllers
}
}
public bool ApprovalsReminderNotifications()
{
try
{
//Get list of approvals
List<ApproveListModel> approveList = miscDMO.GetApprovalReminderList();
foreach (var item in approveList)
{
try
{
NotifyApprover(item.AssignedEmail, item.Title, item.IssueID, item.DocType);
}
catch(Exception e)
{
EventLogDMO.Add(new WinEventLog() { IssueID = item.ApprovalKey, UserID = "SYSTEM", DocumentType = "Approval Reminders", OperationType = "Email", Comments = e.Message });
}
//We want to update the last notification anyway so we don't continue trying on something that may be failing.
miscDMO.UpdateApprovalNotifyDate(item.ApprovalKey);
}
// List<ApproveListModel> approveList = miscDMO.
return true;
}
catch
{
return false;
}
}
public void NotifyApprover(string toEmail, string title, int issueId, string docType)
{
try
{
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
//List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
//string ecnCreatedByEmail = MiscDMO.GetEmail(ecnCreatedById);
string emailTemplate = "ApprovalReminders.txt";
string userEmail = string.Empty;
string subject = string.Empty;
string senderName = docType;
subject = docType + " Approval Reminder: " + title;
EmailNotification en = new EmailNotification(subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = docType;
emailparams[1] = title;
emailparams[2] = issueId.ToString();
userEmail = toEmail;
//#if(DEBUG)
//string SenderEmail = "MesaFabApproval@infineon.com";
//userEmail = "jonathan.ouellette@infineon.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, "jonathan.ouellette@infineon.com", subject, emailparams);
//en.SendNotificationEmail(emailTemplate, SenderEmail, senderName, userEmail, null, subject, emailparams);
//emailSentList = ecnCreatedByEmail;
try
{
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = @User.Identity.Name, DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
}
catch { }
//EmailNotification en = new EmailNotification(subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
//string[] emailparams = new string[4];
//emailparams[0] = issueID.ToString();
//emailparams[1] = issueID.ToString();
//emailparams[2] = GlobalVars.hostURL;
//emailparams[3] =Session[GlobalVars.SESSION_USERNAME].ToString();
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
}
catch (Exception e)
{
string detailedException = "";
try
{
detailedException = e.InnerException.ToString();
}
catch
{
detailedException = e.Message;
}
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = @User.Identity.Name, DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
throw e;
}
}
}
}

View File

@ -72,6 +72,15 @@ namespace Fab2ApprovalSystem.Controllers
{
return request.CreateResponse(HttpStatusCode.InternalServerError);
}
case "ApprovalReminders":
if (homeFunctions.ApprovalsReminderNotifications())
{
return request.CreateResponse(HttpStatusCode.OK);
}
else
{
return request.CreateResponse(HttpStatusCode.InternalServerError);
}
default:
return request.CreateResponse(HttpStatusCode.InternalServerError, "Action Not Found");