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

@ -38,7 +38,6 @@ public class AccountController : Controller {
public UserManager<ApplicationUser> UserManager { get; private set; }
//
// GET: /Account/Login
[AllowAnonymous]
// try to make the browser refresh the login page every time, to prevent issues with changing usernames and the anti-forgery token validation
@ -81,9 +80,6 @@ public class AccountController : Controller {
#if (!DEBUG)
bool isIFX = false;
//domainProvider = Membership.Providers["NA_ADMembershipProvider"];
//isLoginValid = domainProvider.ValidateUser(model.LoginID, model.Password);
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
isLoginValid = true;
} else {
@ -136,9 +132,6 @@ public class AccountController : Controller {
#if (!DEBUG)
bool isIFX = false;
//domainProvider = Membership.Providers["NA_ADMembershipProvider"];
//isLoginValid = domainProvider.ValidateUser(model.LoginID, model.Password);
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
isLoginValid = true;
} else {
@ -220,7 +213,6 @@ public class AccountController : Controller {
return new ChallengeResult(provider, Url.Action("LinkLoginCallback", "Account"), User.Identity.GetUserId());
}
//
// GET: /Account/LinkLoginCallback
public async Task<ActionResult> LinkLoginCallback() {
ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId());

View File

@ -1,3 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
@ -6,12 +12,6 @@ using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -21,13 +21,8 @@ public class AdminController : Controller {
UserAccountDMO userDMO = new UserAccountDMO();
AdminDMO adminDMO = new AdminDMO();
TrainingDMO trainingDMO = new TrainingDMO();
LotDispositionDMO ldDMO;
private readonly AppSettings _AppSettings;
public AdminController(AppSettings appSettings) {
_AppSettings = appSettings;
ldDMO = new LotDispositionDMO(appSettings);
}
LotDispositionDMO ldDMO = new LotDispositionDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index() {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
@ -76,7 +71,7 @@ public class AdminController : Controller {
}
/// <summary>
///OBSOLETE FUNCTION BELOW FOR THE KENDO TREEVIEW
/// OBSOLETE FUNCTION BELOW FOR THE KENDO TREEVIEW
/// </summary>
private IEnumerable<TreeViewItemModel> GetRoles_SubRolesList() {
List<Role> roles = adminDMO.GetSubRoles();
@ -188,7 +183,6 @@ public class AdminController : Controller {
return Content("");
// TODO - Send an email to the OOO person and to the Delegated person
//return View();
}
public void ExpireOOOStatus(int oooUserID) {
@ -197,8 +191,6 @@ public class AdminController : Controller {
}
public ActionResult ManageTrainingGroups() {
//List<TrainingGroup> allGroups = GetTrainingGroups();
//return View(allGroups);
if ((bool)Session[GlobalVars.IS_ADMIN]) {
ViewBag.AllGroups = GetTrainingGroups();
return View();
@ -314,19 +306,18 @@ public class AdminController : Controller {
public ActionResult AddToTrainingReport(int userId) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
//Check to make sure user is not apart of the group already
// Check to make sure user is not apart of the group already
bool userExists = false;
//bool userValid = true;
List<TrainingReportUser> existingUsers = adminDMO.GetTrainingReportUsers();
foreach (var item in existingUsers) {
if (item.UserId == userId) {
userExists = true;
}
}
//Check if user is valid
// Check if user is valid
var validUser = userDMO.GetUserByID(userId);
//Add to group
// Add to group
if (!userExists && validUser != null) {
adminDMO.TrainingReportAddUser(userId);
return Json("Success Added");
@ -340,19 +331,18 @@ public class AdminController : Controller {
public ActionResult AddToTECNNotification(int userId) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
//Check to make sure user is not apart of the group already
// Check to make sure user is not apart of the group already
bool userExists = false;
//bool userValid = true;
List<TECNNotificationsUser> existingUsers = adminDMO.GetTECNNotificationUsers();
foreach (var item in existingUsers) {
if (item.UserId == userId) {
userExists = true;
}
}
//Check if user is valid
// Check if user is valid
var validUser = userDMO.GetUserByID(userId);
//Add to group
// Add to group
if (!userExists && validUser != null) {
try {
adminDMO.TECNExpirationAddUser(userId);

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
@ -21,15 +20,9 @@ namespace Fab2ApprovalSystem.Controllers;
[SessionExpireFilter]
public class AuditController : Controller {
AuditDMO auditDMO;
CorrectiveActionDMO caDMO;
private readonly AppSettings _AppSettings;
public AuditController(AppSettings appSettings) {
_AppSettings = appSettings;
auditDMO = new AuditDMO(appSettings);
caDMO = new CorrectiveActionDMO(appSettings);
}
AuditDMO auditDMO = new AuditDMO(GlobalVars.AppSettings);
CorrectiveActionDMO caDMO = new CorrectiveActionDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: Audit
public ActionResult Index() {
@ -136,7 +129,7 @@ public class AuditController : Controller {
if (AuditReportFiles != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in AuditReportFiles) {
auditDMO.AuditReportAttachSave(auditNo, userId, file.FileName, file.InputStream);
AuditHelper.AuditReportAttachSave(_AppSettings, auditDMO, auditNo, userId, file.FileName, file.InputStream);
}
}
} catch {
@ -159,7 +152,7 @@ public class AuditController : Controller {
public FileResult DownloadAuditReportAttachment(string fileGuid, int auditNo) {
try {
string fileName, sDocument;
List<string> results = auditDMO.GetFileNameAndDocument(fileGuid, auditNo);
List<string> results = AuditHelper.GetFileNameAndDocument(_AppSettings, auditDMO, fileGuid, auditNo);
fileName = results[0];
sDocument = results[1];
if (string.IsNullOrEmpty(sDocument)) {
@ -170,7 +163,6 @@ public class AuditController : 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);
@ -270,7 +262,7 @@ public class AuditController : Controller {
if (CAFindings_Attachemnt != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in CAFindings_Attachemnt) {
auditDMO.SaveAndInsert(caFindingsID, auditNo, userId, file.FileName, file.InputStream);
AuditHelper.SaveAndInsert(_AppSettings, auditDMO, caFindingsID, auditNo, userId, file.FileName, file.InputStream);
}
}
} catch {
@ -282,8 +274,7 @@ public class AuditController : Controller {
public void NotifyActionItemOwner(int issueID, DateTime? dueDate, int? responsibleOwnerID) {
try {
string emailTemplatesPath = ConfigurationManager.AppSettings["EmailTemplatesPath"];
string email = auditDMO.NotifyActionItemOwner(issueID, dueDate, responsibleOwnerID, emailTemplatesPath);
string email = auditDMO.NotifyActionItemOwner(issueID, dueDate, responsibleOwnerID, _AppSettings.EmailTemplatesPath);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Email", Comments = "Task Assigned for 5S/CA Findings" + ":" + email });
@ -299,7 +290,6 @@ public class AuditController : Controller {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + issueID.ToString() + " 5s/CAFindings:" + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n 5s/CAFindings - NotifyActionItemOwner\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Corrective Action", OperationType = "Error", Comments = "5s/CAFindings Notification - " + exceptionString });
//throw e;
}
}

View File

@ -1,3 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Services;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
@ -6,14 +13,6 @@ using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Services;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -21,13 +20,8 @@ namespace Fab2ApprovalSystem.Controllers;
[SessionExpireFilter]
public class ChangeControlController : Controller {
ChangeControlDMO ccDMO;
private readonly AppSettings _AppSettings;
public ChangeControlController(AppSettings appSettings) {
_AppSettings = appSettings;
ccDMO = new ChangeControlDMO(appSettings);
}
ChangeControlDMO ccDMO = new ChangeControlDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index() {
return View();
@ -63,7 +57,7 @@ public class ChangeControlController : Controller {
if (appUser != null) {
ViewBag.IsApprover = "true";
}
//TODO locked functionality
// TODO locked functionality
if (isITARCompliant == 0) // not ITAR Compliant
{
@ -82,8 +76,6 @@ public class ChangeControlController : Controller {
ViewBag.Attendees = ccDMO.GetUsers();
ViewBag.Generations = ccDMO.GetGenerations();
ViewBag.PartNumbers = ccDMO.GetPartNumbers();
//ViewBag.ToolTypes = ccDMO.GetToolTypes();
//ViewBag.MeetingList = ccDMO.GetMeetingList(issueID);
ViewBag.Processes = ccDMO.GetProcesses();
ViewBag.Logistics = ccDMO.GetLogistics();
ViewBag.AIResponsibles = ccDMO.GetActionItemResponsible();
@ -97,7 +89,7 @@ public class ChangeControlController : Controller {
int isITARCompliant = 1;
ChangeControlViewModel cc = new ChangeControlViewModel();
cc = ccDMO.GetChangeControlRead(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
//TODO locked functionality
// TODO locked functionality
if (isITARCompliant == 0) // not ITAR Compliant
{
@ -106,7 +98,6 @@ public class ChangeControlController : Controller {
ViewBag.MeetingList = ccDMO.GetMeetingList(issueID);
ViewBag.Generations = ccDMO.GetGenerations();
ViewBag.PartNumbers = ccDMO.GetPartNumbers();
//ViewBag.ToolTypes = ccDMO.GetToolTypes();
ViewBag.Processes = ccDMO.GetProcesses();
ViewBag.Logistics = ccDMO.GetLogistics();
return View(cc);
@ -153,7 +144,6 @@ public class ChangeControlController : Controller {
ccDMO.UpdateCCAttachemnt(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -163,7 +153,6 @@ public class ChangeControlController : Controller {
ccDMO.DeleteCCAttachemnt(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -180,7 +169,7 @@ public class ChangeControlController : Controller {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
ccDMO.AttachSaveCC(planNumber, attachID, userId, file.FileName, file.InputStream);
ChangeControlHelper.AttachSaveCC(_AppSettings, ccDMO, planNumber, attachID, userId, file.FileName, file.InputStream);
}
}
return Content("");
@ -202,8 +191,6 @@ public class ChangeControlController : Controller {
if (model != null && ModelState.IsValid) {
ccDMO.UpdateMeetingAttachmentAttrib(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -212,8 +199,6 @@ public class ChangeControlController : Controller {
if (model != null && ModelState.IsValid) {
ccDMO.DeleteMeetingAttachemnt(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -231,7 +216,7 @@ public class ChangeControlController : Controller {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
ccDMO.AttachSaveMeeting(planNumber, attachID, userId, file.FileName, file.InputStream);
ChangeControlHelper.AttachSaveMeeting(_AppSettings, ccDMO, planNumber, attachID, userId, file.FileName, file.InputStream);
}
}
return Content("");
@ -243,7 +228,7 @@ public class ChangeControlController : Controller {
string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
string ecnFolderPath = _AppSettings.AttachmentFolder + "ChangeControl\\" + planNumber.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)) {
@ -254,7 +239,6 @@ public class ChangeControlController : 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);
@ -263,9 +247,7 @@ public class ChangeControlController : Controller {
public ActionResult CreateMeeting(int planNumber) {
try {
int meetingID = ccDMO.InsertMeeting(planNumber);
//return RedirectToAction("EditMeeting", new { meetingID = meetingID });
return Content(meetingID.ToString());
//return null;
} catch (Exception e) {
string detailedException = "";
try {
@ -285,7 +267,7 @@ public class ChangeControlController : Controller {
CCMeeting meeting = new CCMeeting();
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.MeetingList = ccDMO.GetMeetingList(meeting.PlanNumber);
//TODO locked functionality
// TODO locked functionality
List<ApproversListViewModel> userList = MiscDMO.GetApproversListByDocument(meeting.PlanNumber, meeting.CurrentStep, (int)GlobalVars.DocumentType.ChangeControl);
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (appUser != null) {
@ -345,7 +327,7 @@ public class ChangeControlController : Controller {
meeting = ccDMO.GetMeetingRead(meetingID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
ViewBag.MeetingList = ccDMO.GetMeetingList(meeting.PlanNumber);
ViewBag.PCRValues = ccDMO.GetPCRValues();
//TODO locked functionality
// TODO locked functionality
List<ApproversListViewModel> userList = MiscDMO.GetApproversListByDocument(meeting.PlanNumber, meeting.CurrentStep, (int)GlobalVars.DocumentType.ChangeControl);
ApproversListViewModel appUser = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (appUser != null) {
@ -375,7 +357,7 @@ public class ChangeControlController : Controller {
string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
string ecnFolderPath = _AppSettings.AttachmentFolder + "ChangeControl\\" + planNumber.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)) {
@ -386,7 +368,6 @@ public class ChangeControlController : 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);
@ -410,8 +391,6 @@ public class ChangeControlController : Controller {
if (model != null && ModelState.IsValid) {
ccDMO.DeleteDecisionSummary(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -448,7 +427,6 @@ public class ChangeControlController : Controller {
public void InsertNewMeetingAttendee(string attendeeName, string jobTitle, string siteName) {
try {
//ccDMO.InsertNewMeetingAttendee(meetingId, attendeeName, jobTitle, siteName);
} catch (Exception e) {
string detailedException = "";
try {
@ -456,10 +434,6 @@ public class ChangeControlController : Controller {
} catch {
detailedException = e.Message;
}
//string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + docid.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
//Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n UpdateMeetingAttendee - Change Control\r\n" + docid.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
//EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "UpdateMeetingAttendee - " + exceptionString });
//throw new Exception(e.Message);
}
}
@ -479,8 +453,6 @@ public class ChangeControlController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "UpdateMeetingAttendee - " + exceptionString });
throw new Exception(e.Message);
}
//return Content("");
}
[HttpPost]
@ -501,8 +473,6 @@ public class ChangeControlController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = docid, UserID = @User.Identity.Name, DocumentType = "Change Control", OperationType = "Error", Comments = "UpdateMeetingAttendee - " + exceptionString });
throw new Exception(e.Message);
}
//return Content("");
}
[AcceptVerbs(HttpVerbs.Post)]
@ -510,8 +480,6 @@ public class ChangeControlController : Controller {
if (model != null && ModelState.IsValid) {
ccDMO.DeleteMeetingAttendee(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -530,8 +498,6 @@ public class ChangeControlController : Controller {
}
return Content("1");
//return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
public ActionResult GetMeetingActionItems([DataSourceRequest] DataSourceRequest request, int meetingID) {
@ -546,17 +512,6 @@ public class ChangeControlController : Controller {
return Json(ccDMO.GetMeetingActionItems_All(planNumber).ToDataSourceResult(request));
}
[AcceptVerbs(HttpVerbs.Post)]
//public ActionResult InsertMeetingActionItem([DataSourceRequest] DataSourceRequest request, CCMeetingActionItem model)
//{
// if (model != null && ModelState.IsValid)
// {
// ccDMO.InsertMeetingActionItem(model);
// }
// return Json(new[] { model }.ToDataSourceResult(request, ModelState));
//}
public ActionResult InsertPCRBActionItem(CCPCRBActionItem model) {
try {
if (model != null) {
@ -597,8 +552,6 @@ public class ChangeControlController : Controller {
}
return Content("1");
//return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
public ActionResult UpdatePCRBActionItem(CCPCRBActionItem model) {
@ -658,8 +611,6 @@ public class ChangeControlController : Controller {
if (model != null && ModelState.IsValid) {
ccDMO.DeleteMeetingActionItem(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -667,8 +618,6 @@ public class ChangeControlController : Controller {
if (model != null && ModelState.IsValid) {
ccDMO.DeletePCRBActionItem(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
@ -713,7 +662,7 @@ public class ChangeControlController : Controller {
if (AIfiles != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in AIfiles) {
ccDMO.AttachSaveActionItem(planNumber, attachID, userId, file.FileName, file.InputStream);
ChangeControlHelper.AttachSaveActionItem(_AppSettings, ccDMO, planNumber, attachID, userId, file.FileName, file.InputStream);
}
}
return Content("");
@ -725,7 +674,7 @@ public class ChangeControlController : Controller {
string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
string ecnFolderPath = _AppSettings.AttachmentFolder + "ChangeControl\\" + planNumber.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)) {
@ -736,7 +685,6 @@ public class ChangeControlController : 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);
@ -760,9 +708,6 @@ public class ChangeControlController : 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);

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;

File diff suppressed because it is too large Load Diff

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 {

View File

@ -1,4 +1,14 @@
using Fab2ApprovalSystem.DMO;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.ViewModels;
@ -6,17 +16,6 @@ using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Web;
using System.Web.Mvc;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -24,19 +23,12 @@ namespace Fab2ApprovalSystem.Controllers;
[SessionExpireFilter]
public class LotDispositionController : Controller {
LotDispositionDMO ldDMO;
LotDispositionDMO ldDMO = new LotDispositionDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
private readonly AppSettings _AppSettings;
public LotDispositionController(AppSettings appSettings) {
_AppSettings = appSettings;
ldDMO = new LotDispositionDMO(appSettings);
}
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: /LotDisposition/Create
public ActionResult Create() {
//excel.FileName = "";
//var lot =
LotDisposition lotDispo = new LotDisposition();
try {
// insert a records to get the issueID
@ -67,14 +59,6 @@ public class LotDispositionController : Controller {
lot.LotStatusOption.LotStatusOptionID = l.LotStatusOptionID;
lot.LotStatusOption.LotStatusOption = l.LotStatusOptionName;
ldDMO.InsertLot(lot, false);
//if (!mrbDMO.DoesMRBLotExist(lot.LotNumber))
//{
//get All the MRBs associated to the Parent lot
//insert the lot into the MRBChildLotNotInMRB table and NOT in the MRB Lot table for each MRB
//ldDMO.InsertChildLot_NotInTheMRB(lot.LotNumber);
//}
} catch (Exception e) {
string detailedException = "";
try {
@ -110,23 +94,6 @@ public class LotDispositionController : Controller {
}
//foreach (string lotNumber in tempLots)
//{
//===================================================================
// ONLY DO THIS PART IF THE LOT DOES NOT EXIST IN THE
//"MRBLot" TABLE AND THE "MRBChildLotNotInMRB" TABLE
//===================================================================
//if (!mrbDMO.DoesMRBLotExist(lotNumber))
//{
// //get All the MRBs associated to the Parent lot
// //insert the lot into the MRBChildLotNotInMRB table and NOT in the MRB Lot table for each MRB
// ldDMO.InsertChildLot_NotInTheMRB(lotNumber);
//}
// }
}
} catch (Exception e) {
@ -145,7 +112,6 @@ public class LotDispositionController : Controller {
return Json(issueWEL, JsonRequestBehavior.AllowGet);
}
//
// GET: /LotDisposition/Edit/5
public ActionResult Edit(int issueID) {
int isITARCompliant = 1;
@ -162,7 +128,6 @@ public class LotDispositionController : Controller {
}
if (lotDispo.CurrentStep == 1) {
List<ApproversListViewModel> userList = MiscDMO.GetPendingApproversListByDocument(issueID, lotDispo.CurrentStep, (int)GlobalVars.DocumentType.LotDisposition);
//ApproversListViewModel approver = userList.Find(delegate(ApproversListViewModel al) { return al.UserID == GlobalVars.USER_ID; });
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (approver == null)
ViewBag.IsApprover = "false";
@ -170,7 +135,6 @@ public class LotDispositionController : Controller {
ViewBag.IsApprover = "true";
if (approver == null && (!(bool)Session[GlobalVars.IS_ADMIN]) && (int)Session[GlobalVars.SESSION_USERID] != lotDispo.OriginatorID) {
//return RedirectToAction("ReadOnly", lotDispo);
return RedirectToAction("ReadOnly", new { issueID = issueID });
} else {
if ((ViewBag.IsApprover == "true" || (bool)Session[GlobalVars.IS_ADMIN])
@ -194,7 +158,7 @@ public class LotDispositionController : Controller {
}
} else if (lotDispo.CurrentStep > 1) {
List<ApproversListViewModel> userList = MiscDMO.GetPendingApproversListByDocument(issueID, lotDispo.CurrentStep, (int)GlobalVars.DocumentType.LotDisposition);
//ApproversListViewModel approver = userList.Find(delegate(ApproversListViewModel al) { return al.UserID == GlobalVars.USER_ID; });
ApproversListViewModel approver = userList.Find(delegate (ApproversListViewModel al) { return al.UserID == (int)Session[GlobalVars.SESSION_USERID]; });
if (approver == null) {
ViewBag.IsApprover = "false";
@ -208,14 +172,6 @@ public class LotDispositionController : Controller {
return RedirectToAction("ReadOnly", new { issueID = issueID });
} else {
//// Check the record Lock indicator
//if ((lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID]) || (ViewBag.IsApprover == "false"))
//{
// return RedirectToAction("ReadOnly", new { issueID = issueID });
//}
//else
// return RedirectToAction("EditStep", new { issueID = issueID });
if ((ViewBag.IsApprover == "true" || (bool)Session[GlobalVars.IS_ADMIN])
|| (int)Session[GlobalVars.SESSION_USERID] == lotDispo.OriginatorID) {
return RedirectToAction("EditStep", new { issueID = issueID });
@ -257,7 +213,6 @@ public class LotDispositionController : Controller {
}
}
//
// POST: /LotDisposition/Edit/5
[HttpPost]
@ -320,19 +275,6 @@ public class LotDispositionController : Controller {
// Check the recordlock indicator
//if ((lotDispo.RecordLockIndicator && lotDispo.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID]))
//{
// return RedirectToAction("ReadOnly", new { issueID = issueID });
//}
//else
//{
// PopulateLotStatusOptions();
// ViewBag.OriginatorList = ldDMO.GetUserList();
// ViewBag.deps = ldDMO.GetDepartments();
// ViewBag.ResponsibilityList = ldDMO.GetResponsibilityList();
// ViewBag.ResponsibilityIssueList = ldDMO.GetResponsibilityIssueList(lotDispo.ResponsibilityID);
//}
if ((ViewBag.IsApprover == "true" || (bool)Session[GlobalVars.IS_ADMIN])) {
lotDispo = ldDMO.GetLotDispositionItem(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
@ -351,7 +293,6 @@ public class LotDispositionController : Controller {
return RedirectToAction("ReadOnly", new { issueID = issueID });
}
//return View(lotDispo);
} catch (Exception e) {
string detailedException = "";
try {
@ -366,7 +307,6 @@ public class LotDispositionController : Controller {
}
}
//
// GET: /LotDisposition/Delete/5
public ActionResult Delete(int id) {
return View();
@ -387,7 +327,6 @@ public class LotDispositionController : Controller {
public void PopulateLotStatusOptions() {
var lotStatusOptions = ldDMO.GetLotStatusOptions();
ViewData["LotStatusOptions"] = lotStatusOptions;
//ViewData["DefaultLotStatusOptions"] = lotStatusOptions.First();
}
public ActionResult EditingCustom_Read([DataSourceRequest] DataSourceRequest request, int issueID) {
@ -397,7 +336,6 @@ public class LotDispositionController : Controller {
/// <summary>
/// Updates the lot tables
/// </summary>
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Update([DataSourceRequest] DataSourceRequest request, Lot lot) {
@ -442,26 +380,19 @@ public class LotDispositionController : Controller {
}
} catch (Exception e) {
//string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Delete =" + attachmentID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
//Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AttachmentID Disposition\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
//EventLogDMO.Add(new WinEventLog() { UserID = @User.Identity.Name, OperationType = "Error", Comments = exceptionString });
//throw new Exception(e.Message);
}
return Json(new[] { attachment }.ToDataSourceResult(request, ModelState));
}
//[AcceptVerbs(HttpVerbs.Post)]
[HttpPost]
public void DeleteAttachment(int attachmentID, string fileName) {
try {
if (ModelState.IsValid) {
ldDMO.DeleteLotDispoAttachment(attachmentID);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "LotDisposition", fileName);
var physicalPath = System.IO.Path.Combine(_AppSettings.AttachmentFolder + "LotDisposition", fileName);
FileInfo f = new FileInfo(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -491,20 +422,16 @@ public class LotDispositionController : Controller {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
ldDMO.AttachSave(issueID, userId, file.FileName, file.InputStream);
LotDispositionHelper.AttachSave(_AppSettings, ldDMO, issueID, userId, file.FileName, file.InputStream);
}
}
//var model = ldDMO.GetLotDispoAttachments(issueID);
return Content("");
}
public JsonResult SearchLots(string searchText, string searchBy) {
List<String> lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList<String>();
//IEnumerable<Lot> lotlist = MiscDMO.SearchLots(searchText, searchBy);
return Json(lotlist, JsonRequestBehavior.AllowGet);
}
@ -546,7 +473,7 @@ public class LotDispositionController : Controller {
byte currentValue = (byte)pi.GetValue(sl, null);
if (currentValue == (int)GlobalVars.LotStatusOption.Release || currentValue == (int)GlobalVars.LotStatusOption.CloseToQDB) {
releaseCount++;
//required to update the lot status option
// required to update the lot status option
if (currentValue == (int)GlobalVars.LotStatusOption.CloseToQDB)
closeToQDBCount++;
} else if (currentValue == (int)GlobalVars.LotStatusOption.Scrap)
@ -586,8 +513,6 @@ public class LotDispositionController : Controller {
sl.IssueID = issueID;
foreach (PropertyInfo pi in sl.GetType().GetProperties()) {
if (pi.Name.ToLower().StartsWith("lot") && pi.Name.ToLower().EndsWith("state")) {
//byte currentValue = (byte)pi.GetValue(sl, null);
//if (currentValue != 2)
pi.SetValue(sl, (byte)1, null);
}
}
@ -616,8 +541,6 @@ public class LotDispositionController : Controller {
sl.IssueID = issueID;
foreach (PropertyInfo pi in sl.GetType().GetProperties()) {
if (pi.Name.ToLower().StartsWith("lot") && pi.Name.ToLower().EndsWith("state")) {
//byte currentValue = (byte)pi.GetValue(sl, null);
//if (currentValue != 2)
pi.SetValue(sl, (byte)2, null);
}
}
@ -727,14 +650,10 @@ public class LotDispositionController : Controller {
/// Get a list of Approvers and the status
/// </summary>
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.LotDisposition).ToDataSourceResult(request));
}
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);
@ -756,24 +675,7 @@ public class LotDispositionController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "LotDispositionReAssigned.txt";
string userEmail = string.Empty;
string subject = "Lot Disposition Re-Assignment";
string senderName = "LotDisposition";
subject = "Lot Disposition Re-Assignment" + " - Email would be sent to " + email;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = issueID.ToString();
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);
LotDispositionHelper.ReAssignApproval(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
@ -795,24 +697,7 @@ public class LotDispositionController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "LotDispositionReAssigned.txt";
string userEmail = string.Empty;
string subject = "Lot Disposition Re-Assignment";
string senderName = "LotDisposition";
subject = "Lot Disposition Re-Assignment" + " - Email would be sent to " + email;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = issueID.ToString();
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);
LotDispositionHelper.ReAssignApproverByAdmin(_AppSettings, issueID, email);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
@ -843,33 +728,7 @@ public class LotDispositionController : Controller {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "LotDispositionAssigned.txt";
string userEmail = string.Empty;
string subject = "Lot Disposition Assignment";
string senderName = "LotDisposition";
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 = "Lot Disposition Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = issueID.ToString();
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 = LotDispositionHelper.AddAdditionalApproval(_AppSettings, issueID, emailSentList, emailArray);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
} catch { }
@ -879,32 +738,8 @@ public class LotDispositionController : Controller {
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.LotDisposition).Distinct().ToList();
string emailTemplate = "LotDispositionAssigned.txt";
string userEmail = string.Empty;
string subject = "Lot Disposition Assignment";
string senderName = "LotDisposition";
foreach (string email in emailIst) {
subject = "Lot Disposition Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = issueID.ToString();
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 = LotDispositionHelper.NotifyApprovers(_AppSettings, issueID, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
@ -924,29 +759,9 @@ public class LotDispositionController : Controller {
public void NotifyRejectionToOrginator(int issueID) {
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
List<string> emailIst = ldDMO.GetRejectionOrginatorEmailList(@issueID).Distinct().ToList();
string emailTemplate = "LotDispositionReject.txt";
string userEmail = string.Empty;
string subject = "Lot Disposition Rejection";
string senderName = "LotDisposition";
foreach (string email in emailIst) {
subject = "Lot Disposition Rejection";
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();
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
}
string userEmail = LotDispositionHelper.NotifyRejectionToOrginator(_AppSettings, issueID, username, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Email", Comments = "Rejection: " + userEmail });
} catch { }
@ -970,7 +785,6 @@ public class LotDispositionController : Controller {
}
public ActionResult GetComments([DataSourceRequest] DataSourceRequest request, int issueID) {
//return Json(ldDMO.GetApproversList(issueID, step).ToDataSourceResult(request));
return Json(ldDMO.GetComments(issueID).ToDataSourceResult(request));
}
@ -996,14 +810,13 @@ public class LotDispositionController : Controller {
var physicalPath = "";
try {
string userIdentityName = @User.Identity.Name;
string lotTempPipeLine = ConfigurationManager.AppSettings["LotTempPipeLine"].ToString();
foreach (var file in Lotfile) {
physicalPath = ldDMO.ExcelLotOpen(issueID, userIdentityName, lotTempPipeLine, file.FileName, file.InputStream);
physicalPath = LotDispositionHelper.ExcelLotOpen(ldDMO, issueID, userIdentityName, _AppSettings.LotTempPipeLine, file.FileName, file.InputStream);
}
return Content("");
} catch {
FileInfo f = new FileInfo(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -1027,11 +840,10 @@ public class LotDispositionController : Controller {
}
public FileResult DownloadFile(string attachmentID) {
//fileName = "ECNForm_71132.pdf";
string fileName = ldDMO.GetFileName(attachmentID);
var sDocument = Path.Combine(_AppSettings.AttachmentFolder + "LotDisposition", fileName);
var sDocument = System.IO.Path.Combine(_AppSettings.AttachmentFolder + "LotDisposition", fileName);
var FDir_AppData = _AppSettings.AttachmentFolder;
if (!sDocument.StartsWith(FDir_AppData)) {
// Ensure that we are serving file only inside the Fab2ApprovalAttachments folder
@ -1041,7 +853,6 @@ public class LotDispositionController : 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);

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web;
@ -23,15 +22,10 @@ namespace Fab2ApprovalSystem.Controllers;
[SessionExpireFilter]
public class LotTravelerController : PdfViewController {
LotTravelerDMO LotTravDMO;
LotTravelerDMO LotTravDMO = new LotTravelerDMO();
string docTypeString = "LotTraveler";
WorkflowDMO wfDMO = new WorkflowDMO();
private readonly AppSettings _AppSettings;
public LotTravelerController(AppSettings appSettings) {
_AppSettings = appSettings;
LotTravDMO = new LotTravelerDMO(appSettings);
}
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult CreateWorkRequest() {
LTWorkRequest workRequest = new LTWorkRequest();
@ -122,7 +116,6 @@ public class LotTravelerController : PdfViewController {
if (Session["CreateNewRevision"].ToString() == "true") {
ViewBag.NewRevision = "false";
Session["CreateNewRevision"] = "false";
//Session["CurrentlyOnSamePage"] = "true";
model.OriginatorID = (int)Session[GlobalVars.SESSION_USERID];
int newRequestID = LotTravDMO.CreateWorkRequestRevision(model, (int)Session[GlobalVars.SESSION_USERID]);
// TODO
@ -131,7 +124,6 @@ public class LotTravelerController : PdfViewController {
return Content(newRequestID.ToString());
} else {
// model.OriginatorID = (int)Session[GlobalVars.SESSION_USERID];
LotTravDMO.UpdateWorkRequest(model, (int)Session[GlobalVars.SESSION_USERID]);
return Content("");
}
@ -176,7 +168,6 @@ public class LotTravelerController : PdfViewController {
else
ViewBag.IsApprover = "true";
//if ((workRequest.RecordLockIndicator && workRequest.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID]) || (!((bool)Session[GlobalVars.IS_ADMIN]) && (ViewBag.IsApprover == "false")) )
if (workRequest.RecordLockIndicator && workRequest.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID]) {
return RedirectToAction("WorkRequestReadOnly", new { issueID = issueID });
}
@ -200,10 +191,6 @@ public class LotTravelerController : PdfViewController {
LTWorkRequest workRequest = new LTWorkRequest();
workRequest = LotTravDMO.GetLTWorkRequestItemForRead(workRequestID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
//if (workRequest.IsCurrentRevision)
//{
// return RedirectToAction("Edit", new { issueID = workRequestID });
//}
return Content("");
}
@ -301,7 +288,6 @@ public class LotTravelerController : PdfViewController {
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
} catch (Exception ex) {
//throw new Exception(ex.Message);
return this.Json(new DataSourceResult {
Errors = ex.Message
});
@ -315,10 +301,8 @@ public class LotTravelerController : PdfViewController {
LotTravDMO.UpdateMaterialDetail(model, (int)Session[GlobalVars.SESSION_USERID]);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
} catch (Exception ex) {
//throw new Exception(ex.Message);
return this.Json(new DataSourceResult {
Errors = ex.Message
});
@ -373,8 +357,6 @@ public class LotTravelerController : PdfViewController {
}
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
//return Json(new[] { modelMaterialDetail }.ToDataSourceResult(request, ModelState));
return Content(newWorkRequestID.ToString());
}
@ -385,10 +367,6 @@ public class LotTravelerController : PdfViewController {
}
} catch (Exception e) {
//string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Delete =" + attachmentID.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
//Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AttachmentID Disposition\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
//EventLogDMO.Add(new WinEventLog() { UserID = @User.Identity.Name, OperationType = "Error", Comments = exceptionString });
//throw new Exception(e.Message);
}
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
@ -415,8 +393,6 @@ public class LotTravelerController : PdfViewController {
}
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
//return Json(new[] { modelMaterialDetail }.ToDataSourceResult(request, ModelState));
return Content(newWorkRequestID.ToString());
}
@ -455,8 +431,6 @@ public class LotTravelerController : PdfViewController {
}
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
//return Json(new[] { modelMaterialDetail }.ToDataSourceResult(request, ModelState));
return Content(newWorkRequestID.ToString());
}
@ -482,8 +456,6 @@ public class LotTravelerController : PdfViewController {
}
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
//return Json(new[] { modelMaterialDetail }.ToDataSourceResult(request, ModelState));
return Content(newWorkRequestID.ToString());
}
@ -509,8 +481,6 @@ public class LotTravelerController : PdfViewController {
}
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
//return Json(new[] { modelMaterialDetail }.ToDataSourceResult(request, ModelState));
return Content(newWorkRequestID.ToString());
}
@ -528,7 +498,6 @@ public class LotTravelerController : PdfViewController {
}
} catch (Exception ex) {
//throw new Exception(ex.Message);
return this.Json(new DataSourceResult {
Errors = ex.Message
});
@ -558,16 +527,10 @@ public class LotTravelerController : PdfViewController {
}
public ActionResult GetHoldStepAttachments([DataSourceRequest] DataSourceRequest request, int holdStepID) {
//var model = LotTravDMO.GetHoldStepAttachemnts(holdStepID);
//return Json(new[] { model }.ToDataSourceResult(request, ModelState));
return Json(LotTravDMO.GetHoldStepAttachemnts(holdStepID).ToDataSourceResult(request));
}
public ActionResult GetLTHoldStepAttachments([DataSourceRequest] DataSourceRequest request, int ltHoldStepID) {
//var model = LotTravDMO.GetHoldStepAttachemnts(holdStepID);
//return Json(new[] { model }.ToDataSourceResult(request, ModelState));
return Json(LotTravDMO.GetLotTravHoldStepAttachemnts(ltHoldStepID).ToDataSourceResult(request));
}
@ -598,13 +561,9 @@ public class LotTravelerController : PdfViewController {
LotTravDMO.UpdateWorkRequestAttachment(model);
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
/// <summary>
///
/// </summary>
public ActionResult UpdateWorkRequestAttachmentRevision(LTWorkRequest model) {
var wrAttachmentDetail = model.WorkRequestAttachment;
int previousWorkRequestAttachmentID = model.WorkRequestAttachment.ID;
@ -627,8 +586,6 @@ public class LotTravelerController : PdfViewController {
}
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
//return Json(new[] { modelMaterialDetail }.ToDataSourceResult(request, ModelState));
return Content(newWorkRequestID.ToString());
}
@ -671,8 +628,6 @@ public class LotTravelerController : PdfViewController {
}
}
//lot.LotStatusOptionID = lot.LotStatusOption.LotStatusOptionID;
//return Json(new[] { modelMaterialDetail }.ToDataSourceResult(request, ModelState));
return Content(newWorkRequestID.ToString());
}
@ -681,7 +636,7 @@ public class LotTravelerController : PdfViewController {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
LotTravDMO.AttachSaveWorkRequest(workRequestID, swrNo, comments, docType, userId, file.FileName, file.InputStream);
LotTravelerHelper.AttachSaveWorkRequest(_AppSettings, LotTravDMO, workRequestID, swrNo, comments, docType, userId, file.FileName, file.InputStream);
}
}
return Content("");
@ -707,7 +662,7 @@ public class LotTravelerController : PdfViewController {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
LotTravDMO.AttachSaveWorkRequestRevision(workRequestID, swrNo, docType, attachComments, newRevision, userId, file.FileName, file.InputStream);
LotTravelerHelper.AttachSaveWorkRequestRevision(_AppSettings, LotTravDMO, workRequestID, swrNo, docType, attachComments, newRevision, userId, file.FileName, file.InputStream);
}
}
return Content("");
@ -719,7 +674,7 @@ public class LotTravelerController : PdfViewController {
if (HoldStepAttachment != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in HoldStepAttachment) {
LotTravDMO.HoldStepAttachSave(holdStepID, swrNo, docType, comments, userId, file.FileName, file.InputStream);
LotTravelerHelper.HoldStepAttachSave(_AppSettings, LotTravDMO, holdStepID, swrNo, docType, comments, userId, file.FileName, file.InputStream);
}
}
} catch (Exception e) {
@ -728,9 +683,6 @@ public class LotTravelerController : PdfViewController {
EventLogDMO.Add(new WinEventLog() { IssueID = holdStepID, UserID = @User.Identity.Name, DocumentType = docTypeString, OperationType = "Error", Comments = "HoldStep Attachment - " + exceptionString });
throw new Exception(e.Message);
}
//var model = ldDMO.GetLotDispoAttachments(issueID);
return Content("");
}
@ -754,7 +706,7 @@ public class LotTravelerController : PdfViewController {
if (HoldStepAttachment != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in HoldStepAttachment) {
LotTravDMO.HoldStepAttachSaveRev(holdStepID, swrNo, docType, comments, newRevision, userId, file.FileName, file.InputStream);
LotTravelerHelper.HoldStepAttachSaveRev(_AppSettings, LotTravDMO, holdStepID, swrNo, docType, comments, newRevision, userId, file.FileName, file.InputStream);
}
}
} catch (Exception e) {
@ -763,9 +715,6 @@ public class LotTravelerController : PdfViewController {
EventLogDMO.Add(new WinEventLog() { IssueID = holdStepID, UserID = @User.Identity.Name, DocumentType = docTypeString, OperationType = "Error", Comments = "HoldStep Attachment - " + exceptionString });
throw new Exception(e.Message);
}
//var model = ldDMO.GetLotDispoAttachments(issueID);
return Content("");
}
@ -819,7 +768,6 @@ public class LotTravelerController : PdfViewController {
} else
return Content("Invalid");
//return View(ltWR);
}
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + workRequestID.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
@ -840,14 +788,6 @@ public class LotTravelerController : PdfViewController {
while (lastApprover && !lastStep) {
currentStep++;
lastApprover = wfDMO.Approve(_AppSettings, workRequestID, currentStep, comments, out lastStep, (int)Session[GlobalVars.SESSION_USERID], documentType, ltWR.WorkFlowNumber);
//if (currentStep == 3 && (!lastStep)) // add orginator to the last step
//{
// int isITARCompliant = 1;
// ltWR = LotTravDMO.GetLTWorkRequestItemForRead(workRequestID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
// wfDMO.AddAdditionalApproval(workRequestID, ltWR.OriginatorID.ToString(), currentStep, documentType);
//}
NotifyApprovers(workRequestID, currentStep, documentType);
}
@ -883,42 +823,12 @@ public class LotTravelerController : PdfViewController {
}
}
// TODO ======================================
public void NotifyRejectionToOrginator(int workRequestID) {
List<string> emailIst = LotTravDMO.GetRejectionOrginatorEmailList(workRequestID).Distinct().ToList();
int isITARCompliant = 0;
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
List<string> emailIst = LotTravDMO.GetRejectionOrginatorEmailList(workRequestID).Distinct().ToList();
LTWorkRequest ltWR = LotTravDMO.GetLTWorkRequestItemForRead(workRequestID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
string emailTemplate = "WorkRequestReject.txt";
string userEmail = string.Empty;
string subject = "Work Request Rejection";
string senderName = "Work Request";
foreach (string email in emailIst) {
subject = "Work Request Rejection notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[5];
emailparams[0] = ltWR.SWRNumber.ToString();
emailparams[1] = workRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = Session[GlobalVars.SESSION_USERNAME].ToString();
emailparams[4] = "Work Request";
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
// en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
try {
//emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Notify Rejection:" + email });
}
}
string userEmail = LotTravelerHelper.NotifyRejectionToOrginator(_AppSettings, @User.Identity.Name, workRequestID, username, emailIst, ltWR);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Email", Comments = "Rejection: " + userEmail });
} catch { }
@ -930,36 +840,7 @@ public class LotTravelerController : PdfViewController {
LTWorkRequest ltWR = LotTravDMO.GetLTWorkRequestItemForRead(workRequestID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(workRequestID, currentStep, documentType).Distinct().ToList();
string emailTemplate = "WorkRequestAssigned.txt";
string userEmail = string.Empty;
string subject = "Work Request Assignment";
var senderName = "";
foreach (string email in emailIst) {
subject = "Work Request Assignment notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = ltWR.SWRNumber.ToString();
emailparams[1] = workRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = "Work Request";
userEmail = email;
#if (DEBUG)
userEmail = "rkotian1@irf.com";
#endif
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
//emailSentList += email + ",";
try {
emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "WR Notify Approvers:" + email });
}
}
emailSentList = LotTravelerHelper.NotifyApprovers(_AppSettings, @User.Identity.Name, workRequestID, emailSentList, ltWR, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
@ -971,35 +852,7 @@ public class LotTravelerController : PdfViewController {
LTWorkRequest ltWR = LotTravDMO.GetLTWorkRequestItemForRead(workRequestID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
List<string> emailIst = MiscDMO.GetWorkRequestApprovedNotifyList((int)GlobalVars.NotificationType.WorkRequest, workRequestID, (int)Session[GlobalVars.SESSION_USERID]).Distinct().ToList();
string emailTemplate = "WorkRequestApproval.txt";
string userEmail = string.Empty;
string subject = "Work Request Approval";
var senderName = "";
foreach (string email in emailIst) {
subject = "Work Request Approval notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = ltWR.SWRNumber.ToString();
emailparams[1] = workRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = "Work Request";
userEmail = email;
#if (DEBUG)
userEmail = "rkotian1@irf.com";
#endif
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
//emailSentList += email + ",";
try {
emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Approval Notification:" + email });
}
}
emailSentList = LotTravelerHelper.NotifyApprovalOfWorkRequest(_AppSettings, @User.Identity.Name, workRequestID, emailSentList, ltWR, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Email", Comments = "Approvers for WorkRequest: " + emailSentList });
@ -1013,36 +866,7 @@ public class LotTravelerController : PdfViewController {
LTWorkRequest ltWR = LotTravDMO.GetLTWorkRequestItemForRead(workRequestID, out isITARCompliant, currentUserID);
List<string> emailIst = MiscDMO.GetWorkRequestRevisionNotifyList((int)GlobalVars.NotificationType.WorkRequest, workRequestID, currentUserID).Distinct().ToList();
string emailTemplate = "WorkRequestRevisionChange.txt";
string userEmail = string.Empty;
string subject = "Work Request Revision Change";
var senderName = "";
foreach (string email in emailIst) {
subject = "Work Request Revision Change notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = ltWR.SWRNumber.ToString();
emailparams[1] = workRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = "Work Request";
userEmail = email;
#if (DEBUG)
userEmail = "rkotian1@irf.com";
#endif
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
//emailSentList += email + ",";
try {
emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "WR Revision Change Notification:" + email });
}
}
emailSentList = LotTravelerHelper.NotifyfWorkRequestRevisionChange(_AppSettings, @User.Identity.Name, workRequestID, emailSentList, ltWR, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Email", Comments = "Work Request Revision Change for :" + emailSentList });
} catch { }
@ -1050,39 +874,10 @@ public class LotTravelerController : PdfViewController {
public void NotifyLotTravelerRevisionChange(int ltLotID, int revisionNumber) {
string emailSentList = "";
var data = LotTravDMO.GetLotTravelerHeaderForReadOnly(ltLotID, revisionNumber);
LTLotTravelerHeaderViewModel data = LotTravDMO.GetLotTravelerHeaderForReadOnly(ltLotID, revisionNumber);
int currentUserID = (int)Session[GlobalVars.SESSION_USERID];
List<string> emailIst = MiscDMO.GetLotTravelerCreationAndRevisionNotifyList(ltLotID, data.LTWorkRequestID, currentUserID).Distinct().ToList();
string emailTemplate = "LotTravelerRevisionChange.txt";
string userEmail = string.Empty;
string subject = "Lot Traveler Revision Change";
var senderName = "";
foreach (string email in emailIst) {
subject = "Lot Traveler Revision for SWR# " + data.SWRNumber + ", Lot# " + data.LotNumber + " - " + data.Title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = data.SWRNumber.ToString();
emailparams[1] = data.LTWorkRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = data.LotNumber;
userEmail = email;
#if (DEBUG)
userEmail = "rkotian1@irf.com";
#endif
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
//emailSentList += email + ",";
try {
emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = data.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Revision Notification:" + email });
}
}
emailSentList = LotTravelerHelper.NotifyLotTravelerRevisionChange(_AppSettings, @User.Identity.Name, emailSentList, data, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = data.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Email", Comments = "Lot Traveler Revision Change Notification:" + emailSentList });
} catch { }
@ -1090,36 +885,10 @@ public class LotTravelerController : PdfViewController {
public void NotifyLotTravelerCreation(int ltLotID, int revisionNumber) {
string emailSentList = "";
var data = LotTravDMO.GetLotTravelerHeaderForReadOnly(ltLotID, revisionNumber);
LTLotTravelerHeaderViewModel data = LotTravDMO.GetLotTravelerHeaderForReadOnly(ltLotID, revisionNumber);
int currentUserID = (int)Session[GlobalVars.SESSION_USERID];
List<string> emailIst = MiscDMO.GetLotTravelerCreationAndRevisionNotifyList(ltLotID, data.LTWorkRequestID, currentUserID).Distinct().ToList();
string emailTemplate = "LotTravelerCreation.txt";
string userEmail = string.Empty;
string subject = "Lot Traveler Revision Change";
var senderName = "";
foreach (string email in emailIst) {
subject = "Lot Traveler created for SWR# " + data.SWRNumber + ", Lot# " + data.LotNumber + " - " + data.Title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = data.SWRNumber.ToString();
emailparams[1] = data.LTWorkRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = data.LotNumber;
userEmail = email;
#if (DEBUG)
userEmail = "rkotian1@irf.com";
#endif
try {
emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = data.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Creation Email Notification:" + email });
}
}
emailSentList = LotTravelerHelper.NotifyLotTravelerCreation(_AppSettings, @User.Identity.Name, emailSentList, data, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = data.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Email", Comments = "Lot Traveler Revision Change Notification:" + emailSentList });
} catch { }
@ -1137,16 +906,13 @@ public class LotTravelerController : PdfViewController {
try {
LotTravDMO.ReleaseLockOnLotTravelerUpdateDoc((int)Session[GlobalVars.SESSION_USERID], lotID);
} catch {
//TODO
// TODO
// unlock the current revision of the Lot traveler
LotTravDMO.ReleaseLockOnLotTravelerUpdateDoc(-1, lotID);
}
}
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);
@ -1164,35 +930,7 @@ public class LotTravelerController : PdfViewController {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "WorkRequestReAssigned.txt";
string userEmail = string.Empty;
string subject;
string senderName = "Work Request";
subject = "Work Request Re-Assignment" + " - Email would be sent to " + email + " for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = ltWR.SWRNumber.ToString();
emailparams[1] = workRequestID.ToString(); // goes into the link
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = "Work Request";
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
try {
//emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "ReAssign Approver Notification:" + email });
}
LotTravelerHelper.ReAssignApproverByAdmin(_AppSettings, @User.Identity.Name, workRequestID, email, ltWR);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
@ -1210,32 +948,7 @@ public class LotTravelerController : PdfViewController {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Error", Comments = "ReAssignApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "WorkRequestReAssigned.txt";
string userEmail = string.Empty;
string subject = "Work Request Re-Assignment";
string senderName = "Work Request";
subject = "Work Request Re-Assignment" + " - Email would be sent to " + email + " for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = ltWR.SWRNumber.ToString();
emailparams[1] = workRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = "Work Request";
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
try {
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "ReAssign Approval Notification:" + email });
}
LotTravelerHelper.ReAssignApproval(_AppSettings, @User.Identity.Name, workRequestID, email, ltWR);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
@ -1254,42 +967,7 @@ public class LotTravelerController : PdfViewController {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Error", Comments = "AddAdditionalApproval - " + exceptionString });
throw new Exception(e.Message);
}
string emailTemplate = "WorkRequestAssigned.txt";
string userEmail = string.Empty;
string subject = "Work Request Assignment";
string senderName = "Work Request";
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 = "Work Request Assignment notice for Number " + workRequestID + ", - " + ltWR.Title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[4];
emailparams[0] = ltWR.SWRNumber.ToString();
emailparams[1] = workRequestID.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = "Work Request";
userEmail = email;
//#if(DEBUG)
// userEmail = "rkotian1@irf.com";
//#endif
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
//emailSentList += email + ",";
try {
emailSentList += email + ",";
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
} catch {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Addtional Approver Notification:" + email });
}
}
}
emailSentList = LotTravelerHelper.AddAdditionalApproval(_AppSettings, @User.Identity.Name, workRequestID, emailSentList, emailArray, ltWR);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = @User.Identity.Name, DocumentType = "Work Request", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
} catch { }
@ -1325,9 +1003,6 @@ public class LotTravelerController : PdfViewController {
public JsonResult SearchLots(string searchText, string searchBy) {
List<String> lotlist = MiscDMO.SearchLTLots(searchText, searchBy).Select(x => x.LotNumber).ToList<String>();
//IEnumerable<Lot> lotlist = MiscDMO.SearchLots(searchText, searchBy);
return Json(lotlist, JsonRequestBehavior.AllowGet);
}
@ -1355,12 +1030,10 @@ public class LotTravelerController : PdfViewController {
public JsonResult GetLotTravelerHeader(int ltLotID) {
LTLotTravelerHeaderViewModel data = new LTLotTravelerHeaderViewModel();
data = LotTravDMO.GetLotTravelerHeaderForUpdate(ltLotID, (int)Session[GlobalVars.SESSION_USERID]);
//data.Revisions = LotTravDMO.GetLotTravRevisions(ltLotID).Select(s => new SelectListItem { Value = s.ID.ToString(), Text = s.RevisionNumber.ToString() }).ToList();
return Json(data, JsonRequestBehavior.AllowGet);
}
public ActionResult GetLotTravRevisions(int ltLotID) {
//return Json(LotTravDMO.GetLotTravRevisions(ltLotID).ToDataSourceResult(request));
return Json(LotTravDMO.GetLotTravRevisions(ltLotID), JsonRequestBehavior.AllowGet);
}
@ -1394,9 +1067,6 @@ public class LotTravelerController : PdfViewController {
return View(data);
}
/// <summary>
/// /
/// </summary>
public ActionResult LotTravelerReadonly(int ltLotID, int revisionNumber) {
LTLotTravelerHeaderViewModel data = new LTLotTravelerHeaderViewModel();
data = LotTravDMO.GetLotTravelerHeaderForReadOnly(ltLotID, revisionNumber);
@ -1459,14 +1129,6 @@ public class LotTravelerController : PdfViewController {
if (Session["CreateLotTravNewRevision"].ToString() == "true") {
// Create a new Revision
Session["CreateLotTravNewRevision"] = "false";
//int result = LotTravDMO.CanAddLocationOperation(ltHoldStepObj);
//if (result == -1)
//{
// Session["CreateLotTravNewRevision"] = "true";
// throw new Exception("Cannot set to this Hold Step as the step has already been passed in the Mfg Process.");
//}
newLotTravRevID = LotTravDMO.CreateLotTravelerRevision(ltHoldStepObj, (int)Session[GlobalVars.SESSION_USERID]);
try {
@ -1514,7 +1176,7 @@ public class LotTravelerController : PdfViewController {
LotTravDMO.InsertLotTravelerHoldStep(ltHoldStepObj, (int)Session[GlobalVars.SESSION_USERID]);
} catch {
//roll back the revision creation
// roll back the revision creation
LotTravDMO.RestoreLotTravToPrevRevision(prevLotTravRevID, newLotTravRevID);
throw new Exception("There was a problem while creating the revision, Please logout and log back and then retry. \n If the problem persist please contact the Site Administrator");
}
@ -1540,7 +1202,6 @@ public class LotTravelerController : PdfViewController {
int prevLotTravRevID = ltHoldStepObj.LotTravelerRevisionID;
int newLotTravRevID = -1;
try {
//int newLotTravRevisionAttribID = 0;
if (Session["CreateLotTravNewRevision"].ToString() == "true") {
// Create a new Revision
Session["CreateLotTravNewRevision"] = "false";
@ -1549,7 +1210,7 @@ public class LotTravelerController : PdfViewController {
try {
LotTravDMO.DeleteLotTravHoldStepRevision(ltHoldStepObj.ID);
} catch {
//roll back the revision creation
// roll back the revision creation
LotTravDMO.RestoreLotTravToPrevRevision(prevLotTravRevID, newLotTravRevID);
throw new Exception("There was a problem while creating the revision, Please logout and log back and then retry. \n If the problem persist please contact the Site Administrator");
}
@ -1573,7 +1234,6 @@ public class LotTravelerController : PdfViewController {
///
public ActionResult DisplayLotTravlerPdf(int ltLotID, int revisionNumber) {
//DateTime? expDt;
LotTravelerPdf traveler = new LotTravelerPdf();
try {
traveler = LotTravDMO.GetLotTravlerPdf(ltLotID, revisionNumber);
@ -1624,7 +1284,7 @@ public class LotTravelerController : PdfViewController {
if (LotTravHoldStepAttachment != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in LotTravHoldStepAttachment) {
LotTravDMO.LotTravHoldStepAttachSaveRev(ltHoldStepID, swrNo, docType, prevLotTravRevID, newLotTravRevID, newRevision, userId, file.FileName, file.InputStream);
LotTravelerHelper.LotTravHoldStepAttachSaveRev(_AppSettings, LotTravDMO, ltHoldStepID, swrNo, docType, prevLotTravRevID, newLotTravRevID, newRevision, userId, file.FileName, file.InputStream);
}
// send a notification
@ -1639,9 +1299,6 @@ public class LotTravelerController : PdfViewController {
EventLogDMO.Add(new WinEventLog() { IssueID = ltHoldStepID, UserID = @User.Identity.Name, DocumentType = docTypeString, OperationType = "Error", Comments = "Lot Traveler HoldStep Attachment - " + exceptionString });
throw new Exception(e.Message);
}
//var model = ldDMO.GetLotDispoAttachments(issueID);
return Content("");
}
@ -1668,7 +1325,7 @@ public class LotTravelerController : PdfViewController {
string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
string ecnFolderPath = _AppSettings.AttachmentFolder + "LotTraveler\\" + swrNumber.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)) {
@ -1679,7 +1336,6 @@ public class LotTravelerController : PdfViewController {
if (!System.IO.File.Exists(sDocument)) {
return null;
//throw new Exception("File not found");
}
return File(sDocument, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);

View File

@ -1,17 +1,8 @@
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
@ -19,6 +10,14 @@ using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -26,29 +25,21 @@ namespace Fab2ApprovalSystem.Controllers;
[SessionExpireFilter]
public class MRBController : Controller {
MRB_DMO mrbDMO;
MRB_DMO mrbDMO = new MRB_DMO(GlobalVars.AppSettings);
WorkflowDMO wfDMO = new WorkflowDMO();
CredentialsStorage credentialsStorage = new CredentialsStorage();
private readonly AppSettings _AppSettings;
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public MRBController(AppSettings appSettings) {
_AppSettings = appSettings;
mrbDMO = new MRB_DMO(appSettings);
}
//
// GET: /MRB/
public ActionResult Index() {
return View();
}
//
// GET: /MRB/Details/5
public ActionResult Details(int id) {
return View();
}
//
// GET: /MRB/Create
public ActionResult Create() {
MRB mrb = new MRB();
@ -60,15 +51,6 @@ public class MRBController : Controller {
try {
PopulateCloseToQDB();
mrbDMO.SubmitDocument(mrb.MRBNumber, (int)Session[GlobalVars.SESSION_USERID]);
//if (appoverCount > 0)
// NotifyApprovers(mrb.MRBNumber, (byte)GlobalVars.WorkFLowStepNumber.Step1);
//if (Request.IsAjaxRequest())
//{
// return Content("Redirect");
//}
//else
// return Content("Invalid");
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + mrb.MRBNumber.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n SubmitDocument - MRB\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
@ -79,7 +61,6 @@ public class MRBController : Controller {
return RedirectToAction("Edit", new { IssueID = mrb.MRBNumber });
}
//
// POST: /MRB/Create
[HttpPost]
public ActionResult Create(FormCollection collection) {
@ -92,7 +73,6 @@ public class MRBController : Controller {
}
}
//
// GET: /MRB/Edit/5
public ActionResult Edit(int issueID) {
string jwt = Session["JWT"].ToString();
@ -106,7 +86,6 @@ public class MRBController : Controller {
return Redirect(mrbUrl);
}
//
// POST: /MRB/Edit/5
[HttpPost]
public void Edit(MRB mrb) {
@ -132,13 +111,11 @@ public class MRBController : Controller {
return Redirect(mrbUrl);
}
//
// GET: /MRB/Delete/5
public ActionResult Delete(int id) {
return View();
}
//
// POST: /MRB/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection) {
@ -152,7 +129,6 @@ public class MRBController : Controller {
}
public JsonResult SearchLots(string searchText, string searchBy) {
//IEnumerable<Lot> lotlist = MiscDMO.SearchLots(searchText, searchBy);
List<String> lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList<String>();
return Json(lotlist, JsonRequestBehavior.AllowGet);
}
@ -169,46 +145,8 @@ public class MRBController : Controller {
/// <summary>
/// Updates the lot tables
/// </summary>
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateMRBLot([DataSourceRequest] DataSourceRequest request, Lot lot) {
//try
//{
// // RJK
// //routine to cascade the "dispo type" to all the child lots in SPN
// MRB mrbInfo = mrbDMO.GetToolIssueStartEndDateData(lot.MRBNumber);
// if (!mrbInfo.ToolCSV.ToUpper().Equals("NA"))
// {
// bool existingLotUpdated;
// Lot l = new Lot();
// l.LotNumber = lot.LotNumber;
// if (lot.DispoType.ToString().Trim().Length == 1)
// {
// l.DispoType = lot.DispoType;
// }
// l.MRBNumber = lot.MRBNumber;
// // check if the lot was sent to SPN
// bool lotSentToSPN = mrbDMO.IsLotSentToSPN(l.LotNumber, l.MRBNumber);
// //only get the child lots if it has been sent to SPN to set the MRB Flag
// if (lotSentToSPN)
// {
// if (!mrbDMO.GetChildLotsFromSPNForDispoTypeUpdate(l.MRBNumber, l.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate, lot.DispoType))
// {
// //warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n", l.LotNumber);
// }
// }
// }
//}
//catch(Exception e)
//{
// // ignore the error
// string s = e.InnerException.ToString();
//}
if (lot != null && ModelState.IsValid) {
mrbDMO.UpdateMRBLot(lot);
}
@ -219,7 +157,6 @@ public class MRBController : Controller {
/// <summary>
/// Deletes record from the lot table
/// </summary>
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteMRBLot([DataSourceRequest] DataSourceRequest request, Lot lot) {
try {
@ -271,17 +208,7 @@ public class MRBController : Controller {
l.LotNumber = lotNumber;
l.MRBNumber = mrbNumber;
mrbDMO.InsertLot(l, true, out existingRowUpdated);
//if (!existingRowUpdated)
//{
// if (!mrbDMO.InsertLotSplitsAffectedByIncident(mrbNumber, l.LotNumber))
// {
// warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n", l.LotNumber);
// }
//}
}
//warnings.Append("No tool info, split lots will NOT be automatically searched and uploaded \n please make sure to include all the child lots in the MRB");
}
return Content(warnings.ToString());
@ -317,9 +244,9 @@ public class MRBController : Controller {
mrbDMO.DeleteMRBAttachment(attachmentID);
if (!String.IsNullOrWhiteSpace(fileName)) {
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "MRB", fileName);
var physicalPath = System.IO.Path.Combine(_AppSettings.AttachmentFolder + "MRB", fileName);
FileInfo f = new FileInfo(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -340,12 +267,9 @@ public class MRBController : Controller {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
mrbDMO.AttachSave(mrbNumber, userId, file.FileName, file.InputStream);
MRBHelper.AttachSave(_AppSettings, mrbDMO, mrbNumber, userId, file.FileName, file.InputStream);
}
}
//var model = mrbDMO.GetMRBAttachments(mrbNumber);
return Json(new { errors = errorList });
}
@ -357,10 +281,8 @@ public class MRBController : Controller {
try {
string userIdentityName = @User.Identity.Name;
var dispos = mrbDMO.GetDispositions(mrbNumber);
string lotTempPipeLine = ConfigurationManager.AppSettings["LotTempPipeLine"].ToString();
foreach (var file in Lotfile) {
physicalPath = mrbDMO.ExcelLotOpen(mrbNumber, warnings, dispos, userIdentityName, lotTempPipeLine, file.FileName, file.InputStream);
physicalPath = MRBHelper.ExcelLotOpen(mrbDMO, mrbNumber, warnings, dispos, userIdentityName, _AppSettings.LotTempPipeLine, file.FileName, file.InputStream);
}
return Content(warnings.ToString());
@ -375,7 +297,7 @@ public class MRBController : Controller {
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n MRB Excel\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = mrbNumber, UserID = @User.Identity.Name, DocumentType = "Lot Disposition", OperationType = "Error", Comments = exceptionString });
FileInfo f = new FileInfo(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -385,16 +307,15 @@ public class MRBController : Controller {
}
public ActionResult ImportAddQDBFlag(IEnumerable<HttpPostedFileBase> AddQDBFlag, string operation) {
//string path = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName"]);
var physicalPath = "";
try {
string message;
string c = Server.MapPath("/FTPBatch/");
string userIdentityName = @User.Identity.Name;
string b = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName"]);
string a = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName_Test"]);
string b = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName);
string a = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
foreach (var file in AddQDBFlag) {
message = mrbDMO.ImportAddQDBFlag(operation, out physicalPath, userIdentityName, a, b, c, file.FileName, file.InputStream);
message = MRBHelper.ImportAddQDBFlag(_AppSettings, mrbDMO, operation, out physicalPath, userIdentityName, a, b, c, file.FileName, file.InputStream);
if (string.IsNullOrEmpty(message))
continue;
return Content(message);
@ -402,7 +323,7 @@ public class MRBController : Controller {
return Content("");
} catch {
FileInfo f = new FileInfo(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -416,10 +337,10 @@ public class MRBController : Controller {
string message;
string c = Server.MapPath("/FTPBatch/");
string userIdentityName = @User.Identity.Name;
string b = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName"]);
string a = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName_Test"]);
string b = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName);
string a = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
foreach (var file in RemoveQDBFlag) {
message = mrbDMO.ImportRemoveQDBFlag(operation, out physicalPath, userIdentityName, a, b, c, file.FileName, file.InputStream);
message = MRBHelper.ImportRemoveQDBFlag(_AppSettings, mrbDMO, operation, out physicalPath, userIdentityName, a, b, c, file.FileName, file.InputStream);
if (string.IsNullOrEmpty(message))
continue;
return Content(message);
@ -427,7 +348,7 @@ public class MRBController : Controller {
return Content("");
} catch {
FileInfo f = new FileInfo(physicalPath);
System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@ -503,38 +424,13 @@ public class MRBController : Controller {
List<CloseToQDBOptionViewModel> options = new List<CloseToQDBOptionViewModel>();
options.Add(new CloseToQDBOptionViewModel { CloseToQDBOptionID = 0, CloseToQDBOption = "No" });
options.Add(new CloseToQDBOptionViewModel { CloseToQDBOptionID = 1, CloseToQDBOption = "Yes" });
//options.Add(new CloseToQDBOptionViewModel{CloseToQDBOption= "No"});
//options.Add(new CloseToQDBOptionViewModel {CloseToQDBOption = "Yes" });
ViewData["CloseToQDBOptions"] = options;
}
public void NotifyApprovers(int mrbNumber, byte currentStep) {
string emailSentList = "";
List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(mrbNumber, currentStep, (int)GlobalVars.DocumentType.MRB).Distinct().ToList();
string emailTemplate = "MRBAssigned.txt";
string userEmail = string.Empty;
string subject = "MRB Assignment";
string senderName = "MRB";
foreach (string email in emailIst) {
subject = "MRB Assignment";
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[3];
emailparams[0] = mrbNumber.ToString();
emailparams[1] = mrbNumber.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 = MRBHelper.NotifyApprovers(_AppSettings, mrbNumber, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = mrbNumber, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
@ -575,15 +471,6 @@ public class MRBController : Controller {
int waferCount = 0;
int dieCount = 0;
mrbDMO.GetLotWaferDieCount(mrbNumber, out lotCount, out waferCount, out dieCount);
//dynamic data = new ExpandoObject();
//data.LotCount = lotCount;
//data.WaferCount = waferCount;
//data.DieCount = dieCount;
//string json = Newtonsoft.Json.JsonConvert.SerializeObject(data);
//return Json(json, JsonRequestBehavior.AllowGet);
return Json(lotCount.ToString() + "~" + waferCount.ToString() + "~" + dieCount, JsonRequestBehavior.AllowGet);
}
@ -601,7 +488,7 @@ public class MRBController : Controller {
var mrbLotInfo = mrbDMO.GetLotsToFindNewChildLots(mrbNumber);
foreach (Lot lot in mrbLotInfo) {
//routine to cascade the "dispo type" to all the child lots in SPN (Lot that are not present in FAb App Sys,)
// routine to cascade the "dispo type" to all the child lots in SPN (Lot that are not present in FAb App Sys,)
mrbDMO.ChildLotsUpdateInSPNWithNewDispoType(lot, mrbInfo);
}
@ -614,11 +501,10 @@ public class MRBController : Controller {
try {
string c = Server.MapPath("/FTPBatch/");
string userIdentityName = @User.Identity.Name;
string b = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName"]);
string a = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName_Test"]);
string b = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName);
string a = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
IEnumerable<string> data = mrbDMO.GetMRBHoldLots(mrbNumber);
foreach (string tempData in data) {
//output = new StringBuilder();
if (tempData != null)
output.Append(tempData.Trim() + Environment.NewLine);
@ -630,9 +516,7 @@ public class MRBController : Controller {
string newsourceFileName = mrbNumber.ToString() + "_S" + dt.Day.ToString("00") + dt.Month.ToString("00") + dt.Year.ToString("00") + dt.Hour.ToString("00") + dt.Minute.ToString("00") + dt.Second.ToString("00") + ".mrb";
string newDestFileName = "S" + dt.Hour.ToString("00") + dt.Minute.ToString("00") + dt.Second.ToString("00");
//string outputFile = @"C:\Websites\SPNLotHoldFlag\" + newsourceFileName;
string ftpLogDirectory = ConfigurationManager.AppSettings["SPNMRBHoldFlagFTPLogDirectory"].ToString();
string outputFile = ConfigurationManager.AppSettings["SPNMRBHoldFlagDirectory"].ToString() + newsourceFileName;
string outputFile = _AppSettings.SPNMRBHoldFlagDirectory + newsourceFileName;
System.IO.File.WriteAllText(outputFile, output.ToString());
@ -640,26 +524,17 @@ public class MRBController : Controller {
Thread.Sleep(1000);
#endif
try {
//#if (!DEBUG)
//FTPWrapper spfSPN = new FTPWrapper(outputFile, newDestFileName);
//spfSPN.FTPToSPN();
if (mrbDMO.BatchFTP(outputFile, newDestFileName, ftpLogDirectory, userIdentityName, a, b, c)) {
//TODO
if (MRBHelper.BatchFTP(_AppSettings, outputFile, newDestFileName, _AppSettings.SPNMRBHoldFlagFTPLogDirectory, userIdentityName, a, b, c)) {
// TODO
mrbDMO.LogHoldFlagSentToSPNHistory(mrbNumber);
}
//#endif
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + mrbNumber.ToString() + " FTPToSPN(): SendMRBHoldFlagToSPN(mrbNumber) - FTP Upload Error " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = @User.Identity.Name, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return Json(new { Error = true, Message = e.Message }, JsonRequestBehavior.AllowGet);
//return false;
}
}
//return true;
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + mrbNumber.ToString() + " SendMRBHoldFlagToSPN(mrbNumber) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Approve\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
@ -678,18 +553,14 @@ public class MRBController : Controller {
}
public bool BatchFTP_Old(string sourceFile, string destFile) {
FileInfo sourcefile = new FileInfo(sourceFile);
//FileInfo sourcefile = new FileInfo(@"C:\Websites\ECNViewerAckResultToSPN\S15122017102017.ecn");
System.IO.FileInfo sourcefile = new System.IO.FileInfo(sourceFile);
try {
//Functions.WriteEvent("HR Emp", "SPNData - Start Send(): FTPing " + sourceFile + " to SPN server.", System.Diagnostics.EventLogEntryType.Information);
ProcessStartInfo psiFab1 = new ProcessStartInfo();
//psiFab1.FileName = ConfigurationManager.AppSettings["FTPSPNBatchFileName"];
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
psiFab1.FileName = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName_Test"]);
psiFab1.FileName = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName_Test);
} else {
psiFab1.FileName = Server.MapPath("/FTPBatch/" + ConfigurationManager.AppSettings["FTPSPNBatchFileName"]);
psiFab1.FileName = Server.MapPath("/FTPBatch/" + _AppSettings.FTPSPNBatchFileName);
}
psiFab1.Arguments = sourcefile.FullName + " " + destFile;
@ -697,8 +568,6 @@ public class MRBController : Controller {
Process procFab1 = new Process();
procFab1.StartInfo = psiFab1;
procFab1.Start();
//Functions.WriteEvent("HR Emp", "SPNData - Finish FTPing to SPN server.", System.Diagnostics.EventLogEntryType.Information);
return true;
} catch (Exception e) {
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n Approve\r\n" + e.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
@ -707,8 +576,6 @@ public class MRBController : Controller {
}
public FileResult DownloadFile(string attachmentID) {
//fileName = "ECNForm_71132.pdf";
var attachment = mrbDMO.GetMRBAttachment(Convert.ToInt32(attachmentID));
if (attachment == null)
@ -718,7 +585,7 @@ public class MRBController : Controller {
if (String.IsNullOrEmpty(fileName))
fileName = attachment.FileName;
var sDocument = Path.Combine(_AppSettings.AttachmentFolder + "MRB", fileName);
var sDocument = System.IO.Path.Combine(_AppSettings.AttachmentFolder + "MRB", fileName);
var FDir_AppData = _AppSettings.AttachmentFolder;
if (!sDocument.StartsWith(FDir_AppData)) {
// Ensure that we are serving file only inside the Fab2ApprovalAttachments folder
@ -728,7 +595,6 @@ public class MRBController : Controller {
if (!System.IO.File.Exists(sDocument)) {
return null;
//throw new Exception("File not found");
}
return File(sDocument, System.Net.Mime.MediaTypeNames.Application.Octet, attachment.FileName);

View File

@ -1,13 +1,13 @@
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -17,13 +17,8 @@ public class ManagerController : Controller {
UserAccountDMO userDMO = new UserAccountDMO();
AdminDMO adminDMO = new AdminDMO();
TrainingDMO trainingDMO = new TrainingDMO();
LotDispositionDMO ldDMO;
private readonly AppSettings _AppSettings;
public ManagerController(AppSettings appSettings) {
_AppSettings = appSettings;
ldDMO = new LotDispositionDMO(appSettings);
}
LotDispositionDMO ldDMO = new LotDispositionDMO();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public ActionResult Index() {
if ((bool)Session[GlobalVars.IS_MANAGER]) {

View File

@ -1,16 +1,16 @@
using Fab2ApprovalSystem.DMO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -20,15 +20,13 @@ public class PartsRequestController : Controller {
const int WorkflowNumber = 1;
PartsRequestDMO prDMO;
PartsRequestDMO prDMO = new PartsRequestDMO();
UserAccountDMO userDMO = new UserAccountDMO();
WorkflowDMO wfDMO = new WorkflowDMO();
private readonly AppSettings _AppSettings;
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public PartsRequestController(AppSettings appSettings) {
_AppSettings = appSettings;
public PartsRequestController() {
ViewBag.ShowReAssignApprovers = false;
prDMO = new PartsRequestDMO(appSettings);
}
protected ActionResult HandleValidationError(string msg) {
@ -248,7 +246,7 @@ public class PartsRequestController : Controller {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
prDMO.AttachSave(prNumber, userId, file.FileName, file.InputStream);
PartsRequestHelper.AttachSave(_AppSettings, prDMO, prNumber, userId, file.FileName, file.InputStream);
}
}
@ -419,28 +417,14 @@ public class PartsRequestController : Controller {
}
}
protected void SendEmailNotification(string subject, int prNumber, string toEmail, string emailTemplate) {
string senderName = "Parts Request";
EmailNotification en = new EmailNotification(_AppSettings, subject, System.Configuration.ConfigurationManager.AppSettings["EmailTemplatesPath"]);
string[] emailparams = new string[5];
emailparams[0] = prNumber.ToString();
emailparams[1] = prNumber.ToString();
emailparams[2] = GlobalVars.hostURL;
emailparams[3] = "Parts Request";
emailparams[4] = Session[GlobalVars.SESSION_USERNAME].ToString();
String userEmail = toEmail;
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
}
protected void NotifyReAssignment(int prNumber, string email) {
var pr = prDMO.Get(prNumber);
if (pr == null)
return;
SendEmailNotification(
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: String.Format("Parts Request Re-Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: email,
@ -463,11 +447,12 @@ public class PartsRequestController : Controller {
var u = userDMO.GetUserByID(pr.RequestorID);
if ((u != null) && (!String.IsNullOrWhiteSpace(u.Email))) {
SendEmailNotification(
subject: String.Format("Parts Request Completion notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: u.Email,
emailTemplate: "PRCompleted.txt");
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: String.Format("Parts Request Completion notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: u.Email,
emailTemplate: "PRCompleted.txt");
EventLogDMO.Add(new WinEventLog() {
IssueID = prNumber,
@ -487,11 +472,12 @@ public class PartsRequestController : Controller {
var u = userDMO.GetUserByID(pr.OriginatorID);
if ((u != null) && (!String.IsNullOrWhiteSpace(u.Email))) {
SendEmailNotification(
subject: String.Format("Parts Request Rejection notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: u.Email,
emailTemplate: "PRReject.txt");
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: String.Format("Parts Request Rejection notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: u.Email,
emailTemplate: "PRReject.txt");
EventLogDMO.Add(new WinEventLog() {
IssueID = prNumber,
@ -517,11 +503,12 @@ public class PartsRequestController : Controller {
foreach (string email in emailList) {
try {
SendEmailNotification(
subject: String.Format("Parts Request Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: email,
emailTemplate: "PRAssigned.txt");
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: String.Format("Parts Request Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: email,
emailTemplate: "PRAssigned.txt");
} catch (Exception ex) {
HandleException(prNumber, ex, "email=" + email);
}
@ -569,7 +556,8 @@ public class PartsRequestController : Controller {
if (pr == null)
return;
SendEmailNotification(
string username = Session[GlobalVars.SESSION_USERNAME].ToString();
PartsRequestHelper.SendEmailNotification(_AppSettings, username,
subject: String.Format("Parts Request Assignment notice for # {0} - {1}", pr.PRNumber, pr.Title),
prNumber: prNumber,
toEmail: email,

View File

@ -1,19 +1,22 @@
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.ViewModels;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
using Fab2ApprovalSystem.ViewModels;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
[SessionExpireFilter]
public class ReportsController : Controller {
public const String specialNullString = "~NULL~";
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: Export
public ActionResult Index() {
@ -84,14 +87,14 @@ public class ReportsController : Controller {
public SSRSHelper.SSRSClient SetupSSRSHelperClient() {
var useCfgForBindings = false;
if (String.Equals(System.Configuration.ConfigurationManager.AppSettings["SSRSBindingsByConfiguration"], "true", StringComparison.OrdinalIgnoreCase))
if (String.Equals(_AppSettings.SSRSBindingsByConfiguration, "true", StringComparison.OrdinalIgnoreCase))
useCfgForBindings = true;
var c = new SSRSHelper.SSRSClient(
Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SSRSBaseURL"]),
Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SSRSDomain"]),
Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SSRSUsername"]),
Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SSRSPassword"]),
Convert.ToString(_AppSettings.SSRSBaseURL),
Convert.ToString(_AppSettings.SSRSDomain),
Convert.ToString(_AppSettings.SSRSUsername),
Convert.ToString(_AppSettings.SSRSPassword),
useCfgForBindings);
c.Initialize();
@ -99,7 +102,7 @@ public class ReportsController : Controller {
}
private IEnumerable<SSRSHelper.ReportInfo> GetReportList(String docType) {
String folderName = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SSRSFolder"]);
String folderName = Convert.ToString(_AppSettings.SSRSFolder);
if (folderName.EndsWith("/"))
folderName = folderName.TrimEnd('/');
if (!String.IsNullOrWhiteSpace(docType))
@ -181,7 +184,7 @@ public class ReportsController : Controller {
protected String MakeFilename(String reportName) {
String r = "";
var invalidChars = System.IO.Path.GetInvalidFileNameChars();
char[] invalidChars = System.IO.Path.GetInvalidFileNameChars();
foreach (char c in reportName) {
if (invalidChars.Contains(c))
r += '_';

View File

@ -1,3 +1,9 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
@ -6,12 +12,6 @@ using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web.Mvc;
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
@ -22,7 +22,7 @@ public class TrainingController : Controller {
AdminDMO adminDMO = new AdminDMO();
TrainingDMO trainingDMO = new TrainingDMO();
ECN_DMO ecnDMO = new ECN_DMO();
private readonly AppSettings _AppSettings;
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
// GET: Training
public ActionResult Index() {
@ -32,7 +32,7 @@ public class TrainingController : Controller {
public int Create(int ecnId) {
ECN_DMO ecnDMO = new ECN_DMO();
//Delete old training if exists
// Delete old training if exists
int oldTrainingId = trainingDMO.GetTrainingId(ecnId);
if (oldTrainingId != null && oldTrainingId != 0) {
trainingDMO.DeleteTraining(oldTrainingId);
@ -57,34 +57,34 @@ public class TrainingController : Controller {
}
public ActionResult AddUserToTrainingAdHoc(int trainingId, int traineeId, int ecnId) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
//Get ECN
// Get ECN
ECN ecn = ecnDMO.GetECN(ecnId);
//Get User
// Get User
LoginModel user = userDMO.GetUserByID(traineeId);
//Get Training
// Get Training
Training training = trainingDMO.GetTraining(trainingId);
if (ecn != null) {
if (user != null) {
if (training != null) {
if (!trainingDMO.IsUserAssigned(traineeId, trainingId)) {
if (training.DeletedDate == null && !ecn.Deleted) {
//Both the ECN and training still exist
// Both the ECN and training still exist
if (training.CompletedDate != null) {
//Training is completed and now we need to re-open it.
// Training is completed and now we need to re-open it.
trainingDMO.reOpenTraining(trainingId);
int assignmentId = trainingDMO.CreateAssignment(trainingId, traineeId);
NotifyTrainee(traineeId, assignmentId, ecnId, ecn.Title);
return Content("Success");
} else {
//training is still open, just add a user and notify
// training is still open, just add a user and notify
int assignmentId = trainingDMO.CreateAssignment(trainingId, traineeId);
NotifyTrainee(traineeId, assignmentId, ecnId, ecn.Title);
return Content("Success");
}
} else {
//Ecn or training task have been deleted.
// Ecn or training task have been deleted.
return Content("Training or ECN has been deleted.");
}
} else {
@ -116,9 +116,9 @@ public class TrainingController : Controller {
if (training != null) {
if (training.DeletedDate == null && !ecn.Deleted) {
if (training.CompletedDate != null) {
//Training is completed and now we need to re-open it.
// Training is completed and now we need to re-open it.
foreach (int id in groupMemberIds) {
//Check to make sure user doesn't have an active assignment for this training
// Check to make sure user doesn't have an active assignment for this training
if (!trainingDMO.IsUserAssigned(id, trainingId)) {
usersAdded++;
int assignmentId = trainingDMO.CreateAssignment(trainingId, id);
@ -129,9 +129,9 @@ public class TrainingController : Controller {
trainingDMO.reOpenTraining(trainingId);
}
} else {
//training is still open, just add a users and notify
// training is still open, just add a users and notify
foreach (int id in groupMemberIds) {
//Check to make sure user doesn't have an active assignment for this training
// Check to make sure user doesn't have an active assignment for this training
if (!trainingDMO.IsUserAssigned(id, trainingId)) {
usersAdded++;
int assignmentId = trainingDMO.CreateAssignment(trainingId, id);
@ -178,28 +178,8 @@ public class TrainingController : Controller {
public void NotifyTrainee(int userId, int assignmentId, int ecnId, string title) {
try {
string emailSentList = "";
string recipient = userDMO.GetUserEmailByID(userId);
string emailTemplate = "ECNTrainingAssigned.txt";
string userEmail = string.Empty;
string subject = string.Empty;
string senderName = "ECN Training";
subject = "ECN# " + ecnId + " - Training Assignment Notice - " + title;
EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
userEmail = recipient;
string[] emailparams = new string[4];
emailparams[0] = assignmentId.ToString();
emailparams[1] = ecnId.ToString();
emailparams[2] = GlobalVars.hostURL;
//#if(DEBUG)
//string SenderEmail = "MesaFabApproval@infineon.com";
//userEmail = "jonathan.ouellette@infineon.com";
//#endif
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
TrainingHelper.NotifyTrainee(_AppSettings, userId, assignmentId, ecnId, title, recipient);
} catch (Exception e) {
string detailedException = "";
try {
@ -220,13 +200,12 @@ public class TrainingController : Controller {
public ActionResult ViewTrainingDocsPartial(int trainingAssignmentId) {
ViewBag.trainingAssignmentId = trainingAssignmentId;
//IEnumerable<TrainingDocAck> attachments = ecnDMO.GetECNAttachments(ecnNumber);
IEnumerable<TrainingDocAck> attachments = trainingDMO.GetAssignedDocs(trainingAssignmentId);
return PartialView(attachments);
}
public ActionResult AcknowledgeDocument(int trainingAssignmentID, int trainingDocAckID) {
//Check to see if acknowledgement is valid(Security Feature to protect data integrity)
// Check to see if acknowledgement is valid(Security Feature to protect data integrity)
if (trainingDMO.CheckValidDocAck(trainingDocAckID)) {
trainingDMO.AcknowledgeDocument(trainingDocAckID);
bool isFinishedTrainingAssignment = trainingDMO.CheckTrainingAssignmentStatus(trainingAssignmentID);
@ -272,7 +251,7 @@ public class TrainingController : Controller {
public ActionResult TrainingReportsView(int? filterType, string filterValue) {
ViewBag.TrainingGroups = adminDMO.GetTrainingGroups();
IEnumerable<Training> trainingList = trainingDMO.GetAllTrainings();
//Group Filter
// Group Filter
if (filterType == 1 && filterValue != "") {
ViewBag.GroupFilter = filterValue;
List<Training> filteredTraining = new List<Training>();
@ -287,27 +266,27 @@ public class TrainingController : Controller {
trainingList = filteredTraining;
return PartialView(trainingList);
}
//Status Filter
// Status Filter
if (filterType == 2 && filterValue != "") {
List<Training> filteredTraining = new List<Training>();
switch (filterValue) {
case "1":
//Completed
// Completed
filteredTraining = (from a in trainingList where a.Status == true && a.Deleted != true select a).ToList();
break;
case "2":
//In Progress
// In Progress
filteredTraining = (from a in trainingList where a.Status != true && a.Deleted != true select a).ToList();
break;
case "3":
//Cancelled
// Cancelled
filteredTraining = (from a in trainingList where a.Deleted == true select a).ToList();
break;
}
trainingList = filteredTraining;
return PartialView(trainingList);
}
//Default return all.
// Default return all.
else {
return PartialView(trainingList);
}
@ -323,9 +302,8 @@ public class TrainingController : Controller {
ViewBag.ECNTitle = ECNTitle;
ViewBag.trainingID = trainingID;
IEnumerable<TrainingAssignment> trainingAssignments = trainingDMO.GetAllTrainingAssignments(trainingID);
//Calculate Percent Complete:
// Calculate Percent Complete:
float percentComplete = 0;
//float assignmentCount = trainingAssignments.Count();
float assignmentCount = (from a in trainingAssignments where a.Deleted != true select a).Count();
float totalCompleted = 0;
foreach (TrainingAssignment assignment in trainingAssignments) {
@ -351,15 +329,15 @@ public class TrainingController : Controller {
List<TrainingAssignment> filteredTraining = new List<TrainingAssignment>();
switch (statusFilter) {
case "1":
//Completed
// Completed
filteredTraining = (from a in trainingAssignments where a.status == true && a.Deleted != true select a).ToList();
break;
case "2":
//In Progress
// In Progress
filteredTraining = (from a in trainingAssignments where a.status != true && a.Deleted != true select a).ToList();
break;
case "3":
//Cancelled
// Cancelled
filteredTraining = (from a in trainingAssignments where a.Deleted == true select a).ToList();
break;
default:
@ -367,7 +345,6 @@ public class TrainingController : Controller {
break;
}
trainingAssignments = filteredTraining;
//return PartialView(trainingList);
}
return PartialView(trainingAssignments);
@ -427,7 +404,7 @@ public class TrainingController : Controller {
IEnumerable<Training> AllTrainings = trainingDMO.GetTrainings();
ViewBag.TrainingGroups = adminDMO.GetTrainingGroups();
ViewBag.AllGroups = trainingDMO.GetTrainingGroups();
//Group Filter
// Group Filter
if (filterType == 1 && filterValue != "") {
ViewBag.GroupFilter = filterValue;
List<Training> filteredTraining = new List<Training>();
@ -455,8 +432,8 @@ public class TrainingController : Controller {
trainingDMO.DeleteTrainingAssignment(assignmentId);
trainingDMO.DeleteTrainingDocAck(assignmentId);
//Below checks and updates the training status
//TO-DO Put this in its own method.
// Below checks and updates the training status
// TO-DO Put this in its own method.
bool isFinishedTrainingAssignment = trainingDMO.CheckTrainingAssignmentStatus(assignmentId);
if (isFinishedTrainingAssignment) {
@ -479,12 +456,11 @@ public class TrainingController : Controller {
public ActionResult ManuallyExecuteECNTraining(int ecnId, int[] trainingGroupsIn) {
if ((bool)Session[GlobalVars.IS_ADMIN]) {
List<int> newTrainingGroupIds = new List<int>(trainingGroupsIn);
//Get ECN
ECN ecn = ecnDMO.GetECN(ecnId);
if (ecn != null) {
if (ecn.CloseDate != null) {
if (newTrainingGroupIds.Count > 0) {
//Check each assigned group id and see if it's already saved to the ECN
// Check each assigned group id and see if it's already saved to the ECN
List<int> assignedTrainingGroups = trainingDMO.GetECNAssignedTrainingGroups(ecnId);
IEnumerable<int> onlyNewTrainingIds = newTrainingGroupIds.Except(assignedTrainingGroups);
try {
@ -539,15 +515,14 @@ public class TrainingController : Controller {
emailBody += "Please ensure the following users complete their training assignments. ";
emailBody += "Dates in red font identify past due training tasks.</p><br />";
emailBody += "<style>table,th,td{border: 1px solid black;}</style>";
//Get all users set up to receive the training report email.
// Get all users set up to receive the training report email.
List<TrainingReportUser> trainingReportUsers = adminDMO.GetTrainingReportUsers();
List<string> emailList = new List<string>();
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
// Get a list of open trainings
List<Training> openTrainings = trainingDMO.GetAllOpenTrainings();
foreach (Training training in openTrainings) {

View File

@ -5,22 +5,17 @@ using System.Net;
using System.Net.Http;
using System.Web.Http;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
namespace Fab2ApprovalSystem.Controllers;
public class WebAPIController : ApiController {
public TrainingController trainingFunctions = new TrainingController();
public CorrectiveActionController carFunctions;
public CorrectiveActionController carFunctions = new CorrectiveActionController();
public AccountController accountFunctions = new AccountController();
public HomeController homeFunctions;
private readonly AppSettings _AppSettings;
public WebAPIController(AppSettings appSettings) {
_AppSettings = appSettings;
carFunctions = new CorrectiveActionController(appSettings);
homeFunctions = new HomeController(appSettings);
}
public HomeController homeFunctions = new HomeController();
private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
public string Get() {
return "Welcome To Web API";

View File

@ -1,33 +1,29 @@
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Models;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Models;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
namespace Fab2ApprovalSystem.Controllers;
public class WorkflowController : Controller {
//
//
// GET: /Workflow/Details/5
public ActionResult Details(int id) {
return View();
}
//
// GET: /Workflow/Create
public ActionResult Create() {
return View();
}
//
// POST: /Workflow/Create
[HttpPost]
public ActionResult Create(FormCollection collection) {
@ -40,13 +36,11 @@ public class WorkflowController : Controller {
}
}
//
// GET: /Workflow/Edit/5
public ActionResult Edit(int id) {
return View();
}
//
// POST: /Workflow/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection) {
@ -59,13 +53,11 @@ public class WorkflowController : Controller {
}
}
//
// GET: /Workflow/Delete/5
public ActionResult Delete(int id) {
return View();
}
//
// POST: /Workflow/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection) {