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

@ -21,23 +21,16 @@ namespace Fab2ApprovalSystem.Controllers;
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public class HomeController : Controller {
MRB_DMO mrbDMO;
PartsRequestDMO prDMO;
LotDispositionDMO ldDMO;
MRB_DMO mrbDMO = new MRB_DMO(GlobalVars.AppSettings);
PartsRequestDMO prDMO = new PartsRequestDMO();
LotDispositionDMO ldDMO = new LotDispositionDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
ECN_DMO ecnDMO = new ECN_DMO();
UserUtilities userDMO = new UserUtilities();
UserAccountDMO originalUserDMO = new UserAccountDMO();
TrainingDMO trainingDMO = new TrainingDMO();
MiscDMO miscDMO = new MiscDMO();
private readonly AppSettings _AppSettings;
public HomeController(AppSettings appSettings) {
_AppSettings = appSettings;
ldDMO = new LotDispositionDMO(appSettings);
mrbDMO = new MRB_DMO(appSettings);
prDMO = new PartsRequestDMO(appSettings);
}
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index(string tabName) {
ViewBag.ActiveTabName = tabName;
@ -113,7 +106,6 @@ public class HomeController : Controller {
public ActionResult GetDocuments([DataSourceRequest] DataSourceRequest request, string tabName) {
ViewBag.ActiveTabName = tabName;
//IEnumerable<IssuesViewModel> data = ldDMO.GetLotDispositions();
IEnumerable<IssuesViewModel> data = ldDMO.GetDocuments();
return Json(data.ToDataSourceResult(request));
}
@ -198,7 +190,7 @@ public class HomeController : Controller {
}
public ActionResult GetLotList([DataSourceRequest] DataSourceRequest request, int workRequestID) {
LotTravelerDMO LotTravDMO = new LotTravelerDMO(_AppSettings);
LotTravelerDMO LotTravDMO = new LotTravelerDMO();
return Json(LotTravDMO.GetLotListBasedOnSWRNumber(workRequestID).ToDataSourceResult(request));
}
@ -301,24 +293,7 @@ public class HomeController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = " + ecnTypeString + ", OperationType = "Error", Comments = "DelegateApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "DelegateApproval.txt";
string userEmail = string.Empty;
string subject;
string senderName = ecnTypeString;
subject = ecnTypeString + " Delegation" + " - Email would be sent to " + email + " for Number " + issueID + ", - " + title;
;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = issueID.ToString();
emailparams[1] = issueID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = ecnTypeString;
userEmail = email;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
HomeHelper.DelegateDocumentApproval(_AppSettings, issueID, ecnTypeString, title, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Delegated to Approver: " + email });
} catch { }
@ -398,31 +373,11 @@ public class HomeController : Controller {
List<string> emailList = new List<string>();
emailList.Add(delegateFrom.Email);
emailList.Add(delegateTo.Email);
string emailTemplate = "DelegationOn.txt";
string userEmail = string.Empty;
string subject = "Mesa Approval Delegation Notification";
string senderName = "Mesa Approval";
foreach (string email in emailList) {
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[5];
emailparams[0] = delegateFrom.FullName;
emailparams[1] = delegateTo.FullName;
emailparams[2] = startDate.ToString("yyyy-MM-dd");
emailparams[3] = endDate.ToString("yyyy-MM-dd");
userEmail = email;
//#if(DEBUG)
// userEmail = GlobalVars.SENDER_EMAIL;
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
}
HomeHelper.NotifyDelegation(_AppSettings, startDate, endDate, delegateFrom, delegateTo, emailList);
try {
//EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Rejection: " + userEmail });
} catch { }
}
public bool ProcessOoO() {
try {
@ -444,7 +399,7 @@ public class HomeController : Controller {
}
public bool ApprovalsReminderNotifications() {
try {
//Get list of approvals
// Get list of approvals
List<ApproveListModel> approveList = miscDMO.GetApprovalReminderList();
foreach (var item in approveList) {
@ -453,7 +408,7 @@ public class HomeController : Controller {
} 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.
// 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.
@ -464,45 +419,12 @@ public class HomeController : Controller {
}
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(_AppSettings, 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;
HomeHelper.NotifyApprover(_AppSettings, toEmail, title, issueId, docType);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = @User.Identity.Name, DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
} catch { }
//EmailNotification en = new EmailNotification(_AppSettings, 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 {