pUSH CHANGES
This commit is contained in:
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
||||
|
Reference in New Issue
Block a user