Moved System.IO references from DMO classes to Static Helpers

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

View File

@ -1,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);