Moved System.IO references from DMO classes to Static Helpers

Removed nugetSource from pipeline
Removed more comments
Created Static Classes for most DMO / Controller Classes
Push ConfigurationManager.AppSettings to controller
Align Tests with other Projects
This commit is contained in:
2024-12-11 09:29:01 -07:00
parent b1c6903c1c
commit b99b721458
86 changed files with 2961 additions and 4432 deletions

View File

@ -1,3 +1,10 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
@ -7,14 +14,6 @@ using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -22,19 +21,13 @@ namespace Fab2ApprovalSystem.Controllers;
[SessionExpireFilter]
public class CorrectiveActionController : Controller {
AuditDMO auditDMO;
CorrectiveActionDMO caDMO;
AuditDMO auditDMO = new AuditDMO(GlobalVars.AppSettings);
CorrectiveActionDMO caDMO = new CorrectiveActionDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
private readonly AppSettings _AppSettings;
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
UserAccountDMO userDMO = new UserAccountDMO();
FileUtilities<System.Web.Mvc.FileContentResult> fileUtilities = new FileUtilities<System.Web.Mvc.FileContentResult>();
public CorrectiveActionController(AppSettings appSettings) {
_AppSettings = appSettings;
auditDMO = new AuditDMO(appSettings);
caDMO = new CorrectiveActionDMO(appSettings);
}
public ActionResult Index() {
return View();
}
@ -141,10 +134,10 @@ public class CorrectiveActionController : Controller {
} else {
ViewBag.ECNList = caDMO.GetECNList();
if (ca.Status == 1 || ca.Status == 2 || ca.Status == 11) {
//Pulling in the user list which includes inactive users.
// Pulling in the user list which includes inactive users.
ViewBag.UserList = caDMO.GetAllUserList();
} else {
//Pulling in the user list which only includes active users.
// Pulling in the user list which only includes active users.
ViewBag.UserList = caDMO.GetUserList();
}
ViewBag.CASourceList = caDMO.GetCASourceList();
@ -177,13 +170,10 @@ public class CorrectiveActionController : Controller {
return Content("User is not authorized to save the CA.");
}
try {
if (model.TriggerApproval) {
//model.FollowUpDate = DateTime.Now.AddMonths(6);
}
caDMO.UpdateCorrectiveAction(model);
if ((model.D1AssigneeID != model.CurrentD1AssigneeID && model.CASubmitted) || (model.CASubmitted && !caPrevious.CASubmitted)) {
//Set Due Dates here:
// Set Due Dates here:
DateTime? D3DueDate = null;
DateTime? D5D7DueDate = null;
@ -208,7 +198,6 @@ public class CorrectiveActionController : Controller {
NotifySectionApprover(model.CANo, model.QAID, model.SectionApproval);
NotifySectionApprover(model.CANo, model.RequestorID, model.SectionApproval);
//NotifyApprovers(model.CANo, 1);
return Content("Successfully Saved...Approval initiated!");
}
if (model.TriggerApproval) {
@ -292,7 +281,7 @@ public class CorrectiveActionController : Controller {
string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
string ecnFolderPath = _AppSettings.AttachmentFolder + "CorrectiveAction\\" + caNo.ToString();
var sDocument = Path.Combine(ecnFolderPath, fileGuid + fileExtension);
var sDocument = System.IO.Path.Combine(ecnFolderPath, fileGuid + fileExtension);
var FDir_AppData = _AppSettings.AttachmentFolder;
if (!sDocument.StartsWith(FDir_AppData)) {
@ -303,7 +292,6 @@ public class CorrectiveActionController : Controller {
if (!System.IO.File.Exists(sDocument)) {
return null;
//throw new Exception("File not found");
}
return File(sDocument, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
@ -314,8 +302,6 @@ public class CorrectiveActionController : Controller {
}
public ActionResult DownloadTemplatesFiles() {
//string templatesPath = GlobalVars.CA_BlankFormsLocation;
//string fullName = Server.MapPath("~" + filePath);
string fileName = "5Why_Is_Is_Not_Fishbone.pptx";
string pathToFile = GlobalVars.MesaTemplateFiles + "\\5Why_Is_Is_Not_Fishbone.pptx";
byte[] fileBytes = fileUtilities.GetFile(pathToFile);
@ -328,7 +314,7 @@ public class CorrectiveActionController : Controller {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
caDMO.AttachSave(caNo, userId, file.FileName, file.InputStream);
CorrectiveActionHelper.AttachSave(_AppSettings, caDMO, caNo, userId, file.FileName, file.InputStream);
}
}
} catch {
@ -374,7 +360,7 @@ public class CorrectiveActionController : Controller {
if (D4Files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in D4Files) {
caDMO.D4FilesAttachSave(caNo, userId, file.FileName, file.InputStream);
CorrectiveActionHelper.D4FilesAttachSave(_AppSettings, caDMO, caNo, userId, file.FileName, file.InputStream);
}
}
} catch {
@ -394,10 +380,6 @@ public class CorrectiveActionController : Controller {
} catch (Exception e) {
return Content(e.Message + " Please try again...");
}
if (data.ResponsibilityOwnerID != null && data.ResponsibilityOwnerID != 0) {
//NotifyActionItemOwner(data.CANo, data.ECD, data.ResponsibilityOwnerID, "CorrectiveActionAIAssigned.txt");
//NotifyRequestor(data.CANo, data.ECD, data.ResponsibilityOwnerID, "CorrectiveActionAIAssigned.txt");
}
return Content("");
}
@ -413,7 +395,7 @@ public class CorrectiveActionController : Controller {
NotifyActionItemOwner(data.CANo, data.ECD, data.ResponsibilityOwnerID, "CorrectiveActionAIAssigned.txt");
}
if (data.IsImplemented && previousData.ImplementedDate == null) {
//Notify completion to Assignee and Requestor
// Notify completion to Assignee and Requestor
NotifyActionItemCompletion(data.CANo, data.ECD, caData.D1AssigneeID, "CorrectiveActionAICompleted.txt");
NotifyActionItemCompletion(data.CANo, data.ECD, caData.RequestorID, "CorrectiveActionAICompleted.txt");
NotifyActionItemCompletion(data.CANo, data.ECD, caData.QAID, "CorrectiveActionAICompleted.txt");
@ -443,7 +425,7 @@ public class CorrectiveActionController : Controller {
if (D5D6CA_Attachemnt != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in D5D6CA_Attachemnt) {
caDMO.SaveD5D6CA_Attachemnt(d5d6CAID, caNo, userId, file.FileName, file.InputStream);
CorrectiveActionHelper.SaveD5D6CA_Attachemnt(_AppSettings, caDMO, d5d6CAID, caNo, userId, file.FileName, file.InputStream);
}
}
} catch {
@ -498,7 +480,7 @@ public class CorrectiveActionController : Controller {
if (D7PA_Attachemnt != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in D7PA_Attachemnt) {
caDMO.SaveD7PA_Attachemnt(d7PAID, caNo, userId, file.FileName, file.InputStream);
CorrectiveActionHelper.SaveD7PA_Attachemnt(_AppSettings, caDMO, d7PAID, caNo, userId, file.FileName, file.InputStream);
}
}
} catch {
@ -520,9 +502,6 @@ public class CorrectiveActionController : Controller {
}
public JsonResult GetAllUsersList() {
//var userList = ldDMO.GetApprovedApproversList(issueID, currentStep);
//return Json(userList, JsonRequestBehavior.AllowGet);
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable<LoginModel> userlist = userDMO.GetAllUsers();
return Json(userlist, JsonRequestBehavior.AllowGet);
@ -544,24 +523,7 @@ public class CorrectiveActionController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "CA", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "CorrectiveActionReAssigned.txt";
string userEmail = string.Empty;
string subject = "Corrective Action Re-Assignment";
string senderName = "CorrectiveAction";
subject = "Corrective Action Re-Assignment" + " - Email would be sent to " + email;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
CorrectiveActionHelper.ReAssignApproverByAdmin(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
@ -583,24 +545,7 @@ public class CorrectiveActionController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "CorrectiveActionReAssigned.txt";
string userEmail = string.Empty;
string subject = "Corrective Action Re-Assignment";
string senderName = "CorrectiveAction";
subject = "Corrective Action Re-Assignment" + " - Email would be sent to " + email;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
CorrectiveActionHelper.ReAssignApproval(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
@ -629,30 +574,9 @@ public class CorrectiveActionController : Controller {
}
public void NotifyRejectionToAssignee(int issueID, string comments) {
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
List<string> emailIst = caDMO.GetRejectionAssigneeEmailList(@issueID).Distinct().ToList();
string emailTemplate = "CorrectiveActionReject.txt";
string userEmail = string.Empty;
string subject = "Corrective Action Rejection";
string senderName = "CorrectiveAction";
foreach (string email in emailIst) {
subject = "Corrective Action Rejection";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[5];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = Session[GlobalVars.SESSION_USERNAME].ToString();
emailparams[4] = comments;
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
}
string userEmail = CorrectiveActionHelper.NotifyRejectionToAssignee(_AppSettings, issueID, comments, username, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Rejection: " + userEmail });
} catch { }
@ -666,21 +590,15 @@ public class CorrectiveActionController : Controller {
bool lastApprover = wfDMO.Approve(_AppSettings, issueID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.CorrectiveAction, ca.WorkFlowNumber);
//while (lastApprover && !lastStep)
//{
// currentStep++;
// //lastApprover = wfDMO.Approve(issueID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], (int)GlobalVars.DocumentType.CorrectiveAction, ca.WorkFlowNumber);
// NotifyApprovers(issueID, currentStep);
//}
if (lastApprover && !lastStep) {
//Set to complete
// Set to complete
DateTime followUpDate = caDMO.SetCAComplete(issueID);
//Notify completion and send follow up date
// Notify completion and send follow up date
NotifyCompletionOf8D(issueID, followUpDate);
}
if (lastApprover && lastStep) {
//Notify re the closure of the 8D
// Notify re the closure of the 8D
NotifyClosureOf8D(issueID);
}
@ -701,25 +619,7 @@ public class CorrectiveActionController : Controller {
public void NotifySectionApprover(int issueID, int userId, string section) {
try {
string userEmail = userDMO.GetUserEmailByID(userId);
string emailTemplate = "CorrectiveActionSectionAssignee.txt";
//string userEmail = string.Empty;
string subject = "Corrective Action Assignment";
string senderName = "CorrectiveAction";
subject = "Corrective Action Assignment - Section Approval";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = section;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
CorrectiveActionHelper.NotifySectionApprover(_AppSettings, issueID, section, userEmail);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
@ -736,34 +636,11 @@ public class CorrectiveActionController : Controller {
throw e;
}
}
public void NotifyApprovers(int issueID, byte currentStep) {
try {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(@issueID, currentStep, (int)GlobalVars.DocumentType.CorrectiveAction).Distinct().ToList();
string emailTemplate = "CorrectiveActionAssigned.txt";
string userEmail = string.Empty;
string subject = "Corrective Action Assignment";
string senderName = "CorrectiveAction";
foreach (string email in emailIst) {
subject = "Corrective Action Assignment - Final Approval";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
emailSentList += email + ",";
}
string emailSentList = CorrectiveActionHelper.NotifyApprovers(_AppSettings, issueID, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
@ -780,6 +657,7 @@ public class CorrectiveActionController : Controller {
throw e;
}
}
#region Additional Approvers
public void AddAdditionalApproval(int issueID, byte step, string userIDs) {
@ -799,33 +677,7 @@ public class CorrectiveActionController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "CorrectiveActionAssigned.txt";
string userEmail = string.Empty;
string subject = "Corrective Action Assignment - Final Approval";
string senderName = "CorrectiveAction";
string[] emailIst = emailArray.Split(new char[] { '~' });
foreach (string email in emailIst) {
if (email.Length > 0) {
//subject = "Lot Disposition Assignment" + " - Email would be sent to " + email;
subject = "Corrective Action Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
emailSentList += email + ",";
}
}
emailSentList = CorrectiveActionHelper.AddAdditionalApproval(_AppSettings, issueID, emailSentList, emailArray);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
} catch { }
@ -834,38 +686,17 @@ public class CorrectiveActionController : Controller {
#endregion
public ActionResult GetApproversList([DataSourceRequest] DataSourceRequest request, int issueID, byte step) {
//return Json(ldDMO.GetApproversList(issueID, step).ToDataSourceResult(request));
return Json(MiscDMO.GetApproversListByDocument(issueID, step, (int)GlobalVars.DocumentType.CorrectiveAction).ToDataSourceResult(request));
}
public ActionResult GetSectionApprovalLog([DataSourceRequest] DataSourceRequest request, int caNo) {
//return Json(ldDMO.GetApproversList(issueID, step).ToDataSourceResult(request));
return Json(caDMO.GetCASectionApprovalLog(caNo).ToDataSourceResult(request));
}
public void NotifyRequestor(int issueID, DateTime? dueDate, int? responsibleOwnerID, string template) {
try {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
string email = MiscDMO.GetEmail(responsibleOwnerID);
string emailTemplate = template;
string userEmail = string.Empty;
string subject = "Corrective Action Assignment - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[5];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = dueDate.ToString();
emailparams[2] = Functions.DocumentTypeMapper(GlobalVars.DocumentType.CorrectiveAction);
emailparams[3] = GlobalVars.hostURL;
emailparams[4] = issueID.ToString();
//userEmail = email;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
emailSentList += email + ",";
CorrectiveActionHelper.NotifyRequestor(_AppSettings, issueID, dueDate, template, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
@ -880,37 +711,13 @@ public class CorrectiveActionController : Controller {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
//throw e;
}
}
public void NotifyAssignee(int issueID, int? responsibleOwnerID, string template, DateTime? D3DueDate, DateTime? D5D7DueDate) {
try {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
string email = MiscDMO.GetEmail(responsibleOwnerID);
string emailTemplate = template;
string userEmail = string.Empty;
string subject = "CAR Assigned - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
string D3DueDateString = D3DueDate != null ? D3DueDate.ToString() : "N/A";
string D5D7DueDateString = D5D7DueDate != null ? D5D7DueDate.ToString() : "N/A";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[6];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = Functions.DocumentTypeMapper(GlobalVars.DocumentType.CorrectiveAction);
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = issueID.ToString();
emailparams[4] = D3DueDateString;
emailparams[5] = D5D7DueDateString;
//userEmail = email;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
emailSentList += email + ",";
CorrectiveActionHelper.NotifyAssignee(_AppSettings, issueID, template, D3DueDate, D5D7DueDate, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
@ -925,34 +732,12 @@ public class CorrectiveActionController : Controller {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
//throw e;
}
}
public void NotifyActionItemOwner(int issueID, DateTime? dueDate, int? responsibleOwnerID, string template) {
try {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
string email = MiscDMO.GetEmail(responsibleOwnerID);
string emailTemplate = template;
string userEmail = string.Empty;
string subject = "Action Item in " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[5];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = dueDate.ToString();
emailparams[2] = Functions.DocumentTypeMapper(GlobalVars.DocumentType.CorrectiveAction);
emailparams[3] = GlobalVars.hostURL;
emailparams[4] = issueID.ToString();
//userEmail = email;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
emailSentList += email + ",";
string email = CorrectiveActionHelper.NotifyActionItemOwner(_AppSettings, issueID, dueDate, responsibleOwnerID, template);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
@ -967,33 +752,12 @@ public class CorrectiveActionController : Controller {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
//throw e;
}
}
public void NotifyActionItemCompletion(int issueID, DateTime? dueDate, int? recipientId, string template) {
try {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
string email = MiscDMO.GetEmail(recipientId);
string emailTemplate = template;
string userEmail = string.Empty;
string subject = "8D Action Item Completion - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[5];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = dueDate.ToString();
emailparams[2] = Functions.DocumentTypeMapper(GlobalVars.DocumentType.CorrectiveAction);
emailparams[3] = GlobalVars.hostURL;
emailparams[4] = issueID.ToString();
//userEmail = email;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
emailSentList += email + ",";
string email = CorrectiveActionHelper.NotifyActionItemCompletion(_AppSettings, issueID, dueDate, recipientId, template);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 8D Item" + ":" + email });
} catch { }
@ -1008,34 +772,12 @@ public class CorrectiveActionController : Controller {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 8D Action Item:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 8D Action Item - NotifyActionItemCompletion\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "8D Action Item Notification - " + exceptionString });
//throw e;
}
}
public void NotifyClosureOf8D(int issueID) {
try {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
List<string> emailIst = MiscDMO.Get8DEmailListForClosureNotification(issueID);
string emailTemplate = "CorrectiveActionClosed.txt";
//string userEmail = string.Empty;
string subject = "Corrective Action Follow Up Closure - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
foreach (string email in emailIst) {
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = GlobalVars.hostURL;
emailparams[2] = issueID.ToString();
//userEmail = email;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
emailSentList += email + ",";
}
string emailSentList = CorrectiveActionHelper.NotifyClosureOf8D(_AppSettings, issueID);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Closure of 8D Item" + ":" + emailSentList });
} catch { }
@ -1050,34 +792,12 @@ public class CorrectiveActionController : Controller {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Closure of 8D:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Closure of 8D - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Closure of 8D Notification - " + exceptionString });
//throw e;
}
}
public void NotifyCompletionOf8D(int issueID, DateTime? followUpDate) {
try {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
List<string> emailIst = MiscDMO.Get8DEmailListForClosureNotification(issueID);
string emailTemplate = "CorrectiveActionCompleted.txt";
//string userEmail = string.Empty;
string subject = "Corrective Action Completion - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
foreach (string email in emailIst) {
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = GlobalVars.hostURL;
emailparams[2] = issueID.ToString();
emailparams[3] = followUpDate.ToString();
//userEmail = email;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
emailSentList += email + ",";
}
string emailSentList = CorrectiveActionHelper.NotifyCompletionOf8D(_AppSettings, issueID, followUpDate);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Closure of 8D Item" + ":" + emailSentList });
} catch { }
@ -1092,16 +812,15 @@ public class CorrectiveActionController : Controller {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " Closure of 8D:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Closure of 8D - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Closure of 8D Notification - " + exceptionString });
//throw e;
}
}
public void StartSectionApproval(int issueID, string dSection) {
try {
CorrectiveAction ca = caDMO.GetCAItem(issueID, (int)Session[GlobalVars.SESSION_USERID]);
int requestorId = ca.RequestorID;
int qaId = ca.QAID;
//int userID = (int)Session[GlobalVars.SESSION_USERID];
caDMO.StartSectionApproval(issueID, requestorId, dSection);
NotifySectionApprover(issueID, requestorId, dSection);
@ -1133,7 +852,7 @@ public class CorrectiveActionController : Controller {
NotifyForD5D6D7Validation(issueID, caItem.RequestorID, dSection);
NotifyForD5D6D7Validation(issueID, caItem.QAID, dSection);
//Notify AI owners of pending action items
// Notify AI owners of pending action items
List<D5D6CorrectivetAction> actionItems = caDMO.GetD5D6CorrectivetActions(issueID).ToList();
foreach (var item in actionItems) {
NotifyActionItemOwner(issueID, item.ECD, item.CurrentResponsibilityOwnerID, "CorrectiveActionAIAssigned.txt");
@ -1143,7 +862,7 @@ public class CorrectiveActionController : Controller {
NotifyUsersDSectionApproved(issueID, caItem.RequestorID, dSection);
NotifyUsersDSectionApproved(issueID, caItem.QAID, dSection);
}
//TODO Notify Requestor for approval
// TODO Notify Requestor for approval
return Content("Successfully Saved, Last Approver");
} else {
return Content("Successfully Saved, More Approvers");
@ -1160,7 +879,6 @@ public class CorrectiveActionController : Controller {
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n " + "Approve\r\n" + issueID.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "Approve - " + exceptionString });
return Content(e.Message);
//return Content(ex.Message);
}
}
[HttpPost]
@ -1170,7 +888,7 @@ public class CorrectiveActionController : Controller {
int userID = (int)Session[GlobalVars.SESSION_USERID];
CorrectiveAction ca = caDMO.GetCAItem(issueID, userID);
caDMO.RejectSection(issueID, userID, dSection, comments);
//Notify Rejection to assignee and requestor
// Notify Rejection to assignee and requestor
int assigneeId = ca.D1AssigneeID;
int requestorId = ca.RequestorID;
int qaId = ca.QAID;
@ -1195,30 +913,8 @@ public class CorrectiveActionController : Controller {
public void NotifySectionRejection(int issueID, int recipientUserId, int loggedInUserId, string section, string comment) {
try {
LoginModel recipient = userDMO.GetUserByID(recipientUserId);
string recipientEmail = recipient.Email;
LoginModel loggedInUser = userDMO.GetUserByID(loggedInUserId);
string emailTemplate = "CorrectiveActionSectionRejection.txt";
//string userEmail = string.Empty;
string subject = "Corrective Action Rejection - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
//subject = "Corrective Action Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[6];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = section;
emailparams[4] = loggedInUser.FirstName + " " + loggedInUser.LastName;
emailparams[5] = comment;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, recipientEmail, null, subject, emailparams);
CorrectiveActionHelper.NotifySectionRejection(_AppSettings, issueID, section, comment, recipient, loggedInUser);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
@ -1235,28 +931,11 @@ public class CorrectiveActionController : Controller {
throw e;
}
}
public void NotifyForD5D6D7Validation(int issueID, int userId, string dSection) {
try {
string userEmail = userDMO.GetUserEmailByID(userId);
string emailTemplate = "CorrectiveActionSectionApproved.txt";
//string userEmail = string.Empty;
string subject = "Corrective Action Section Approval - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
//subject = "Corrective Action Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = dSection;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
CorrectiveActionHelper.NotifyForD5D6D7Validation(_AppSettings, issueID, dSection, userEmail);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
@ -1277,25 +956,7 @@ public class CorrectiveActionController : Controller {
public void NotifyUsersDSectionApproved(int issueID, int userId, string dSection) {
try {
string userEmail = userDMO.GetUserEmailByID(userId);
string emailTemplate = "CorrectiveActionSectionApproved.txt";
//string userEmail = string.Empty;
string subject = "Corrective Action Section Approval - " + Functions.ReturnCANoStringFormat(issueID);
string senderName = "CorrectiveAction";
//subject = "Corrective Action Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = dSection;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
CorrectiveActionHelper.NotifyUsersDSectionApproved(_AppSettings, issueID, dSection, userEmail);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Approvers for Step " });
} catch { }
@ -1312,6 +973,7 @@ public class CorrectiveActionController : Controller {
throw e;
}
}
public DateTime SetD3DueDate(int caNo) {
DateTime d3DueDate = caDMO.SetCAD3DueDate(caNo);
@ -1331,30 +993,7 @@ public class CorrectiveActionController : Controller {
LoginModel user = userDMO.GetUserByID(assigneeID);
try {
string emailTemplate = "D3D5D7Due.txt";
//string userEmail = string.Empty;
string subject = "Corrective Action " + dueCA.ItemDue + " " + dueCA.ExpiryType + " - " + Functions.ReturnCANoStringFormat(dueCA.CANo);
string senderName = "CorrectiveAction";
string[] emailparams = new string[7];
emailparams[0] = Functions.ReturnCANoStringFormat(dueCA.CANo);
emailparams[1] = dueCA.CANo.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = dueCA.ExpiryType;
emailparams[4] = dueCA.ItemDue;
if (ca.D3DueDate != null) {
emailparams[5] = ca.D3DueDate.ToString();
} else {
emailparams[5] = "N/A";
}
if (ca.D5D7DueDate != null) {
emailparams[6] = ca.D5D7DueDate.ToString();
} else {
emailparams[6] = "N/A";
}
//subject = "Corrective Action Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, user.Email, "jonathan.ouellette@infineon.com", subject, emailparams);
CorrectiveActionHelper.ProcessCARDueDates(_AppSettings, dueCA, ca, user);
caDMO.SetD3D5D7NotificationDate(dueCA.CANo, dueCA.ItemDue);
isSuccess = true;