From b99b7214580445ca0c9440898a036922613374ef Mon Sep 17 00:00:00 2001
From: Mike Phares
Date: Wed, 11 Dec 2024 09:29:01 -0700
Subject: [PATCH] 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
---
Fab2ApprovalSystem/App_Start/BundleConfig.cs | 2 +-
Fab2ApprovalSystem/App_Start/RouteConfig.cs | 5 -
Fab2ApprovalSystem/App_Start/Startup.Auth.cs | 15 -
.../Controllers/AccountController.cs | 8 -
.../Controllers/AdminController.cs | 40 +-
.../Controllers/AuditController.cs | 24 +-
.../Controllers/ChangeControlController.cs | 93 +-
.../Controllers/CorrectiveActionController.cs | 463 ++--------
.../Controllers/ECNController.cs | 819 +-----------------
.../Controllers/HomeController.cs | 100 +--
.../Controllers/LotDispositionController.cs | 243 +-----
.../Controllers/LotTravelerController.cs | 392 +--------
.../Controllers/MRBController.cs | 204 +----
.../Controllers/ManagerController.cs | 17 +-
.../Controllers/PartsRequestController.cs | 78 +-
.../Controllers/ReportsController.cs | 27 +-
.../Controllers/TrainingController.cs | 99 +--
.../Controllers/WebAPIController.cs | 13 +-
.../Controllers/WorkflowController.cs | 22 +-
Fab2ApprovalSystem/DMO/AdminDMO.cs | 77 +-
Fab2ApprovalSystem/DMO/AuditDMO.cs | 142 +--
Fab2ApprovalSystem/DMO/ChangeControlDMO.cs | 263 ------
Fab2ApprovalSystem/DMO/CorrectiveActionDMO.cs | 143 ---
Fab2ApprovalSystem/DMO/ECN_DMO.cs | 81 +-
Fab2ApprovalSystem/DMO/LotDispositionDMO.cs | 295 +------
Fab2ApprovalSystem/DMO/LotTravelerDMO.cs | 251 ------
Fab2ApprovalSystem/DMO/MRB_DMO.cs | 439 +---------
Fab2ApprovalSystem/DMO/MiscDMO.cs | 33 +-
Fab2ApprovalSystem/DMO/PartsRequestDMO.cs | 29 -
Fab2ApprovalSystem/DMO/SAM_DMO.cs | 1 -
Fab2ApprovalSystem/DMO/TrainingDMO.cs | 32 +-
Fab2ApprovalSystem/DMO/UserAccountDMO.cs | 16 -
Fab2ApprovalSystem/DMO/WorkflowDMO.cs | 86 +-
Fab2ApprovalSystem/Fab2ApprovalSystem.csproj | 10 +
Fab2ApprovalSystem/Global.asax.cs | 6 +-
.../Jobs/OOOTrainingReportJob.cs | 6 +-
Fab2ApprovalSystem/Misc/AuditHelper.cs | 88 ++
.../Misc/ChangeControlHelper.cs | 96 ++
.../Misc/CorrectiveActionHelper.cs | 464 ++++++++++
Fab2ApprovalSystem/Misc/ECNHelper.cs | 524 +++++++++++
Fab2ApprovalSystem/Misc/EmailNotification.cs | 76 +-
Fab2ApprovalSystem/Misc/ExcelData.cs | 10 -
Fab2ApprovalSystem/Misc/FTPWrapper.cs | 7 +-
Fab2ApprovalSystem/Misc/Functions.cs | 13 +-
Fab2ApprovalSystem/Misc/GlobalVars.cs | 8 +-
Fab2ApprovalSystem/Misc/HomeHelper.cs | 67 ++
.../Misc/LotDispositionHelper.cs | 167 ++++
Fab2ApprovalSystem/Misc/LotTravelerHelper.cs | 469 ++++++++++
Fab2ApprovalSystem/Misc/MRBHelper.cs | 320 +++++++
Fab2ApprovalSystem/Misc/PartsRequestHelper.cs | 49 ++
Fab2ApprovalSystem/Misc/TrainingHelper.cs | 26 +
Fab2ApprovalSystem/Misc/Zipper.cs | 4 +-
Fab2ApprovalSystem/Misc/ftplib.cs | 55 +-
.../Models/AccountViewModels.cs | 1 -
Fab2ApprovalSystem/Models/AppSettings.cs | 251 ++++--
.../Models/ApprovalLogHistory.cs | 1 -
Fab2ApprovalSystem/Models/Common.cs | 2 -
Fab2ApprovalSystem/Models/ECNModel.cs | 2 -
.../Models/LotDispositionModels.cs | 7 +-
Fab2ApprovalSystem/Models/MRBModels.cs | 6 +-
Fab2ApprovalSystem/Models/WinEventLogModel.cs | 1 -
.../PdfGenerator/PdfViewController.cs | 13 -
Fab2ApprovalSystem/Utilities/FileUtilities.cs | 3 -
.../ViewModels/ChangeControlViewModel.cs | 6 -
Fab2ApprovalSystem/ViewModels/PdfViewModel.cs | 1 -
.../Controller/HomeControllerTests.cs | 3 +
Fab2ApprovalTests/DMO/AccountDMOTests.cs | 4 +
Fab2ApprovalTests/DMO/AdminDMOTests.cs | 2 +
Fab2ApprovalTests/DMO/AuditDMOTests.cs | 3 +
.../DMO/ChangeControlDMOTests.cs | 2 +
.../DMO/CorrectiveActionDMOTests.cs | 3 +
.../DMO/EngChangeNoticeDMOTests.cs | 3 +
.../DMO/LotDispositionDMOTests.cs | 3 +
Fab2ApprovalTests/DMO/LotTravelerDMOTests.cs | 2 +
.../DMO/MatReviewBoardDMOTests.cs | 3 +
Fab2ApprovalTests/DMO/MiscDMOTests.cs | 2 +
Fab2ApprovalTests/DMO/PartsRequestDMOTests.cs | 3 +
Fab2ApprovalTests/DMO/TrainingDMOTests.cs | 2 +
Fab2ApprovalTests/DMO/UserAccountDMOTests.cs | 3 +
Fab2ApprovalTests/DMO/WorkflowDMOTests.cs | 2 +
Fab2ApprovalTests/Fab2ApprovalTests.csproj | 25 +-
.../General/CorrectiveActionTests.cs | 2 +
Fab2ApprovalTests/General/ScheduleTests.cs | 2 +
.../Utilities/EmailUtilitiesTests.cs | 2 +
.../Utilities/UserUtilitiesTests.cs | 3 +
azure-pipelines.yml | 8 +-
86 files changed, 2961 insertions(+), 4432 deletions(-)
create mode 100644 Fab2ApprovalSystem/Misc/AuditHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/ChangeControlHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/CorrectiveActionHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/ECNHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/HomeHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/LotDispositionHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/LotTravelerHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/MRBHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/PartsRequestHelper.cs
create mode 100644 Fab2ApprovalSystem/Misc/TrainingHelper.cs
diff --git a/Fab2ApprovalSystem/App_Start/BundleConfig.cs b/Fab2ApprovalSystem/App_Start/BundleConfig.cs
index 352e365..6f89da1 100644
--- a/Fab2ApprovalSystem/App_Start/BundleConfig.cs
+++ b/Fab2ApprovalSystem/App_Start/BundleConfig.cs
@@ -11,7 +11,7 @@ public class BundleConfig {
"~/Scripts/jquery-ui-{version}.js")
);
- //bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
+ // bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
// "~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
diff --git a/Fab2ApprovalSystem/App_Start/RouteConfig.cs b/Fab2ApprovalSystem/App_Start/RouteConfig.cs
index d572936..4fa2886 100644
--- a/Fab2ApprovalSystem/App_Start/RouteConfig.cs
+++ b/Fab2ApprovalSystem/App_Start/RouteConfig.cs
@@ -20,10 +20,5 @@ public class RouteConfig {
// otherwise MVC generates the wrong form action url
defaults: new { controller = "Home", action = "MyTasks", id = UrlParameter.Optional }
);
- //routes.MapHttpRoute(
- // name: "ApiRoute",
- // routeTemplate: "api/{controller}/{id}",
- // defaults: new { id = RouteParameter.Optional }
- //);
}
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/App_Start/Startup.Auth.cs b/Fab2ApprovalSystem/App_Start/Startup.Auth.cs
index 29dcc8b..9645d0d 100644
--- a/Fab2ApprovalSystem/App_Start/Startup.Auth.cs
+++ b/Fab2ApprovalSystem/App_Start/Startup.Auth.cs
@@ -16,20 +16,5 @@ public partial class Startup {
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
// app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
-
- // Uncomment the following lines to enable logging in with third party login providers
- //app.UseMicrosoftAccountAuthentication(
- // clientId: "",
- // clientSecret: "");
-
- //app.UseTwitterAuthentication(
- // consumerKey: "",
- // consumerSecret: "");
-
- //app.UseFacebookAuthentication(
- // appId: "",
- // appSecret: "");
-
- //app.UseGoogleAuthentication();
}
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Controllers/AccountController.cs b/Fab2ApprovalSystem/Controllers/AccountController.cs
index ca67adc..2f56686 100644
--- a/Fab2ApprovalSystem/Controllers/AccountController.cs
+++ b/Fab2ApprovalSystem/Controllers/AccountController.cs
@@ -38,7 +38,6 @@ public class AccountController : Controller {
public UserManager 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 LinkLoginCallback() {
ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId());
diff --git a/Fab2ApprovalSystem/Controllers/AdminController.cs b/Fab2ApprovalSystem/Controllers/AdminController.cs
index c51d14b..e94e766 100644
--- a/Fab2ApprovalSystem/Controllers/AdminController.cs
+++ b/Fab2ApprovalSystem/Controllers/AdminController.cs
@@ -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 {
}
///
- ///OBSOLETE FUNCTION BELOW FOR THE KENDO TREEVIEW
+ /// OBSOLETE FUNCTION BELOW FOR THE KENDO TREEVIEW
///
private IEnumerable GetRoles_SubRolesList() {
List 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 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 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 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);
diff --git a/Fab2ApprovalSystem/Controllers/AuditController.cs b/Fab2ApprovalSystem/Controllers/AuditController.cs
index 69469c8..96328f5 100644
--- a/Fab2ApprovalSystem/Controllers/AuditController.cs
+++ b/Fab2ApprovalSystem/Controllers/AuditController.cs
@@ -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 results = auditDMO.GetFileNameAndDocument(fileGuid, auditNo);
+ List 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;
}
}
diff --git a/Fab2ApprovalSystem/Controllers/ChangeControlController.cs b/Fab2ApprovalSystem/Controllers/ChangeControlController.cs
index cd2c719..3e1ed71 100644
--- a/Fab2ApprovalSystem/Controllers/ChangeControlController.cs
+++ b/Fab2ApprovalSystem/Controllers/ChangeControlController.cs
@@ -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 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 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 userlist = userDMO.GetAllUsers();
return Json(userlist, JsonRequestBehavior.AllowGet);
diff --git a/Fab2ApprovalSystem/Controllers/CorrectiveActionController.cs b/Fab2ApprovalSystem/Controllers/CorrectiveActionController.cs
index 224223d..fbcda14 100644
--- a/Fab2ApprovalSystem/Controllers/CorrectiveActionController.cs
+++ b/Fab2ApprovalSystem/Controllers/CorrectiveActionController.cs
@@ -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 fileUtilities = new FileUtilities();
- 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 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 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 emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
List 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 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 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 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 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 emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- List 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 emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- List 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 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;
diff --git a/Fab2ApprovalSystem/Controllers/ECNController.cs b/Fab2ApprovalSystem/Controllers/ECNController.cs
index d00035b..aaca0ba 100644
--- a/Fab2ApprovalSystem/Controllers/ECNController.cs
+++ b/Fab2ApprovalSystem/Controllers/ECNController.cs
@@ -1,31 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+
using Dapper;
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Models;
-//using ReportManagement;
using Fab2ApprovalSystem.PdfGenerator;
using Fab2ApprovalSystem.ViewModels;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.IO;
-//using Ionic.Zip;
-using System.IO.Compression;
-using System.Linq;
-using System.Web;
-using System.Web.Mvc;
-
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
[SessionExpireFilter]
public class ECNController : PdfViewController {
+
private const string ECN_PREFIX = "ECN_";
private const string TECN_PREFIX = "TECN_";
private const string ETECN_PREFIX = "ETECN_";
@@ -34,25 +31,18 @@ public class ECNController : PdfViewController {
WorkflowDMO wfDMO = new WorkflowDMO();
TrainingDMO trainingDMO = new TrainingDMO();
UserAccountDMO userDMO = new UserAccountDMO();
- private readonly AppSettings _AppSettings;
+ private readonly AppSettings _AppSettings = GlobalVars.AppSettings;
- public ECNController(AppSettings appSettings) {
- _AppSettings = appSettings;
- }
-
- //
// GET: /ECN/
public ActionResult Index() {
return View();
}
- //
// GET: /ECN/Details/5
public ActionResult Details(int id) {
return View();
}
- //
// GET: /ECN/Create
public ActionResult Create() {
@@ -77,38 +67,25 @@ public class ECNController : PdfViewController {
}
}
- //
-
- //
// GET: /ECN/Edit/5
public ActionResult Edit(int issueID) {
int isITARCompliant = 1;
ECN ecn = new ECN();
- //GlobalVars.DocumentType docType = GlobalVars.DocumentType.ECN;
try {
- //ecn = ecnDMO.GetECN(issueID);
ecn = ecnDMO.GetECNForRead(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
- //if (ecn.IsTECN && ecn.IsEmergencyTECN)
- // docType = GlobalVars.DocumentType.EECN;
-
if (isITARCompliant == 0) // not ITAR Compliant
{
return View("UnAuthorizedAccess");
} else {
- //if (ecn.CloseDate != null)
- //{
- // return RedirectToAction("ReadOnly", new { issueID = issueID });
- //}
if (ecn.Deleted) {
return RedirectToAction("ReadOnly", new { issueID = issueID });
}
if (ecn.CurrentStep >= 1) {
return RedirectToAction("EditApproval", new { issueID = issueID });
} else {
- //ecn = ecnDMO.GetECN(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
if ((ecn.RecordLockIndicator && ecn.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID])) {
return RedirectToAction("ReadOnly", new { issueID = issueID });
@@ -137,7 +114,6 @@ public class ECNController : PdfViewController {
}
}
- //
// POST: /ECN/Edit/5
[HttpPost]
public void Edit(ECN ecn) {
@@ -147,7 +123,6 @@ public class ECNController : PdfViewController {
ecnDMO.UpdateECN(ecn);
;
} catch {
- //return View();
}
}
@@ -209,13 +184,13 @@ public class ECNController : PdfViewController {
throw new Exception(e.Message);
}
}
+
[OutputCache(Duration = 60, VaryByCustom = "host")]
public ActionResult ECNTrainingView(int issueID) {
int isITARCompliant = 1;
ECN ecn = new ECN();
try {
ecn = ecnDMO.GetECNForRead(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
- //bool trainingRequired = ecn.TrainingRequired;
if (isITARCompliant == 0) // not ITAR Compliant
{
return PartialView("UnAuthorizedAccess");
@@ -244,6 +219,7 @@ public class ECNController : PdfViewController {
throw new Exception(e.Message);
}
}
+
public ActionResult Acknowledge(int issueID) {
int isITARCompliant = 1;
ECN ecn = new ECN();
@@ -324,21 +300,6 @@ public class ECNController : PdfViewController {
else
ViewBag.IsOriginator = "false";
- //==============
-
- //if ((ViewBag.IsApprover == "true" && ecn.CancellationInProgress)
- // ||
- // (ViewBag.IsApprover == "true" && ecn.ExpirationInProgress)
- // ||
- // (
- // (ViewBag.IsApprover == "true" && ecn.TECNExtensionState && ecn.CurrentStep > 2)
- // || (ViewBag.IsApprover == "true" && ecn.CurrentStep == 3 && ecn.ConvertedFromNumber != null)
- // )
- // ||
- // (ViewBag.IsApprover == "true")
- // ||
- // (ecn.CurrentStep <= 2 && ecn.CloseDate == null && !ecn.ReSubmitted && ecn.ConvertedFromNumber == null && ecn.TECNExtensionState == false)
- //)
int trainingId = trainingDMO.GetTrainingId(ecn.ECNNumber);
if (trainingId > 0) {
bool? trainingStatus = (trainingDMO.GetTraining(trainingId)).Status;
@@ -365,30 +326,6 @@ public class ECNController : PdfViewController {
} else {
return RedirectToAction("ReadOnly", new { issueID = issueID });
}
-
- //if (ecn.CloseDate != null )
- //{
- // return RedirectToAction("ReadOnly", new { issueID = issueID });
- //}
-
- //if (
- // (ecn.RecordLockIndicator && ecn.RecordLockedBy != (int)Session[GlobalVars.SESSION_USERID])
- // || ((ViewBag.IsApprover == "false") && (ViewBag.IsOriginator == "false"))
- // )
- //{
- // return RedirectToAction("ReadOnly", new { issueID = issueID });
- //}
- //else
- //{
- // ecn = ecnDMO.GetECN(issueID, out isITARCompliant, (int)Session[GlobalVars.SESSION_USERID]);
- // ViewBag.Departments = ecnDMO.GetDepartments();
- // ViewBag.AffectedModules = ecnDMO.GetModules();
- // ViewBag.AffectedAreas = ecnDMO.GetECNAreas();
- // ViewBag.AffectedTechnologies = ecnDMO.GetECNTechnologies();
- // ViewBag.AcknowledgementTrainingByIDs = ecnDMO.GetECNAcknowledgementTrainingBy();
-
- // return View(ecn);
- //}
}
} catch (Exception e) {
string detailedException = "";
@@ -411,7 +348,7 @@ public class ECNController : PdfViewController {
if (files != null) {
int userId = (int)Session[GlobalVars.SESSION_USERID];
foreach (var file in files) {
- returnString = ecnDMO.AttachSave(_AppSettings, ecnNumber, returnString, userId, file.FileName, file.InputStream);
+ returnString = ECNHelper.AttachSave(_AppSettings, ecnDMO, ecnNumber, returnString, userId, file.FileName, file.InputStream);
}
}
return Content(returnString);
@@ -425,18 +362,14 @@ public class ECNController : PdfViewController {
return Json(ecnDMO.GetECNApprovalLogHistory(ecnNumber).ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
- //[AcceptVerbs(HttpVerbs.Post)]
-
[HttpPost]
public void DeleteAttachment(int attachmentID, string fileName, int ecnNumber) {
try {
if (ModelState.IsValid) {
ecnDMO.DeleteECNAttachment(attachmentID);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- //var physicalPath = Path.Combine(@"C:\Websites\Fab2ApprovalAttachments\ECN\" + ecnNumber.ToString(), fileName);
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"ECN\" + ecnNumber.ToString(), fileName);
+ var physicalPath = System.IO.Path.Combine(_AppSettings.AttachmentFolder + @"ECN\" + ecnNumber.ToString(), fileName);
- FileInfo f = new FileInfo(physicalPath);
+ System.IO.FileInfo f = new System.IO.FileInfo(physicalPath);
if (f.Exists)
f.Delete();
@@ -464,17 +397,11 @@ public class ECNController : 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 ECN\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));
}
- ///
- ///
public ActionResult SubmitDocument(int ecnNumber, int documentType, string ecnTypeString) {
int isITARCompliant = 1;
try {
@@ -516,28 +443,11 @@ public class ECNController : PdfViewController {
try {
int appoverCount = ecnDMO.SubmitTECNExtensionDocument(ecnNumber, (int)Session[GlobalVars.SESSION_USERID], documentType, extensionDate);
- // Update the TECN Extension History
- try {
- //ecnDMO.TECNExtensionLog(ecnNumber, extensionDate);
- } catch (Exception e) {
- string detailedException = "";
- try {
- detailedException = e.InnerException.ToString();
- } catch {
- detailedException = e.Message;
- }
- string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ecnNumber.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
- Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n TECNExtensionLog\r\n" + ecnNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
- EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "ECN", OperationType = "Error", Comments = "TECNExtensionLog - " + exceptionString });
-
- }
-
if (appoverCount > 0)
NotifyApprovers(ecnNumber, (byte)GlobalVars.WorkFLowStepNumber.Step1, documentType, ecnTypeString);
else {
// automaically approve current step (Step 1) beacuase there are no approvers in step 1 and move to the next step of approval
Approve(ecnNumber, (byte)GlobalVars.WorkFLowStepNumber.Step1, "", documentType, ecnTypeString); // this is the Submit Level Approval
-
}
if (Request.IsAjaxRequest()) {
@@ -558,8 +468,6 @@ public class ECNController : PdfViewController {
}
}
- ///
- ///
public ActionResult SubmitDocument_EmergencyTECN(int ecnNumber, int documentType) {
int isITARCompliant = 0;
try {
@@ -588,9 +496,6 @@ public class ECNController : PdfViewController {
}
}
- ///
- ///
- ///
public void Approve(int ecnNumber, byte currentStep, string comments, int documentType, string ecnTypeString) {
try {
bool lastStep = false;
@@ -600,13 +505,12 @@ public class ECNController : PdfViewController {
while (lastApprover && !lastStep) {
currentStep++;
- //Changed this next line of code to not pass the currently approving user. This prevents a user from approving multiple steps at once. An undesired function.
+ // Changed this next line of code to not pass the currently approving user. This prevents a user from approving multiple steps at once. An undesired function.
lastApprover = wfDMO.Approve(_AppSettings, ecnNumber, currentStep, comments, out lastStep, 11111111, documentType, ecn.WorkFlowNumber);
NotifyApprovers(ecnNumber, currentStep, documentType, ecnTypeString);
}
- //#if(!DEBUG)
// only execute at the last step of the Approval loop
if (lastApprover && lastStep) {
NotifySubmitter(ecn.ECNNumber, ecnTypeString);
@@ -620,7 +524,7 @@ public class ECNController : PdfViewController {
// Set the cancellation date for the TECN
ecnDMO.CancelECN(ecn.ConvertedFromNumber);
- //copy the TECN to the new ECN folder
+ // copy the TECN to the new ECN folder
GenerateECNPdfDifferentLocation((int)ecn.ConvertedFromNumber, ecnNumber);
}
@@ -644,7 +548,6 @@ public class ECNController : PdfViewController {
}
}
- //#endif
} catch (Exception e) {
string detailedException = "";
@@ -660,16 +563,14 @@ public class ECNController : PdfViewController {
}
}
- void PostApproval(int ecnNumber, int documentType) {
+ private void PostApproval(int ecnNumber, int documentType) {
try {
ECNPdf ecn = new ECNPdf();
// Generate the PDF version of the ECN form and Approval log
if (GenerateECNPdf(ecnNumber, out ecn)) {
// Zip up all the attached files along with the Pdf version of the ECN form and the Approval Log
- if (CreateZip(ecn)) {
- //Documentum.Process(_AppSettings.AttachmentFolder + "\\ECNZipped\\" + ecnNumber.ToString() + ".zip");
-
+ if (ECNHelper.CreateZip(_AppSettings, ecn, @User.Identity.Name)) {
} else {
// TODO How to recreate and send the files to documentum
throw new Exception("Problems while generating the ZIP file. Please contact the system Administrator");
@@ -696,71 +597,14 @@ public class ECNController : PdfViewController {
}
}
- //void PostApprovalForECNsDerivedFromTECN(int ecnNumber, int tecnNumber)
- //{
- // try
- // {
- // // Generate the PDF version of the ECN form and Approval log
- // string sourceFile = _AppSettings.AttachmentFolder + "ECN\\" + tecnNumber + "\\ECNForm_" + tecnNumber + ".pdf";
- // string destFile = _AppSettings.AttachmentFolder + "ECN\\" + ecnNumber + "\\ECNForm_" + tecnNumber + ".pdf";
-
- // GenerateECNPdfDifferentLocation(ecnNumber, tecnNumber);
-
- // }
-
- // catch(Exception e)
- // {
- // string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ecnNumber.ToString() + " " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
- // Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ECN - PostApprovalForECNsDerivedFromTECN \r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
- // EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "ECN", OperationType = "Error", Comments = "PostApprovalForECNsDerivedFromTECN - " + exceptionString });
- // throw e;
- // }
-
- //}
-
public void NotifySubmitter(int ecnNumber, string ecnTypeString) {
try {
string emailSentList = "";
ECN ecn = ecnDMO.GetECN(ecnNumber);
- //List emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- //List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
- int ecnCreatedById = ecn.OriginatorID;
- string ecnCreatedByEmail = MiscDMO.GetEmail(ecnCreatedById);
-
- string emailTemplate = "ECNApproved.txt";
- string userEmail = string.Empty;
- string subject = string.Empty;
- string senderName = ecnTypeString;
-
- subject = ecnTypeString + " Approval notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
-
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[4];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = ecnTypeString;
- userEmail = ecnCreatedByEmail;
- //#if(DEBUG)
- //string SenderEmail = "MesaFabApproval@infineon.com";
- //userEmail = "jonathan.ouellette@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- //en.SendNotificationEmail(emailTemplate, SenderEmail, senderName, userEmail, null, subject, emailparams);
- emailSentList = ecnCreatedByEmail;
-
+ emailSentList = ECNHelper.NotifySubmitter(_AppSettings, ecnNumber, ecnTypeString, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Approvers for Step " + ":" + emailSentList });
} 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 {
@@ -774,50 +618,17 @@ public class ECNController : PdfViewController {
throw e;
}
}
+
public void NotifyAdmin(int ecnNumber, string ecnTypeString) {
try {
string emailSentList = "";
ECN ecn = ecnDMO.GetECN(ecnNumber);
- //List emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- //List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
IEnumerable ecnAdminIDs = MiscDMO.GetUserIDsBySubRoleID(383);
foreach (int id in ecnAdminIDs) {
- string ecnCreatedByEmail = MiscDMO.GetEmail(id);
-
- string emailTemplate = "ECNApproved.txt";
- string userEmail = string.Empty;
- string subject = string.Empty;
- string senderName = ecnTypeString;
-
- subject = ecnTypeString + " Approval notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
-
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[4];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = ecnTypeString;
- userEmail = ecnCreatedByEmail;
- //#if(DEBUG)
- //string SenderEmail = "MesaFabApproval@infineon.com";
- //userEmail = "jonathan.ouellette@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- //en.SendNotificationEmail(emailTemplate, SenderEmail, senderName, userEmail, null, subject, emailparams);
- emailSentList = ecnCreatedByEmail;
-
+ emailSentList = ECNHelper.NotifyAdmin(_AppSettings, ecnNumber, ecnTypeString, ecn, id);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Approvers for Step " + ":" + emailSentList });
} 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) {
@@ -838,45 +649,12 @@ public class ECNController : PdfViewController {
try {
string emailSentList = "";
ECN ecn = ecnDMO.GetECN(ecnNumber);
- //List emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
-
- string emailTemplate = "ECNAssigned.txt";
- string userEmail = string.Empty;
- string subject = string.Empty;
- string senderName = ecnTypeString;
-
- subject = ecnTypeString + " Assignment notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
- foreach (string email in emailIst) {
-
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[4];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = ecnTypeString;
- userEmail = email;
- //#if(DEBUG)
- //string SenderEmail = "MesaFabApproval@infineon.com";
- //userEmail = "jonathan.ouellette@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- //en.SendNotificationEmail(emailTemplate, SenderEmail, senderName, userEmail, null, subject, emailparams);
- emailSentList += email + ",";
- }
-
+ emailSentList = ECNHelper.NotifyApprovers(_AppSettings, ecnNumber, ecnTypeString, emailSentList, ecn, emailIst);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} 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 {
@@ -912,30 +690,8 @@ public class ECNController : PdfViewController {
public void NotifyRejectionToOrginator(int issueID, string ecnTypeString, string comments) {
List emailIst = ecnDMO.GetRejectionOrginatorEmailList(@issueID).Distinct().ToList();
ECN ecn = ecnDMO.GetECN(issueID);
-
- string emailTemplate = "ECNReject.txt";
- string userEmail = string.Empty;
- string subject = ecnTypeString + " Rejection";
- string senderName = ecnTypeString;
-
- foreach (string email in emailIst) {
- subject = ecnTypeString + " Rejection notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[6];
- emailparams[0] = issueID.ToString();
- emailparams[1] = issueID.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = Session[GlobalVars.SESSION_USERNAME].ToString();
- emailparams[4] = ecnTypeString;
- emailparams[5] = comments;
- userEmail = email;
- //#if(DEBUG)
- // userEmail = GlobalVars.SENDER_EMAIL;
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- }
-
+ string username = Session[GlobalVars.SESSION_USERNAME].ToString();
+ string userEmail = ECNHelper.NotifyRejectionToOrginator(_AppSettings, issueID, ecnTypeString, comments, emailIst, ecn, username);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Rejection: " + userEmail });
} catch { }
@@ -944,28 +700,8 @@ public class ECNController : PdfViewController {
public void NotifyTECNExtensionRejectionToOrginator(int issueID, string ecnTypeString) {
List emailIst = ecnDMO.GetRejectionOrginatorEmailList(@issueID).Distinct().ToList();
ECN ecn = ecnDMO.GetECN(issueID);
-
- string emailTemplate = "TECNExtensionReject.txt";
- string userEmail = string.Empty;
- string subject = ecnTypeString + " Rejection";
- string senderName = ecnTypeString;
-
- foreach (string email in emailIst) {
- subject = ecnTypeString + " Extension Rejection notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[5];
- emailparams[0] = issueID.ToString();
- emailparams[1] = issueID.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = Session[GlobalVars.SESSION_USERNAME].ToString();
- emailparams[4] = ecnTypeString;
- userEmail = email;
- //#if(DEBUG)
- // userEmail = GlobalVars.SENDER_EMAIL;
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- }
+ string username = Session[GlobalVars.SESSION_USERNAME].ToString();
+ string userEmail = ECNHelper.NotifyTECNExtensionRejectionToOrginator(_AppSettings, issueID, ecnTypeString, emailIst, ecn, username);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Rejection: " + userEmail });
@@ -1010,6 +746,7 @@ public class ECNController : PdfViewController {
throw new Exception(e.Message);
}
}
+
public void RecallDocument(int ecnNumber, byte currentStep, string comments, int docType, string ecnTypeString) {
try {
// TODO
@@ -1022,8 +759,6 @@ public class ECNController : PdfViewController {
if (Session[GlobalVars.SESSION_USERID] != null) {
NotifyApproversForRecall(ecnNumber, currentStep, docType, ecnTypeString, comments);
wfDMO.Recall(ecnNumber, currentStep, comments, (int)Session[GlobalVars.SESSION_USERID], docType);
-
- //NotifyRejectionToOrginator(ecnNumber, ecnTypeString, comments);
} else {
Response.Redirect("~/Account/Login");
}
@@ -1045,7 +780,6 @@ public class ECNController : PdfViewController {
public void ReAssignApproverByAdmin(int issueID, int reAssignApproverFrom, int reAssignApproverTo, byte step, int docType, string ecnTypeString) {
var email = "";
try {
-
email = wfDMO.ReAssignApproval(issueID, reAssignApproverFrom, reAssignApproverTo, step, docType);
} catch (Exception e) {
string detailedException = "";
@@ -1061,26 +795,7 @@ public class ECNController : PdfViewController {
}
ECN ecn = ecnDMO.GetECN(issueID);
- string emailTemplate = "ECNReAssigned.txt";
- string userEmail = string.Empty;
- string subject;
- string senderName = ecnTypeString;
-
- subject = ecnTypeString + " Re-Assignment" + " - ECN #" + ecn.ECNNumber + ", - " + ecn.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;
- //#if(DEBUG)
- // userEmail = "rkotian1@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ ECNHelper.ReAssignApproverByAdmin(_AppSettings, issueID, ecnTypeString, email, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
@@ -1127,37 +842,13 @@ public class ECNController : PdfViewController {
}
ECN ecn = ecnDMO.GetECN(issueID);
- string emailTemplate = "ECNReAssigned.txt";
- string userEmail = string.Empty;
- string subject = ecnTypeString + " Re-Assignment";
- string senderName = ecnTypeString;
-
- subject = ecnTypeString + " Re-Assignment" + " - Email would be sent to " + email + " for Number " + ecn.ECNNumber + ", - " + ecn.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;
- //#if(DEBUG)
- // userEmail = GlobalVars.SENDER_EMAIL;
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ ECNHelper.ReAssignApproval(_AppSettings, issueID, ecnTypeString, email, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "ReAssign Approver: " + email });
} catch { }
}
- #region
- #endregion
-
public JsonResult GetAllUsersList() {
- //var userList = ldDMO.GetApprovedApproversList(issueID, currentStep);
- //return Json(userList, JsonRequestBehavior.AllowGet);
-
UserAccountDMO userDMO = new UserAccountDMO();
IEnumerable userlist = userDMO.GetAllActiveUsers();
return Json(userlist, JsonRequestBehavior.AllowGet);
@@ -1181,55 +872,21 @@ public class ECNController : PdfViewController {
throw new Exception(e.Message);
}
ECN ecn = ecnDMO.GetECN(issueID);
-
- string emailTemplate = "ECNAssigned.txt";
- string userEmail = string.Empty;
- string subject = ecnTypeString + " Assignment";
- string senderName = ecnTypeString;
-
- 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 = ecnTypeString + "Assignment notice for Number " + ecn.ECNNumber + ", - " + ecn.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;
- //#if(DEBUG)
- // userEmail = "rkotian1@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- emailSentList += email + ",";
-
- }
-
- }
+ emailSentList = ECNHelper.AddAdditionalApproval(_AppSettings, issueID, ecnTypeString, emailSentList, emailArray, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = issueID, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
} catch { }
}
public bool GenerateECNPdf(int ecnNumber, out ECNPdf ecn) {
- //DateTime? expDt;
try {
string outputFileName = "";
-
ecn = ecnDMO.GetECNPdf(ecnNumber);
- //expDate = ecn.ExpirationDate;
- //extensionDate = ecn.ExtensionDate;
-
outputFileName = ecnNumber.ToString() + ".pdf";
string ecnFolderPath = _AppSettings.AttachmentFolder + "ECN\\" + ecnNumber.ToString();
- //string ecnFolderPath = @"C:\Users\Ouellette\Desktop";
- DirectoryInfo di = new DirectoryInfo(ecnFolderPath);
+ System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(ecnFolderPath);
// create the folder for the ECN if it does not exist
if (!di.Exists)
di.Create();
@@ -1253,14 +910,11 @@ public class ECNController : PdfViewController {
string outputFileName = "";
ecn = ecnDMO.GetECNPdf(ecnNumber);
- //expDate = ecn.ExpirationDate;
- //extensionDate = ecn.ExtensionDate;
-
outputFileName = ecnNumber.ToString() + ".pdf";
string ecnFolderPath = _AppSettings.AttachmentFolder + "ECN\\" + folderName.ToString();
- DirectoryInfo di = new DirectoryInfo(ecnFolderPath);
+ System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(ecnFolderPath);
// create the folder for the ECN if it does not exist
if (!di.Exists)
di.Create();
@@ -1280,8 +934,6 @@ public class ECNController : PdfViewController {
public ActionResult PrintECNPdf(int ecnNumber) {
ECNPdf ecn;
try {
- //string outputFileName = "";
-
ecn = ecnDMO.GetECNPdf(ecnNumber);
// To render a PDF instead of an HTML, all we need to do is call ViewPdf instead of View. This
// requires the controller to be inherited from MyController instead of MVC's Controller.
@@ -1291,44 +943,11 @@ public class ECNController : PdfViewController {
ecn = null;
return Content("");
}
-
- //return true;
}
public void NotifyEmergencyTECNApproval(int ecnNumber, DateTime? expDate) {
- string ecnFolderPath = _AppSettings.AttachmentFolder + "E-TECNZipped\\" + ETECN_PREFIX + ecnNumber.ToString() + ".zip";
-
- string emailSentList = "";
-
- List emailIst = MiscDMO.GetEmergencyTECNApprovalNotifyList(ecnNumber).Distinct().ToList();
-
- string emailTemplate = "ETECNApproved.txt";
- string userEmail = string.Empty;
- string subject = "E-TECN Approved";
- string senderName = "E-TECN";
-
ECN ecn = ecnDMO.GetECN(ecnNumber);
- subject = "E-TECN Approved notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[5];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = "E-TECN";
- emailparams[4] = expDate.ToString();
-
- //#if(DEBUG)
- // userEmail = "rkotian1@infineon.com";
- //#endif
-
- if (IsITAR(ecn))
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
- else
- en.SendNotificationEmailWithAttachment(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, ecnFolderPath, emailparams);
-
- //emailSentList += email + ",";
- emailSentList = String.Join(", ", emailIst.Distinct().ToArray());
-
+ string emailSentList = ECNHelper.NotifyEmergencyTECNApproval(_AppSettings, ecnNumber, expDate, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "E-TECN", OperationType = "Email", Comments = "Approvers for Step 1:" + emailSentList });
} catch { }
@@ -1336,32 +955,7 @@ public class ECNController : PdfViewController {
public void NotifyApproversForCancellation(int ecnNumber, byte currentStep, int documentType, string ecnTypeString) {
ECN ecn = ecnDMO.GetECN(ecnNumber);
- string emailSentList = "";
-
- //List emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
-
- string emailTemplate = "TECNCancellationApproval.txt";
- string userEmail = string.Empty;
- string subject = ecnTypeString + " Cancellation Approval Required - " + ecnNumber + " for " + ecn.Title + ", Cancellation initiated on :" + ecn.CancellationDate;
- string senderName = ecnTypeString;
-
- foreach (string email in emailIst) {
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[4];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = ecnTypeString;
- userEmail = email;
- //#if(DEBUG)
- // userEmail = "rkotian1@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- emailSentList += email + ",";
- }
-
+ string emailSentList = ECNHelper.NotifyApproversForCancellation(_AppSettings, ecnNumber, currentStep, documentType, ecnTypeString, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
@@ -1369,34 +963,7 @@ public class ECNController : PdfViewController {
public void NotifyApproversForRecall(int ecnNumber, byte currentStep, int documentType, string ecnTypeString, string recallComments) {
ECN ecn = ecnDMO.GetECN(ecnNumber);
- string emailSentList = "";
-
- //List emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
- emailIst.Add("Jeanne.McIntyre@infineon.com");
- emailIst.Add("Jonathan.Ouellette@infineon.com");
- string emailTemplate = "ECNRecallApproval.txt";
- string userEmail = string.Empty;
- string subject = ecnTypeString + " Recalled - " + ecnNumber + " for " + ecn.Title + ", Recall initiated on :" + DateTime.Now.ToString();
- string senderName = ecnTypeString;
-
- foreach (string email in emailIst) {
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[5];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = ecnTypeString;
- emailparams[4] = recallComments;
- userEmail = email;
- //#if(DEBUG)
- // userEmail = "rkotian1@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- emailSentList += email + ",";
- }
-
+ string emailSentList = ECNHelper.NotifyApproversForRecall(_AppSettings, ecnNumber, currentStep, documentType, ecnTypeString, recallComments, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
@@ -1404,129 +971,24 @@ public class ECNController : PdfViewController {
public void NotifyApproversForExpiration(int ecnNumber, byte currentStep, int documentType, string ecnTypeString) {
ECN ecn = ecnDMO.GetECN(ecnNumber);
- string emailSentList = "";
-
- //List emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
-
- string emailTemplate = "TECNExpirationApproval.txt";
- string userEmail = string.Empty;
- string subject = " TECN Expiration Approval Reqquired - " + ecnTypeString + "# " + ecnNumber + " for " + ecn.Title + ", Expired:" + ecn.ExpirationDate;
- string senderName = ecnTypeString;
-
- foreach (string email in emailIst) {
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[4];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = ecnTypeString;
- userEmail = email;
-#if (DEBUG)
- userEmail = GlobalVars.SENDER_EMAIL;
-#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- emailSentList += email + ",";
- }
-
+ string emailSentList = ECNHelper.NotifyApproversForExpiration(_AppSettings, ecnNumber, currentStep, documentType, ecnTypeString, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Email", Comments = "Approvers for Step " + currentStep.ToString() + ":" + emailSentList });
} catch { }
}
public void NotifyTECNCancellation(int ecnNumber, string ecnFolderPath) {
- //string ecnFolderPath = _AppSettings.AttachmentFolder + "TECNCancelledZipped\\" + TECN_PREFIX + ecnNumber.ToString() + ".zip";
ECN ecn = ecnDMO.GetECN(ecnNumber);
- string emailSentList = "";
-
- List emailIst = MiscDMO.GetTECNCancelledApprovalNotifyList(ecnNumber).Distinct().ToList();
List notificationUserList = ecnDMO.GetTECNNotificationUsers().ToList();
- foreach (int userId in notificationUserList) {
- string email = userDMO.GetUserEmailByID(userId);
- if (email != null && !emailIst.Contains(email))
- emailIst.Add(email);
- }
-
- string emailTemplate = "TECNCancelled.txt";
- string userEmail = string.Empty;
- string subject = string.Empty;
- if (ecn.CancellationApprovalDate == null) {
- subject = "TECN Cancellation Initiated Notice - " + ecnNumber + " for " + ecn.Title + ", Cancellation Initiated on:" + DateTime.Now;
- } else {
- subject = "TECN Cancellation Approved Notice - " + ecnNumber + " for " + ecn.Title + ", Cancelled:" + ecn.CancellationApprovalDate;
- }
- string senderName = "ECN";
-
- //foreach (string email in emailIst)
- //{
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[5];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = "TECN";
- emailparams[4] = DateTime.Now.ToString();
- //userEmail = email;
-
-#if (DEBUG)
- userEmail = GlobalVars.SENDER_EMAIL;
-#endif
-
- //en.SendNotificationEmailWithAttachment(emailTemplate, "rkotian1@irf.com", senderName, userEmail, null, subject, ecnFolderPath, emailparams);
- if (IsITAR(ecn))
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
- else
- en.SendNotificationEmailWithAttachment(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, ecnFolderPath, emailparams);
- //emailSentList += email + ",";
- emailSentList = String.Join(", ", emailIst.Distinct().ToArray());
-
- //}
-
+ string emailSentList = ECNHelper.NotifyTECNCancellation(_AppSettings, userDMO, ecnNumber, ecnFolderPath, ecn, notificationUserList);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "E-TECN", OperationType = "Email", Comments = "Approvers for Cancellation :" + emailSentList });
} catch { }
}
public void NotifyTECNAutoCancellation(int ecnNumber, int tecnNumber, List attachments) {
- //string ecnFolderPath = _AppSettings.AttachmentFolder + "TECNCancelledZipped\\" + TECN_PREFIX + ecnNumber.ToString() + ".zip";
ECN ecn = ecnDMO.GetECN(tecnNumber);
- string emailSentList = "";
-
- List emailIst = MiscDMO.GetTECNCancelledApprovalNotifyList(ecnNumber).Distinct().ToList();
-
- string emailTemplate = "TECNAutoCancelled.txt";
- string userEmail = string.Empty;
- string subject = string.Empty;
- subject = "TECN Conversion and Cancellation Notice - " + tecnNumber + " for " + ecn.Title + ", Converted on:" + DateTime.Now;
- string senderName = "ECN";
-
- //foreach (string email in emailIst)
- //{
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[6];
- emailparams[0] = tecnNumber.ToString();
- emailparams[1] = tecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = "TECN";
- emailparams[4] = DateTime.Now.ToString();
- emailparams[5] = ecnNumber.ToString();
- //userEmail = email;
-
-#if (DEBUG)
- userEmail = GlobalVars.SENDER_EMAIL;
-#endif
-
- //en.SendNotificationEmailWithAttachment(emailTemplate, "rkotian1@irf.com", senderName, userEmail, null, subject, ecnFolderPath, emailparams);
- if (IsITAR(ecn))
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
- else
- en.SendNotificationEmailWithAttachments(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, attachments, emailparams);
- //emailSentList += email + ",";
- emailSentList = String.Join(", ", emailIst.Distinct().ToArray());
-
- //}
-
+ string emailSentList = ECNHelper.NotifyTECNAutoCancellation(_AppSettings, ecnNumber, tecnNumber, attachments, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "E-TECN", OperationType = "Email", Comments = "Approvers for Cancellation :" + emailSentList });
} catch { }
@@ -1534,127 +996,15 @@ public class ECNController : PdfViewController {
public void NotifyTECNExpiration(int ecnNumber, string ecnFolderPath) {
ECN ecn = ecnDMO.GetECN(ecnNumber);
- //string ecnFolderPath = _AppSettings.AttachmentFolder + "TECNExpiredZipped\\" + TECN_PREFIX + ecnNumber.ToString() + ".zip";
-
- string emailSentList = "";
-
- List emailIst = MiscDMO.GetEmergencyTECNApprovalNotifyList(ecnNumber).Distinct().ToList();
-
- string emailTemplate = "TECNExpired.txt";
- string userEmail = string.Empty;
- string subject = "TECN Expiration Approved Notice - " + ecnNumber + " for " + ecn.Title + ", Expired:" + ecn.ExpirationDate;
- string senderName = "ECN";
-
- //foreach (string email in emailIst)
- //{
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[5];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = "TECN";
- emailparams[4] = ecn.ExpirationDate.Value.ToShortDateString();
- //userEmail = email;
-
- //#if(DEBUG)
- // userEmail = "rkotian1@infineon.com";
- //#endif
-
- //en.SendNotificationEmailWithAttachment(emailTemplate, "rkotian1@infineon.com", senderName, userEmail, null, subject, ecnFolderPath, emailparams);
- if (IsITAR(ecn))
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
- else
- en.SendNotificationEmailWithAttachment(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, ecnFolderPath, emailparams);
-
- //emailSentList += email + ",";
- emailSentList = String.Join(", ", emailIst.Distinct().ToArray());
-
- //}
-
+ string emailSentList = ECNHelper.NotifyTECNExpiration(_AppSettings, ecnNumber, ecnFolderPath, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "TECN", OperationType = "Email", Comments = "Approvers for Expiration:" + emailSentList });
} catch { }
}
- bool CreateZip(ECNPdf ecn) {
- try {
- string sourceDirectory = _AppSettings.AttachmentFolder + "ECN\\" + ecn.ECNNumber.ToString() + "\\";
- string outputFullFilePath = "";
-
- string outputFileName;
- if (ecn.IsTECN) {
- if (ecn.ExtensionDate != null)
- outputFileName = TECN_PREFIX + ecn.ECNNumber.ToString() + "_Extension.zip";
- else
- outputFileName = TECN_PREFIX + ecn.ECNNumber.ToString() + ".zip";
-
- outputFullFilePath = _AppSettings.AttachmentFolder + "\\ECNZipped\\" + outputFileName;
- } else if (ecn.IsEmergencyTECN) // Transfer it to different folder , coz documentum does not need to have a Workflow Item created for Emergency TECN
- {
- outputFileName = ETECN_PREFIX + ecn.ECNNumber.ToString() + ".zip";
- outputFullFilePath = _AppSettings.AttachmentFolder + "\\E-TECNZipped\\" + outputFileName;
- } else {
- outputFileName = ECN_PREFIX + ecn.ECNNumber.ToString() + ".zip";
- outputFullFilePath = _AppSettings.AttachmentFolder + "\\ECNZipped\\" + outputFileName;
- }
-
- Zipper zip = new Zipper();
- zip.CreateZip(outputFullFilePath, sourceDirectory);
- } catch (Exception ex) {
- EventLogDMO.Add(new WinEventLog() { IssueID = ecn.ECNNumber, UserID = @User.Identity.Name, DocumentType = ecn.IsECN ? "ECN" : (ecn.IsEmergencyTECN ? "E-TECN" : "TECN"), OperationType = "Error", Comments = ex.Message });
- return false;
- }
-
- return true;
- }
-
public void AddEECNApproval(int ecnNumber, byte step, string engUserIDs, string OpUserIDs) {
- // it is always going to be the first step
- step = 1;
- string emailSentList = "";
- var emailArray = "";
- try {
- emailArray = wfDMO.AddEECNApproval(ecnNumber, step, (int)GlobalVars.DocumentType.EECN, engUserIDs, OpUserIDs);
- } catch (Exception e) {
- string detailedException = "";
- try {
- detailedException = e.InnerException.ToString();
- } catch {
- detailedException = e.Message;
- }
- string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ecnNumber.ToString() + " Step:" + step + " " + " Userid:" + engUserIDs + " - " + OpUserIDs + " - " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
- Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n AddEECNApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
- EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "E-TECN ", OperationType = "Error", Comments = "AddEECNApproval - " + exceptionString });
- throw new Exception(e.Message);
- }
ECN ecn = ecnDMO.GetECN(ecnNumber);
- string emailTemplate = "ECNAssigned.txt";
- string userEmail = string.Empty;
- string subject = "E-TECN Assignment";
- string senderName = "E-TECN";
-
- string[] emailIst = emailArray.Split(new char[] { '~' });
- foreach (string email in emailIst) {
- if (email.Length > 0) {
- subject = "E-TECN Assignment notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
- EmailNotification en = new EmailNotification(_AppSettings, subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
- string[] emailparams = new string[4];
- emailparams[0] = ecnNumber.ToString();
- emailparams[1] = ecnNumber.ToString();
- emailparams[2] = GlobalVars.hostURL;
- emailparams[3] = "E-TECN";
-
- userEmail = email;
- //#if(DEBUG)
- // userEmail = "rkotian1@infineon.com";
- //#endif
-
- en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
- emailSentList += email + ",";
-
- }
-
- }
+ string emailSentList = ECNHelper.AddEECNApproval(_AppSettings, @User.Identity.Name, wfDMO, ecnNumber, out step, engUserIDs, OpUserIDs, ecn);
try {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "E-TECN", OperationType = "Email", Comments = "Additonal Approver: " + emailSentList });
} catch { }
@@ -1693,6 +1043,7 @@ public class ECNController : PdfViewController {
throw new Exception(e.Message);
}
}
+
public void DeleteDocumentBySubmitter(int ecnNumber, string ecnTypeString) {
ECN ecn = ecnDMO.GetECN(ecnNumber);
int submitterId = ecn.OriginatorID;
@@ -1716,8 +1067,6 @@ public class ECNController : PdfViewController {
}
public ActionResult ReSubmitDocument(int ecnNumber, int documentType, string ecnTypeString, string oldECNTypeString, string descriptionOfChange, string reasonForChange, string categoryId = "") {
- // Update ECN Type in the ECN table
-
ECN ecn = new ECN();
int isITARCompliant = 1;
@@ -1738,18 +1087,13 @@ public class ECNController : PdfViewController {
if (isITARCompliant == 0) // not ITAR Compliant
{
- // the content gets evaluated on the client side
return Content("ITAR");
} else {
- //TODO - COPY ATTACHMENTS
Functions.CopyAttachments(_AppSettings, ecnNumber, newECNNumber);
- // Log into the Approval Log
try {
ecn = ecnDMO.GetECN(ecnNumber);
- //ecnDMO.UpdateECNType(ecnNumber, ecnTypeString);
-
ApprovalLogDMO.Add(new ApprovalLog {
IssueID = ecnNumber,
DocumentTypeID = documentType,
@@ -1770,7 +1114,6 @@ public class ECNController : PdfViewController {
}
- // Add to the Document Change Log
try {
ECNTypeChangeLogDMO.Add(new ECNTypeChangeLog {
ECNNumber = ecnNumber,
@@ -1788,22 +1131,9 @@ public class ECNController : PdfViewController {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ecnNumber.ToString() + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, @User.Identity.Name + "\r\n ReSubmitDocument (ECNTypeChangeLogDMO)\r\n" + ecnNumber.ToString() + "\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = ecnTypeString, OperationType = "Error", Comments = "ReSubmitDocument (ECNTypeChangeLogDMO)" + exceptionString });
-
}
- //if (appoverCount > 0)
- //{
- // NotifyApprovers(newECNNumber, (byte)GlobalVars.WorkFLowStepNumber.Step1, documentType, ecnTypeString);
- //}
- //else
- //{
- // // automaically approve current step (Step 1) beacuase there are no approvers in step 1 and move to the next step of approval
- // Approve(newECNNumber, (byte)GlobalVars.WorkFLowStepNumber.Step1, "", documentType, ecnTypeString); // this is the Submit Level Approval
-
- //}
-
if (Request.IsAjaxRequest()) {
- // the content gets evaluated on the client side
return Content("Redirect~" + newECNNumber);
} else
@@ -1824,15 +1154,10 @@ public class ECNController : PdfViewController {
}
public ActionResult PCRBExists(int pcrb) {
-
return Content(ecnDMO.PCRBExists(pcrb).ToString());
}
public ActionResult CancelDocument(int ecnNumber, byte currentStep, int documentType, string ecnTypeString) {
- // log the cancelled event
- //EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = docTypeString, OperationType = "Cancelled", Comments = "Cancelled the document" });
- // Set the ECN Current step to the last step of the document type, which is the execution step
-
bool lastApproverAndLastStep = false;
int appoverCount = ecnDMO.SubmitForCancellation(ecnNumber, (byte)GlobalVars.WorkFLowStepNumber.Step1, (int)Session[GlobalVars.SESSION_USERID], documentType, ecnTypeString, (int)GlobalVars.TECNExpirationCancellation.Cancellation);
if (appoverCount > 0) {
@@ -1840,14 +1165,9 @@ public class ECNController : PdfViewController {
} else // TODO Automatically close the
{
lastApproverAndLastStep = ApproveCancellation(ecnNumber, currentStep, "", documentType, ecnTypeString);
- // automaically approve current step (Step 1) because there are no approvers in step 1 and move to the next step of approval
- //Approve(ecnNumber, currentStep, "", documentType, ecnTypeString); // this is the Submit Level Approval
-
}
- // if there are approvers dont wait for it to finish the approval loop for sending cancel notications.
if (!lastApproverAndLastStep) {
- // send notifications
try {
lastApproverAndLastStep = true;
@@ -1862,7 +1182,6 @@ public class ECNController : PdfViewController {
outputFullFilePath = _AppSettings.AttachmentFolder + "\\TECNCancelledZipped\\" + outputFileName;
- // Create the zipped package
Zipper zip = new Zipper();
zip.CreateZip(outputFullFilePath, sourceDirectory);
NotifyTECNCancellation(ecnNumber, outputFullFilePath);
@@ -1877,11 +1196,11 @@ public class ECNController : PdfViewController {
trainingDMO.DeleteTraining(trainingId);
if (Request.IsAjaxRequest()) {
- // the content gets evaluated on the client side
return Content("Redirect");
} else
return Content("Invalid");
}
+
public ActionResult CancelDocumentBySubmitter(int ecnNumber, byte currentStep, int documentType, string ecnTypeString) {
return Content("Redirect");
}
@@ -1911,7 +1230,6 @@ public class ECNController : PdfViewController {
outputFullFilePath = _AppSettings.AttachmentFolder + "\\TECNCancelledZipped\\" + outputFileName;
- // Create the zipped package
Zipper zip = new Zipper();
zip.CreateZip(outputFullFilePath, sourceDirectory);
NotifyTECNCancellation(ecnNumber, outputFullFilePath);
@@ -1974,6 +1292,7 @@ public class ECNController : PdfViewController {
ecnDMO.ReleaseLockOnDocument(-1, issueID);
}
}
+
public void ReleaseLockOnDocumentAdmin(int issueID) {
try {
ecnDMO.ReleaseLockOnDocument(-1, issueID);
@@ -1986,71 +1305,21 @@ public class ECNController : PdfViewController {
}
public FileResult DownloadFile(string attachmentID, string ecnNumber) {
- //fileName = "ECNForm_71132.pdf";
-
string fileName = ecnDMO.GetFileName(attachmentID);
string ecnFolderPath = _AppSettings.AttachmentFolder + "ECN\\" + ecnNumber.ToString();
- var sDocument = Path.Combine(ecnFolderPath, fileName);
+ var sDocument = System.IO.Path.Combine(ecnFolderPath, fileName);
var FDir_AppData = _AppSettings.AttachmentFolder;
if (!sDocument.StartsWith(FDir_AppData)) {
- // Ensure that we are serving file only inside the Fab2ApprovalAttachments folder
- // and block requests outside like "../web.config"
throw new HttpException(403, "Forbidden");
}
if (!System.IO.File.Exists(sDocument)) {
return null;
- //throw new Exception("File not found");
}
return File(sDocument, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
- /////
- /////
- /////
- //void CreateZipFile()
- //{
- // try
- // {
- // using (ZipFile zip = new ZipFile())
- // {
- // // note: this does not recurse directories!
- // String[] filenames = System.IO.Directory.GetFiles(@"C:\Documents\Approval System\ECN-TECN");
-
- // // This is just a sample, provided to illustrate the DotNetZip interface.
- // // This logic does not recurse through sub-directories.
- // // If you are zipping up a directory, you may want to see the AddDirectory() method,
- // // which operates recursively.
- // foreach (String filename in filenames)
- // {
- // Console.WriteLine("Adding {0}...", filename);
-
- // ZipEntry e = zip.AddFile(filename);
- // e.Comment = "Added by Cheeso's CreateZip utility.";
- // }
-
- // zip.Comment = String.Format("This zip archive was created by the CreateZip example application on machine '{0}'",
- // System.Net.Dns.GetHostName());
-
- // zip.Save(@"C:\Documents\Approval System\ECN-TECN\New.Zip");
- // }
-
- // }
- // catch (System.Exception ex1)
- // {
- // System.Console.Error.WriteLine("exception: " + ex1);
- // }
-
- //}
-
- bool IsITAR(ECN ecn) {
- if (ecn.IsRH && !ecn.IsAU && !ecn.IsIndustrial && !ecn.IsMA) {
- return true;
- } else
- return false;
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Controllers/HomeController.cs b/Fab2ApprovalSystem/Controllers/HomeController.cs
index a04752a..75d2d1e 100644
--- a/Fab2ApprovalSystem/Controllers/HomeController.cs
+++ b/Fab2ApprovalSystem/Controllers/HomeController.cs
@@ -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 data = ldDMO.GetLotDispositions();
IEnumerable 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 emailList = new List();
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 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 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 emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
- //List 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 {
diff --git a/Fab2ApprovalSystem/Controllers/LotDispositionController.cs b/Fab2ApprovalSystem/Controllers/LotDispositionController.cs
index d062ded..ffc5ee6 100644
--- a/Fab2ApprovalSystem/Controllers/LotDispositionController.cs
+++ b/Fab2ApprovalSystem/Controllers/LotDispositionController.cs
@@ -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 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 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 {
///
/// Updates the lot tables
///
-
[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 lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList();
- //IEnumerable 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
///
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 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 emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
List 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 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);
diff --git a/Fab2ApprovalSystem/Controllers/LotTravelerController.cs b/Fab2ApprovalSystem/Controllers/LotTravelerController.cs
index 1acd43f..b1503d7 100644
--- a/Fab2ApprovalSystem/Controllers/LotTravelerController.cs
+++ b/Fab2ApprovalSystem/Controllers/LotTravelerController.cs
@@ -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));
}
- ///
- ///
- ///
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 emailIst = LotTravDMO.GetRejectionOrginatorEmailList(workRequestID).Distinct().ToList();
int isITARCompliant = 0;
+ string username = Session[GlobalVars.SESSION_USERNAME].ToString();
+ List 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 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 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 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 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 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 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 lotlist = MiscDMO.SearchLTLots(searchText, searchBy).Select(x => x.LotNumber).ToList();
-
- //IEnumerable 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);
}
- ///
- /// /
- ///
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);
diff --git a/Fab2ApprovalSystem/Controllers/MRBController.cs b/Fab2ApprovalSystem/Controllers/MRBController.cs
index 4fef16b..c90d591 100644
--- a/Fab2ApprovalSystem/Controllers/MRBController.cs
+++ b/Fab2ApprovalSystem/Controllers/MRBController.cs
@@ -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 lotlist = MiscDMO.SearchLots(searchText, searchBy);
List lotlist = MiscDMO.SearchLots(searchText, searchBy).Select(x => x.LotNumber).ToList();
return Json(lotlist, JsonRequestBehavior.AllowGet);
}
@@ -169,46 +145,8 @@ public class MRBController : Controller {
///
/// Updates the lot tables
///
-
[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 {
///
/// Deletes record from the lot table
///
-
[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 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 options = new List();
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 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 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);
diff --git a/Fab2ApprovalSystem/Controllers/ManagerController.cs b/Fab2ApprovalSystem/Controllers/ManagerController.cs
index 3d42577..f0e9fe7 100644
--- a/Fab2ApprovalSystem/Controllers/ManagerController.cs
+++ b/Fab2ApprovalSystem/Controllers/ManagerController.cs
@@ -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]) {
diff --git a/Fab2ApprovalSystem/Controllers/PartsRequestController.cs b/Fab2ApprovalSystem/Controllers/PartsRequestController.cs
index ddcad1d..aaeb3a7 100644
--- a/Fab2ApprovalSystem/Controllers/PartsRequestController.cs
+++ b/Fab2ApprovalSystem/Controllers/PartsRequestController.cs
@@ -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,
diff --git a/Fab2ApprovalSystem/Controllers/ReportsController.cs b/Fab2ApprovalSystem/Controllers/ReportsController.cs
index 1a4a5f2..2c7caea 100644
--- a/Fab2ApprovalSystem/Controllers/ReportsController.cs
+++ b/Fab2ApprovalSystem/Controllers/ReportsController.cs
@@ -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 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 += '_';
diff --git a/Fab2ApprovalSystem/Controllers/TrainingController.cs b/Fab2ApprovalSystem/Controllers/TrainingController.cs
index 626a5a9..755abae 100644
--- a/Fab2ApprovalSystem/Controllers/TrainingController.cs
+++ b/Fab2ApprovalSystem/Controllers/TrainingController.cs
@@ -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 attachments = ecnDMO.GetECNAttachments(ecnNumber);
IEnumerable 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 trainingList = trainingDMO.GetAllTrainings();
- //Group Filter
+ // Group Filter
if (filterType == 1 && filterValue != "") {
ViewBag.GroupFilter = filterValue;
List filteredTraining = new List();
@@ -287,27 +266,27 @@ public class TrainingController : Controller {
trainingList = filteredTraining;
return PartialView(trainingList);
}
- //Status Filter
+ // Status Filter
if (filterType == 2 && filterValue != "") {
List filteredTraining = new List();
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 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 filteredTraining = new List();
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 AllTrainings = trainingDMO.GetTrainings();
ViewBag.TrainingGroups = adminDMO.GetTrainingGroups();
ViewBag.AllGroups = trainingDMO.GetTrainingGroups();
- //Group Filter
+ // Group Filter
if (filterType == 1 && filterValue != "") {
ViewBag.GroupFilter = filterValue;
List filteredTraining = new List();
@@ -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 newTrainingGroupIds = new List(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 assignedTrainingGroups = trainingDMO.GetECNAssignedTrainingGroups(ecnId);
IEnumerable 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.
";
emailBody += "";
- //Get all users set up to receive the training report email.
+ // Get all users set up to receive the training report email.
List trainingReportUsers = adminDMO.GetTrainingReportUsers();
List emailList = new List();
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 openTrainings = trainingDMO.GetAllOpenTrainings();
foreach (Training training in openTrainings) {
diff --git a/Fab2ApprovalSystem/Controllers/WebAPIController.cs b/Fab2ApprovalSystem/Controllers/WebAPIController.cs
index b6d6544..4d558e4 100644
--- a/Fab2ApprovalSystem/Controllers/WebAPIController.cs
+++ b/Fab2ApprovalSystem/Controllers/WebAPIController.cs
@@ -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";
diff --git a/Fab2ApprovalSystem/Controllers/WorkflowController.cs b/Fab2ApprovalSystem/Controllers/WorkflowController.cs
index 7f0765f..667dcc2 100644
--- a/Fab2ApprovalSystem/Controllers/WorkflowController.cs
+++ b/Fab2ApprovalSystem/Controllers/WorkflowController.cs
@@ -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) {
diff --git a/Fab2ApprovalSystem/DMO/AdminDMO.cs b/Fab2ApprovalSystem/DMO/AdminDMO.cs
index d51b97d..de0090c 100644
--- a/Fab2ApprovalSystem/DMO/AdminDMO.cs
+++ b/Fab2ApprovalSystem/DMO/AdminDMO.cs
@@ -71,8 +71,6 @@ public class AdminDMO {
if (!lookup.TryGetValue(parent.RoleID, out role)) {
lookup.Add(parent.RoleID, role = parent);
}
- //if (role.RoleID == null)
- // role.SubRoles = new List();
role.SubRoles.Add(child);
return role;
},
@@ -80,7 +78,7 @@ public class AdminDMO {
return data;
}
- ///
+
public List GetUserSubRoles(int userId) {
DynamicParameters parameters = new();
parameters.Add("@UserId", userId);
@@ -130,14 +128,17 @@ public class AdminDMO {
}
}
+
#if !NET8
public List GetTrainingReportUsers() {
List CurrentReportUsers = (from a in FabApprovalDB.TrainingReportUsers select a).ToList();
return CurrentReportUsers;
}
#else
- public List GetTrainingReportUsers() => throw new NotImplementedException();
+ public List GetTrainingReportUsers() =>
+ throw new NotImplementedException();
#endif
+
#if !NET8
public List GetTECNNotificationUsers() {
List currentTECNNotificationUsers = (from a in FabApprovalDB.TECNNotificationsUsers select a).ToList();
@@ -164,8 +165,6 @@ public class AdminDMO {
public void TrainingReportDeleteUser(int userId) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@UserID", userId);
db.Execute("DeleteUserFromTrainingReport", parameters, commandType: CommandType.StoredProcedure);
@@ -174,25 +173,14 @@ public class AdminDMO {
public void TECNExpirationDeleteUser(int userId) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@UserID", userId);
db.Execute("DeleteUserFromTECNReport", parameters, commandType: CommandType.StoredProcedure);
return;
}
+
#if !NET8
public List GetTrainingGroups() {
- //StringBuilder sql = new StringBuilder();
- //sql.Append(
- // "SELECT 'TrainingGroupID', TrainingGroupName " +
- // "FROM TrainingGroups " +
- // "ORDER BY TrainingGroupID ");
-
- //db.Open();
- //var lookup = new Dictionary();
- ////List data = this.db.Query(sql.ToString()
- //return this.db.Query(sql.ToString()).ToList();
var TrainingGroups = from a in FabApprovalDB.TrainingGroups select a;
List GroupsToReturn = TrainingGroups.ToList();
@@ -201,16 +189,14 @@ public class AdminDMO {
public void AddNewTrainingGroup(string groupName) {
TrainingGroup existing = null;
- //Check to see that the group name doesn't exist.
+ // Check to see that the group name doesn't exist.
try {
existing = (from a in FabApprovalDB.TrainingGroups where a.TrainingGroupName == groupName select a).FirstOrDefault();
} catch {
- // string test = "";
}
if (existing == null) {
- //string sql = new StringBuilder();
string sql = "INSERT INTO TrainingGroups (TrainingGroupName) " + "VALUES ('" + groupName + "') ";
this.db.Open();
@@ -234,6 +220,7 @@ public class AdminDMO {
} catch {
}
}
+
#if !NET8
public List GetTrainingGroupMembers(int GroupID) {
return (from a in FabApprovalDB.TrainingGroupMembers where a.TrainingGroupID == GroupID select a).ToList();
@@ -259,34 +246,10 @@ public class AdminDMO {
throw new Exception("The user already exists in this training group.");
}
-
- //if (existing == null)
- //{
- // //string sql = new StringBuilder();
-
- // string sql = "INSERT INTO TrainingGroupMembers (TrainingGroupID, UserID, FullName) " + "VALUES ('" + groupId + "','" + userId + "','" + userFullName + "') ";
-
- // try
- // {
- // this.db.Open();
- // this.db.Execute(sql);
- // }
- // catch(Exception e)
- // {
- // return;
- // }
- // return;
- //}
- //else
- //{
- // return;
-
}
#endif
public void DeleteFromGroup(int userId, int groupId) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@GroupID", groupId);
parameters.Add("@UserID", userId);
@@ -298,35 +261,35 @@ public class AdminDMO {
public void DeleteUser(UserAccountDMO userDMO, TrainingDMO trainingDMO, LoginModel loginModel) {
if (loginModel != null) {
userDMO.DeleteUser(loginModel);
- //Remove open trainings
- //Get a list of all user assigned trainings.
+ // Remove open trainings
+ // Get a list of all user assigned trainings.
List trainingAssignments = trainingDMO.GetTrainingAssignmentsByUserID(loginModel.UserID);
- //Go Through that list.
+ // Go Through that list.
foreach (var trainingAssignment in trainingAssignments) {
- //Delete Any document acknowledgements.
+ // Delete Any document acknowledgements.
trainingDMO.DeleteTrainingDocAck(trainingAssignment.ID);
- //Delete the training assignment itself
+ // Delete the training assignment itself
trainingDMO.DeleteTrainingAssignment(trainingAssignment.ID);
- //Check the parent Training task to set to to complete if applicable.
+ // Check the parent Training task to set to to complete if applicable.
if (trainingDMO.CheckTrainingStatus(trainingAssignment.ID)) {
int TrainingID = trainingAssignment.TrainingID;
- //Set Training status to complete
+ // Set Training status to complete
trainingDMO.UpdateTrainingStatus(TrainingID);
}
}
- //Remove user from any Training Groups
+ // Remove user from any Training Groups
DeleteUserFromAllTrainingGroups(loginModel.UserID);
- //Remove User from training report notifications
+ // Remove User from training report notifications
TrainingReportDeleteUser(loginModel.UserID);
- //Remove user from TECN Expiration Notifications
+ // Remove user from TECN Expiration Notifications
TECNExpirationDeleteUser(loginModel.UserID);
- //Get user subroles
+ // Get user subroles
List userSubRoles = GetUserSubRoles(loginModel.UserID);
- //Delete user from any subroles
+ // Delete user from any subroles
foreach (var userSubRole in userSubRoles) {
DeleteUserRoles(userSubRole.SubRoleID, loginModel.UserID.ToString());
}
diff --git a/Fab2ApprovalSystem/DMO/AuditDMO.cs b/Fab2ApprovalSystem/DMO/AuditDMO.cs
index 37ba686..a39dfcf 100644
--- a/Fab2ApprovalSystem/DMO/AuditDMO.cs
+++ b/Fab2ApprovalSystem/DMO/AuditDMO.cs
@@ -17,8 +17,6 @@ using System.Transactions;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Utilities;
-using System.IO;
-
namespace Fab2ApprovalSystem.DMO;
public class AuditDMO {
@@ -31,8 +29,6 @@ public class AuditDMO {
public Audit InsertAudit(Audit audit) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@AuditNo", value: audit.AuditNo, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@OriginatorID", audit.OriginatorID);
@@ -45,14 +41,11 @@ public class AuditDMO {
public Audit GetAuditItem(int auditNo, int userID) {
Audit audit = new();
- //isITAR = 2;
+ // isITAR = 2;
DynamicParameters parameters = new();
parameters.Add("@AuditNo", value: auditNo);
parameters.Add("@UserID", userID);
- //parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
-
- //audit = this.db.Query("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure)) {
audit = multipleResultItems.Read().SingleOrDefault();
@@ -76,29 +69,15 @@ public class AuditDMO {
audit.AuditedAreaIDs.AddRange(auditorAreas);
}
}
- //FabApprovalSystemEntitiesAll auditDb = new FabApprovalSystemEntitiesAll();
-
- //var auditedStandardIDs = (from a in auditDb.C_8DAuditedStandardByAudit where a.AuditNo == audit.AuditNo select a.AuditedStandardID).ToList();
-
- //foreach (var id in auditedStandardIDs)
- //{
- // audit.AuditedStandardIDs.Add(id);
- //}
-
return audit;
}
public Audit GetAuditItemReadOnly(int auditNo, int userID) {
Audit audit = new();
- //isITAR = 2;
-
DynamicParameters parameters = new();
parameters.Add("@AuditNo", value: auditNo);
parameters.Add("@UserID", userID);
- //parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
-
- //audit = this.db.Query("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("_8DGetAuditItemReadOnly", parameters, commandType: CommandType.StoredProcedure)) {
audit = multipleResultItems.Read().SingleOrDefault();
@@ -164,11 +143,9 @@ public class AuditDMO {
try {
parameters.Add("AuditNo", audit.AuditNo);
parameters.Add("Title", audit.AuditTitle);
- //parameters.Add("AuditTypeID", audit.AuditTypeID);
parameters.Add("AuditDate", audit.AuditDate);
parameters.Add("AuditStatus", audit.AuditStatus);
parameters.Add("AuditScore", audit.AuditScore);
- //parameters.Add("AuditedAreaID", audit.AuditedAreaID);
parameters.Add("Auditees", audit.Auditees);
db.Execute("_8DUpdateAudit", param: parameters, commandType: CommandType.StoredProcedure);
@@ -218,31 +195,6 @@ public class AuditDMO {
throw new Exception(ex.Message + " " + ex.InnerException);
}
}
- //FabApprovalSystemEntitiesAll auditDb = new FabApprovalSystemEntitiesAll();
-
- //List auditedStandards = audit.AuditedStandardIDs;
- //if (auditedStandards != null)
- //{
- // foreach (int auditedStandard in auditedStandards)
- // {
- // var auditStandardExists = (from a in auditDb.C_8DAuditedStandardByAudit where a.AuditNo == audit.AuditNo && a.AuditedStandardID == auditedStandard select a).ToList();
- // if (auditStandardExists.Count() <= 0)
- // {
- // C_8DAuditedStandardByAudit standard = new C_8DAuditedStandardByAudit
- // {
- // AuditNo = audit.AuditNo,
- // AuditedStandardID = auditedStandard
- // };
- // auditDb.C_8DAuditedStandardByAudit.Add(standard);
- // auditDb.SaveChanges();
- // }
-
- // }
- //}
-
- //parameters = new DynamicParameters();
- //parameters.Add("AuditNo", audit.AuditNo);
- //this.db.Execute("_8DUpdateAuditScore", parameters, commandType: CommandType.StoredProcedure);
}
public IEnumerable GetAuditReportAttachments(int auditNo) {
@@ -450,7 +402,7 @@ public class AuditDMO {
}
audit = GetAuditItem(issueID, userId);
- //transform audit users from string to list, delimited by a comma.
+ // transform audit users from string to list, delimited by a comma.
if (audit.Auditees == null) {
result.AuditeeNames = new List();
} else {
@@ -468,7 +420,7 @@ public class AuditDMO {
result.IsAdmin = true;
}
if ((audit.RecordLockIndicator && audit.RecordLockedBy != userId)
- || audit.AuditStatus != 0) //open
+ || audit.AuditStatus != 0) // open
{
result.RedirectToAction = true;
}
@@ -486,33 +438,16 @@ public class AuditDMO {
return result;
}
- public List GetFileNameAndDocument(string fileGuid, int auditNo) {
- List results = new();
- string fileName = GetAuditReportAttachmentFileName(fileGuid);
- string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
-
- string ecnFolderPath = _AppSettings.AttachmentFolder + "Audit\\" + auditNo.ToString();
- string sDocument = Path.Combine(ecnFolderPath, fileGuid + fileExtension);
-
- string FDir_AppData = _AppSettings.AttachmentFolder;
- if (!sDocument.StartsWith(FDir_AppData)) {
- sDocument = string.Empty;
- }
- results.Add(fileName);
- results.Add(sDocument);
- return results;
- }
-
public Audit InsertAndGetAudit(CorrectiveActionDMO caDMO, AuditFindings data, int userID) {
Audit audit = new();
InsertAuditFindingsItem(data);
audit = GetAuditItem(data.AuditNo, userID);
- //Transfer Finding Details to CA
+ // Transfer Finding Details to CA
if (data.CANo != 0) {
CorrectiveAction ca = caDMO.GetCAItem(data.CANo, userID);
ca.CATitle = data.Title;
- ca.CASourceID = 1;//Audit
+ ca.CASourceID = 1; // Audit
caDMO.UpdateCorrectiveAction(ca);
}
@@ -524,11 +459,11 @@ public class AuditDMO {
UpdateAuditFindingsItem(data);
audit = GetAuditItem(data.AuditNo, userID);
- //Transfer Finding Details to CA
+ // Transfer Finding Details to CA
if (data.CANo != 0) {
CorrectiveAction ca = caDMO.GetCAItem(data.CANo, userID);
ca.CATitle = data.Title;
- ca.CASourceID = 1;//Audit
+ ca.CASourceID = 1; // Audit
caDMO.UpdateCorrectiveAction(ca);
}
@@ -542,72 +477,9 @@ public class AuditDMO {
return audit;
}
- public void AuditReportAttachSave(int auditNo, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"Audit\" + auditNo;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"Audit\" + auditNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- AuditReportAttachment attach = new() {
- AuditNo = auditNo,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId
-
- };
-
- //ccDMO.InsertCCAttachment(attach);
- InsertAuditReportAttachment(attach);
- }
-
- public void SaveAndInsert(int caFindingsID, int auditNo, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"Audit\" + auditNo;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"Audit\" + auditNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- AuditReportAttachment attach = new() {
- CAFindingsID = caFindingsID,
- AuditNo = auditNo,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId
-
- };
-
- InsertAuditReportAttachment(attach);
- }
-
public string NotifyActionItemOwner(int issueID, DateTime? dueDate, int? responsibleOwnerID, string emailTemplatesPath) {
string emailSentList = "";
- //List emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
string email = MiscDMO.GetEmail(responsibleOwnerID);
string emailTemplate = "CorrectiveActionFindingAssigned.txt";
diff --git a/Fab2ApprovalSystem/DMO/ChangeControlDMO.cs b/Fab2ApprovalSystem/DMO/ChangeControlDMO.cs
index abb7561..474ef96 100644
--- a/Fab2ApprovalSystem/DMO/ChangeControlDMO.cs
+++ b/Fab2ApprovalSystem/DMO/ChangeControlDMO.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.IO;
using System.Linq;
using System.Transactions;
@@ -16,12 +15,8 @@ namespace Fab2ApprovalSystem.DMO;
public class ChangeControlDMO {
- private readonly AppSettings _AppSettings;
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
- public ChangeControlDMO(AppSettings appSettings) =>
- _AppSettings = appSettings;
-
internal ChangeControlViewModel InsertChangeControl(ChangeControlViewModel cc) {
DynamicParameters parameters = new();
parameters.Add("@PlanNumber", value: cc.PlanNumber, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
@@ -40,42 +35,14 @@ public class ChangeControlDMO {
parameters.Add("@planNumber", planNumber);
parameters.Add("@UserID", userID);
- //parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
- //cc = this.db.Query("CCGetChangeControl", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
-
using (var multipleResultItems = db.QueryMultiple("CCGetChangeControl", parameters, commandType: CommandType.StoredProcedure)) {
ccItem = multipleResultItems.Read().SingleOrDefault();
List gens = multipleResultItems.Read().ToList();
- //if (ccItem != null && gens != null)
- //{
- // if (gens.Count > 0)
- // ccItem.GenerationIDs.AddRange(gens);
- //}
-
List logis = multipleResultItems.Read().ToList();
- //if (ccItem != null && logis != null)
- //{
- // if (logis.Count > 0)
- // ccItem.LogisticsIDs.AddRange(logis);
- //}
-
List procs = multipleResultItems.Read().ToList();
- //if (ccItem != null && procs != null)
- //{
- // if (procs.Count > 0)
- // ccItem.ProcessIDs.AddRange(procs);
- //}
-
- //var parts = multipleResultItems.Read().ToList();
- //if (ccItem != null && parts != null)
- //{
- // if (parts.Count > 0)
- // ccItem.PartNumberIDs.AddRange(parts);
- //}
-
}
return ccItem;
}
@@ -87,49 +54,14 @@ public class ChangeControlDMO {
parameters.Add("@planNumber", planNumber);
parameters.Add("@UserID", userID);
- //parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
- //cc = this.db.Query("CCGetChangeControl", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
-
using (var multipleResultItems = db.QueryMultiple("CCGetChangeControlRead", parameters, commandType: CommandType.StoredProcedure)) {
ccItem = multipleResultItems.Read().SingleOrDefault();
List gens = multipleResultItems.Read().ToList();
- //if (ccItem != null && gens != null)
- //{
- // if (gens.Count > 0)
- // ccItem.GenerationIDs.AddRange(gens);
- //}
-
List logis = multipleResultItems.Read().ToList();
- //if (ccItem != null && logis != null)
- //{
- // if (logis.Count > 0)
- // ccItem.LogisticsIDs.AddRange(logis);
- //}
-
List procs = multipleResultItems.Read().ToList();
- //if (ccItem != null && procs != null)
- //{
- // if (procs.Count > 0)
- // ccItem.ProcessIDs.AddRange(procs);
- //}
-
- //var tools = multipleResultItems.Read().ToList();
- //if (ccItem != null && tools != null)
- //{
- // if (tools.Count > 0)
- // ccItem.ToolTypeIDs.AddRange(tools);
- //}
-
- //var parts = multipleResultItems.Read().ToList();
- //if (ccItem != null && parts != null)
- //{
- // if (parts.Count > 0)
- // ccItem.PartNumberIDs.AddRange(parts);
- //}
-
canViewITAR = parameters.Get("@CanViewITAR");
}
@@ -147,13 +79,6 @@ public class ChangeControlDMO {
return db.Query("CCGetLogistics", commandType: CommandType.StoredProcedure).ToList();
}
- ///
- //internal List GetToolTypes()
- //{
- // var parameters = new DynamicParameters();
- // return this.db.Query("CCGetToolTypes", commandType: CommandType.StoredProcedure).ToList();
- //}
-
internal List GetProcesses() {
DynamicParameters parameters = new();
return db.Query("CCGetProcesses", commandType: CommandType.StoredProcedure).ToList();
@@ -175,73 +100,12 @@ public class ChangeControlDMO {
parameters.Add("@IsMedical", model.IsMedical);
parameters.Add("@IsRadHard", model.IsRadHard);
parameters.Add("@Notes", model.Notes);
- //parameters.Add("@PartNumbers", model.PartNumbers);
parameters.Add("@IsAutomotive", model.IsAutomotive);
- //parameters.Add("@ToolTypes", model.ToolTypes);
parameters.Add("@Title", model.Title);
parameters.Add("@ReasonForChange", model.ReasonForChange);
parameters.Add("@ChangeDescription", model.ChangeDescription);
db.Execute("CCUpdateChangeControl", param: parameters, commandType: CommandType.StoredProcedure);
- //parameters = new DynamicParameters();
- //parameters.Add("@PlanNumber", model.PlanNumber);
- //this.db.Execute("CCDeleteGenerations", parameters, commandType: CommandType.StoredProcedure);
- //List gens = model.GenerationIDs;
- //if (gens != null)
- //{
- // foreach (int genId in gens)
- // {
- // parameters = new DynamicParameters();
- // parameters.Add("@PlanNumber", model.PlanNumber);
- // parameters.Add("@GenerationID", genId);
- // this.db.Execute("CCInsertGeneration", parameters, commandType: CommandType.StoredProcedure);
- // }
- //}
-
- //parameters = new DynamicParameters();
- //parameters.Add("@PlanNumber", model.PlanNumber);
- //this.db.Execute("CCDeleteLogistics", parameters, commandType: CommandType.StoredProcedure);
- //List logistics = model.LogisticsIDs;
- //if (logistics != null)
- //{
- // foreach (int logisticsId in logistics)
- // {
- // parameters = new DynamicParameters();
- // parameters.Add("@PlanNumber", model.PlanNumber);
- // parameters.Add("@LogisticsID", logisticsId);
- // this.db.Execute("CCInsertLogistics", parameters, commandType: CommandType.StoredProcedure);
- // }
- //}
-
- //parameters = new DynamicParameters();
- //parameters.Add("@PlanNumber", model.PlanNumber);
- //this.db.Execute("CCDeleteProcesses", parameters, commandType: CommandType.StoredProcedure);
- //List processes = model.ProcessIDs;
- //if (processes != null)
- //{
- // foreach (int processId in processes)
- // {
- // parameters = new DynamicParameters();
- // parameters.Add("@PlanNumber", model.PlanNumber);
- // parameters.Add("@ProcessID", processId);
- // this.db.Execute("CCInsertProcess", parameters, commandType: CommandType.StoredProcedure);
- // }
- //}
-
- //parameters = new DynamicParameters();
- //parameters.Add("@PlanNumber", model.PlanNumber);
- //this.db.Execute("CCDeletePartNumbers", parameters, commandType: CommandType.StoredProcedure);
- //if (model.PartNumbers != null)
- //{
- // string[] parts = model.PartNumbers.Split(new char[] { ',' });
- // foreach (string part in parts)
- // {
- // parameters = new DynamicParameters();
- // parameters.Add("@PlanNumber", model.PlanNumber);
- // parameters.Add("@PartNumber", part);
- // this.db.Execute("CCInsertPartNumber", parameters, commandType: CommandType.StoredProcedure);
- // }
- //}
transaction.Complete();
} catch (Exception ex) {
transaction.Dispose();
@@ -330,7 +194,6 @@ public class ChangeControlDMO {
parameters.Add("@UserID", userID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
- //ccMeeting = this.db.Query("CCGetMeeting", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("CCGetMeetingRead", parameters, commandType: CommandType.StoredProcedure)) {
ccMeeting = multipleResultItems.Read().SingleOrDefault();
List pcrvalues = multipleResultItems.Read().ToList();
@@ -351,7 +214,6 @@ public class ChangeControlDMO {
parameters.Add("@UserID", userID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
- //ccMeeting = this.db.Query("CCGetMeetingRead", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("CCGetMeetingRead", parameters, commandType: CommandType.StoredProcedure)) {
ccMeeting = multipleResultItems.Read().SingleOrDefault();
List pcrvalues = multipleResultItems.Read().ToList();
@@ -376,7 +238,6 @@ public class ChangeControlDMO {
int result = 0;
DynamicParameters parameters = new();
parameters.Add("@MeetingID", meeting.MeetingID);
- //parameters.Add("@PCRB", meeting.PCRB.ToUpper() == "SELECT" ? null : meeting.PCRB);
parameters.Add("@Decision", meeting.Decision);
parameters.Add("@MeetingDate", meeting.MeetingDate);
parameters.Add("@Notes", meeting.Notes);
@@ -526,9 +387,6 @@ public class ChangeControlDMO {
parameters.Add("@Site", siteName);
db.Execute("CCInsertNewMeetingAttendee", parameters, commandType: CommandType.StoredProcedure);
}
- ///
- /// /
- ///
internal void UpdateMeetingAttendee(int id, string attendeeName, string jobTitle, string siteName) {
DynamicParameters parameters = new();
@@ -538,9 +396,6 @@ public class ChangeControlDMO {
parameters.Add("@Site", siteName);
db.Execute("CCUpdateMeetingAttendee", parameters, commandType: CommandType.StoredProcedure);
}
- ///
- /// /
- ///
internal void UpdatePCRBAttendee(int id, int attendeeID, string jobTitle, string siteName) {
DynamicParameters parameters = new();
@@ -593,10 +448,6 @@ public class ChangeControlDMO {
db.Execute("CCUpdateMeetingActionItem_All", parameters, commandType: CommandType.StoredProcedure);
}
- ///
- /// /
- ///
-
internal void InsertMeetingActionItem(CCMeetingActionItem meetingActionItem) {
DynamicParameters parameters = new();
parameters.Add("@MeetingID", meetingActionItem.MeetingID);
@@ -626,10 +477,6 @@ public class ChangeControlDMO {
db.Execute("CCInsertPCRBActionItem", parameters, commandType: CommandType.StoredProcedure);
}
- ///
- /// /
- ///
-
internal void UpdateMeetingActionItem(CCMeetingActionItem meetingActionItem) {
DynamicParameters parameters = new();
parameters.Add("@ID", meetingActionItem.ID);
@@ -659,20 +506,6 @@ public class ChangeControlDMO {
db.Execute("CCUpdateMeetingActionItemRespPersons", parameters, commandType: CommandType.StoredProcedure);
}
- /////
- /////
- /////
- //
- //internal void UpdateMeetingActionItemAll(CCMeetingActionItemAll meetingActionItem)
- //{
- // var parameters = new DynamicParameters();
- // parameters.Add("@ID", meetingActionItem.ID);
- // parameters.Add("@Updates", meetingActionItem.Updates);
- // parameters.Add("@ClosedStatus", meetingActionItem.ClosedStatus);
- // parameters.Add("@UserID", meetingActionItem.ClosedBy);
- // this.db.Execute("CCUpdateMeetingActionItem_All", parameters, commandType: CommandType.StoredProcedure);
- //}
-
internal void DeleteMeetingActionItem(CCMeetingActionItem meetingAttendee) {
DynamicParameters parameters = new();
parameters.Add("@ID", meetingAttendee.ID);
@@ -730,9 +563,6 @@ public class ChangeControlDMO {
return fileName;
}
- ///
- ///
- ///
internal List GetUsers() {
DynamicParameters parameters = new();
return db.Query("CCGetUsers", commandType: CommandType.StoredProcedure).ToList();
@@ -778,97 +608,4 @@ public class ChangeControlDMO {
db.Execute("CCReassignOwner", parameters, commandType: CommandType.StoredProcedure);
}
- public void AttachSaveCC(int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- CCAttachment attach = new() {
- ID = attachID,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId
- // Title = title,
- // RequirementsNotes = requirementsNotes
- };
-
- // InsertCCAttachment(attach);
- UpdateCCAttachmentDocument(attach);
- }
-
- public void AttachSaveMeeting(int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- CCMeetingAttachment attach = new() {
- ID = attachID,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId
- };
-
- // InsertCCAttachment(attach);
- UpdateMeetingAttachmentDocument(attach);
- }
-
- public void AttachSaveActionItem(int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- CCMeetingActionItemAll attach = new() {
- ID = attachID,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId
-
- };
-
- // InsertCCAttachment(attach);
- UpdateActionItemAttachment(attach);
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/CorrectiveActionDMO.cs b/Fab2ApprovalSystem/DMO/CorrectiveActionDMO.cs
index 8363b04..6052fa4 100644
--- a/Fab2ApprovalSystem/DMO/CorrectiveActionDMO.cs
+++ b/Fab2ApprovalSystem/DMO/CorrectiveActionDMO.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.IO;
using System.Linq;
using System.Transactions;
@@ -16,17 +15,12 @@ namespace Fab2ApprovalSystem.DMO;
public class CorrectiveActionDMO {
- private readonly AppSettings _AppSettings;
private readonly WorkflowDMO wfDMO = new();
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
- public CorrectiveActionDMO(AppSettings appSettings) =>
- _AppSettings = appSettings;
-
public CorrectiveAction InsertCA(CorrectiveAction ca) {
DynamicParameters parameters = new();
- parameters = new DynamicParameters();
parameters.Add("@CANo", value: ca.CANo, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@RequestorID", ca.RequestorID);
@@ -151,8 +145,6 @@ public class CorrectiveActionDMO {
public CorrectiveAction GetCAItem(int caNo, int userID) {
CorrectiveAction ca = new();
- //isITAR = 2;
-
DynamicParameters parameters = new();
parameters.Add("@CANo", value: caNo);
parameters.Add("@UserID", userID);
@@ -185,8 +177,6 @@ public class CorrectiveActionDMO {
public CorrectiveAction GetCAItemReadOnly(int caNo, int userID) {
CorrectiveAction ca = new();
- //isITAR = 2;
-
DynamicParameters parameters = new();
parameters.Add("@CANo", value: caNo);
parameters.Add("@UserID", userID);
@@ -512,8 +502,6 @@ public class CorrectiveActionDMO {
}
public void StartSectionApproval(int issueID, int userID, string DSection) {
- //string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
-
// bubble the error
DynamicParameters parameters = new();
parameters.Add("@CANo", issueID);
@@ -524,8 +512,6 @@ public class CorrectiveActionDMO {
}
public void ApproveSection(int issueID, int userID, string DSection) {
- //string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
-
// bubble the error
DynamicParameters parameters = new();
parameters.Add("@UserID", userID);
@@ -550,8 +536,6 @@ public class CorrectiveActionDMO {
}
public void RejectSection(int issueID, int userID, string DSection, string comments) {
- //string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
-
// bubble the error
DynamicParameters parameters = new();
parameters.Add("@UserID", userID);
@@ -643,131 +627,4 @@ public class CorrectiveActionDMO {
return ecnList;
}
- public void AttachSave(int caNo, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- CA_Attachment attach = new() {
- CANo = caNo,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId,
- Section = Functions.CASectionMapper(GlobalVars.CASection.Main)
- };
-
- // InsertCCAttachment(attach);
- InsertCAAttachment(attach);
- }
-
- public void D4FilesAttachSave(int caNo, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- CA_Attachment attach = new() {
- CANo = caNo,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId,
- Section = Functions.CASectionMapper(GlobalVars.CASection.D4)
-
- };
-
- //InsertCCAttachment(attach);
- InsertCAAttachment(attach);
- }
-
- public void SaveD7PA_Attachemnt(int d7PAID, int caNo, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- CA_Attachment attach = new() {
- D7PAID = d7PAID,
- CANo = caNo,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId,
- Section = Functions.CASectionMapper(GlobalVars.CASection.D7)
-
- };
-
- InsertCAAttachment(attach);
- }
-
- public void SaveD5D6CA_Attachemnt(int d5d6CAID, int caNo, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
- di = new DirectoryInfo(ccPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- CA_Attachment attach = new() {
- D5D6CAID = d5d6CAID,
- CANo = caNo,
- FileGUID = guid,
- FileName = fileName,
- UploadedByID = userId,
- Section = Functions.CASectionMapper(GlobalVars.CASection.D5)
-
- };
-
- InsertCAAttachment(attach);
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/ECN_DMO.cs b/Fab2ApprovalSystem/DMO/ECN_DMO.cs
index ccec594..4751ec1 100644
--- a/Fab2ApprovalSystem/DMO/ECN_DMO.cs
+++ b/Fab2ApprovalSystem/DMO/ECN_DMO.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.IO;
using System.Linq;
using System.Text;
using System.Transactions;
@@ -21,8 +20,6 @@ public class ECN_DMO {
internal ECN InsertECN(ECN ecn) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@ECNNumber", value: ecn.ECNNumber, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@OriginatorID", ecn.OriginatorID);
@@ -33,12 +30,6 @@ public class ECN_DMO {
}
internal void UpdateECN(ECN ecn) {
- //ECN temp = GetECN(ecn.ECNNumber);
- //if (temp.Equals(ecn))
- //{
- // string s = "good to go...";
- //}
-
DynamicParameters parameters = new();
using (TransactionScope transanction = new()) {
parameters = new DynamicParameters();
@@ -82,7 +73,7 @@ public class ECN_DMO {
parameters.Add("@FIChangeRequired", ecn.FIChangeRequired);
parameters.Add("@NumberOfLotsAffected", ecn.NumberOfLotsAffected);
parameters.Add("@RecipeChange", ecn.RecipeChange);
- //RJK ITAR/EC
+ // RJK ITAR/EC
parameters.Add("@IsDocEC", ecn.IsDocEC);
db.Execute("ECNUpdate", parameters, commandType: CommandType.StoredProcedure);
@@ -203,11 +194,8 @@ public class ECN_DMO {
DynamicParameters parameters = new();
parameters.Add("@ECNNumber", value: ecnNumber);
parameters.Add("@UserID", userID);
- //parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
- //StringBuilder query = new StringBuilder("ECNGetItem");
-
using (var multipleResultItems = db.QueryMultiple("ECNGetItem", parameters, commandType: CommandType.StoredProcedure)) {
ecnItem = multipleResultItems.Read().SingleOrDefault();
@@ -285,11 +273,8 @@ public class ECN_DMO {
DynamicParameters parameters = new();
parameters.Add("@ECNNumber", value: ecnNumber);
parameters.Add("@UserID", userID);
- //parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
- //StringBuilder query = new StringBuilder("ECNGetItem");
-
using (var multipleResultItems = db.QueryMultiple("ECNGetItemForRead", parameters, commandType: CommandType.StoredProcedure)) {
ecnItem = multipleResultItems.Read().SingleOrDefault();
@@ -347,25 +332,11 @@ public class ECN_DMO {
DynamicParameters parameters = new();
parameters.Add("@ECNNumber", value: ecnNumber);
- //StringBuilder query = new StringBuilder("ECNGetItem");
-
using (var multipleResultItems = db.QueryMultiple("ECNGetPdfItem", parameters, commandType: CommandType.StoredProcedure)) {
ecnItem = multipleResultItems.Read().SingleOrDefault();
List departments = multipleResultItems.Read().ToList();
- //if (ecnItem != null && departments != null)
- //{
- // if (departments.Count > 0)
- // ecnItem.AffectedDepartments.AddRange(departments);
- //}
-
List modules = multipleResultItems.Read().ToList();
- //if (ecnItem != null && modules != null)
- //{
- // if (modules.Count > 0)
- // ecnItem.AffectedModules.AddRange(modules);
- //}
-
List attachments = multipleResultItems.Read().ToList();
if (ecnItem != null && attachments != null) {
if (attachments.Count > 0)
@@ -426,17 +397,6 @@ public class ECN_DMO {
return db.Query(query.ToString()).ToList();
}
- ///
- //internal List GetECNTechnology(int? areaId)
- //{
- // var parameters = new DynamicParameters();
- // parameters.Add("@AreaId", value: areaId);
-
- // StringBuilder query = new StringBuilder("SELECT TechnologyID, Technology FROM ECNTechnology WHERE AreaID = @AreaId ORDER BY Technology");
- // return this.db.Query(query.ToString(), parameters ).ToList();
-
- //}
-
internal List GetECNTechnologies() {
DynamicParameters parameters = new();
@@ -540,7 +500,6 @@ public class ECN_DMO {
db.Execute("ECNReSubmitForApproval", parameters, commandType: CommandType.StoredProcedure);
appoverCount = parameters.Get("@AppoverCount");
- //allowedITAR = parameters.Get("@AllowedITAR");
newECNNumber = parameters.Get("@NewECNNumber");
return appoverCount;
}
@@ -751,42 +710,4 @@ public class ECN_DMO {
return r;
}
- public string AttachSave(AppSettings appSettings, int ecnNumber, string returnString, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
- var fileName = Path.GetFileName(fullFileName);
-
- string ecnFolderPath = appSettings.AttachmentFolder + "ECN\\" + ecnNumber.ToString();
-
- DirectoryInfo di = new(ecnFolderPath);
- if (!di.Exists)
- try {
- di.Create();
- } catch {
- returnString = "Error creating ECN directory.";
- }
- if (returnString == "") {
- var physicalPath = Path.Combine(ecnFolderPath, fileName);
- if (!File.Exists(physicalPath)) {
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- ECNAttachment attach = new() {
- ECNNumber = ecnNumber,
- FileName = fileName,
- UserID = userId,
- };
- if (File.Exists(physicalPath)) {
- InsertECNAttachment(attach);
- } else {
- returnString = "File was not uploaded to server.";
- }
- } else {
- returnString = "Cannot have duplicate file names.";
- }
- }
-
- return returnString;
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/LotDispositionDMO.cs b/Fab2ApprovalSystem/DMO/LotDispositionDMO.cs
index 4a75255..4309a09 100644
--- a/Fab2ApprovalSystem/DMO/LotDispositionDMO.cs
+++ b/Fab2ApprovalSystem/DMO/LotDispositionDMO.cs
@@ -1,8 +1,6 @@
-using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -18,16 +16,11 @@ namespace Fab2ApprovalSystem.DMO;
public class LotDispositionDMO {
- private readonly AppSettings _AppSettings;
private readonly WorkflowDMO wfDMO = new();
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
- public LotDispositionDMO(AppSettings appSettings) =>
- _AppSettings = appSettings;
-
public IEnumerable GetTaskList(int userID) {
// eventually, the View Model will refer to a generic task list instead of the just Lot Disposition Items
- //var lotDispostions = this.db.Query("GetLotDispositionsByUser", new { UserID = userID }, commandType: CommandType.StoredProcedure).ToList();
DynamicParameters parameters = new();
parameters.Add("@UserID", userID);
@@ -121,7 +114,6 @@ public class LotDispositionDMO {
DynamicParameters parameters = new();
parameters.Add("@IssueID", value: issueID);
parameters.Add("@UserID", userID);
- //parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
using (var multipleResultItems = db.QueryMultiple("GetLotDispositionItem", parameters, commandType: CommandType.StoredProcedure)) {
@@ -149,7 +141,6 @@ public class LotDispositionDMO {
DynamicParameters parameters = new();
parameters.Add("@IssueID", value: issueID);
parameters.Add("@UserID", userID);
- //parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
using (var multipleResultItems = db.QueryMultiple("GetLotDispositionItemForRead", parameters, commandType: CommandType.StoredProcedure)) {
@@ -168,7 +159,6 @@ public class LotDispositionDMO {
public int GetRHLotCount(int issueID) {
StringBuilder query = new("SELECT COUNT(*) FROM dbo.fnGetLot_RH(@IssueID) ");
- //query.Append("WHERE UserID = @UserID AND AND EmployeeStatus = 'Active'");
return db.Query(query.ToString(), new { IssueID = issueID }).SingleOrDefault();
}
@@ -200,35 +190,6 @@ public class LotDispositionDMO {
// Lot Update
- //parameters = new DynamicParameters();
- //IEnumerable lots = lotDispo.Lots;
- //foreach (Lot lot in lots)
- //{
- // parameters = new DynamicParameters();
- // parameters.Add("@LotNumber", lot.LotNumber);
- // parameters.Add("@IssueID", lotDispo.IssueID);
- // parameters.Add("@Description", lot.Description);
- // parameters.Add("@NewPartNo", lot.NewPartNo);
- // parameters.Add("@WipPartNo", lot.WipPartNo);
- // parameters.Add("@DiePartNo", lot.DiePartNo);
- // parameters.Add("@ProductFamily", lot.ProductFamily);
- // parameters.Add("@Gen", lot.Gen);
-
- // parameters.Add("@Channel", lot.Channel);
- // parameters.Add("@Hexsize", lot.Hexsize);
-
- // parameters.Add("@Voltage", lot.Voltage);
- // parameters.Add("@WaferCount", lot.WaferCount);
- // parameters.Add("@DieCount", lot.DieCount);
-
- // parameters.Add("@Location", lot.Location);
- // parameters.Add("@TotalCost", lot.TotalCost);
- // parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
-
- // this.db.Execute("InsertLot", parameters, commandType: CommandType.StoredProcedure);
-
- //}
-
// LotDispoDepartment
List lotDispDepIDs = lotDispo.DepartmentIDs;
@@ -443,123 +404,10 @@ public class LotDispositionDMO {
lot.ScrapCount = 0;
lot.ReleaseCount = 0;
}
- //else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable)
- //{
- // sl.ScrapCount = 0;
- // sl.ReleaseCount = 0;
-
- // lot.ScrapCount = 0;
- // lot.ReleaseCount = 0;
- //}
UpdateLotScrapReleaseStatus(sl);
}
- ///
- /// Updates the Lot object with additional info based on Lot data downlaoded from SPN
- ///
-
- //void GetLotInformation(Lot lot)
- //{
- // string qryLotInfo = "SELECT WP_LOT_NO, WP_PART_NUMBER, MP_PRODUCT_FAMILY, MP_DESCRIPTION, WP_CURRENT_QTY, WP_CURRENT_LOCATION, DieLotNumber, DiePartNo, DieCount FROM SPNLot WHERE WP_Lot_No = @LotNumber ";
- // var lotInfoRow = this.db.Query(qryLotInfo, new { lot.LotNumber }).ToList();
-
- // //lot.LotNumber = lotInfoRow.Get("@WP_LOT_NO");
- // //lot.WipPartNo = lotInfoRow.Get("@WP_Part_Number");
- // ////lotInfoRow.WP_LOT_NO;
- // //lot.WipPartNo = lotInfoRow.WP_Part_Number;
-
- // foreach (dynamic lotInfoColumn in lotInfoRow)
- // {
-
- // lot.LotNumber = lotInfoColumn.WP_LOT_NO;
- // lot.DieLotNumber = lotInfoColumn.DieLotNumber;
-
- // if (lotInfoColumn.WP_PART_NUMBER != null)
- // lot.WipPartNo = lotInfoColumn.WP_PART_NUMBER.Trim();
-
- // if (lotInfoColumn.WP_CURRENT_LOCATION != null)
- // {
- // lot.Location = lotInfoColumn.WP_CURRENT_LOCATION;
- // }
-
- // if (lotInfoColumn.MP_DESCRIPTION != null)
- // {
- // lot.Description = lotInfoColumn.MP_DESCRIPTION;
- // if (lot.Description.Length > 0)
- // {
- // string[] temp = lot.Description.Split(new char[] { ',' });
- // if (temp.Length > 0)
- // {
- // try
- // {
- // lot.ProductFamily = temp[0];
- // }
- // catch { } // ignore the error
-
- // try
- // {
- // lot.Gen = double.Parse(temp[2].Substring(1,temp[2].Length - 1));
- // }
- // catch { }// ignore the error
- // try
- // {
- // lot.Hexsize = double.Parse(temp[6]);
- // }
- // catch { }// ignore the error
-
- // }
- // }
- // }
-
- // if (lotInfoColumn.DieCount != null)
- // lot.DieCount = int.Parse(lotInfoColumn.DieCount.ToString());
-
- // if (lotInfoColumn.DiePartNo != null)
- // lot.DiePartNo = lotInfoColumn.DiePartNo.Trim();
-
- // if (lotInfoColumn.WP_CURRENT_QTY != null)
- // lot.WaferCount = lotInfoColumn.WP_CURRENT_QTY;
-
- // if (lot.WipPartNo.Length > 0 || lot.DiePartNo.Length > 0)
- // {
- // qryLotInfo = "SELECT DiePartNo, SourceFAB, Diameter, Silicon, Gen, Layers,HexSize,Voltage,Channel, Type AS ProductFamily, WaferCost, DieCost FROM FabApprovalSystem.dbo.StdCost WHERE WIPWaferNo = @WIPPartNo OR DiePartNo = @DiePartNo ";
- // var moreLotInfoRow = this.db.Query(qryLotInfo, new { lot.WipPartNo, lot.DiePartNo }).ToList();
-
- // foreach (var moreLotInfoColumn in moreLotInfoRow)
- // {
- // lot.DieCost = double.Parse(moreLotInfoColumn.DieCost.ToString());
- // lot.WaferCost = double.Parse(moreLotInfoColumn.WaferCost.ToString());
-
- // if (moreLotInfoColumn.Channel != null)
- // lot.Channel = moreLotInfoColumn.Channel;
-
- // //if (moreLotInfoColumn.ProductFamily != null)
- // // lot.ProductFamily = moreLotInfoColumn.ProductFamily;
-
- // if (moreLotInfoColumn.Hexsize != null)
- // lot.Hexsize = moreLotInfoColumn.Hexsize;
-
- // if (moreLotInfoColumn.Voltage != null)
- // lot.Voltage = moreLotInfoColumn.Voltage;
-
- // //if (moreLotInfoColumn.Gen != null)
- // // lot.Gen = moreLotInfoColumn.Gen;
-
- // if (lot.DieCount == 0)
- // lot.TotalCost = Math.Round(lot.WaferCount * lot.WaferCost,2);
- // else
- // lot.TotalCost = Math.Round(lot.DieCount * lot.DieCost,2);
- // }
-
- // }
-
- // }
-
- // //return lotStatusOption;
-
- //}
-
#endregion
public IEnumerable GetLotStatusOptions() {
@@ -571,86 +419,6 @@ public class LotDispositionDMO {
// NOTE: Any new fields that needs to be added to select list , needs to be referenced prior to the "LS.LotStatusOptionID , LS.LotStatusOption" fields
db.Open();
- #region Commented Code
- /*
- StringBuilder sql = new StringBuilder();
- sql.Append("SELECT DISTINCT SQ.IssueIDs AS MRBsLinkedToLot , DispoType.MRBDispoType, SQP.IssueIDs AS IssueIDWithoutMRB, ");
- sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 1 ");
- sql.Append("WHEN PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2 THEN 0 ");
- sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 0 ");
-
- sql.Append("WHEN (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
- sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
- sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
- sql.Append(" AND LS.LotStatusOptionID <> 6 ) ");
- sql.Append(" AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB') THEN 0 ");
-
- sql.Append("ELSE 1 ");
- sql.Append("END AS GoodToSubmit, ");
-
- sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 'NA' ");
- sql.Append("WHEN (PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2) ");
- sql.Append("OR ( ");
- sql.Append(" (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
- sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
- sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
- sql.Append(" AND LS.LotStatusOptionID <> 6 AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB')) ");
- sql.Append(" )");
- sql.Append(" THEN 'MRB Disposition different from Lot Dispostion' ");
-
- sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 'MRB Dispo missing' ");
- sql.Append("ELSE 'NA' ");
- sql.Append("END AS SubmitErrorMessage, ");
-
- sql.Append(" ");
- sql.Append("L.LotID, L.LotNumber, L.IssueID ,L.DieLotNumber ,L.Description ,L.NewPartNo ,L.WipPartNo ,L.DiePartNo ,L.ProductFamily, ");
- sql.Append("L.Gen ,L.Channel, L.HexSize, L.Voltage, L.WaferCount, L.DieCount, L.Location, L.TotalCost, L.LotStatusOptionID,");
- sql.Append("S.ReleaseCount, S.ScrapCount, L.QualityCode, LS.LotStatusOptionID , LS.LotStatusOption FROM Lot L ");
- sql.Append("INNER JOIN LotStatusOption LS ON L.LotStatusOptionID = LS.LotStatusOptionID ");
- sql.Append("LEFT JOIN ScrapLot S ON L.LotNumber = S.LotNo AND L.IssueID = S.IssueID ");
-
- sql.Append("LEFT JOIN ");
- sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
- // Code changed 12/11/2019 RJK
- //sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
- sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) + '_' + CAST(ISNULL(ML.DispoType,'') AS varchar(512)) ");
- sql.Append("FROM vMRBLot ML ");
- //sql.Append("WHERE SUBSTRING(LTRIM(RTRIM(L.LotNumber)),1,7) = SUBSTRING(LTRIM(RTRIM(ML.LotNumber)),1,7) ");
- sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
- sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
- sql.Append("FROM Lot L) AS SQ ");
- sql.Append("ON L.LotID = SQ.LotID ");
-
- sql.Append("LEFT JOIN ");
- sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
- sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
- sql.Append("FROM vMRBLot ML ");
- sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
- sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
- sql.Append("FROM Lot L) AS SQP ");
- sql.Append("ON L.LotID = SQP.LotID ");
-
- sql.Append("LEFT JOIN ");
- sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
- sql.Append("((SELECT DISTINCT ',' + CAST(ISNULL(ML.DispoType, 'X') AS varchar(512)) ");
- sql.Append("FROM vMRBLot ML ");
- sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
- sql.Append("FOR XML PATH('')), 1, 1, '') AS MRBDispoType ");
- sql.Append("FROM Lot L) AS DispoType ");
- sql.Append("ON L.LotID = DispoType.LotID ");
-
- sql.Append("WHERE L.IssueID = " + issueID);
-
- var data = this.db.Query
- (sql.ToString(), (lot, lotstatusoption) =>
- {
- lot.LotStatusOption = lotstatusoption;
- return lot;
- },
- splitOn: "LotStatusOptionID").ToList();
-
- */
- #endregion
DynamicParameters parameters = new();
parameters.Add("@IssueID", issueID, DbType.Int32);
@@ -786,7 +554,7 @@ public class LotDispositionDMO {
}
public void UpdateLotStatus(ScrapLot lotStatus) {
- //if all the wafers in a lot is either "RELEASE" or "SCRAP" from the "SELECT WAFERS SCREEN" set the Lot Status Option accodingly for the particula lot
+ // if all the wafers in a lot is either "RELEASE" or "SCRAP" from the "SELECT WAFERS SCREEN" set the Lot Status Option accodingly for the particula lot
int tempLotStatus;
if ((lotStatus.ReleaseCount == lotStatus.WaferCount || lotStatus.ScrapCount == lotStatus.WaferCount) && (lotStatus.ReleaseCount > 0 || lotStatus.WaferCount > 0)) {
// set the LotStatus appropriately because the entire lot either is set to "RELEASE" or "SCRAP"'
@@ -951,16 +719,12 @@ public class LotDispositionDMO {
totalReleaseCost += releaseCost;
}
- //}
-
return new LotDispositionLotSummaryViewModel() {
LotCount = lotCount,
ReleaseCost = string.Format("{0:C}", totalReleaseCost),
- //Math.Round(totalReleaseCost, 2).ToString(,
ReleaseWaferCount = totalWaferReleaseCount,
ReleaseDieCount = totalDieReleaseCount,
ScrapCost = string.Format("{0:C}", totalScrapCost),
- //Math.Round(totalScrapCost, 2),
ScrapWaferCount = totalWaferScrapCount,
ScrapDieCount = totalDieScrapCount
@@ -1036,61 +800,4 @@ public class LotDispositionDMO {
return fileName;
}
- public void AttachSave(int issueID, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
- var fileName = Path.GetFileName(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "LotDisposition", fileName);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- Attachment attach = new() {
- IssueID = issueID,
- FileName = fileName,
- UserID = userId,
- };
- InsertLotDispositionAttachment(attach);
- }
-
- public string ExcelLotOpen(int issueID, string userIdentityName, string lotTempPipeLine, string fullFileName, Stream stream) {
- string physicalPath;
-
- var fileExtension = Path.GetExtension(fullFileName);
- string fName = userIdentityName + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
-
- physicalPath = Path.Combine(lotTempPipeLine, fName + "." + fileExtension);
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
-#if !NET8
- ExcelData x = new ExcelData(physicalPath);
- var lotNumbers = x.ReadData();
-
- foreach (var lotInfo in lotNumbers) {
- Lot l = new Lot();
- l.LotNumber = lotInfo.LotNo;
- l.IssueID = issueID;
- if (l.LotStatusOptionID == 0)
- l.LotStatusOption.LotStatusOptionID = (int)GlobalVars.LotStatusOption.Release;
-
- InsertLot(l, true);
- //if (!mrbDMO.DoesMRBLotExist(lotInfo.LotNo))
- //{
- // //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
- // InsertChildLot_NotInTheMRB(lotInfo.LotNo);
-
- //}
- }
-#endif
-
- FileInfo f = new(physicalPath);
- if (f.Exists)
- f.Delete();
-
- return physicalPath;
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/LotTravelerDMO.cs b/Fab2ApprovalSystem/DMO/LotTravelerDMO.cs
index a30f9e2..3aec32e 100644
--- a/Fab2ApprovalSystem/DMO/LotTravelerDMO.cs
+++ b/Fab2ApprovalSystem/DMO/LotTravelerDMO.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.IO;
using System.Linq;
using System.Text;
using System.Transactions;
@@ -17,13 +16,9 @@ namespace Fab2ApprovalSystem.DMO;
public class LotTravelerDMO {
- private readonly AppSettings _AppSettings;
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
private readonly WorkflowDMO wfDMO = new();
- public LotTravelerDMO(AppSettings appSettings) =>
- _AppSettings = appSettings;
-
///
///
internal LTWorkRequest InsertWorkRequest(LTWorkRequest workRequest) {
@@ -59,9 +54,6 @@ public class LotTravelerDMO {
workRequestItem.ModuleIDs.AddRange(modules);
}
- //var holdsteps = multipleResultItems.Read().SingleOrDefault();
- //workRequestItem.LTHoldStep = holdsteps;
-
isITAR = parameters.Get("@IsITAR");
}
@@ -121,9 +113,6 @@ public class LotTravelerDMO {
workRequestItem.ModuleIDs.AddRange(modules);
}
- //var holdsteps = multipleResultItems.Read().SingleOrDefault();
- //workRequestItem.LTHoldStep = holdsteps;
-
isITAR = parameters.Get("@IsITAR");
}
@@ -149,7 +138,6 @@ public class LotTravelerDMO {
parameters.Add("@AllocationToUse", data.AllocationToUse);
parameters.Add("@PredictedCyleTime", data.PredictedCyleTime);
parameters.Add("@DeptChargedForRawWafers", data.ChargeDepartment);
- //parameters.Add("@EstimatedBinCLoseDate", data.EstimatedBinCLoseDate);
parameters.Add("@TotalQty", data.TotalQty);
parameters.Add("@WIPArea", data.WIPArea);
parameters.Add("@LotStartDate", data.LotStartDate);
@@ -422,11 +410,6 @@ public class LotTravelerDMO {
result = parameters.Get("@Result");
- //if (result == -1)
- //{
- // throw new Exception("In order to do the UPDATE or SUBMIT operation the record needs to exclusively locked by you.\nThe record was unlocked by the system due to inactivity for more than 30 minutes, hence the update was not successful");
- //}
-
}
internal void UpdateHoldStep(LTHoldStep model) {
@@ -443,8 +426,6 @@ public class LotTravelerDMO {
db.Execute("LTUpdateHoldStep", parameters, commandType: CommandType.StoredProcedure);
- //int id = parameters.Get("@LTHoldStepID");
- //model.ID = id;
}
internal void InsertHoldStepRevision(LTHoldStep model) {
@@ -470,7 +451,6 @@ public class LotTravelerDMO {
int result = 0;
DynamicParameters parameters = new();
parameters.Add("@LTHoldStepID", model.ID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
- //parameters.Add("@BaseFlow", model.BaseFlow);
parameters.Add("@BaseFlowLocation", model.Location);
parameters.Add("@BaseFlowOperationSeq", model.OperSequence);
parameters.Add("@BaseFlowOperation", model.Operation);
@@ -478,16 +458,8 @@ public class LotTravelerDMO {
parameters.Add("@ChangeInstruction", model.ChangeInstructions);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", model.UpdatedBy);
- //parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
db.Execute("LTUpdateHoldStepRevision", parameters, commandType: CommandType.StoredProcedure);
-
- //result = parameters.Get("@Result");
- //if (result == -1)
- //{
- // throw new Exception("Cannot add the Hold Step as the step has already been passed in the Mfg Process.");
- //}
-
}
internal void DeleteHoldStep(int holdStepID, int userID) {
@@ -524,7 +496,6 @@ public class LotTravelerDMO {
}
internal IEnumerable GetHoldStepAttachemnts(int holdStepID) {
- //var holdStepAttachments = this.db.Query("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
DynamicParameters parameters = new();
parameters.Add("@HoldStepID", holdStepID);
List data = db.Query("LTGetHoldStepAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
@@ -532,7 +503,6 @@ public class LotTravelerDMO {
}
internal IEnumerable GetLotTravHoldStepAttachemnts(int ltHoldStepID) {
- //var holdStepAttachments = this.db.Query("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
DynamicParameters parameters = new();
parameters.Add("@LTHoldStepID", ltHoldStepID);
List data = db.Query("LTGetLotTravHoldStepAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
@@ -612,7 +582,6 @@ public class LotTravelerDMO {
}
internal IEnumerable GetWorkRequestAttachments(int workRequestID) {
- //var holdStepAttachments = this.db.Query("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
DynamicParameters parameters = new();
parameters.Add("@WorkRequestID", workRequestID);
List data = db.Query("LTGetWorkRequestAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
@@ -786,12 +755,10 @@ public class LotTravelerDMO {
db.Execute("LTInsertLTLot", parameters, commandType: CommandType.StoredProcedure);
- //int lotID = parameters.Get("@LotID");
if (parameters.Get("@WRWithExistingLot") != 0) {
lot.WRWithExistingLot = parameters.Get("@WRWithExistingLot");
}
- //return lotID;
}
public IEnumerable GetLotList(int workRequestID) {
@@ -810,7 +777,6 @@ public class LotTravelerDMO {
sql.Append("LEFT JOIN Users U ON L.LotUploadedBy = U.UserID ");
sql.Append("WHERE WR.SWRNumber = @SWRNumber ORDER BY LotNumber ");
List lots = db.Query(sql.ToString(), new { @SWRNumber = swrNumber }, commandType: CommandType.Text).ToList();
- //var lots = this.db.Query("SELECT L.*, U.FirstName + ' ' + U.LastName AS UploadedByName FROM LTWorkRequest WR INNER JOIN LTLot L ON WR.ID = L.WorkRequestID AND WR.IsCurrentRevision = 1 LEFT JOIN Users U ON L.LotUploadedBy = U.UserID WHERE WR.SWRNumber = @SWRNumber ORDER BY LotNumber ", new { swrNumber }, commandType: CommandType.Text).ToList();
return lots;
}
@@ -999,7 +965,6 @@ public class LotTravelerDMO {
}
- //var data = this.db.Query("LTGetLotTravelerForPDF", parameters, commandType: CommandType.StoredProcedure).Single();
return data;
}
@@ -1088,220 +1053,4 @@ public class LotTravelerDMO {
db.Execute("LTReassignOriginator", parameters, commandType: CommandType.StoredProcedure);
}
- public void HoldStepAttachSave(int holdStepID, int swrNo, string docType, string comments, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- // TODO
- //int currentRevision = 1;
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWRPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- //var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
- var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWR_RevPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- //var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision + @"\", guid + fileExtension);
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- LTWorkRequestAttachment attach = new() {
- FileGUID = guid,
- LTHoldStepID = holdStepID,
- FileName = fileName,
- UploadedByID = userId,
- DocType = docType,
- Comments = comments
- };
-
- InsertLotHoldStepAttachment(attach);
- }
-
- public void HoldStepAttachSaveRev(int holdStepID, int swrNo, string docType, string comments, bool newRevision, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- // TODO
- //int currentRevision = 1;
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWRPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- //var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
- var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWR_RevPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- //var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision + @"\", guid + fileExtension);
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- LTWorkRequestAttachment attach = new() {
- FileGUID = guid,
- LTHoldStepID = holdStepID,
- FileName = fileName,
- UploadedByID = userId,
- DocType = docType,
- Comments = comments
- };
- if (newRevision)
- InsertLotHoldStepAttachmentRevision(attach);
- else
- InsertLotHoldStepAttachment(attach);
- }
-
- public void AttachSaveWorkRequestRevision(int workRequestID, int swrNo, string docType, string attachComments, bool newRevision, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- // TODO
- //int currentRevision = 1;
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWRPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- //var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
- var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWR_RevPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- LTWorkRequestAttachment attach = new() {
- WorkRequestID = workRequestID,
- FileGUID = guid,
- LTHoldStepID = -1,
- FileName = fileName,
- UploadedByID = userId,
- DocType = docType,
- Comments = attachComments
- };
-
- // InsertWorkRequestAttachment(attach);
- if (newRevision)
- InsertWorkRequestAttachmentRevision(attach);
- else
- InsertWorkRequestAttachment(attach);
- }
-
- public void AttachSaveWorkRequest(int workRequestID, int swrNo, string comments, string docType, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- // TODO
- //int currentRevision = 1;
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWRPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- //var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
- var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWR_RevPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- LTWorkRequestAttachment attach = new() {
- WorkRequestID = workRequestID,
- FileGUID = guid,
- LTHoldStepID = -1,
- FileName = fileName,
- UploadedByID = userId,
- DocType = docType,
- Comments = comments
-
- };
-
- InsertWorkRequestAttachment(attach);
- }
-
- public void LotTravHoldStepAttachSaveRev(int ltHoldStepID, int swrNo, string docType, int prevLotTravRevID, int newLotTravRevID, bool newRevision, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
-
- // TODO
- //int currentRevision = 1;
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- //var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
- DirectoryInfo di;
- var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWRPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- //var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
- var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
- di = new DirectoryInfo(SWR_RevPhysicalPath);
- if (!di.Exists)
- di.Create();
-
- var guid = Guid.NewGuid().ToString();
- //var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision + @"\", guid + fileExtension);
- var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- LTLotTravAttachment attach = new() {
- FileGUID = guid,
- LTLotTravHoldStepID = ltHoldStepID,
- LotTravelerRevisionID = newLotTravRevID,
- FileName = fileName,
- UploadedByID = userId,
- DocType = docType
- };
- if (newRevision) {
- try {
- InsertLotTravLotHoldStepAttachmentRevision(attach);
- } catch {
- //roll back the revision creation
- 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");
- }
-
- } else
- InsertLotTravLotHoldStepAttachment(attach);
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/MRB_DMO.cs b/Fab2ApprovalSystem/DMO/MRB_DMO.cs
index 7648955..b25037a 100644
--- a/Fab2ApprovalSystem/DMO/MRB_DMO.cs
+++ b/Fab2ApprovalSystem/DMO/MRB_DMO.cs
@@ -2,11 +2,8 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Text;
-using System.Threading;
using System.Transactions;
using Dapper;
@@ -28,8 +25,6 @@ public class MRB_DMO {
internal MRB InsertMRB(MRB mrb) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@MRBNumber", value: mrb.MRBNumber, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@OriginatorID", mrb.OriginatorID);
@@ -116,28 +111,12 @@ public class MRB_DMO {
}
- //List dispositionIDs = mrb.DispositionIDs;
- //if (dispositionIDs != null)
- //{
- // parameters = new DynamicParameters();
- // parameters.Add("@MRBNumber", mrb.MRBNumber);
- // this.db.Execute("MRBDeleteDispositionsByMRB", parameters, commandType: CommandType.StoredProcedure);
-
- // foreach (int dispositionID in dispositionIDs)
- // {
- // parameters = new DynamicParameters();
- // parameters.Add("@MRBNumber", mrb.MRBNumber);
- // parameters.Add("@DispositionID", dispositionID);
- // this.db.Execute("MRBInsertDispositionsByMRB", parameters, commandType: CommandType.StoredProcedure);
- // }
-
- //}
transanction.Complete();
}
}
internal MRB GetMRBItem(int mrbNumber, out int isITAR, int userID) {
- //IsITAR
+ // IsITAR
// 0 = false
// 1 = true
// 2 = not required
@@ -208,10 +187,6 @@ public class MRB_DMO {
}
internal IEnumerable GetDispositions(int mrbNumber) {
- //var disposition = this.db.Query("MRBGetDispositionsByMRB", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure).ToList();
-
- // StringBuilder sql = new StringBuilder();
-
db.Open();
List disposition = db.Query
(
@@ -266,8 +241,6 @@ public class MRB_DMO {
}
internal IEnumerable GetMRBHoldFlagReport(int mrbNumber) {
- //db.Open();
-
string sql = "SELECT * FROM MRBHoldFlagReport WHERE MRBNumber = @MRBNumber ORDER BY LotNo";
List data = db.Query(sql, new { MRBNumber = mrbNumber }).ToList();
@@ -275,8 +248,6 @@ public class MRB_DMO {
}
internal IEnumerable GetMRHoldFlagSentHistory(int mrbNumber) {
- //db.Open();
-
string sql = "SELECT * FROM MRBLotsToBeSentToSPN WHERE MRBNumber = @MRBNumber ORDER BY LotNumber";
List data = db.Query(sql, new { MRBNumber = mrbNumber }).ToList();
@@ -284,7 +255,6 @@ public class MRB_DMO {
}
internal IEnumerable GetTools() =>
- //return db.Query("SELECT DISTINCT RTRIM(WO_STATION_ID) AS ToolID from vFAB2SPN_WO_RECORD ORDER BY 1").ToList();
db.Query("SELECT 'NA', '1' UNION SELECT DISTINCT LTRIM(RTRIM(ToolID)),LTRIM(RTRIM(ToolID)) FROM [TEMIRWAP019].[SPNPDB].[dbo].[tblToolGroups2] ORDER BY 2").ToList();
internal MRB GetToolIssueStartEndDateData(int mrbNumber, IDbTransaction dbTrans = null) {
@@ -322,17 +292,6 @@ public class MRB_DMO {
var analysisTime = DateTime.Now;
// get mrb info
- //var mrbInfo = db.Query(
- // "SELECT ToolCSV, IssueStartDate, IssueEndDate FROM MRB WHERE MRBNumber = @mrbNo",
- // new { mrbNo = mrbNumber }).First();
-
- //var tools = ((string)mrbInfo.ToolCSV).Split(',');
- //DateTime? issueStartDate = mrbInfo.IssueStartDate;
- //DateTime? issueEndDate = mrbInfo.IssueEndDate;
-
- //if (issueStartDate.HasValue == false) throw new Exception("MRB Issue Start Date cannot be blank");
- //if (issueEndDate.HasValue == false) throw new Exception("MRB Issue End Date cannot be blank");
-
// search WO for MRB tools between incident start+end to find the earliest WO record for this lot and use the Out time
DateTime? incidentTime = null;
@@ -340,7 +299,6 @@ public class MRB_DMO {
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
incidentTime = db.Query(
"SELECT MIN(OutTime) FROM WO_RECORD_MJ " +
- //"SELECT MIN(OutTime) FROM vFAB2SPN_WO_RECORD " +
"WHERE WO_LOT_NO = @LotNo " +
"AND WO_STATION_ID IN @Tools " +
"AND (InTime BETWEEN @StartDate AND @EndDate " +
@@ -377,14 +335,12 @@ public class MRB_DMO {
string parmsXML =
new System.Xml.Linq.XElement("IssueStartDate", issueStartDate).ToString() +
new System.Xml.Linq.XElement("IssueEndDate", issueEndDate).ToString() +
- //new System.Xml.Linq.XElement("ToolCSV", (string)mrbInfo.ToolCSV).ToString();
new System.Xml.Linq.XElement("ToolCSV", toolCSV).ToString();
IEnumerable analysisResults = null;
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
analysisResults = db.Query(
"AnalyzeLotAncestry_TEST",
- //"AnalyzeLotAncestry",
new {
LotNo = incidentLotNo,
IncidentTime = incidentTime,
@@ -524,15 +480,11 @@ public class MRB_DMO {
///
internal bool ChildLotsUpdateInSPNWithNewDispoType(Lot parentLot, MRB mrb) {
- //db.Open();
-
- //var dbTrans = db.BeginTransaction();
var analysisTime = DateTime.Now;
DateTime? incidentTime = null;
- //var tools = ((string)mrb.ToolCSV).Split(',');
- //This is the "time", when the lot was first uploaded into the system
- //Get the child lots that were split after this datetime
+ // This is the "time", when the lot was first uploaded into the system
+ // Get the child lots that were split after this datetime
incidentTime = db.Query(
"SELECT InsertDateTimeStamp FROM MRBLot " +
@@ -583,10 +535,6 @@ public class MRB_DMO {
db.Open();
var dbTrans = db.BeginTransaction();
- //var newAnalysisResults = from r in analysisResults
- // where r.IsAffected.HasValue && r.IsAffected == true
- // select r;
-
IEnumerable newAnalysisResults = analysisResults.Where(r => r.IsAffected.HasValue && r.IsAffected == true).ToList();
try {
// insert lots
@@ -744,31 +692,9 @@ public class MRB_DMO {
db.Execute("MRBUpdateLot", parameters, commandType: CommandType.StoredProcedure, transaction: dbTrans);
- ////routine to cascade the "dispo type" to all the child lots in SPN (Lot that are not present in FAb App Sys,)
- //MRB mrbInfo = GetToolIssueStartEndDateData(lot.MRBNumber, dbTrans);
+ // routine to cascade the "dispo type" to all the child lots in SPN (Lot that are not present in FAb App Sys,)
+ // MRB mrbInfo = GetToolIssueStartEndDateData(lot.MRBNumber, dbTrans);
- //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 = IsLotSentToSPN(l.LotNumber, l.MRBNumber, dbTrans);
- // //only get the child lots if it has been sent to SPN to set the MRB Flag
- // if (lotSentToSPN)
- // {
- // if (!GetChildLotsFromSPNForDispoTypeUpdate(lot.MRBNumber, lot.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate, lot.DispoType, dbTrans))
- // {
- // //warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n", l.LotNumber);
- // }
- // }
-
- //}
dbTrans.Commit();
} catch {
@@ -817,18 +743,6 @@ public class MRB_DMO {
return db.Query(sql.ToString(), new { AttachmentID = attachmentID }).SingleOrDefault();
}
- //internal IEnumerable GetMRBAttachmentsByFilename(string fileName)
- //{
- // StringBuilder sql = new StringBuilder();
- // sql.Append("SELECT A.AttachmentID, A.MRBNumber, A.FileName, A.UserID, CONVERT(VARCHAR(10), A.UploadDate, 101) AS UploadDate, ");
- // sql.Append("U.FirstName + ' ' + U.LastName AS FullName ");
- // sql.Append("FROM MRBAttachment A INNER JOIN Users U ON A.UserID = U.UserID ");
- // sql.Append("WHERE A.Filename = @filename");
-
- // var attachments = this.db.Query(sql.ToString(), new { filename = fileName }).ToList();
- // return attachments;
- //}
-
internal void DeleteMRBAttachment(int attachmentID) {
DynamicParameters parameters = new();
parameters.Add("@AttachmentID", attachmentID);
@@ -846,11 +760,6 @@ public class MRB_DMO {
}
internal IEnumerable GetContainmentActions(int mrbNumber) {
- //db.Open();
-
- //string sql = "SELECT * FROM MRBContainmentAction WHERE MRBNumber = " + mrbNumber;
- //var data = this.db.Query(sql).ToList();
-
DynamicParameters parameters = new();
parameters.Add("@MRBNumber", mrbNumber);
@@ -864,7 +773,6 @@ public class MRB_DMO {
parameters.Add("@ContainmentActionID", model.ContainmentActionID, DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@MRBNumber", model.MRBNumber);
parameters.Add("@ContainmentAction", model.ContainmentAction);
- //parameters.Add("@ResponsibilityOwner", model.ResponsibilityOwner);
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
parameters.Add("@ECD", model.ECD);
parameters.Add("@ImplementedDate", model.ImplementedDate);
@@ -880,7 +788,6 @@ public class MRB_DMO {
parameters.Add("@ContainmentActionID", model.ContainmentActionID);
parameters.Add("@ContainmentAction", model.ContainmentAction);
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
- //parameters.Add("@ResponsibilityOwner", model.ResponsibilityOwner);
parameters.Add("@ECD", model.ECD);
parameters.Add("@ImplementedDate", model.ImplementedDate);
@@ -914,9 +821,6 @@ public class MRB_DMO {
db.Execute("UPDATE MRB SET ApprovalStatus = " + (int)GlobalVars.ApprovalOption.Closed + ", CloseDate = GETDATE() WHERE MRBNumber = " + mrbNumber, commandType: CommandType.Text);
internal void SetDispositionTypeForAllLots(int mrbNumber, string dispoType) =>
- //var sql = "UPDATE MRBLot SET DispoType = '" + dispoType + "' WHERE MRBNumber = " + mrbNumber;
- //this.db.Execute(sql, commandType: CommandType.Text);
-
db.Execute("MRBSetDispositionTypeForAllLots", new { @MRBNumber = mrbNumber, @DispoType = dispoType }, commandType: CommandType.StoredProcedure);
internal void GetLotWaferDieCount(int mrbNumber, out int lotCount, out int waferCount, out int dieCount) {
@@ -945,18 +849,6 @@ public class MRB_DMO {
internal void LogHoldFlagSentToSPNHistory(int mrbNumber) =>
db.Execute("MRBLogHoldFlagSentToSPNHistory", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure);
- //internal IEnumerable GetSPN_MRB_HoldFlagLots(int mrbNumber)
- //{
- // var disposition = this.db.Query("MRBGet_SPN_HoldLots", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure).ToList();
- // return disposition;
- //}
-
- //internal void InsertSPN_MRB_HoldFlagLots(int mrbNumber)
- //{
- // var disposition = this.db.Query("MRBInsertSPN_HoldFlagLots", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure).ToList();
- // //return disposition;
- //}
-
internal void InsertMRB_QDB_HoldFlag(string guid, string data, string operation) {
string[] tempData = data.Split(new char[] { '~' });
@@ -981,12 +873,6 @@ public class MRB_DMO {
db.Execute("MRBUpdateQDB_HoldProcessedFlag", parameters, commandType: CommandType.StoredProcedure);
}
- //internal IEnumerable GetLotsForMRBHoldFlags(string guid)
- //{
- // var data = this.db.Query("MRBGetMRB_QDB_HoldFlags", new { @Guid = guid }, commandType: CommandType.StoredProcedure).ToList();
- // return data;
- //}
-
public IEnumerable GetUserList() {
DynamicParameters parameters = new();
List userList = db.Query("_8DGetUserList", parameters, commandType: CommandType.StoredProcedure).ToList();
@@ -1013,319 +899,4 @@ public class MRB_DMO {
return sb.ToString();
}
- public string ImportRemoveQDBFlag(string operation, out string physicalPath, string userIdentityName, string a, string b, string c, string fullFileName, Stream stream) {
- IEnumerable lotDataList = null;
- var guid = Guid.NewGuid().ToString();
-
- var fileExtension = Path.GetExtension(fullFileName);
- physicalPath = Path.Combine(_AppSettings.LotTempPipeLine, guid + "." + fileExtension);
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
-#if !NET8
- ExcelData x = new ExcelData(physicalPath);
- lotDataList = x.ReadQDBFlagData();
-
- foreach (string lotData in lotDataList) {
- InsertMRB_QDB_HoldFlag(guid, lotData, operation);
- }
-#endif
-
- FileInfo f = new(physicalPath);
- if (f.Exists)
- f.Delete();
-
- //Send the data to SPN
- if (SendQDBFlagToSPN(guid, userIdentityName, a, b, c))
- UpdateMRB_QDB_HoldFlag(guid, true);
- else {
- UpdateMRB_QDB_HoldFlag(guid, false);
- return "Problems while uploading to SPN";
- }
- return string.Empty;
- }
-
- public bool BatchFTP(string sourceFile, string destFile, string ftpLogDirectory, string userIdentityName, string a, string b, string c) {
- FileInfo sourcefile = new(sourceFile);
-
- //FileInfo sourcefile = new FileInfo(@"C:\Websites\ECNViewerAckResultToSPN\S15122017102017.ecn");
-
- try {
- //Functions.WriteEvent("HR Emp", "SPNData - Start Send(): FTPing " + sourceFile + " to SPN server.", System.Diagnostics.EventLogEntryType.Information);
-
- //System.Security.SecureString ss = new System.Security.SecureString();
- //foreach (char c in credentialsStorage.Password)
- // ss.AppendChar(c);
-
- ProcessStartInfo psiFab1 = new();
- Process procFab1 = new();
- StringBuilder sb = new();
-
- if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
- psiFab1.FileName = a; // Server.MapPath("/FTPBatch/" + @Functions.FTPSPNBatch_Test());
- } else {
- psiFab1.FileName = b; // Server.MapPath("/FTPBatch/" + @Functions.FTPSPNBatch());
- }
-
- psiFab1.Arguments = sourcefile.FullName + " " + destFile;
-
- psiFab1.RedirectStandardOutput = true;
- psiFab1.UseShellExecute = false;
- psiFab1.WorkingDirectory = c; // Server.MapPath("/FTPBatch/");
- //credentialsStorage = MiscDMO.GetCredentialsInfo("TEMSA01EC", "LocalAdmin");
- //psiFab1.UserName = credentialsStorage.UserName;
- //psiFab1.Password = ss;
-
- procFab1.StartInfo = psiFab1;
- procFab1.OutputDataReceived += (sender, args) => sb.AppendLine(args.Data);
- ;
- procFab1.Start();
- procFab1.BeginOutputReadLine();
- procFab1.WaitForExit(4000);
-
- File.WriteAllText(Path.Combine(ftpLogDirectory, sourcefile.Name + ".txt"), sb.ToString());
-
- //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, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
- return false;
- }
-
- }
-
- public bool SendQDBFlagToSPN(string guid, string userIdentityName, string a, string b, string c) {
- StringBuilder output = new();
- try {
- IEnumerable data = GetMRB_QDB_HoldFlags(guid);
- foreach (string tempData in data) {
- //output = new StringBuilder();
- output.Append(tempData.Trim() + Environment.NewLine);
-
- }
-
- try {
- if (output.Length > 0) {
- DateTime dt = DateTime.Now;
- string newsourceFileName = "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") + ".mrb";
-
- //string outputFile = @"C:\Websites\SPNLotHoldFlag\" + newsourceFileName;
- string outputFile = _AppSettings.HoldFlagDirectory + newsourceFileName;
-
- File.WriteAllText(outputFile, output.ToString());
-
-#if (DEBUG)
- Thread.Sleep(1000);
-#endif
- try {
- //#if (!DEBUG)
- //FTPWrapper spfSPN = new FTPWrapper(outputFile, newDestFileName);
- //spfSPN.FTPToSPN();
-
- if (BatchFTP(outputFile, newDestFileName, _AppSettings.SPNMRBHoldFlagFTPLogDirectory, userIdentityName, a, b, c)) {
- UpdateMRB_QDB_HoldFlag(guid, true);
- } else {
- UpdateMRB_QDB_HoldFlag(guid, false);
- }
-
- //#endif
- } catch (Exception e) {
- string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + guid.ToString() + " FTPToSPN(): FTP Upload Error " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
- EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
- return false;
- }
-
- }
-
- return true;
- } catch (Exception e) {
- string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + guid.ToString() + " SPN Hold Flag(SendToSPN) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
- Functions.WriteEvent(_AppSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
- EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
- return false;
- }
-
- } catch (Exception e) {
- string exceptionString = e.Message.ToString().Trim().Length > 500 ? "GUID =" + guid.ToString() + " SPN Hold Flag(SendToSPN) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
- Functions.WriteEvent(_AppSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
- EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
- return false;
- }
-
- }
-
- public string ImportAddQDBFlag(string operation, out string physicalPath, string userIdentityName, string a, string b, string c, string fullFileName, Stream stream) {
- IEnumerable lotDataList = null;
- var guid = Guid.NewGuid().ToString();
-
- var fileExtension = Path.GetExtension(fullFileName);
- physicalPath = Path.Combine(_AppSettings.LotTempPipeLine, guid + "." + fileExtension);
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
-
-#if !NET8
- ExcelData x = new ExcelData(physicalPath);
- lotDataList = x.ReadQDBFlagData();
-
- foreach (string lotData in lotDataList) {
- InsertMRB_QDB_HoldFlag(guid, lotData, operation);
- }
-#endif
-
- FileInfo f = new(physicalPath);
- if (f.Exists)
- f.Delete();
-
- if (SendQDBFlagToSPN(guid, userIdentityName, a, b, c))
- UpdateMRB_QDB_HoldFlag(guid, true);
- else {
- UpdateMRB_QDB_HoldFlag(guid, false);
- return "Problems while uploading to SPN";
- }
- return string.Empty;
- }
-
- public void AttachSave(int mrbNumber, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
- var fileName = Path.GetFileName(fullFileName);
- string physicalFileName;
- string physicalPath;
-
- // Check to see if this filename is in use
- var attachments = GetMRBAttachments(mrbNumber);
- if (attachments.Count() > 0) {
- if (attachments.Count(a => string.Equals(a.FileName, fileName, StringComparison.OrdinalIgnoreCase)) > 0) {
- // This filename is used on this MRB
- // So we want to delete those records so the new record replaces them
- foreach (var a in attachments) {
- DeleteMRBAttachment(a.AttachmentID);
-
- physicalFileName = a.Path;
- if (string.IsNullOrEmpty(physicalFileName))
- physicalFileName = a.FileName;
- physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "MRB", physicalFileName);
-
- if (File.Exists(physicalPath))
- File.Delete(physicalPath);
- }
- }
- }
-
- physicalFileName = mrbNumber.ToString() + "_" + Guid.NewGuid().ToString() + Path.GetExtension(fileName);
- physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "MRB", physicalFileName);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- MRBAttachment attach = new() {
- MRBNumber = mrbNumber,
- FileName = fileName,
- Path = physicalFileName,
-#if (DEBUG)
- UserID = 114,
-#endif
-
-#if (!DEBUG)
- UserID = userId,
-#endif
- };
- InsertMRBAttachment(attach);
- }
-
- public string ExcelLotOpen(int mrbNumber, StringBuilder warnings, IEnumerable dispos, string userIdentityName, string lotTempPipeLine, string fullFileName, Stream stream) {
- var fileName = Path.GetFileName(fullFileName);
- var fileExtension = Path.GetExtension(fullFileName);
- string fName = userIdentityName + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
- string physicalPath = Path.Combine(lotTempPipeLine, fName + "." + fileExtension);
-
-#if !NET8
- IEnumerable lotNumbers;
-
- try {
- using (var fileStream = new FileStream(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- ExcelData x = new ExcelData(physicalPath);
- lotNumbers = x.ReadData();
- } catch (Exception ex) {
- throw new Exception(String.Format("Invalid file format for {0}: {1}", fileName, ex.Message));
- }
-
- // Get Tool, Issue Start and End Date
-
- MRB mrbInfo = GetToolIssueStartEndDateData(mrbNumber, null);
-
- foreach (var lotInfo in lotNumbers) {
- if (lotInfo.LotDispo.Length == 1) {
- if (dispos.Count(d => d.DispositionType.Trim().ToUpper() == lotInfo.LotDispo.Trim().ToUpper()) == 0) {
- throw new Exception(String.Format("Invalid lot disposition {0} for lot no {1}",
- lotInfo.LotDispo, lotInfo.LotNo));
- }
- }
- }
- // RJK - 12/17
- // Only find the child Splits when a Tool or a list of Tools is provided
- if (!mrbInfo.ToolCSV.ToUpper().Equals("NA")) {
- foreach (var lotInfo in lotNumbers) {
- bool existingLotUpdated;
- Lot l = new Lot();
- l.LotNumber = lotInfo.LotNo;
- if (lotInfo.LotDispo.Length == 1) {
- l.DispoType = lotInfo.LotDispo[0];
- }
- l.MRBNumber = mrbNumber;
- InsertLot(l, true, out existingLotUpdated);
- // cannot do the check below , because what if the parent lot had splits after the prior lot split analysis
- //if (!existingLotUpdated)
- //{
- if (!InsertLotSplitsAffectedByIncident(mrbNumber, l.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate)) {
- warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n Uploaded without Lot Genealogy tracing", l.LotNumber);
- }
- //}
- }
-
- // Not required - Will be using each lot's Insert Date time stamp,
- // as lot could be added using search functionality
- // UpdateLastLotSplitAnalysisTime(mrbNumber);
-
- } else {
- // RJK - 12/17
- // Only find the child Splits when a Tool or a list of Tools is provided
- foreach (var lotInfo in lotNumbers) {
- bool existingLotUpdated;
- Lot l = new Lot();
- l.LotNumber = lotInfo.LotNo;
- if (lotInfo.LotDispo.Length == 1) {
- l.DispoType = lotInfo.LotDispo[0];
- }
- l.MRBNumber = mrbNumber;
- // do not insert any new lots when importing from excel
- InsertLot(l, true, out existingLotUpdated);
- //UpdateLotDispoType(mrbNumber, l.LotNumber, l.DispoType);
-
- //if (!existingLotUpdated)
- //{
- // if (!InsertLotSplitsAffectedByIncident(mrbNumber, l.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate))
- // {
- // warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n", l.LotNumber);
- // }
- //}
- }
- }
-#endif
-
- FileInfo f = new(physicalPath);
- if (f.Exists)
- f.Delete();
-
- return physicalPath;
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/MiscDMO.cs b/Fab2ApprovalSystem/DMO/MiscDMO.cs
index ecad775..6b78475 100644
--- a/Fab2ApprovalSystem/DMO/MiscDMO.cs
+++ b/Fab2ApprovalSystem/DMO/MiscDMO.cs
@@ -22,7 +22,6 @@ public class MiscDMO {
string sql = "";
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
if (searchBy == GlobalVars.LOT_NO)
- //sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM WP_RECORD_MJ WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
else if (searchBy == GlobalVars.LOCATION) {
sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM SPNLot WHERE WP_CURRENT_LOCATION = '" + searchText.Trim() + "' AND WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') IS NOT NULL";
@@ -73,13 +72,6 @@ public class MiscDMO {
sql.Append("SELECT PartNumber + '~' + SiliconPart + '~' + ProcessFlow + '~' + PartDescription AS WIPPartData ");
sql.Append("FROM vWIPPartData WHERE PartNumber LIKE '%" + searchText + "%' ORDER BY PartNumber");
- //StringBuilder sql = new StringBuilder();
- //sql.Append("SELECT TO_PART AS PartNumber, FROM_PART AS SiliconPart, P.MP_DESCRIPTION AS PartDescirption, ");
- //sql.Append("RTRIM(LTRIM(SUBSTRING(TO_PART_PROC, PATINDEX('% %', TO_PART_PROC), LEN(TO_PART_PROC)))) AS ProcessFlow ");
- //sql.Append("FROM TEMIRWAP019.FAB2SPN.dbo.PG_RECORD W ");
- //sql.Append("INNER JOIN TEMIRWAP019.Fab2SPN.dbo.MP_RECORD P ON W.TO_PART = P.MP_PART_NUMBER ");
- //sql.Append("WHERE PartNumber LIKE '%" + searchText + "%' ORDER BY PartNumber ");
-
List parList = db.Query(sql.ToString()).ToList();
db.Close();
return parList;
@@ -92,7 +84,6 @@ public class MiscDMO {
qryLotInfo.Append("WP_CURRENT_QTY, WP_CURRENT_LOCATION, DieLotNumber, DiePartNo, DieCount, MP_QUALITY_CODE FROM SPNLot ");
qryLotInfo.Append("WHERE WP_Lot_No = @LotNumber ");
- //var tempLotNumber = lot.LotNumber.Substring(0, 9);
var tempLotNumber = "";
if (lot.LotNumber.IndexOf('/') >= 0) {
tempLotNumber = lot.LotNumber.Substring(0, lot.LotNumber.IndexOf('/'));
@@ -113,7 +104,7 @@ public class MiscDMO {
// The data is returned from a view which is a combination from various sources and at times when the
// Lot is at the QDB location, which is extracted out of SAP, it also shows up at the 6600 location in SPN.
// There is a duplication.
- //if the result returns 2 records , QDB overrides the other location (6600)
+ // if the result returns 2 records , QDB overrides the other location (6600)
if (lot.Location == "QDB" && lotInfoColumn.WP_CURRENT_LOCATION == "6600")
lot.Location = "QDB";
else
@@ -130,14 +121,13 @@ public class MiscDMO {
} catch { } // ignore the error
try {
- //lot.Gen = double.Parse(temp[2].Substring(1, temp[2].Length - 1));
if (lot.Description.StartsWith("MA,"))
lot.Gen = temp[2];
else
lot.Gen = temp[2].Substring(1, temp[2].Length - 1);
} catch { }// ignore the error
try {
- //lot.Hexsize = double.Parse(temp[6]);
+ // lot.Hexsize = double.Parse(temp[6]);
lot.Hexsize = temp[6];
} catch { }// ignore the error
@@ -184,8 +174,6 @@ public class MiscDMO {
}
// added this code if the data shows up at the 6600 location and also at QDB for a lot.
- //if (lot.DieCost > 0)
- // lot.Location = "QDB";
if (lotInfoColumn.MP_QUALITY_CODE != null)
lot.QualityCode = lotInfoColumn.MP_QUALITY_CODE.Trim();
@@ -193,12 +181,8 @@ public class MiscDMO {
}
db.Close();
- //return lotStatusOption;
}
- ///
- /// /
- ///
public static IEnumerable GetUserList() {
IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
@@ -358,14 +342,6 @@ public class MiscDMO {
public static void GetLTLotInformation(LTLot lot) {
IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
StringBuilder qryLotInfo = new();
- //qryLotInfo.Append("SELECT DISTINCT ");
- //qryLotInfo.Append("WP_LOT_NO, WP_CURRENT_QTY, WP.WP_PART_NUMBER, MP_DESCRIPTION, WP_PROCESS, WO_LOCATION, WO_OPER_NO, WP_STATUS ");
- //qryLotInfo.Append("FROM TEMIRWAP019.FAB2SPN.dbo.WO_RECORD WO ");
- //qryLotInfo.Append("INNER JOIN TEMIRWAP019.FAB2SPN.dbo.WP_RECORD WP ");
- //qryLotInfo.Append("ON WO.WO_LOT_NO = WP.WP_LOT_NO AND WO.InTime = (SELECT MAX(InTime) FROM TEMIRWAP019.FAB2SPN.dbo.WO_RECORD WHERE WO_LOT_NO = @LotNumber) ");
- //qryLotInfo.Append("LEFT JOIN TEMIRWAP019.FAB2SPN.dbo.MP_RECORD MP ");
- //qryLotInfo.Append("ON WP.WP_PART_NUMBER = MP.MP_PART_NUMBER ");
- //qryLotInfo.Append("WHERE WO_LOT_NO = @LotNumber ");
qryLotInfo.Append("SELECT DISTINCT ");
qryLotInfo.Append("WP_LOT_NO, WP_CURRENT_QTY, WP.WP_PART_NUMBER, MP_DESCRIPTION, WP_PROCESS, WP_CURRENT_LOCATION, WP_OPER_NO, WP_STATUS ");
@@ -374,8 +350,6 @@ public class MiscDMO {
qryLotInfo.Append("ON WP.WP_PART_NUMBER = MP.MP_PART_NUMBER ");
qryLotInfo.Append("WHERE WP_LOT_NO = @LotNumber ");
- //var tempLotNumber = lot.LotNumber.Substring(0, 9);
-
var tempLotNumber = "";
if (lot.LotNumber.IndexOf('/') >= 0) {
tempLotNumber = lot.LotNumber.Substring(0, lot.LotNumber.IndexOf('/'));
@@ -437,7 +411,6 @@ public class MiscDMO {
DynamicParameters parameters = new();
parameters.Add("@ApprovalId", approvalId);
db.Query("UpdateApprovalLastNotifyDate", param: parameters, commandType: CommandType.StoredProcedure).Single();
- //return data;
}
- //================================================================== End of Class
+
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/PartsRequestDMO.cs b/Fab2ApprovalSystem/DMO/PartsRequestDMO.cs
index 8d48a9b..da626a3 100644
--- a/Fab2ApprovalSystem/DMO/PartsRequestDMO.cs
+++ b/Fab2ApprovalSystem/DMO/PartsRequestDMO.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.IO;
using System.Linq;
using Dapper;
@@ -13,12 +12,8 @@ namespace Fab2ApprovalSystem.DMO;
public class PartsRequestDMO {
- private readonly AppSettings _AppSettings;
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
- public PartsRequestDMO(AppSettings appSettings) =>
- _AppSettings = appSettings;
-
public IEnumerable GetPartsRequestList() {
List r = db.Query("PartsRequestGetList", commandType: CommandType.StoredProcedure).ToList();
return r;
@@ -114,28 +109,4 @@ public class PartsRequestDMO {
db.Execute("PartsRequestDelete", parameters, commandType: CommandType.StoredProcedure);
}
- public void AttachSave(int prNumber, int userId, string fullFileName, Stream stream) {
- // Some browsers send file names with full path.
- // We are only interested in the file name.
- var fileName = Path.GetFileName(fullFileName);
-
- string prFolderPath = _AppSettings.AttachmentFolder + "PartsRequest\\" + prNumber.ToString();
-
- DirectoryInfo di = new(prFolderPath);
- if (!di.Exists)
- di.Create();
-
- var physicalPath = Path.Combine(prFolderPath, fileName);
-
- using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
- stream.CopyTo(fileStream);
- }
- PartsRequestAttachment attach = new() {
- PRNumber = prNumber,
- FileName = fileName,
- UserID = userId,
- };
- InsertAttachment(attach);
- }
-
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/DMO/SAM_DMO.cs b/Fab2ApprovalSystem/DMO/SAM_DMO.cs
index 08cb4cc..73ceaef 100644
--- a/Fab2ApprovalSystem/DMO/SAM_DMO.cs
+++ b/Fab2ApprovalSystem/DMO/SAM_DMO.cs
@@ -13,7 +13,6 @@ public class SAM_DMO {
public int HasITARAccess(string userID) {
StringBuilder query = new("SELECT COUNT(*) FROM dbo.fnIsUserITARCompliant(@UserID) ");
- //query.Append("WHERE UserID = @UserID AND AND EmployeeStatus = 'Active'");
return db.Query(query.ToString(), new { UserID = userID }).SingleOrDefault();
}
diff --git a/Fab2ApprovalSystem/DMO/TrainingDMO.cs b/Fab2ApprovalSystem/DMO/TrainingDMO.cs
index 5b3b05c..2452282 100644
--- a/Fab2ApprovalSystem/DMO/TrainingDMO.cs
+++ b/Fab2ApprovalSystem/DMO/TrainingDMO.cs
@@ -19,8 +19,6 @@ public class TrainingDMO {
public int Create(int issueId) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@TrainingId", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@ECNNumber", issueId);
@@ -32,9 +30,6 @@ public class TrainingDMO {
public int CreateAssignment(int trainingId, int userId) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
- //parameters.Add("@TrainingId", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@TrainingID", trainingId);
parameters.Add("@UserID", userId);
parameters.Add("@AssignmentID", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
@@ -147,9 +142,6 @@ public class TrainingDMO {
public void AddTrainingGroupToECN(int ECNNumber, int groupId) {
#if !NET8
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
- //ECNTrainingBy ecnTraining = new ECNTrainingBy();
- //ecnTraining.AcknowledgementTrainingByID = groupId;
- //ecnTraining.ECNNumber = ECNNumber;
var parameters = new DynamicParameters();
parameters.Add("@ECNNumber", ECNNumber);
@@ -157,7 +149,6 @@ public class TrainingDMO {
this.db.Execute("ECNInsertTrainingBy", parameters, commandType: CommandType.StoredProcedure);
- //db.ECNTrainingBies.Add(ecnTraining);
#else
throw new NotImplementedException();
#endif
@@ -166,16 +157,11 @@ public class TrainingDMO {
public void SetTrainingFlag(int ECNNumber) {
#if !NET8
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
- //ECNTrainingBy ecnTraining = new ECNTrainingBy();
- //ecnTraining.AcknowledgementTrainingByID = groupId;
- //ecnTraining.ECNNumber = ECNNumber;
-
var parameters = new DynamicParameters();
parameters.Add("@ECNNumber", ECNNumber);
this.db.Execute("ECNSetTrainingFlag", parameters, commandType: CommandType.StoredProcedure);
- //db.ECNTrainingBies.Add(ecnTraining);
#else
throw new NotImplementedException();
#endif
@@ -235,10 +221,7 @@ public class TrainingDMO {
public void AcknowledgeDocument(int trainingDocAckID) {
DynamicParameters parameters = new();
-
- parameters = new DynamicParameters();
parameters.Add("@TrainingDocAckID", trainingDocAckID);
- //parameters.Add("@AttachmentID", attachmentID);
db.Execute("TrainingAcknowledgeDocument", parameters, commandType: CommandType.StoredProcedure);
}
@@ -337,7 +320,7 @@ public class TrainingDMO {
#if !NET8
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
bool isFinished = true;
- //TrainingDocAck docsAssigned = null;
+ // TrainingDocAck docsAssigned = null;
var docsAssigned = from a in db.TrainingDocAcks where a.TrainingAssignmentID == trainingAssignmentID && a.Deleted != true select a;
@@ -447,7 +430,6 @@ public class TrainingDMO {
foreach (TrainingAssignment trainingAssignment in trainingAssignments) {
DeleteTrainingAssignment(trainingAssignment.ID);
DeleteTrainingDocAck(trainingAssignment.ID);
- //db.SaveChanges();
}
#else
throw new NotImplementedException();
@@ -461,9 +443,9 @@ public class TrainingDMO {
var userAssignments = (from a in db.TrainingAssignments where a.UserID == userId select a).ToList();
foreach (var item in userAssignments) {
- //get document assignments
+ // get document assignments
var docAssignments = (from a in db.TrainingDocAcks where a.TrainingAssignmentID == item.TrainingID select a).ToList();
- //delete each docAssignment
+ // delete each docAssignment
foreach (var docAssignment in docAssignments) {
DeleteTrainingDocAck(docAssignment.ID);
}
@@ -479,15 +461,15 @@ public class TrainingDMO {
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
TrainingDocAck ack = (from a in db.TrainingDocAcks where a.ID == docAckId select a).FirstOrDefault();
- //TODO Check the user is valid
+ // TODO Check the user is valid
- //Check that the assignment exists
+ // Check that the assignment exists
if (ack != null) {
- //Check that the assignment isn't deleted
+ // Check that the assignment isn't deleted
if (ack.Deleted == true) {
return false;
}
- //Check that the assignment isn't completed
+ // Check that the assignment isn't completed
else if (ack.Reviewed == true) {
return false;
} else {
diff --git a/Fab2ApprovalSystem/DMO/UserAccountDMO.cs b/Fab2ApprovalSystem/DMO/UserAccountDMO.cs
index df28cda..a3b9ab3 100644
--- a/Fab2ApprovalSystem/DMO/UserAccountDMO.cs
+++ b/Fab2ApprovalSystem/DMO/UserAccountDMO.cs
@@ -17,11 +17,6 @@ public class UserAccountDMO {
public IEnumerable GetAllUsers() {
StringBuilder sql = new();
- //sql.Append("SELECT U.FirstName + ' ' + U.LastName AS FullName, U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName, U.* ");
- //sql.Append("FROM Users U LEFT JOIN Users U1 ");
- //sql.Append("ON U.UserID = U1.DelegatedTo ORDER BY FirstName ");
-
- //sql.Append("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users ORDER BY FirstName ");
sql.Append(" SELECT U.FirstName + ' ' + U.LastName AS FullName, U.* , U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName ");
sql.Append("FROM Users U LEFT JOIN Users U1 ON U.DelegatedTo = U1.UserID ");
sql.Append("ORDER BY FirstName ");
@@ -31,11 +26,6 @@ public class UserAccountDMO {
public IEnumerable GetAllActiveUsers() {
StringBuilder sql = new();
- //sql.Append("SELECT U.FirstName + ' ' + U.LastName AS FullName, U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName, U.* ");
- //sql.Append("FROM Users U LEFT JOIN Users U1 ");
- //sql.Append("ON U.UserID = U1.DelegatedTo ORDER BY FirstName ");
-
- //sql.Append("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users ORDER BY FirstName ");
sql.Append(" SELECT U.FirstName + ' ' + U.LastName AS FullName, U.* , U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName ");
sql.Append("FROM Users U LEFT JOIN Users U1 ON U.DelegatedTo = U1.UserID ");
sql.Append("WHERE U.IsActive = 1 ");
@@ -45,9 +35,6 @@ public class UserAccountDMO {
}
public LoginModel GetUser(string loginID) =>
- //StringBuilder sql = new StringBuilder();
- //sql.Append("SELECT * FROM Users WHERE LoginID = '" + loginID + "'");
- //return this.db.Query(sql.ToString()).SingleOrDefault();
db.Query("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users WHERE LoginID = @loginID AND IsActive = 1 ", new { loginID = loginID }).Take(1).SingleOrDefault();
public LoginModel GetUserByID(int userID) {
@@ -79,7 +66,6 @@ public class UserAccountDMO {
internal void DeleteUser(LoginModel model) {
string sql;
- //sql = "DELETE Users WHERE UserID = @UserID";
sql = "UPDATE Users SET IsActive = 0 WHERE UserID = @UserID";
DynamicParameters parameters = new();
parameters.Add("@UserID", model.UserID);
@@ -88,8 +74,6 @@ public class UserAccountDMO {
}
internal void InsertUser(LoginModel model) {
- //string sql;
- //sql = "INSERT Users (LoginID, FirstName, LastName, IsAdmin) VALUES (@LoginID, @FirstName, @LastName, @IsAdmin )";
DynamicParameters parameters = new();
parameters.Add("@UserID", model.UserID, DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@LoginID", model.LoginID);
diff --git a/Fab2ApprovalSystem/DMO/WorkflowDMO.cs b/Fab2ApprovalSystem/DMO/WorkflowDMO.cs
index be2877b..70f2f26 100644
--- a/Fab2ApprovalSystem/DMO/WorkflowDMO.cs
+++ b/Fab2ApprovalSystem/DMO/WorkflowDMO.cs
@@ -15,18 +15,6 @@ namespace Fab2ApprovalSystem.DMO;
public class WorkflowDMO {
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
- //delegate TResult MathFunction(T1 var1, T2 var2);
-
- //static void PrintResult(MathFunction mathFunction, T1 var1, T2 var2)
- //{
- // TResult result = mathFunction(var1, var2);
- // Console.WriteLine(String.Format("Result is {0}", result));
- //}
-
- //PrintResult((x, y) => x / y, 2, 8);
- //GenericDelegateNumber e = new GenericDelegateNumber(AddInt);
-
public string GetSubRoleItems(int issueID, int docType) {
List subRoleItems = new();
StringBuilder sqlString = new();
@@ -240,19 +228,10 @@ public class WorkflowDMO {
/* ===== Remove the code for Director Approval Loop - Changed per Dixie's request 08/06/2018
*/
- //If Location = "QDB" OR PRRequired or MRB Required OR(Product = MA / RH AND Location = Probe) Get "Director" Role for all departments, except "Facilities"
-
sqlString = new StringBuilder();
- //sqlString.Append("SELECT COUNT(*) FROM LotDisposition LD INNER JOIN Lot L ON LD.IssueID = L.IssueID ");
- //sqlString.Append("WHERE ( ((L.ProductFamily = 'RH' OR L.ProductFamily = 'MA') ");
- //sqlString.Append("AND (Location = '6300' OR Location = '6400' OR Location = '6600')) ");
- //sqlString.Append("OR Location = 'QDB' OR Location = 'EDB' OR LD.PERequired = 1 OR LD.MRBRequired = 1) AND LD.IssueID = @IssueID ");
// 09/01/2020 -
// Per Hans, do not include directors if PE required is checked
- //sqlString.Append("SELECT COUNT(*) FROM LotDisposition LD INNER JOIN Lot L ON LD.IssueID = L.IssueID ");
- //sqlString.Append("WHERE (LD.PERequired = 1 OR Location = 'QDB' OR Location = 'EDB' ) ");
- //sqlString.Append("AND LD.IssueID = @IssueID ");
// 09/01/2020
// Per Hans, do not include directors if PE required is checked
@@ -300,7 +279,6 @@ public class WorkflowDMO {
int recordCount = 0;
// EMERGENCY TECNS ==============================================================================================
if (GlobalVars.DocumentType.EECN == (GlobalVars.DocumentType)documentType) {
- //subRoleItems.Add("'QA Pre Approver'");
qryString.Clear();
qryString.Append("SELECT DISTINCT SRC.SubRoleCategoryItem FROM DocumentType D ");
qryString.Append("INNER JOIN Workflows W ON D.DocumentTypeID = W.DocumentTypeID ");
@@ -309,25 +287,13 @@ public class WorkflowDMO {
qryString.Append("INNER JOIN SubRole SR ON R.RoleID = SR.RoleID ");
qryString.Append("INNER JOIN SubRoleCategory SRC ON SR.SubRoleCategoryID = SRC.SubRoleCategoryID ");
qryString.Append("WHERE D.DocumentTypeID = @DocumentType");
- //qryString.Append("WHERE D.DocumentTypeID = 3");
- //subRoleItems.Add("'QA_Admin'");
List dataRows = db.Query(qryString.ToString(), new { DocumentType = documentType }).ToList();
foreach (var dataRow in dataRows) {
subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
}
- //subRoleItems.Add("'QA Final Approver'");
- } //===============================================================================================================
- else {
+ } else {
subRoleItems.Add("'QA Pre Approver'");
// get the affected Department: Removed by JRO per Jeanne
- //qryString.Clear();
- //qryString.Append("SELECT ModuleName FROM ECNModule E INNER JOIN ECNAffectedModule AM ON E.ModuleID = AM.ModuleID WHERE AM.ECNNumber= @ECNNumber");
- //var dataRows = this.db.Query(qryString.ToString(), new { ECNNumber = ecnNumber }).ToList();
- //foreach (var dataRow in dataRows)
- //{
- // subRoleItems.Add("'" + dataRow.ModuleName.ToString() + "'");
- //}
- // get the approvers
qryString.Clear();
qryString.Append("SELECT SubRoleCategoryItem FROM SubRoleCategory S INNER JOIN ECNAffectedDepartment AD ON S.SubRoleCategoryID = AD.DepartmentID WHERE AD.ECNNumber= @ECNNumber");
List dataRows = db.Query(qryString.ToString(), new { ECNNumber = ecnNumber }).ToList();
@@ -346,13 +312,6 @@ public class WorkflowDMO {
recordCount = db.Query(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
subRoleItems.Add("'Environment'");
- //qryString.Clear();
- //qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'Environment' ");
- //dataRows = this.db.Query(qryString.ToString()).ToList();
- //foreach (var dataRow in dataRows)
- //{
- // subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
- //}
}
// Get the "Capacity" Impact SubRole
@@ -361,13 +320,6 @@ public class WorkflowDMO {
recordCount = db.Query(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
subRoleItems.Add("'Capacity'");
- //qryString.Clear();
- //qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'Capacity' ");
- //dataRows = this.db.Query(qryString.ToString()).ToList();
- //foreach (var dataRow in dataRows)
- //{
- // subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
- //}
}
// Get the "MaterialConsumptionChangeRequired" Impact SubRole
@@ -376,13 +328,6 @@ public class WorkflowDMO {
recordCount = db.Query(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
subRoleItems.Add("'MaterialConsumption'");
- //qryString.Clear();
- //qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'MaterialConsumption' ");
- //dataRows = this.db.Query(qryString.ToString()).ToList();
- //foreach (var dataRow in dataRows)
- //{
- // subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
- //}
}
// Get the "NewPartFlow" Impact SubRole
@@ -392,21 +337,12 @@ public class WorkflowDMO {
if (recordCount > 0) {
subRoleItems.Add("'NewPartFlow'");
subRoleItems.Add("'SPN-Execution'");
- //subRoleItems.Add("'TestProgram'");
subRoleItems.Add("'Metrology Change'");
subRoleItems.Add("'SPC'");
- //qryString.Clear();
- //qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'NewPartFlow' ");
- //dataRows = this.db.Query(qryString.ToString()).ToList();
- //foreach (var dataRow in dataRows)
- //{
- // subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
- //}
}
subRoleItems.Add("'Document Control Admin'");
subRoleItems.Add("'Training Notification'");
- //=======================================================================================================================
// Execution level========================================================================================================
// Get the "SPN" SubRole
@@ -414,15 +350,6 @@ public class WorkflowDMO {
qryString.Append("SELECT COUNT(*) FROM ECN WHERE ECNNumber= @ECNNumber AND (SPNChangeRequired = 1) ");
recordCount = db.Query(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
- //subRoleItems.Add("'SPN-Execution'");
-
- //qryString.Clear();
- //qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'SPN' ");
- //dataRows = this.db.Query(qryString.ToString()).ToList();
- //foreach (var dataRow in dataRows)
- //{
- // subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
- //}
}
// Get the "Metrology Change" SubRole
@@ -622,11 +549,9 @@ public class WorkflowDMO {
public string ReAssignApproval(int issueID, int assignedFromUser, int assignedToUser, byte step, int docType) {
string email = "";
- //string emailArray = "";
string emailIDArray = "";
DynamicParameters parameters = new();
- ;
email = "";
parameters = new DynamicParameters();
parameters.Add("@IssueID", issueID);
@@ -644,11 +569,9 @@ public class WorkflowDMO {
public string DelegateDocumentApproval(int issueID, int delegateFromUser, int delegateToUser) {
string email = "";
- //string emailArray = "";
string emailID = "";
DynamicParameters parameters = new();
- ;
email = "";
parameters = new DynamicParameters();
parameters.Add("@IssueID", issueID);
@@ -664,13 +587,11 @@ public class WorkflowDMO {
public string AddAdditionalApproval(int issueID, string userIDs, byte step, int documentType) {
string email = "";
- //string emailArray = "";
string emailIDArray = "";
string[] arrayOfUsers = userIDs.Split(new char[] { '~' });
DynamicParameters parameters = new();
- ;
for (int i = 0; i < arrayOfUsers.Length; i++) {
email = "";
parameters = new DynamicParameters();
@@ -689,14 +610,12 @@ public class WorkflowDMO {
public string AddEECNApproval(int ecnNumber, byte step, int documentType, string engUserIDs, string opUserIDs) {
string email = "";
- //string emailArray = "";
string emailIDArray = "";
string[] arrayOfUsers = engUserIDs.Split(new char[] { '~' });
- //Engineering SubRole
+ // Engineering SubRole
DynamicParameters parameters = new();
- ;
for (int i = 0; i < arrayOfUsers.Length; i++) {
email = "";
parameters = new DynamicParameters();
@@ -714,7 +633,6 @@ public class WorkflowDMO {
// Operations SubRole
arrayOfUsers = opUserIDs.Split(new char[] { '~' });
parameters = new DynamicParameters();
- ;
for (int i = 0; i < arrayOfUsers.Length; i++) {
email = "";
parameters = new DynamicParameters();
diff --git a/Fab2ApprovalSystem/Fab2ApprovalSystem.csproj b/Fab2ApprovalSystem/Fab2ApprovalSystem.csproj
index 8a39d82..00df588 100644
--- a/Fab2ApprovalSystem/Fab2ApprovalSystem.csproj
+++ b/Fab2ApprovalSystem/Fab2ApprovalSystem.csproj
@@ -275,16 +275,26 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Fab2ApprovalSystem/Global.asax.cs b/Fab2ApprovalSystem/Global.asax.cs
index 7b2daef..8dcb2c7 100644
--- a/Fab2ApprovalSystem/Global.asax.cs
+++ b/Fab2ApprovalSystem/Global.asax.cs
@@ -63,7 +63,7 @@ public class MvcApplication : System.Web.HttpApplication {
protected void Application_EndRequest() {
var context = new HttpContextWrapper(Context);
- //Do a direct 401 unauthorized
+ // Do a direct 401 unauthorized
if (Context.Response.StatusCode == 301 && context.Request.IsAjaxRequest()) {
Context.Response.Clear();
Context.Response.StatusCode = 401;
@@ -79,11 +79,11 @@ public class MvcApplication : System.Web.HttpApplication {
}
protected void Session_End(object sender, EventArgs e) {
- //FormsAuthentication.SignOut();
+ // FormsAuthentication.SignOut();
try {
Session[GlobalVars.SESSION_USERNAME] = "";
Session[GlobalVars.SESSION_USERID] = "";
- Session[GlobalVars.IS_ADMIN] = "";
+ Session[GlobalVars.IS_ADMIN] = null;
} catch (Exception ex) {
Functions.WriteEvent(null, @User.Identity.Name + "\r\n Session Closed - \r\n" + ex.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
}
diff --git a/Fab2ApprovalSystem/Jobs/OOOTrainingReportJob.cs b/Fab2ApprovalSystem/Jobs/OOOTrainingReportJob.cs
index 9661e94..93999c8 100644
--- a/Fab2ApprovalSystem/Jobs/OOOTrainingReportJob.cs
+++ b/Fab2ApprovalSystem/Jobs/OOOTrainingReportJob.cs
@@ -23,15 +23,15 @@ public class OOOTrainingReportJob : IJob {
emailBody += "The following contains open training assignments in the Mesa Approval system for out of office users.";
emailBody += " Please ensure they complete their training assignments promptly upon their return.
";
emailBody += "";
- //Get all users set up to receive the training report email.
+ // Get all users set up to receive the training report email.
List trainingReportUsers = adminDMO.GetTrainingReportUsers();
List emailList = new();
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
+ // emailList.Add("Chase.Tucker@infineon.com");
+ // Get a list of open trainings
List openTrainings = trainingDMO.GetAllOpenTrainings();
foreach (Training training in openTrainings) {
diff --git a/Fab2ApprovalSystem/Misc/AuditHelper.cs b/Fab2ApprovalSystem/Misc/AuditHelper.cs
new file mode 100644
index 0000000..67714d8
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/AuditHelper.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class AuditHelper {
+
+ public static List GetFileNameAndDocument(AppSettings appSettings, AuditDMO auditDMO, string fileGuid, int auditNo) {
+ List results = new();
+ string fileName = auditDMO.GetAuditReportAttachmentFileName(fileGuid);
+ string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
+
+ string ecnFolderPath = appSettings.AttachmentFolder + "Audit\\" + auditNo.ToString();
+ string sDocument = Path.Combine(ecnFolderPath, fileGuid + fileExtension);
+
+ string FDir_AppData = appSettings.AttachmentFolder;
+ if (!sDocument.StartsWith(FDir_AppData)) {
+ sDocument = string.Empty;
+ }
+ results.Add(fileName);
+ results.Add(sDocument);
+ return results;
+ }
+
+ public static void AuditReportAttachSave(AppSettings appSettings, AuditDMO auditDMO, int auditNo, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"Audit\" + auditNo;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"Audit\" + auditNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ AuditReportAttachment attach = new() {
+ AuditNo = auditNo,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId
+
+ };
+
+ auditDMO.InsertAuditReportAttachment(attach);
+ }
+
+ public static void SaveAndInsert(AppSettings appSettings, AuditDMO auditDMO, int caFindingsID, int auditNo, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"Audit\" + auditNo;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"Audit\" + auditNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ AuditReportAttachment attach = new() {
+ CAFindingsID = caFindingsID,
+ AuditNo = auditNo,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId
+
+ };
+
+ auditDMO.InsertAuditReportAttachment(attach);
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/ChangeControlHelper.cs b/Fab2ApprovalSystem/Misc/ChangeControlHelper.cs
new file mode 100644
index 0000000..6357de6
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/ChangeControlHelper.cs
@@ -0,0 +1,96 @@
+using System;
+using System.IO;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class ChangeControlHelper {
+
+ public static void AttachSaveCC(AppSettings appSettings, ChangeControlDMO changeControlDMO, int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ CCAttachment attach = new() {
+ ID = attachID,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId
+ };
+
+ changeControlDMO.UpdateCCAttachmentDocument(attach);
+ }
+
+ public static void AttachSaveMeeting(AppSettings appSettings, ChangeControlDMO changeControlDMO, int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ CCMeetingAttachment attach = new() {
+ ID = attachID,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId
+ };
+
+ changeControlDMO.UpdateMeetingAttachmentDocument(attach);
+ }
+
+ public static void AttachSaveActionItem(AppSettings appSettings, ChangeControlDMO changeControlDMO, int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ CCMeetingActionItemAll attach = new() {
+ ID = attachID,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId
+
+ };
+
+ changeControlDMO.UpdateActionItemAttachment(attach);
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/CorrectiveActionHelper.cs b/Fab2ApprovalSystem/Misc/CorrectiveActionHelper.cs
new file mode 100644
index 0000000..f8507a2
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/CorrectiveActionHelper.cs
@@ -0,0 +1,464 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class CorrectiveActionHelper {
+
+ public static void ProcessCARDueDates(AppSettings appSettings, CAD3D5D7Due dueCA, CorrectiveAction ca, LoginModel user) {
+ string[] emailparams = new string[7];
+ string emailTemplate = "D3D5D7Due.txt";
+ string senderName = "CorrectiveAction";
+ string subject = "Corrective Action " + dueCA.ItemDue + " " + dueCA.ExpiryType + " - " + Functions.ReturnCANoStringFormat(dueCA.CANo);
+ 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 is null ? string.Empty : ca.D3DueDate.Value.ToString();
+ } else {
+ emailparams[5] = "N/A";
+ }
+ if (ca.D5D7DueDate != null) {
+ emailparams[6] = ca.D5D7DueDate is null ? string.Empty : ca.D5D7DueDate.Value.ToString();
+ } else {
+ emailparams[6] = "N/A";
+ }
+
+ EmailNotification en = new(appSettings, subject);
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, user.Email, "jonathan.ouellette@infineon.com", subject, emailparams);
+ }
+
+ public static void NotifyUsersDSectionApproved(AppSettings appSettings, int issueID, string dSection, string userEmail) {
+ string senderName = "CorrectiveAction";
+ string emailTemplate = "CorrectiveActionSectionApproved.txt";
+ string subject = "Corrective Action Section Approval - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = dSection;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static void NotifyForD5D6D7Validation(AppSettings appSettings, int issueID, string dSection, string userEmail) {
+ string senderName = "CorrectiveAction";
+ string emailTemplate = "CorrectiveActionSectionApproved.txt";
+ string subject = "Corrective Action Section Approval - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = dSection;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static void NotifySectionRejection(AppSettings appSettings, int issueID, int loggedInUserId, string section, string comment, LoginModel recipient, LoginModel loggedInUser) {
+ string senderName = "CorrectiveAction";
+ string recipientEmail = recipient.Email;
+ string emailTemplate = "CorrectiveActionSectionRejection.txt";
+ string subject = "Corrective Action Rejection - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ 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;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, recipientEmail, null, subject, emailparams);
+ }
+
+ public static void NotifySectionRejection(AppSettings appSettings, int issueID, string section, string comment, LoginModel recipient, LoginModel loggedInUser) {
+ string senderName = "CorrectiveAction";
+ string recipientEmail = recipient.Email;
+ string emailTemplate = "CorrectiveActionSectionRejection.txt";
+ string subject = "Corrective Action Rejection - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ 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;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, recipientEmail, null, subject, emailparams);
+ }
+
+ public static string NotifyCompletionOf8D(AppSettings appSettings, int issueID, DateTime? followUpDate) {
+ string emailSentList = "";
+ string senderName = "CorrectiveAction";
+ string emailTemplate = "CorrectiveActionCompleted.txt";
+ List emailIst = MiscDMO.Get8DEmailListForClosureNotification(issueID);
+ string subject = "Corrective Action Completion - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ 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 is null ? string.Empty : followUpDate.Value.ToString();
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyClosureOf8D(AppSettings appSettings, int issueID) {
+ string emailSentList = "";
+ string senderName = "CorrectiveAction";
+ string emailTemplate = "CorrectiveActionClosed.txt";
+ List emailIst = MiscDMO.Get8DEmailListForClosureNotification(issueID);
+ string subject = "Corrective Action Follow Up Closure - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ foreach (string email in emailIst) {
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = GlobalVars.hostURL;
+ emailparams[2] = issueID.ToString();
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyActionItemCompletion(AppSettings appSettings, int issueID, DateTime? dueDate, int? recipientId, string template) {
+ string emailSentList = "";
+ string emailTemplate = template;
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string email = MiscDMO.GetEmail(recipientId);
+ string subject = "8D Action Item Completion - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = dueDate is null ? string.Empty : dueDate.Value.ToString();
+ emailparams[2] = Functions.DocumentTypeMapper(GlobalVars.DocumentType.CorrectiveAction);
+ emailparams[3] = GlobalVars.hostURL;
+ emailparams[4] = issueID.ToString();
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
+ emailSentList += email + ",";
+ return email;
+ }
+
+ public static string NotifyActionItemOwner(AppSettings appSettings, int issueID, DateTime? dueDate, int? responsibleOwnerID, string template) {
+ string emailSentList = "";
+ string emailTemplate = template;
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string email = MiscDMO.GetEmail(responsibleOwnerID);
+ string subject = "Action Item in " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = dueDate is null ? string.Empty : dueDate.Value.ToString();
+ emailparams[2] = Functions.DocumentTypeMapper(GlobalVars.DocumentType.CorrectiveAction);
+ emailparams[3] = GlobalVars.hostURL;
+ emailparams[4] = issueID.ToString();
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
+ emailSentList += email + ",";
+ return email;
+ }
+
+ public static void NotifyAssignee(AppSettings appSettings, int issueID, string template, DateTime? D3DueDate, DateTime? D5D7DueDate, string email) {
+ string emailSentList = "";
+ string emailTemplate = template;
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string subject = "CAR Assigned - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ 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] = D3DueDate is not null ? D3DueDate.Value.ToString() : "N/A";
+ emailparams[5] = D5D7DueDate is not null ? D5D7DueDate.Value.ToString() : "N/A";
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ public static void NotifyRequestor(AppSettings appSettings, int issueID, DateTime? dueDate, string template, string email) {
+ string emailSentList = "";
+ string emailTemplate = template;
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string subject = "Corrective Action Assignment - " + Functions.ReturnCANoStringFormat(issueID);
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = dueDate is null ? string.Empty : dueDate.Value.ToString();
+ emailparams[2] = Functions.DocumentTypeMapper(GlobalVars.DocumentType.CorrectiveAction);
+ emailparams[3] = GlobalVars.hostURL;
+ emailparams[4] = issueID.ToString();
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, email, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ public static string AddAdditionalApproval(AppSettings appSettings, int issueID, string emailSentList, string emailArray) {
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string emailTemplate = "CorrectiveActionAssigned.txt";
+ string subject = "Corrective Action Assignment - Final Approval";
+
+ string[] emailIst = emailArray.Split(new char[] { '~' });
+ foreach (string email in emailIst) {
+ if (email.Length > 0) {
+ subject = "Corrective Action Assignment";
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyApprovers(AppSettings appSettings, int issueID, List emailIst) {
+ string emailSentList = "";
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string subject = "Corrective Action Assignment";
+ string emailTemplate = "CorrectiveActionAssigned.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Corrective Action Assignment - Final Approval";
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static void NotifySectionApprover(AppSettings appSettings, int issueID, string section, string userEmail) {
+ string senderName = "CorrectiveAction";
+ string subject = "Corrective Action Assignment";
+ string emailTemplate = "CorrectiveActionSectionAssignee.txt";
+
+ subject = "Corrective Action Assignment - Section Approval";
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = section;
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static string NotifyRejectionToAssignee(AppSettings appSettings, int issueID, string comments, string username, List emailIst) {
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string subject = "Corrective Action Rejection";
+ string emailTemplate = "CorrectiveActionReject.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Corrective Action Rejection";
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = username;
+ emailparams[4] = comments;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ return userEmail;
+ }
+
+ public static void ReAssignApproval(AppSettings appSettings, int issueID, string email) {
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string subject = "Corrective Action Re-Assignment";
+ string emailTemplate = "CorrectiveActionReAssigned.txt";
+
+ subject = "Corrective Action Re-Assignment" + " - Email would be sent to " + email;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static void ReAssignApproverByAdmin(AppSettings appSettings, int issueID, string email) {
+ string userEmail = string.Empty;
+ string senderName = "CorrectiveAction";
+ string subject = "Corrective Action Re-Assignment";
+ string emailTemplate = "CorrectiveActionReAssigned.txt";
+
+ subject = "Corrective Action Re-Assignment" + " - Email would be sent to " + email;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = Functions.ReturnCANoStringFormat(issueID);
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static void AttachSave(AppSettings appSettings, CorrectiveActionDMO correctiveActionDMO, int caNo, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ CA_Attachment attach = new() {
+ CANo = caNo,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId,
+ Section = Functions.CASectionMapper(GlobalVars.CASection.Main)
+ };
+
+ correctiveActionDMO.InsertCAAttachment(attach);
+ }
+
+ public static void D4FilesAttachSave(AppSettings appSettings, CorrectiveActionDMO correctiveActionDMO, int caNo, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ CA_Attachment attach = new() {
+ CANo = caNo,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId,
+ Section = Functions.CASectionMapper(GlobalVars.CASection.D4)
+
+ };
+
+ correctiveActionDMO.InsertCAAttachment(attach);
+ }
+
+ public static void SaveD7PA_Attachemnt(AppSettings appSettings, CorrectiveActionDMO correctiveActionDMO, int d7PAID, int caNo, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ CA_Attachment attach = new() {
+ D7PAID = d7PAID,
+ CANo = caNo,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId,
+ Section = Functions.CASectionMapper(GlobalVars.CASection.D7)
+
+ };
+
+ correctiveActionDMO.InsertCAAttachment(attach);
+ }
+
+ public static void SaveD5D6CA_Attachemnt(AppSettings appSettings, CorrectiveActionDMO correctiveActionDMO, int d5d6CAID, int caNo, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var ccPhysicalPath = appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
+ di = new DirectoryInfo(ccPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ CA_Attachment attach = new() {
+ D5D6CAID = d5d6CAID,
+ CANo = caNo,
+ FileGUID = guid,
+ FileName = fileName,
+ UploadedByID = userId,
+ Section = Functions.CASectionMapper(GlobalVars.CASection.D5)
+
+ };
+
+ correctiveActionDMO.InsertCAAttachment(attach);
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/ECNHelper.cs b/Fab2ApprovalSystem/Misc/ECNHelper.cs
new file mode 100644
index 0000000..770927f
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/ECNHelper.cs
@@ -0,0 +1,524 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+using Fab2ApprovalSystem.ViewModels;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class ECNHelper {
+
+ private const string ECN_PREFIX = "ECN_";
+ private const string TECN_PREFIX = "TECN_";
+ private const string ETECN_PREFIX = "ETECN_";
+
+ public static bool IsITAR(ECN ecn) {
+ if (ecn.IsRH && !ecn.IsAU && !ecn.IsIndustrial && !ecn.IsMA) {
+ return true;
+ } else
+ return false;
+ }
+
+ public static string NotifyEmergencyTECNApproval(AppSettings appSettings, int ecnNumber, DateTime? expDate, ECN ecn) {
+ string emailSentList = "";
+ string senderName = "E-TECN";
+ string userEmail = string.Empty;
+ string subject = "E-TECN Approved";
+ string emailTemplate = "ETECNApproved.txt";
+ List emailIst = MiscDMO.GetEmergencyTECNApprovalNotifyList(ecnNumber).Distinct().ToList();
+ string ecnFolderPath = appSettings.AttachmentFolder + "E-TECNZipped\\" + ETECN_PREFIX + ecnNumber.ToString() + ".zip";
+ subject = "E-TECN Approved notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "E-TECN";
+ emailparams[4] = expDate is null ? string.Empty : expDate.Value.ToString();
+
+ if (IsITAR(ecn))
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
+ else
+ en.SendNotificationEmailWithAttachment(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, ecnFolderPath, emailparams);
+
+ emailSentList = string.Join(", ", emailIst.Distinct().ToArray());
+ return emailSentList;
+ }
+
+ public static string NotifyApproversForCancellation(AppSettings appSettings, int ecnNumber, byte currentStep, int documentType, string ecnTypeString, ECN ecn) {
+ string emailSentList = "";
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "TECNCancellationApproval.txt";
+ List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
+ string subject = ecnTypeString + " Cancellation Approval Required - " + ecnNumber + " for " + ecn.Title + ", Cancellation initiated on :" + ecn.CancellationDate;
+ foreach (string email in emailIst) {
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = ecnTypeString;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyApproversForRecall(AppSettings appSettings, int ecnNumber, byte currentStep, int documentType, string ecnTypeString, string recallComments, ECN ecn) {
+ string emailSentList = "";
+
+ List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
+ emailIst.Add("Jeanne.McIntyre@infineon.com");
+ emailIst.Add("Jonathan.Ouellette@infineon.com");
+ string emailTemplate = "ECNRecallApproval.txt";
+ string userEmail = string.Empty;
+ string subject = ecnTypeString + " Recalled - " + ecnNumber + " for " + ecn.Title + ", Recall initiated on :" + DateTime.Now.ToString();
+ string senderName = ecnTypeString;
+
+ foreach (string email in emailIst) {
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = ecnTypeString;
+ emailparams[4] = recallComments;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyApproversForExpiration(AppSettings appSettings, int ecnNumber, byte currentStep, int documentType, string ecnTypeString, ECN ecn) {
+ string emailSentList = "";
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "TECNExpirationApproval.txt";
+ List emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
+ string subject = " TECN Expiration Approval Reqquired - " + ecnTypeString + "# " + ecnNumber + " for " + ecn.Title + ", Expired:" + ecn.ExpirationDate;
+
+ foreach (string email in emailIst) {
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = ecnTypeString;
+ userEmail = email;
+#if (DEBUG)
+ userEmail = GlobalVars.SENDER_EMAIL;
+#endif
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyTECNCancellation(AppSettings appSettings, UserAccountDMO userDMO, int ecnNumber, string ecnFolderPath, ECN ecn, List notificationUserList) {
+ string emailSentList = "";
+ List emailIst = MiscDMO.GetTECNCancelledApprovalNotifyList(ecnNumber).Distinct().ToList();
+ foreach (int userId in notificationUserList) {
+ string email = userDMO.GetUserEmailByID(userId);
+ if (email != null && !emailIst.Contains(email))
+ emailIst.Add(email);
+ }
+
+ string subject = string.Empty;
+ string userEmail = string.Empty;
+ string emailTemplate = "TECNCancelled.txt";
+ if (ecn.CancellationApprovalDate == null) {
+ subject = "TECN Cancellation Initiated Notice - " + ecnNumber + " for " + ecn.Title + ", Cancellation Initiated on:" + DateTime.Now;
+ } else {
+ subject = "TECN Cancellation Approved Notice - " + ecnNumber + " for " + ecn.Title + ", Cancelled:" + ecn.CancellationApprovalDate;
+ }
+ string senderName = "ECN";
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "TECN";
+ emailparams[4] = DateTime.Now.ToString();
+
+#if (DEBUG)
+ userEmail = GlobalVars.SENDER_EMAIL;
+#endif
+
+ if (IsITAR(ecn))
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
+ else
+ en.SendNotificationEmailWithAttachment(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, ecnFolderPath, emailparams);
+ emailSentList = string.Join(", ", emailIst.Distinct().ToArray());
+ return emailSentList;
+ }
+
+ public static string NotifyTECNAutoCancellation(AppSettings appSettings, int ecnNumber, int tecnNumber, List attachments, ECN ecn) {
+ string emailSentList = "";
+ string senderName = "ECN";
+ string subject = string.Empty;
+ string userEmail = string.Empty;
+ string emailTemplate = "TECNAutoCancelled.txt";
+ List emailIst = MiscDMO.GetTECNCancelledApprovalNotifyList(ecnNumber).Distinct().ToList();
+ subject = "TECN Conversion and Cancellation Notice - " + tecnNumber + " for " + ecn.Title + ", Converted on:" + DateTime.Now;
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[6];
+ emailparams[0] = tecnNumber.ToString();
+ emailparams[1] = tecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "TECN";
+ emailparams[4] = DateTime.Now.ToString();
+ emailparams[5] = ecnNumber.ToString();
+
+#if (DEBUG)
+ userEmail = GlobalVars.SENDER_EMAIL;
+#endif
+
+ if (IsITAR(ecn))
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
+ else
+ en.SendNotificationEmailWithAttachments(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, attachments, emailparams);
+ emailSentList = string.Join(", ", emailIst.Distinct().ToArray());
+ return emailSentList;
+ }
+
+ public static string NotifyTECNExpiration(AppSettings appSettings, int ecnNumber, string ecnFolderPath, ECN ecn) {
+ string emailSentList = "";
+ string senderName = "ECN";
+ string userEmail = string.Empty;
+ string emailTemplate = "TECNExpired.txt";
+ List emailIst = MiscDMO.GetEmergencyTECNApprovalNotifyList(ecnNumber).Distinct().ToList();
+ string subject = "TECN Expiration Approved Notice - " + ecnNumber + " for " + ecn.Title + ", Expired:" + ecn.ExpirationDate;
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "TECN";
+ emailparams[4] = ecn.ExpirationDate.Value.ToShortDateString();
+
+ if (IsITAR(ecn))
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
+ else
+ en.SendNotificationEmailWithAttachment(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, ecnFolderPath, emailparams);
+
+ emailSentList = string.Join(", ", emailIst.Distinct().ToArray());
+ return emailSentList;
+ }
+
+ public static void ReAssignApproval(AppSettings appSettings, int issueID, string ecnTypeString, string email, ECN ecn) {
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "ECNReAssigned.txt";
+ string subject = ecnTypeString + " Re-Assignment";
+
+ subject = ecnTypeString + " Re-Assignment" + " - Email would be sent to " + email + " for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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);
+ }
+
+ public static string AddEECNApproval(AppSettings appSettings, int ecnNumber, string emailSentList, string emailArray, ECN ecn) {
+ string senderName = "E-TECN";
+ string userEmail = string.Empty;
+ string subject = "E-TECN Assignment";
+ string emailTemplate = "ECNAssigned.txt";
+ string[] emailIst = emailArray.Split(new char[] { '~' });
+ foreach (string email in emailIst) {
+ if (email.Length > 0) {
+ subject = "E-TECN Assignment notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "E-TECN";
+
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+
+ }
+
+ }
+
+ return emailSentList;
+ }
+
+ public static string AddAdditionalApproval(AppSettings appSettings, int issueID, string ecnTypeString, string emailSentList, string emailArray, ECN ecn) {
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "ECNAssigned.txt";
+ string subject = ecnTypeString + " Assignment";
+ string[] emailIst = emailArray.Split(new char[] { '~' });
+ foreach (string email in emailIst) {
+ if (email.Length > 0) {
+ subject = ecnTypeString + "Assignment notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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);
+ emailSentList += email + ",";
+
+ }
+
+ }
+
+ return emailSentList;
+ }
+
+ public static void ReAssignApproverByAdmin(AppSettings appSettings, int issueID, string ecnTypeString, string email, ECN ecn) {
+ string subject;
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "ECNReAssigned.txt";
+
+ subject = ecnTypeString + " Re-Assignment" + " - ECN #" + ecn.ECNNumber + ", - " + ecn.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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);
+ }
+
+ public static string NotifyTECNExtensionRejectionToOrginator(AppSettings appSettings, int issueID, string ecnTypeString, List emailIst, ECN ecn, string username) {
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string subject = ecnTypeString + " Rejection";
+ string emailTemplate = "TECNExtensionReject.txt";
+
+ foreach (string email in emailIst) {
+ subject = ecnTypeString + " Extension Rejection notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = issueID.ToString();
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = username;
+ emailparams[4] = ecnTypeString;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ return userEmail;
+ }
+
+ public static string NotifyRejectionToOrginator(AppSettings appSettings, int issueID, string ecnTypeString, string comments, List emailIst, ECN ecn, string username) {
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "ECNReject.txt";
+ string subject = ecnTypeString + " Rejection";
+
+ foreach (string email in emailIst) {
+ subject = ecnTypeString + " Rejection notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[6];
+ emailparams[0] = issueID.ToString();
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = username;
+ emailparams[4] = ecnTypeString;
+ emailparams[5] = comments;
+ userEmail = email;
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ return userEmail;
+ }
+
+ public static string NotifyApprovers(AppSettings appSettings, int ecnNumber, string ecnTypeString, string emailSentList, ECN ecn, List emailIst) {
+ string subject = string.Empty;
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "ECNAssigned.txt";
+
+ subject = ecnTypeString + " Assignment notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+ foreach (string email in emailIst) {
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = ecnTypeString;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyAdmin(AppSettings appSettings, int ecnNumber, string ecnTypeString, ECN ecn, int id) {
+ string emailSentList;
+ string subject = string.Empty;
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "ECNApproved.txt";
+ string ecnCreatedByEmail = MiscDMO.GetEmail(id);
+
+ subject = ecnTypeString + " Approval notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = ecnTypeString;
+ userEmail = ecnCreatedByEmail;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList = ecnCreatedByEmail;
+ return emailSentList;
+ }
+
+ public static string NotifySubmitter(AppSettings appSettings, int ecnNumber, string ecnTypeString, ECN ecn) {
+ string emailSentList;
+ string subject = string.Empty;
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ int ecnCreatedById = ecn.OriginatorID;
+ string emailTemplate = "ECNApproved.txt";
+ string ecnCreatedByEmail = MiscDMO.GetEmail(ecnCreatedById);
+
+ subject = ecnTypeString + " Approval notice for Number " + ecn.ECNNumber + ", - " + ecn.Title;
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ecnNumber.ToString();
+ emailparams[1] = ecnNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = ecnTypeString;
+ userEmail = ecnCreatedByEmail;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList = ecnCreatedByEmail;
+ return emailSentList;
+ }
+
+ public static bool CreateZip(AppSettings appSettings, ECNPdf ecn, string UserId) {
+ try {
+ string sourceDirectory = appSettings.AttachmentFolder + "ECN\\" + ecn.ECNNumber.ToString() + "\\";
+ string outputFullFilePath = "";
+
+ string outputFileName;
+ if (ecn.IsTECN) {
+ if (ecn.ExtensionDate != null)
+ outputFileName = TECN_PREFIX + ecn.ECNNumber.ToString() + "_Extension.zip";
+ else
+ outputFileName = TECN_PREFIX + ecn.ECNNumber.ToString() + ".zip";
+
+ outputFullFilePath = appSettings.AttachmentFolder + "\\ECNZipped\\" + outputFileName;
+ } else if (ecn.IsEmergencyTECN) // Transfer it to different folder , coz documentum does not need to have a Workflow Item created for Emergency TECN
+ {
+ outputFileName = ETECN_PREFIX + ecn.ECNNumber.ToString() + ".zip";
+ outputFullFilePath = appSettings.AttachmentFolder + "\\E-TECNZipped\\" + outputFileName;
+ } else {
+ outputFileName = ECN_PREFIX + ecn.ECNNumber.ToString() + ".zip";
+ outputFullFilePath = appSettings.AttachmentFolder + "\\ECNZipped\\" + outputFileName;
+ }
+
+ Zipper zip = new();
+ zip.CreateZip(outputFullFilePath, sourceDirectory);
+ } catch (Exception ex) {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ecn.ECNNumber, UserID = UserId, DocumentType = ecn.IsECN ? "ECN" : (ecn.IsEmergencyTECN ? "E-TECN" : "TECN"), OperationType = "Error", Comments = ex.Message });
+ return false;
+ }
+
+ return true;
+ }
+
+ public static string AddEECNApproval(AppSettings appSettings, string userId, WorkflowDMO wfDMO, int ecnNumber, out byte step, string engUserIDs, string OpUserIDs, ECN ecn) {
+ string emailSentList = "";
+ step = 1;
+ string emailArray = "";
+ try {
+ emailArray = wfDMO.AddEECNApproval(ecnNumber, step, (int)GlobalVars.DocumentType.EECN, engUserIDs, OpUserIDs);
+ } catch (Exception e) {
+ string detailedException = "";
+ try {
+ detailedException = e.InnerException.ToString();
+ } catch {
+ detailedException = e.Message;
+ }
+ string exceptionString = e.Message.ToString().Trim().Length > 500 ? "Issue=" + ecnNumber.ToString() + " Step:" + step + " " + " Userid:" + engUserIDs + " - " + OpUserIDs + " - " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
+ Functions.WriteEvent(appSettings, userId + "\r\n AddEECNApproval\r\n" + detailedException, System.Diagnostics.EventLogEntryType.Error);
+ EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = userId, DocumentType = "E-TECN ", OperationType = "Error", Comments = "AddEECNApproval - " + exceptionString });
+ throw new Exception(e.Message);
+ }
+ emailSentList = AddEECNApproval(appSettings, ecnNumber, emailSentList, emailArray, ecn);
+ return emailSentList;
+ }
+
+ public static string AttachSave(AppSettings appSettings, ECN_DMO ecnDMO, int ecnNumber, string returnString, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+ var fileName = Path.GetFileName(fullFileName);
+
+ string ecnFolderPath = appSettings.AttachmentFolder + "ECN\\" + ecnNumber.ToString();
+
+ DirectoryInfo di = new(ecnFolderPath);
+ if (!di.Exists)
+ try {
+ di.Create();
+ } catch {
+ returnString = "Error creating ECN directory.";
+ }
+ if (returnString == "") {
+ var physicalPath = Path.Combine(ecnFolderPath, fileName);
+ if (!File.Exists(physicalPath)) {
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ ECNAttachment attach = new() {
+ ECNNumber = ecnNumber,
+ FileName = fileName,
+ UserID = userId,
+ };
+ if (File.Exists(physicalPath)) {
+ ecnDMO.InsertECNAttachment(attach);
+ } else {
+ returnString = "File was not uploaded to server.";
+ }
+ } else {
+ returnString = "Cannot have duplicate file names.";
+ }
+ }
+
+ return returnString;
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/EmailNotification.cs b/Fab2ApprovalSystem/Misc/EmailNotification.cs
index 01abf69..ce1e29c 100644
--- a/Fab2ApprovalSystem/Misc/EmailNotification.cs
+++ b/Fab2ApprovalSystem/Misc/EmailNotification.cs
@@ -22,6 +22,12 @@ public class EmailNotification {
public EmailNotification(Models.AppSettings appSettings) =>
_AppSettings = appSettings;
+ public EmailNotification(Models.AppSettings appSettings, string EmailHeaderSubject) {
+ _AppSettings = appSettings;
+ _subject = EmailHeaderSubject;
+ _TemplatesPath = appSettings.EmailTemplatesPath;
+ }
+
///
/// The Constructor Function
///
@@ -52,16 +58,15 @@ public class EmailNotification {
protected string ReadEmailFile(string FileName) {
string retVal = null;
try {
- //setting the file name path
string path = _TemplatesPath + FileName;
#if !NET8
FileInfo TheFile = new FileInfo(System.Web.HttpContext.Current.Server.MapPath(path));
- //check if the file exists in the location.
+ // check if the file exists in the location.
if (!TheFile.Exists)
throw new Exception("Could Not Find the file : " + FileName + " in the location " + _TemplatesPath); // throw an exception here.
- //start reading the file. i have used Encoding 1256 to support arabic text also.
+ // start reading the file. i have used Encoding 1256 to support arabic text also.
StreamReader sr = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(@path), System.Text.Encoding.GetEncoding(1256));
retVal = sr.ReadToEnd(); // getting the entire text from the file.
sr.Close();
@@ -88,21 +93,19 @@ public class EmailNotification {
msg.IsBodyHtml = true;// email body will allow html elements
// setting the Sender Email ID
- //msg.From = new MailAddress(SenderEmail, SenderName);
msg.From = new MailAddress("MesaFabApproval@infineon.com", "Mesa Fab Approval");
msg.Sender = new MailAddress("MesaFabApproval@infineon.com", "Mesa Fab Approval");
// adding the Recepient Email ID
msg.To.Add(Recep);
- //msg.To.Add("Jonathan.Ouellette@infineon.com");
// add CC email ids if supplied.
if (!string.IsNullOrEmpty(cc))
msg.CC.Add(cc);
- //setting email subject and body
+ // setting email subject and body
msg.Subject = email_title;
msg.Body = email_body;
- //create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
+ // create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
SmtpClient SmtpMail = new("mailrelay-internal.infineon.com");
// sending the message.
@@ -130,12 +133,12 @@ public class EmailNotification {
if (!string.IsNullOrEmpty(cc))
msg.CC.Add(cc);
- //setting email subject and body
+ // setting email subject and body
msg.Subject = email_title;
msg.Body = email_body;
msg.Attachments.Add(new Attachment(attachmentPath));
- //create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
+ // create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
SmtpClient SmtpMail = new();
#if(!DEBUG)
// sending the message.
@@ -150,7 +153,6 @@ public class EmailNotification {
msg.IsBodyHtml = true;// email body will allow html elements
// setting the Sender Email ID
- //msg.From = new MailAddress(SenderEmail, SenderName);
msg.From = new MailAddress("MesaFabApproval@infineon.com", "Mesa Fab Approval");
// adding the Recepient Email ID
foreach (string recepient in RecepientList) {
@@ -161,11 +163,11 @@ public class EmailNotification {
if (!string.IsNullOrEmpty(cc))
msg.CC.Add(cc);
- //setting email subject and body
+ // setting email subject and body
msg.Subject = email_title;
msg.Body = email_body;
- //create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
+ // create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
SmtpClient SmtpMail = new();
// sending the message.
@@ -196,12 +198,12 @@ public class EmailNotification {
if (!string.IsNullOrEmpty(cc))
msg.CC.Add(cc);
- //setting email subject and body
+ // setting email subject and body
msg.Subject = email_title;
msg.Body = email_body;
msg.Attachments.Add(new Attachment(attachmentPath));
- //create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
+ // create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
SmtpClient SmtpMail = new();
// sending the message.
@@ -223,14 +225,14 @@ public class EmailNotification {
if (!string.IsNullOrEmpty(cc))
msg.CC.Add(cc);
- //setting email subject and body
+ // setting email subject and body
msg.Subject = email_title;
msg.Body = email_body;
foreach (string attachment in attachments) {
msg.Attachments.Add(new Attachment(attachment));
}
- //create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
+ // create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
SmtpClient SmtpMail = new();
#if(!DEBUG)
// sending the message.
@@ -256,7 +258,7 @@ public class EmailNotification {
if (!string.IsNullOrEmpty(cc))
msg.CC.Add(cc);
- //setting email subject and body
+ // setting email subject and body
msg.Subject = email_title;
msg.Body = email_body;
@@ -264,7 +266,7 @@ public class EmailNotification {
msg.Attachments.Add(new Attachment(attachment));
}
- //create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
+ // create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
SmtpClient SmtpMail = new();
// sending the message.
@@ -285,16 +287,16 @@ public class EmailNotification {
public string SendNotificationEmail(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, params string[] Args) {
string retVal = null;
- //reading the file
+ // reading the file
string FileContents = ReadEmailFile(EmailTemplateFile);
string emailBody = FileContents;
- //setting formatting the string
+ // setting formatting the string
retVal = string.Format(emailBody, Args);
try {
- //check if we are in debug mode or not. to send email
+ // check if we are in debug mode or not. to send email
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
SendEmail(SenderEmail, SenderName, GetTestRecipientsList(), CC, (!string.IsNullOrEmpty(Subject) ? Subject + " for: " + RecepientEmail : _subject), retVal);
} else {
@@ -316,16 +318,16 @@ public class EmailNotification {
public string SendNotificationEmailWithAttachment(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, string attachmentPath, params string[] Args) {
string retVal = null;
- //reading the file
+ // reading the file
string FileContents = ReadEmailFile(EmailTemplateFile);
string emailBody = FileContents;
- //setting formatting the string
+ // setting formatting the string
retVal = string.Format(emailBody, Args);
try {
- //check if we are in debug mode or not. to send email
+ // check if we are in debug mode or not. to send email
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
SendEmailWithAttachment(SenderEmail, SenderName, GetTestRecipientsList(), CC, (!string.IsNullOrEmpty(Subject) ? " TESTING ONLY -IGNORE : " + Subject + RecepientEmail : _subject), retVal, attachmentPath);
} else {
@@ -343,16 +345,16 @@ public class EmailNotification {
public string SendNotificationEmailWithAttachment(string EmailTemplateFile, string SenderEmail, string SenderName, List RecepientEmail, string CC, string Subject, string attachmentPath, params string[] Args) {
string retVal = null;
- //reading the file
+ // reading the file
string FileContents = ReadEmailFile(EmailTemplateFile);
string emailBody = FileContents;
- //setting formatting the string
+ // setting formatting the string
retVal = string.Format(emailBody, Args);
try {
- //check if we are in debug mode or not. to send email
+ // check if we are in debug mode or not. to send email
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
foreach (string email in RecepientEmail) {
Subject += email + ";";
@@ -375,16 +377,16 @@ public class EmailNotification {
public string SendNotificationEmailWithAttachments(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, List attachments, params string[] Args) {
string retVal = null;
- //reading the file
+ // reading the file
string FileContents = ReadEmailFile(EmailTemplateFile);
string emailBody = FileContents;
- //setting formatting the string
+ // setting formatting the string
retVal = string.Format(emailBody, Args);
try {
- //check if we are in debug mode or not. to send email
+ // check if we are in debug mode or not. to send email
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
SendEmailWithAttachments(SenderEmail, SenderName, GetTestRecipientsList(), CC, (!string.IsNullOrEmpty(Subject) ? " TESTING ONLY -IGNORE : " + Subject + RecepientEmail : _subject), retVal, attachments);
} else {
@@ -402,16 +404,16 @@ public class EmailNotification {
public string SendNotificationEmailWithAttachments(string EmailTemplateFile, string SenderEmail, string SenderName, List RecepientEmail, string CC, string Subject, List attachments, params string[] Args) {
string retVal = null;
- //reading the file
+ // reading the file
string FileContents = ReadEmailFile(EmailTemplateFile);
string emailBody = FileContents;
- //setting formatting the string
+ // setting formatting the string
retVal = string.Format(emailBody, Args);
try {
- //check if we are in debug mode or not. to send email
+ // check if we are in debug mode or not. to send email
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
foreach (string email in RecepientEmail) {
Subject += email + ";";
@@ -434,16 +436,16 @@ public class EmailNotification {
public string SendNotificationEmail(string EmailTemplateFile, string SenderEmail, string SenderName, List RecepientEmail, string CC, string Subject, params string[] Args) {
string retVal = null;
- //reading the file
+ // reading the file
string FileContents = ReadEmailFile(EmailTemplateFile);
string emailBody = FileContents;
- //setting formatting the string
+ // setting formatting the string
retVal = string.Format(emailBody, Args);
try {
- //check if we are in debug mode or not. to send email
+ // check if we are in debug mode or not. to send email
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
foreach (string email in RecepientEmail) {
Subject += email + ";";
@@ -480,9 +482,7 @@ public class EmailNotification {
msg.Subject = subject;
msg.Body = temp;
msg.Priority = importance;
- //#if(!DEBUG)
client.Send(msg);
- //#endif
} catch (Exception ex) {
throw;
}
diff --git a/Fab2ApprovalSystem/Misc/ExcelData.cs b/Fab2ApprovalSystem/Misc/ExcelData.cs
index f93a4bb..7ced44c 100644
--- a/Fab2ApprovalSystem/Misc/ExcelData.cs
+++ b/Fab2ApprovalSystem/Misc/ExcelData.cs
@@ -44,10 +44,6 @@ namespace Fab2ApprovalSystem.Misc {
public string LotDispo { get; set; }
}
- ///
- ///
- ///
- ///
public IEnumerable ReadData() {
var r = new List();
var excelData = new ExcelData(_path);
@@ -78,7 +74,6 @@ namespace Fab2ApprovalSystem.Misc {
List s = new List();
// We return the interface, so that
var excelData = new ExcelData(_path);
- //var albums = excelData.getData("Sheet1");
var lotNos = excelData.getData();
foreach (var row in lotNos) {
string temValue = row[0].ToString();
@@ -94,11 +89,6 @@ namespace Fab2ApprovalSystem.Misc {
return s;
}
- ///
- ///
- ///
-
- ///
public IEnumerable getData(bool firstRowIsColumnNames = true) {
var reader = this.getExcelReader();
reader.IsFirstRowAsColumnNames = firstRowIsColumnNames;
diff --git a/Fab2ApprovalSystem/Misc/FTPWrapper.cs b/Fab2ApprovalSystem/Misc/FTPWrapper.cs
index 3d5375f..f1d159d 100644
--- a/Fab2ApprovalSystem/Misc/FTPWrapper.cs
+++ b/Fab2ApprovalSystem/Misc/FTPWrapper.cs
@@ -16,13 +16,10 @@ internal class FTPWrapper {
_DestinationFileName = destinationFileName;
}
- ///
- ///
- ///
public void FTPToSPN() {
FTP ftpLib = new();
- //Connect to the FTP server
+ // Connect to the FTP server
try {
ftpLib.Connect(_AppSettings.FTPServer, _AppSettings.FTPUser, _AppSettings.FTPPassword);
} catch (Exception ec) {
@@ -30,7 +27,7 @@ internal class FTPWrapper {
": " + ec.Message, System.Diagnostics.EventLogEntryType.Error);
}
- //Upload the file
+ // Upload the file
try {
int pct = 0;
ftpLib.OpenUpload(_OutputFile, _DestinationFileName);
diff --git a/Fab2ApprovalSystem/Misc/Functions.cs b/Fab2ApprovalSystem/Misc/Functions.cs
index f13811c..391163c 100644
--- a/Fab2ApprovalSystem/Misc/Functions.cs
+++ b/Fab2ApprovalSystem/Misc/Functions.cs
@@ -28,7 +28,6 @@ public static class Functions {
///
public static void WriteEvent(AppSettings? appSettings, string logtext, EventLogEntryType eventType) {
- //#if(!DEBUG)
#if !NET8
EmailNotification? en = appSettings is null ? null : new EmailNotification(appSettings);
#endif
@@ -36,22 +35,19 @@ public static class Functions {
ev.Source = "Fab Approval System";
try {
- //Write to the Event Log
+ // Write to the Event Log
ev.WriteEntry(logtext, eventType);
- ////Send an email notification if appropriate
- ////Don't attempt to send an email if the error is pertaining to an email problem
+ // Send an email notification if appropriate
+ // Don't attempt to send an email if the error is pertaining to an email problem
if (!logtext.Contains("SendEmailNotification()")) {
- //Only send email notifications for Error and Warning level events
+ // Only send email notifications for Error and Warning level events
#if !NET8
if (appSettings is not null && eventType == System.Diagnostics.EventLogEntryType.Error)
en.SendNotificationEmailToAdmin(ev.Source + " - Error Notification", logtext, MailPriority.High);
#endif
- //else if (eventType == System.Diagnostics.EventLogEntryType.Warning)
- // SendEmailNotification(ErrorRecipient(), ev.Source + " Warning Event Logged", logtext, NORMAL_PRI);
}
} catch {
- //throw;
} finally {
ev = null;
}
@@ -70,7 +66,6 @@ public static class Functions {
FileInfo[] existingFiles = new DirectoryInfo(oldFolderPath).GetFiles();
foreach (FileInfo file in existingFiles) {
if (!file.Name.Contains("ECNApprovalLog_" + oldECNNumber.ToString()) && !file.Name.Contains("ECNForm_" + oldECNNumber.ToString()))
- //var fileName = Path.GetFileName(file.FullName);
file.CopyTo(Path.Combine(newFolderPath, file.Name));
}
}
diff --git a/Fab2ApprovalSystem/Misc/GlobalVars.cs b/Fab2ApprovalSystem/Misc/GlobalVars.cs
index 501e244..12a5af7 100644
--- a/Fab2ApprovalSystem/Misc/GlobalVars.cs
+++ b/Fab2ApprovalSystem/Misc/GlobalVars.cs
@@ -53,10 +53,10 @@ public static class GlobalVars {
Pending = 0,
Approved = 1,
Denied = 2,
- Waiting = 3, //waiting on other approver to approve first
- Skipped = 4, //set to this state if the original approval is no longer needed.
- ReAssigned = 5, //set to this state if current approver got reassigned
- Terminated = 6, //future use
+ Waiting = 3, // waiting on other approver to approve first
+ Skipped = 4, // set to this state if the original approval is no longer needed.
+ ReAssigned = 5, // set to this state if current approver got reassigned
+ Terminated = 6, // future use
Closed = 7,
Recalled = 8
diff --git a/Fab2ApprovalSystem/Misc/HomeHelper.cs b/Fab2ApprovalSystem/Misc/HomeHelper.cs
new file mode 100644
index 0000000..482536b
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/HomeHelper.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class HomeHelper {
+
+ public static void NotifyApprover(AppSettings appSettings, string toEmail, string title, int issueId, string docType) {
+ string emailSentList = "";
+ string senderName = docType;
+ string subject = string.Empty;
+ string userEmail = string.Empty;
+ string emailTemplate = "ApprovalReminders.txt";
+
+ subject = docType + " Approval Reminder: " + title;
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = docType;
+ emailparams[1] = title;
+ emailparams[2] = issueId.ToString();
+ userEmail = toEmail;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, "jonathan.ouellette@infineon.com", subject, emailparams);
+ }
+
+ public static void NotifyDelegation(AppSettings appSettings, DateTime startDate, DateTime endDate, LoginModel delegateFrom, LoginModel delegateTo, List emailList) {
+ string userEmail = string.Empty;
+ string senderName = "Mesa Approval";
+ string emailTemplate = "DelegationOn.txt";
+ string subject = "Mesa Approval Delegation Notification";
+
+ foreach (string email in emailList) {
+ EmailNotification en = new(appSettings, subject);
+ 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;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+ }
+
+ public static void DelegateDocumentApproval(AppSettings appSettings, int issueID, string ecnTypeString, string title, string email) {
+ string subject;
+ string userEmail = string.Empty;
+ string senderName = ecnTypeString;
+ string emailTemplate = "DelegateApproval.txt";
+
+ subject = ecnTypeString + " Delegation" + " - Email would be sent to " + email + " for Number " + issueID + ", - " + title;
+ EmailNotification en = new(appSettings, subject);
+ 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);
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/LotDispositionHelper.cs b/Fab2ApprovalSystem/Misc/LotDispositionHelper.cs
new file mode 100644
index 0000000..ab216d8
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/LotDispositionHelper.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class LotDispositionHelper {
+
+ public static string NotifyRejectionToOrginator(AppSettings appSettings, int issueID, string username, List emailIst) {
+ string userEmail = string.Empty;
+ string senderName = "LotDisposition";
+ string subject = "Lot Disposition Rejection";
+ string emailTemplate = "LotDispositionReject.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Lot Disposition Rejection";
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = issueID.ToString();
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = username;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ return userEmail;
+ }
+
+ public static string NotifyApprovers(AppSettings appSettings, int issueID, List emailIst) {
+ string emailSentList = "";
+ string userEmail = string.Empty;
+ string senderName = "LotDisposition";
+ string subject = "Lot Disposition Assignment";
+ string emailTemplate = "LotDispositionAssigned.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Lot Disposition Assignment";
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = issueID.ToString();
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string AddAdditionalApproval(AppSettings appSettings, int issueID, string emailSentList, string emailArray) {
+ string userEmail = string.Empty;
+ string senderName = "LotDisposition";
+ string subject = "Lot Disposition Assignment";
+ string emailTemplate = "LotDispositionAssigned.txt";
+
+ string[] emailIst = emailArray.Split(new char[] { '~' });
+ foreach (string email in emailIst) {
+ if (email.Length > 0) {
+ subject = "Lot Disposition Assignment";
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = issueID.ToString();
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+
+ }
+
+ }
+
+ return emailSentList;
+ }
+
+ public static void ReAssignApproverByAdmin(AppSettings appSettings, int issueID, string email) {
+ string userEmail = string.Empty;
+ string senderName = "LotDisposition";
+ string subject = "Lot Disposition Re-Assignment";
+ string emailTemplate = "LotDispositionReAssigned.txt";
+
+ subject = "Lot Disposition Re-Assignment" + " - Email would be sent to " + email;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = issueID.ToString();
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static void ReAssignApproval(AppSettings appSettings, int issueID, string email) {
+ string userEmail = string.Empty;
+ string senderName = "LotDisposition";
+ string subject = "Lot Disposition Re-Assignment";
+ string emailTemplate = "LotDispositionReAssigned.txt";
+
+ subject = "Lot Disposition Re-Assignment" + " - Email would be sent to " + email;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[3];
+ emailparams[0] = issueID.ToString();
+ emailparams[1] = issueID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static void AttachSave(AppSettings appSettings, LotDispositionDMO lotDispositionDMO, int issueID, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+ var fileName = Path.GetFileName(fullFileName);
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + "LotDisposition", fileName);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ Attachment attach = new() {
+ IssueID = issueID,
+ FileName = fileName,
+ UserID = userId,
+ };
+ lotDispositionDMO.InsertLotDispositionAttachment(attach);
+ }
+
+ public static string ExcelLotOpen(LotDispositionDMO lotDispositionDMO, int issueID, string userIdentityName, string lotTempPipeLine, string fullFileName, Stream stream) {
+ string physicalPath;
+
+ var fileExtension = Path.GetExtension(fullFileName);
+ string fName = userIdentityName + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
+
+ physicalPath = Path.Combine(lotTempPipeLine, fName + "." + fileExtension);
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+
+#if !NET8
+ ExcelData x = new ExcelData(physicalPath);
+ var lotNumbers = x.ReadData();
+
+ foreach (var lotInfo in lotNumbers) {
+ Lot l = new Lot();
+ l.LotNumber = lotInfo.LotNo;
+ l.IssueID = issueID;
+ if (l.LotStatusOptionID == 0)
+ l.LotStatusOption.LotStatusOptionID = (int)GlobalVars.LotStatusOption.Release;
+
+ lotDispositionDMO.InsertLot(l, true);
+ }
+#endif
+
+ FileInfo f = new(physicalPath);
+ if (f.Exists)
+ f.Delete();
+
+ return physicalPath;
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/LotTravelerHelper.cs b/Fab2ApprovalSystem/Misc/LotTravelerHelper.cs
new file mode 100644
index 0000000..5802b9a
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/LotTravelerHelper.cs
@@ -0,0 +1,469 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class LotTravelerHelper {
+
+ public static string NotifyRejectionToOrginator(AppSettings appSettings, string userId, int workRequestID, string username, List emailIst, LTWorkRequest ltWR) {
+ string userEmail = string.Empty;
+ string senderName = "Work Request";
+ string subject = "Work Request Rejection";
+ string emailTemplate = "WorkRequestReject.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Work Request Rejection notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = ltWR.SWRNumber.ToString();
+ emailparams[1] = workRequestID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = username;
+ emailparams[4] = "Work Request";
+ userEmail = email;
+
+ try {
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+
+ } catch {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Notify Rejection:" + email });
+ }
+ }
+
+ return userEmail;
+ }
+
+ public static string NotifyApprovers(AppSettings appSettings, string userId, int workRequestID, string emailSentList, LTWorkRequest ltWR, List emailIst) {
+ string senderName = "";
+ string userEmail = string.Empty;
+ string subject = "Work Request Assignment";
+ string emailTemplate = "WorkRequestAssigned.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Work Request Assignment notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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
+
+ try {
+ emailSentList += email + ",";
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+
+ } catch {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "WR Notify Approvers:" + email });
+ }
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyApprovalOfWorkRequest(AppSettings appSettings, string userId, int workRequestID, string emailSentList, LTWorkRequest ltWR, List emailIst) {
+ string senderName = "";
+ string userEmail = string.Empty;
+ string subject = "Work Request Approval";
+ string emailTemplate = "WorkRequestApproval.txt";
+ foreach (string email in emailIst) {
+ subject = "Work Request Approval notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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
+
+ try {
+ emailSentList += email + ",";
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+
+ } catch {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Approval Notification:" + email });
+ }
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyfWorkRequestRevisionChange(AppSettings appSettings, string userId, int workRequestID, string emailSentList, LTWorkRequest ltWR, List emailIst) {
+ string senderName = "";
+ string userEmail = string.Empty;
+ string subject = "Work Request Revision Change";
+ string emailTemplate = "WorkRequestRevisionChange.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Work Request Revision Change notice for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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
+
+ try {
+ emailSentList += email + ",";
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+
+ } catch {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "WR Revision Change Notification:" + email });
+ }
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyLotTravelerRevisionChange(AppSettings appSettings, string userId, string emailSentList, LTLotTravelerHeaderViewModel data, List emailIst) {
+ string senderName = "";
+ string userEmail = string.Empty;
+ string subject = "Lot Traveler Revision Change";
+ string emailTemplate = "LotTravelerRevisionChange.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Lot Traveler Revision for SWR# " + data.SWRNumber + ", Lot# " + data.LotNumber + " - " + data.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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 = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Revision Notification:" + email });
+ }
+ }
+
+ return emailSentList;
+ }
+
+ public static string NotifyLotTravelerCreation(AppSettings appSettings, string userId, string emailSentList, LTLotTravelerHeaderViewModel data, List emailIst) {
+ string senderName = "";
+ string userEmail = string.Empty;
+ string subject = "Lot Traveler Revision Change";
+ string emailTemplate = "LotTravelerCreation.txt";
+
+ foreach (string email in emailIst) {
+ subject = "Lot Traveler created for SWR# " + data.SWRNumber + ", Lot# " + data.LotNumber + " - " + data.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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 = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Lot Traveler Creation Email Notification:" + email });
+ }
+ }
+
+ return emailSentList;
+ }
+
+ public static void ReAssignApproval(AppSettings appSettings, string userId, int workRequestID, string email, LTWorkRequest ltWR) {
+ string userEmail = string.Empty;
+ string senderName = "Work Request";
+ string subject = "Work Request Re-Assignment";
+ string emailTemplate = "WorkRequestReAssigned.txt";
+
+ subject = "Work Request Re-Assignment" + " - Email would be sent to " + email + " for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ltWR.SWRNumber.ToString();
+ emailparams[1] = workRequestID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "Work Request";
+ userEmail = email;
+ try {
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ } catch {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "ReAssign Approval Notification:" + email });
+ }
+ }
+
+ public static string AddAdditionalApproval(AppSettings appSettings, string userId, int workRequestID, string emailSentList, string emailArray, LTWorkRequest ltWR) {
+ string userEmail = string.Empty;
+ string senderName = "Work Request";
+ string subject = "Work Request Assignment";
+ string emailTemplate = "WorkRequestAssigned.txt";
+
+ string[] emailIst = emailArray.Split(new char[] { '~' });
+ foreach (string email in emailIst) {
+ if (email.Length > 0) {
+ subject = "Work Request Assignment notice for Number " + workRequestID + ", - " + ltWR.Title;
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[4];
+ emailparams[0] = ltWR.SWRNumber.ToString();
+ emailparams[1] = workRequestID.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "Work Request";
+
+ userEmail = email;
+ try {
+ emailSentList += email + ",";
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+
+ } catch {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "Addtional Approver Notification:" + email });
+ }
+
+ }
+
+ }
+
+ return emailSentList;
+ }
+
+ public static void ReAssignApproverByAdmin(AppSettings appSettings, string userId, int workRequestID, string email, LTWorkRequest ltWR) {
+ string subject;
+ string userEmail = string.Empty;
+ string senderName = "Work Request";
+ string emailTemplate = "WorkRequestReAssigned.txt";
+
+ subject = "Work Request Re-Assignment" + " - Email would be sent to " + email + " for Number " + ltWR.SWRNumber + ", - " + ltWR.Title;
+ EmailNotification en = new(appSettings, subject);
+ 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;
+
+ try {
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ } catch {
+ EventLogDMO.Add(new WinEventLog() { IssueID = ltWR.SWRNumber, UserID = userId, DocumentType = "Lot Traveler", OperationType = "Error", Comments = "ReAssign Approver Notification:" + email });
+ }
+ }
+
+ public static void HoldStepAttachSave(AppSettings appSettings, LotTravelerDMO lotTravelerDMO, int holdStepID, int swrNo, string docType, string comments, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ // TODO
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var SWRPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWRPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var SWR_RevPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWR_RevPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ LTWorkRequestAttachment attach = new() {
+ FileGUID = guid,
+ LTHoldStepID = holdStepID,
+ FileName = fileName,
+ UploadedByID = userId,
+ DocType = docType,
+ Comments = comments
+ };
+
+ lotTravelerDMO.InsertLotHoldStepAttachment(attach);
+ }
+
+ public static void HoldStepAttachSaveRev(AppSettings appSettings, LotTravelerDMO lotTravelerDMO, int holdStepID, int swrNo, string docType, string comments, bool newRevision, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ // TODO
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var SWRPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWRPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var SWR_RevPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWR_RevPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ LTWorkRequestAttachment attach = new() {
+ FileGUID = guid,
+ LTHoldStepID = holdStepID,
+ FileName = fileName,
+ UploadedByID = userId,
+ DocType = docType,
+ Comments = comments
+ };
+ if (newRevision)
+ lotTravelerDMO.InsertLotHoldStepAttachmentRevision(attach);
+ else
+ lotTravelerDMO.InsertLotHoldStepAttachment(attach);
+ }
+
+ public static void AttachSaveWorkRequestRevision(AppSettings appSettings, LotTravelerDMO lotTravelerDMO, int workRequestID, int swrNo, string docType, string attachComments, bool newRevision, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ // TODO
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var SWRPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWRPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var SWR_RevPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWR_RevPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ LTWorkRequestAttachment attach = new() {
+ WorkRequestID = workRequestID,
+ FileGUID = guid,
+ LTHoldStepID = -1,
+ FileName = fileName,
+ UploadedByID = userId,
+ DocType = docType,
+ Comments = attachComments
+ };
+
+ // InsertWorkRequestAttachment(attach);
+ if (newRevision)
+ lotTravelerDMO.InsertWorkRequestAttachmentRevision(attach);
+ else
+ lotTravelerDMO.InsertWorkRequestAttachment(attach);
+ }
+
+ public static void AttachSaveWorkRequest(AppSettings appSettings, LotTravelerDMO lotTravelerDMO, int workRequestID, int swrNo, string comments, string docType, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ // TODO
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var SWRPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWRPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var SWR_RevPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWR_RevPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ LTWorkRequestAttachment attach = new() {
+ WorkRequestID = workRequestID,
+ FileGUID = guid,
+ LTHoldStepID = -1,
+ FileName = fileName,
+ UploadedByID = userId,
+ DocType = docType,
+ Comments = comments
+
+ };
+
+ lotTravelerDMO.InsertWorkRequestAttachment(attach);
+ }
+
+ public static void LotTravHoldStepAttachSaveRev(AppSettings appSettings, LotTravelerDMO lotTravelerDMO, int ltHoldStepID, int swrNo, string docType, int prevLotTravRevID, int newLotTravRevID, bool newRevision, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+
+ // TODO
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ DirectoryInfo di;
+ var SWRPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWRPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var SWR_RevPhysicalPath = appSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
+ di = new DirectoryInfo(SWR_RevPhysicalPath);
+ if (!di.Exists)
+ di.Create();
+
+ var guid = Guid.NewGuid().ToString();
+ var physicalPath = Path.Combine(appSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ LTLotTravAttachment attach = new() {
+ FileGUID = guid,
+ LTLotTravHoldStepID = ltHoldStepID,
+ LotTravelerRevisionID = newLotTravRevID,
+ FileName = fileName,
+ UploadedByID = userId,
+ DocType = docType
+ };
+ if (newRevision) {
+ try {
+ lotTravelerDMO.InsertLotTravLotHoldStepAttachmentRevision(attach);
+ } catch {
+ // roll back the revision creation
+ lotTravelerDMO.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");
+ }
+
+ } else
+ lotTravelerDMO.InsertLotTravLotHoldStepAttachment(attach);
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/MRBHelper.cs b/Fab2ApprovalSystem/Misc/MRBHelper.cs
new file mode 100644
index 0000000..abcb1a6
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/MRBHelper.cs
@@ -0,0 +1,320 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class MRBHelper {
+
+ public static string NotifyApprovers(AppSettings appSettings, int mrbNumber, List emailIst) {
+ string emailSentList = "";
+ 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(appSettings, subject, emailTemplate);
+ string[] emailparams = new string[3];
+ emailparams[0] = mrbNumber.ToString();
+ emailparams[1] = mrbNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ userEmail = email;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ emailSentList += email + ",";
+ }
+
+ return emailSentList;
+ }
+
+ public static string ImportRemoveQDBFlag(AppSettings appSettings, MRB_DMO mrbDMO, string operation, out string physicalPath, string userIdentityName, string a, string b, string c, string fullFileName, Stream stream) {
+ IEnumerable lotDataList = null;
+ var guid = Guid.NewGuid().ToString();
+
+ var fileExtension = Path.GetExtension(fullFileName);
+ physicalPath = Path.Combine(appSettings.LotTempPipeLine, guid + "." + fileExtension);
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+
+#if !NET8
+ ExcelData x = new ExcelData(physicalPath);
+ lotDataList = x.ReadQDBFlagData();
+
+ foreach (string lotData in lotDataList) {
+ mrbDMO.InsertMRB_QDB_HoldFlag(guid, lotData, operation);
+ }
+#endif
+
+ FileInfo f = new(physicalPath);
+ if (f.Exists)
+ f.Delete();
+
+ // Send the data to SPN
+ if (SendQDBFlagToSPN(appSettings, mrbDMO, guid, userIdentityName, a, b, c))
+ mrbDMO.UpdateMRB_QDB_HoldFlag(guid, true);
+ else {
+ mrbDMO.UpdateMRB_QDB_HoldFlag(guid, false);
+ return "Problems while uploading to SPN";
+ }
+ return string.Empty;
+ }
+
+ public static bool BatchFTP(AppSettings appSettings, string sourceFile, string destFile, string ftpLogDirectory, string userIdentityName, string a, string b, string c) {
+ FileInfo sourcefile = new(sourceFile);
+
+ try {
+ ProcessStartInfo psiFab1 = new();
+ Process procFab1 = new();
+ StringBuilder sb = new();
+
+ if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
+ psiFab1.FileName = a;
+ } else {
+ psiFab1.FileName = b;
+ }
+
+ psiFab1.Arguments = sourcefile.FullName + " " + destFile;
+
+ psiFab1.RedirectStandardOutput = true;
+ psiFab1.UseShellExecute = false;
+ psiFab1.WorkingDirectory = c;
+
+ procFab1.StartInfo = psiFab1;
+ procFab1.OutputDataReceived += (sender, args) => sb.AppendLine(args.Data);
+ ;
+ procFab1.Start();
+ procFab1.BeginOutputReadLine();
+ procFab1.WaitForExit(4000);
+
+ File.WriteAllText(Path.Combine(ftpLogDirectory, sourcefile.Name + ".txt"), sb.ToString());
+
+ return true;
+ } catch (Exception e) {
+ Functions.WriteEvent(appSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
+ return false;
+ }
+
+ }
+
+ public static bool SendQDBFlagToSPN(AppSettings appSettings, MRB_DMO mrbDMO, string guid, string userIdentityName, string a, string b, string c) {
+ StringBuilder output = new();
+ try {
+ IEnumerable data = mrbDMO.GetMRB_QDB_HoldFlags(guid);
+ foreach (string tempData in data) {
+ output.Append(tempData.Trim() + Environment.NewLine);
+
+ }
+
+ try {
+ if (output.Length > 0) {
+ DateTime dt = DateTime.Now;
+ string newsourceFileName = "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") + ".mrb";
+
+ string outputFile = appSettings.HoldFlagDirectory + newsourceFileName;
+
+ File.WriteAllText(outputFile, output.ToString());
+
+#if (DEBUG)
+ Thread.Sleep(1000);
+#endif
+ try {
+ if (BatchFTP(appSettings, outputFile, newDestFileName, appSettings.SPNMRBHoldFlagFTPLogDirectory, userIdentityName, a, b, c)) {
+ mrbDMO.UpdateMRB_QDB_HoldFlag(guid, true);
+ } else {
+ mrbDMO.UpdateMRB_QDB_HoldFlag(guid, false);
+ }
+
+ } catch (Exception e) {
+ string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + guid.ToString() + " FTPToSPN(): FTP Upload Error " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
+ EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
+ return false;
+ }
+
+ }
+
+ return true;
+ } catch (Exception e) {
+ string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + guid.ToString() + " SPN Hold Flag(SendToSPN) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
+ Functions.WriteEvent(appSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
+ EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
+ return false;
+ }
+
+ } catch (Exception e) {
+ string exceptionString = e.Message.ToString().Trim().Length > 500 ? "GUID =" + guid.ToString() + " SPN Hold Flag(SendToSPN) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
+ Functions.WriteEvent(appSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
+ EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
+ return false;
+ }
+
+ }
+
+ public static string ImportAddQDBFlag(AppSettings appSettings, MRB_DMO mrbDMO, string operation, out string physicalPath, string userIdentityName, string a, string b, string c, string fullFileName, Stream stream) {
+ IEnumerable lotDataList = null;
+ var guid = Guid.NewGuid().ToString();
+
+ var fileExtension = Path.GetExtension(fullFileName);
+ physicalPath = Path.Combine(appSettings.LotTempPipeLine, guid + "." + fileExtension);
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+
+#if !NET8
+ ExcelData x = new ExcelData(physicalPath);
+ lotDataList = x.ReadQDBFlagData();
+
+ foreach (string lotData in lotDataList) {
+ mrbDMO.InsertMRB_QDB_HoldFlag(guid, lotData, operation);
+ }
+#endif
+
+ FileInfo f = new(physicalPath);
+ if (f.Exists)
+ f.Delete();
+
+ if (SendQDBFlagToSPN(appSettings, mrbDMO, guid, userIdentityName, a, b, c))
+ mrbDMO.UpdateMRB_QDB_HoldFlag(guid, true);
+ else {
+ mrbDMO.UpdateMRB_QDB_HoldFlag(guid, false);
+ return "Problems while uploading to SPN";
+ }
+ return string.Empty;
+ }
+
+ public static void AttachSave(AppSettings appSettings, MRB_DMO mrbDMO, int mrbNumber, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+ var fileName = Path.GetFileName(fullFileName);
+ string physicalFileName;
+ string physicalPath;
+
+ // Check to see if this filename is in use
+ var attachments = mrbDMO.GetMRBAttachments(mrbNumber);
+ if (attachments.Count() > 0) {
+ if (attachments.Count(a => string.Equals(a.FileName, fileName, StringComparison.OrdinalIgnoreCase)) > 0) {
+ // This filename is used on this MRB
+ // So we want to delete those records so the new record replaces them
+ foreach (var a in attachments) {
+ mrbDMO.DeleteMRBAttachment(a.AttachmentID);
+
+ physicalFileName = a.Path;
+ if (string.IsNullOrEmpty(physicalFileName))
+ physicalFileName = a.FileName;
+ physicalPath = Path.Combine(appSettings.AttachmentFolder + "MRB", physicalFileName);
+
+ if (File.Exists(physicalPath))
+ File.Delete(physicalPath);
+ }
+ }
+ }
+
+ physicalFileName = mrbNumber.ToString() + "_" + Guid.NewGuid().ToString() + Path.GetExtension(fileName);
+ physicalPath = Path.Combine(appSettings.AttachmentFolder + "MRB", physicalFileName);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ MRBAttachment attach = new() {
+ MRBNumber = mrbNumber,
+ FileName = fileName,
+ Path = physicalFileName,
+#if (DEBUG)
+ UserID = 114,
+#endif
+
+#if (!DEBUG)
+ UserID = userId,
+#endif
+ };
+ mrbDMO.InsertMRBAttachment(attach);
+ }
+
+ public static string ExcelLotOpen(MRB_DMO mrbDMO, int mrbNumber, StringBuilder warnings, IEnumerable dispos, string userIdentityName, string lotTempPipeLine, string fullFileName, Stream stream) {
+ var fileName = Path.GetFileName(fullFileName);
+ var fileExtension = Path.GetExtension(fullFileName);
+ string fName = userIdentityName + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
+ string physicalPath = Path.Combine(lotTempPipeLine, fName + "." + fileExtension);
+
+#if !NET8
+ IEnumerable lotNumbers;
+
+ try {
+ using (var fileStream = new FileStream(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ ExcelData x = new ExcelData(physicalPath);
+ lotNumbers = x.ReadData();
+ } catch (Exception ex) {
+ throw new Exception(String.Format("Invalid file format for {0}: {1}", fileName, ex.Message));
+ }
+
+ // Get Tool, Issue Start and End Date
+
+ MRB mrbInfo = mrbDMO.GetToolIssueStartEndDateData(mrbNumber, null);
+
+ foreach (var lotInfo in lotNumbers) {
+ if (lotInfo.LotDispo.Length == 1) {
+ if (dispos.Count(d => d.DispositionType.Trim().ToUpper() == lotInfo.LotDispo.Trim().ToUpper()) == 0) {
+ throw new Exception(String.Format("Invalid lot disposition {0} for lot no {1}",
+ lotInfo.LotDispo, lotInfo.LotNo));
+ }
+ }
+ }
+ // RJK - 12/17
+ // Only find the child Splits when a Tool or a list of Tools is provided
+ if (!mrbInfo.ToolCSV.ToUpper().Equals("NA")) {
+ foreach (var lotInfo in lotNumbers) {
+ bool existingLotUpdated;
+ Lot l = new Lot();
+ l.LotNumber = lotInfo.LotNo;
+ if (lotInfo.LotDispo.Length == 1) {
+ l.DispoType = lotInfo.LotDispo[0];
+ }
+ l.MRBNumber = mrbNumber;
+ mrbDMO.InsertLot(l, true, out existingLotUpdated);
+ // cannot do the check below , because what if the parent lot had splits after the prior lot split analysis
+ if (!mrbDMO.InsertLotSplitsAffectedByIncident(mrbNumber, l.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate)) {
+ warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n Uploaded without Lot Genealogy tracing", l.LotNumber);
+ }
+ }
+
+ // Not required - Will be using each lot's Insert Date time stamp,
+ // as lot could be added using search functionality
+ // UpdateLastLotSplitAnalysisTime(mrbNumber);
+
+ } else {
+ // RJK - 12/17
+ // Only find the child Splits when a Tool or a list of Tools is provided
+ foreach (var lotInfo in lotNumbers) {
+ bool existingLotUpdated;
+ Lot l = new Lot();
+ l.LotNumber = lotInfo.LotNo;
+ if (lotInfo.LotDispo.Length == 1) {
+ l.DispoType = lotInfo.LotDispo[0];
+ }
+ l.MRBNumber = mrbNumber;
+ // do not insert any new lots when importing from excel
+ mrbDMO.InsertLot(l, true, out existingLotUpdated);
+ }
+ }
+#endif
+
+ FileInfo f = new(physicalPath);
+ if (f.Exists)
+ f.Delete();
+
+ return physicalPath;
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/PartsRequestHelper.cs b/Fab2ApprovalSystem/Misc/PartsRequestHelper.cs
new file mode 100644
index 0000000..cdfdaac
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/PartsRequestHelper.cs
@@ -0,0 +1,49 @@
+using System.IO;
+
+using Fab2ApprovalSystem.DMO;
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class PartsRequestHelper {
+
+ public static void SendEmailNotification(AppSettings appSettings, string username, string subject, int prNumber, string toEmail, string emailTemplate) {
+ string senderName = "Parts Request";
+
+ EmailNotification en = new(appSettings, subject);
+ string[] emailparams = new string[5];
+ emailparams[0] = prNumber.ToString();
+ emailparams[1] = prNumber.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+ emailparams[3] = "Parts Request";
+ emailparams[4] = username;
+ string userEmail = toEmail;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+ public static void AttachSave(AppSettings appSettings, PartsRequestDMO partsRequestDMO, int prNumber, int userId, string fullFileName, Stream stream) {
+ // Some browsers send file names with full path.
+ // We are only interested in the file name.
+ var fileName = Path.GetFileName(fullFileName);
+
+ string prFolderPath = appSettings.AttachmentFolder + "PartsRequest\\" + prNumber.ToString();
+
+ DirectoryInfo di = new(prFolderPath);
+ if (!di.Exists)
+ di.Create();
+
+ var physicalPath = Path.Combine(prFolderPath, fileName);
+
+ using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
+ stream.CopyTo(fileStream);
+ }
+ PartsRequestAttachment attach = new() {
+ PRNumber = prNumber,
+ FileName = fileName,
+ UserID = userId,
+ };
+ partsRequestDMO.InsertAttachment(attach);
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/TrainingHelper.cs b/Fab2ApprovalSystem/Misc/TrainingHelper.cs
new file mode 100644
index 0000000..5ac7e0c
--- /dev/null
+++ b/Fab2ApprovalSystem/Misc/TrainingHelper.cs
@@ -0,0 +1,26 @@
+using Fab2ApprovalSystem.Models;
+
+namespace Fab2ApprovalSystem.Misc;
+
+public class TrainingHelper {
+
+ public static void NotifyTrainee(AppSettings appSettings, int userId, int assignmentId, int ecnId, string title, string recipient) {
+ string emailSentList = "";
+ string subject = string.Empty;
+ string userEmail = string.Empty;
+ string senderName = "ECN Training";
+ string emailTemplate = "ECNTrainingAssigned.txt";
+
+ subject = "ECN# " + ecnId + " - Training Assignment Notice - " + title;
+
+ EmailNotification en = new(appSettings, subject);
+ userEmail = recipient;
+ string[] emailparams = new string[4];
+ emailparams[0] = assignmentId.ToString();
+ emailparams[1] = ecnId.ToString();
+ emailparams[2] = GlobalVars.hostURL;
+
+ en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
+ }
+
+}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Misc/Zipper.cs b/Fab2ApprovalSystem/Misc/Zipper.cs
index 3344ff3..a44bb7c 100644
--- a/Fab2ApprovalSystem/Misc/Zipper.cs
+++ b/Fab2ApprovalSystem/Misc/Zipper.cs
@@ -18,9 +18,7 @@ public class Zipper {
FileStream fsOut = File.Create(outPathname);
ZipOutputStream zipStream = new(fsOut);
- zipStream.SetLevel(3); //0-9, 9 being the highest level of compression
-
- //zipStream.Password = password; // optional. Null is the same as not setting. Required if using AES.
+ zipStream.SetLevel(3); // 0-9, 9 being the highest level of compression
// This setting will strip the leading part of the folder path in the entries, to
// make the entries relative to the starting folder.
diff --git a/Fab2ApprovalSystem/Misc/ftplib.cs b/Fab2ApprovalSystem/Misc/ftplib.cs
index d130a6d..2ed7b02 100644
--- a/Fab2ApprovalSystem/Misc/ftplib.cs
+++ b/Fab2ApprovalSystem/Misc/ftplib.cs
@@ -57,15 +57,12 @@ public class FTP {
#endregion
#region Constructors
- ///
- /// Constructor
- ///
public FTP() {
server = null;
user = null;
pass = null;
port = 21;
- passive_mode = true; // #######################################
+ passive_mode = true;
main_sock = null;
main_ipEndPoint = null;
listening_sock = null;
@@ -77,18 +74,13 @@ public class FTP {
timeout = 10000; // 10 seconds
messages = "";
}
- ///
- /// Constructor
- ///
- /// Server to connect to
- /// Account to login as
- /// Account password
+
public FTP(string server, string user, string pass) {
this.server = server;
this.user = user;
this.pass = pass;
port = 21;
- passive_mode = true; // #######################################
+ passive_mode = true;
main_sock = null;
main_ipEndPoint = null;
listening_sock = null;
@@ -100,19 +92,13 @@ public class FTP {
timeout = 10000; // 10 seconds
messages = "";
}
- ///
- /// Constructor
- ///
- /// Server to connect to
- /// Port server is listening on
- /// Account to login as
- /// Account password
+
public FTP(string server, int port, string user, string pass) {
this.server = server;
this.user = user;
this.pass = pass;
this.port = port;
- passive_mode = true; // #######################################
+ passive_mode = true;
main_sock = null;
main_ipEndPoint = null;
listening_sock = null;
@@ -275,7 +261,6 @@ public class FTP {
messages = "";
while (true) {
- //buf = GetLineFromBucket();
buf = GetLineFromBucket();
#if (FTP_DEBUG)
@@ -570,8 +555,8 @@ public class FTP {
SendCommand("LIST");
ReadResponse();
- //FILIPE MADUREIRA.
- //Added response 125
+ // FILIPE MADUREIRA.
+ // Added response 125
switch (response) {
case 125:
case 150:
@@ -589,13 +574,10 @@ public class FTP {
// so the code doesn't hang if there is
// no data comming.
if (msecs_passed > (timeout / 10)) {
- //CloseDataSocket();
- //throw new Exception("Timed out waiting on server to respond.");
-
- //FILIPE MADUREIRA.
- //If there are no files to list it gives timeout.
- //So I wait less time and if no data is received, means that there are no files
- break;//Maybe there are no files
+ // FILIPE MADUREIRA.
+ // If there are no files to list it gives timeout.
+ // So I wait less time and if no data is received, means that there are no files
+ break; // Maybe there are no files
}
}
@@ -626,8 +608,7 @@ public class FTP {
ArrayList list = new();
foreach (string f in List()) {
- //FILIPE MADUREIRA
- //In Windows servers it is identified by
+ // FILIPE MADUREIRA
if ((f.Length > 0)) {
if ((f[0] != 'd') && (f.ToUpper().IndexOf("") < 0))
list.Add(f);
@@ -636,6 +617,7 @@ public class FTP {
return list;
}
+
///
/// Gets a directory list only
///
@@ -644,8 +626,8 @@ public class FTP {
ArrayList list = new();
foreach (string f in List()) {
- //FILIPE MADUREIRA
- //In Windows servers it is identified by
+ // FILIPE MADUREIRA
+ // In Windows servers it is identified by
if (f.Length > 0) {
if ((f[0] == 'd') || (f.ToUpper().IndexOf("") >= 0))
list.Add(f);
@@ -685,7 +667,7 @@ public class FTP {
if (input.Length < 14)
throw new ArgumentException("Input Value for ConvertFTPDateToDateTime method was too short.");
- //YYYYMMDDhhmmss":
+ // YYYYMMDDhhmmss":
int year = Convert.ToInt16(input.Substring(0, 4));
int month = Convert.ToInt16(input.Substring(4, 2));
int day = Convert.ToInt16(input.Substring(6, 2));
@@ -700,7 +682,7 @@ public class FTP {
///
/// The working directory
public string GetWorkingDirectory() {
- //PWD - print working directory
+ // PWD - print working directory
Connect();
SendCommand("PWD");
ReadResponse();
@@ -710,7 +692,7 @@ public class FTP {
string pwd;
try {
- pwd = responseStr.Substring(responseStr.IndexOf("\"", 0) + 1);//5);
+ pwd = responseStr.Substring(responseStr.IndexOf("\"", 0) + 1);
pwd = pwd.Substring(0, pwd.LastIndexOf("\""));
pwd = pwd.Replace("\"\"", "\""); // directories with quotes in the name come out as "" from the server
} catch (Exception ex) {
@@ -719,6 +701,7 @@ public class FTP {
return pwd;
}
+
///
/// Change to another directory on the ftp server
///
diff --git a/Fab2ApprovalSystem/Models/AccountViewModels.cs b/Fab2ApprovalSystem/Models/AccountViewModels.cs
index 477d516..1e9f1e7 100644
--- a/Fab2ApprovalSystem/Models/AccountViewModels.cs
+++ b/Fab2ApprovalSystem/Models/AccountViewModels.cs
@@ -11,7 +11,6 @@ public class LoginModel {
[Display(Name = "Login ID")]
public string LoginID { get; set; }
- //[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
diff --git a/Fab2ApprovalSystem/Models/AppSettings.cs b/Fab2ApprovalSystem/Models/AppSettings.cs
index 70a5969..a3a4037 100644
--- a/Fab2ApprovalSystem/Models/AppSettings.cs
+++ b/Fab2ApprovalSystem/Models/AppSettings.cs
@@ -7,37 +7,47 @@ namespace Fab2ApprovalSystem.Models;
public class AppSettings {
- internal AppSettings(string adminNotificationRecepient,
- string? apiBaseUrl,
- string attachmentFolder,
- string? attachmentUrl,
- string caBlankFormsLocation,
- string? company,
- string dBConnection,
- string dbConnectionString,
- string ftpPassword,
- string ftpServer,
- string ftpUser,
- string holdFlagDirectory,
- string hostURL,
- string ifxContainer,
- string ifxDomain,
- bool isInfineonDomain,
- string lotTempPipeLine,
- string mesaTemplateFiles,
- string naContainer,
- string naDomain,
- string nDriveURL,
- string notificationSender,
- string senderEmail,
- string? smtpServer,
- string spnMRBHoldFlagFTPLogDirectory,
- string testEmailRecipients,
- string urls,
- int userId,
- bool userIsAdmin,
- string wsrURL,
- string? workingDirectoryName) {
+ public AppSettings(string adminNotificationRecepient,
+ string? apiBaseUrl,
+ string attachmentFolder,
+ string? attachmentUrl,
+ string caBlankFormsLocation,
+ string? company,
+ string dBConnection,
+ string dbConnectionString,
+ string emailTemplatesPath,
+ string ftpPassword,
+ string ftpSPNBatchFileName,
+ string ftpSPNBatchFileName_Test,
+ string ftpServer,
+ string ftpUser,
+ string holdFlagDirectory,
+ string hostURL,
+ string ifxContainer,
+ string ifxDomain,
+ bool isInfineonDomain,
+ string lotTempPipeLine,
+ string mesaTemplateFiles,
+ string nDriveURL,
+ string naContainer,
+ string naDomain,
+ string notificationSender,
+ string senderEmail,
+ string? smtpServer,
+ string spnMRBHoldFlagDirectory,
+ string spnMRBHoldFlagFTPLogDirectory,
+ string ssrSFolder,
+ string ssrSBindingsByConfiguration,
+ string ssrSBaseURL,
+ string ssrSDomain,
+ string ssrSUsername,
+ string ssrSPassword,
+ string testEmailRecipients,
+ string urls,
+ int userId,
+ bool userIsAdmin,
+ string wsr_URL,
+ string? workingDirectoryName) {
AdminNotificationRecepient = adminNotificationRecepient;
ApiBaseUrl = apiBaseUrl;
AttachmentFolder = attachmentFolder;
@@ -46,7 +56,10 @@ public class AppSettings {
Company = company;
DBConnection = dBConnection;
DBConnectionString = dbConnectionString;
+ EmailTemplatesPath = emailTemplatesPath;
FTPPassword = ftpPassword;
+ FTPSPNBatchFileName = ftpSPNBatchFileName;
+ FTPSPNBatchFileName_Test = ftpSPNBatchFileName_Test;
FTPServer = ftpServer;
FTPUser = ftpUser;
HoldFlagDirectory = holdFlagDirectory;
@@ -56,18 +69,25 @@ public class AppSettings {
IsInfineonDomain = isInfineonDomain;
LotTempPipeLine = lotTempPipeLine;
MesaTemplateFiles = mesaTemplateFiles;
+ NDriveURL = nDriveURL;
NAContainer = naContainer;
NADomain = naDomain;
- NDriveURL = nDriveURL;
NotificationSender = notificationSender;
SenderEmail = senderEmail;
SMTPServer = smtpServer;
+ SPNMRBHoldFlagDirectory = spnMRBHoldFlagDirectory;
SPNMRBHoldFlagFTPLogDirectory = spnMRBHoldFlagFTPLogDirectory;
TestEmailRecipients = testEmailRecipients;
+ SSRSFolder = ssrSFolder;
+ SSRSBindingsByConfiguration = ssrSBindingsByConfiguration;
+ SSRSBaseURL = ssrSBaseURL;
+ SSRSDomain = ssrSDomain;
+ SSRSUsername = ssrSUsername;
+ SSRSPassword = ssrSPassword;
URLs = urls;
UserId = userId;
UserIsAdmin = userIsAdmin;
- WSR_URL = wsrURL;
+ WSR_URL = wsr_URL;
WorkingDirectoryName = workingDirectoryName;
}
@@ -79,7 +99,10 @@ public class AppSettings {
public string? Company { get; }
public string DBConnection { get; }
public string DBConnectionString { get; }
+ public string EmailTemplatesPath { get; }
public string FTPPassword { get; }
+ public string FTPSPNBatchFileName { get; }
+ public string FTPSPNBatchFileName_Test { get; }
public string FTPServer { get; }
public string FTPUser { get; }
public string HoldFlagDirectory { get; }
@@ -95,7 +118,14 @@ public class AppSettings {
public string NotificationSender { get; }
public string SenderEmail { get; }
public string? SMTPServer { get; }
+ public string SPNMRBHoldFlagDirectory { get; }
public string SPNMRBHoldFlagFTPLogDirectory { get; }
+ public string SSRSFolder { get; }
+ public string SSRSBindingsByConfiguration { get; }
+ public string SSRSBaseURL { get; }
+ public string SSRSDomain { get; }
+ public string SSRSUsername { get; }
+ public string SSRSPassword { get; }
public string TestEmailRecipients { get; }
public string URLs { get; }
public int UserId { get; }
@@ -131,59 +161,108 @@ public class AppSettings {
internal static AppSettings LoadConfigurationManager() {
AppSettings result;
- int userId = 0;
- string adminNotificationRecepient = ConfigurationManager.ConnectionStrings["Admin Notification Recepient"].ToString();
- string attachmentFolder = ConfigurationManager.ConnectionStrings["AttachmentFolder"].ToString();
- string ftpPassword = ConfigurationManager.ConnectionStrings["FTP Password"].ToString();
- string ftpServer = ConfigurationManager.ConnectionStrings["FTP Server"].ToString();
- string ftpUser = ConfigurationManager.ConnectionStrings["FTP User"].ToString();
- string holdFlagDirectory = ConfigurationManager.ConnectionStrings["HoldFlagDirectory"].ToString();
- string ifxContainer = ConfigurationManager.ConnectionStrings["IFXContainer"].ToString();
- string ifxDomain = ConfigurationManager.ConnectionStrings["IFXDomain"].ToString();
- string lotTempPipeLine = ConfigurationManager.ConnectionStrings["LotTempPipeLine"].ToString();
- string naContainer = ConfigurationManager.ConnectionStrings["NAContainer"].ToString();
- string naDomain = ConfigurationManager.ConnectionStrings["NADomain"].ToString();
- string notificationSender = ConfigurationManager.ConnectionStrings["Notification Sender"].ToString();
- string spnMRBHoldFlagFTPLogDirectory = ConfigurationManager.ConnectionStrings["SPNMRBHoldFlagFTPLogDirectory"].ToString();
- string testEmailRecipients = ConfigurationManager.ConnectionStrings["Test Email Recipients"].ToString();
- string? apiBaseUrl = ConfigurationManager.ConnectionStrings["FabApprovalApiBaseUrl"]?.ToString();
- string? attachmentUrl = ConfigurationManager.ConnectionStrings["AttachmentUrl"]?.ToString();
- string? company = ConfigurationManager.ConnectionStrings["Company"]?.ToString();
- string? smtpServer = ConfigurationManager.ConnectionStrings["SMTP Server"]?.ToString();
- string? urls = ConfigurationManager.ConnectionStrings["URLs"]?.ToString();
- string? workingDirectoryName = ConfigurationManager.ConnectionStrings["WorkingDirectoryName"]?.ToString();
- result = new(adminNotificationRecepient: adminNotificationRecepient,
- apiBaseUrl: apiBaseUrl,
- attachmentFolder: attachmentFolder,
- attachmentUrl: attachmentUrl,
- caBlankFormsLocation: Misc.GlobalVars.CA_BlankFormsLocation,
- company: company,
- dBConnection: Misc.GlobalVars.DBConnection,
- dbConnectionString: Misc.GlobalVars.DB_CONNECTION_STRING,
- ftpPassword: ftpPassword,
- ftpServer: ftpServer,
- ftpUser: ftpUser,
- holdFlagDirectory: holdFlagDirectory,
- hostURL: Misc.GlobalVars.hostURL,
- ifxContainer: ifxContainer,
- ifxDomain: ifxDomain,
- isInfineonDomain: Misc.GlobalVars.IS_INFINEON_DOMAIN,
- lotTempPipeLine: lotTempPipeLine,
- mesaTemplateFiles: Misc.GlobalVars.MesaTemplateFiles,
- naContainer: naContainer,
- naDomain: naDomain,
- nDriveURL: Misc.GlobalVars.NDriveURL,
- notificationSender: notificationSender,
- senderEmail: Misc.GlobalVars.SENDER_EMAIL,
- smtpServer: smtpServer,
- spnMRBHoldFlagFTPLogDirectory: spnMRBHoldFlagFTPLogDirectory,
- testEmailRecipients: testEmailRecipients,
- urls: urls,
- userId: userId,
- userIsAdmin: Misc.GlobalVars.USER_ISADMIN,
- wsrURL: Misc.GlobalVars.WSR_URL,
- workingDirectoryName: workingDirectoryName);
- return result;
+ try {
+ int userId = 0;
+ string adminNotificationRecepient = ConfigurationManager.AppSettings["Admin Notification Recepient"] ??
+ throw new ArgumentNullException("Admin Notification Recepient environment variable not found");
+ string attachmentFolder = ConfigurationManager.AppSettings["AttachmentFolder"] ??
+ throw new ArgumentNullException("AttachmentFolder environment variable not found");
+ string emailTemplatesPath = ConfigurationManager.AppSettings["EmailTemplatesPath"] ??
+ throw new ArgumentNullException("EmailTemplatesPath environment variable not found");
+ string ftpPassword = ConfigurationManager.AppSettings["FTP Password"] ??
+ throw new ArgumentNullException("FTP Password environment variable not found");
+ string ftpServer = ConfigurationManager.AppSettings["FTP Server"] ??
+ throw new ArgumentNullException("FTP Server environment variable not found");
+ string ftpSPNBatchFileName = ConfigurationManager.AppSettings["FTPSPNBatchFileName"] ??
+ throw new ArgumentNullException("FTPSPNBatchFileName environment variable not found");
+ string ftpSPNBatchFileName_Test = ConfigurationManager.AppSettings["FTPSPNBatchFileName_Test"] ??
+ throw new ArgumentNullException("FTPSPNBatchFileName_Test environment variable not found");
+ string ftpUser = ConfigurationManager.AppSettings["FTP User"] ??
+ throw new ArgumentNullException("FTP User environment variable not found");
+ string holdFlagDirectory = ConfigurationManager.AppSettings["HoldFlagDirectory"] ??
+ throw new ArgumentNullException("HoldFlagDirectory environment variable not found");
+ string ifxContainer = ConfigurationManager.AppSettings["IFXContainer"] ??
+ throw new ArgumentNullException("IFXContainer environment variable not found");
+ string ifxDomain = ConfigurationManager.AppSettings["IFXDomain"] ??
+ throw new ArgumentNullException("IFXDomain environment variable not found");
+ string lotTempPipeLine = ConfigurationManager.AppSettings["LotTempPipeLine"] ??
+ throw new ArgumentNullException("LotTempPipeLine environment variable not found");
+ string naContainer = ConfigurationManager.AppSettings["NAContainer"] ??
+ throw new ArgumentNullException("NAContainer environment variable not found");
+ string naDomain = ConfigurationManager.AppSettings["NADomain"] ??
+ throw new ArgumentNullException("NADomain environment variable not found");
+ string notificationSender = ConfigurationManager.AppSettings["Notification Sender"] ??
+ throw new ArgumentNullException("Notification Sender environment variable not found");
+ string spnMRBHoldFlagDirectory = ConfigurationManager.AppSettings["SPNMRBHoldFlagDirectory"] ??
+ throw new ArgumentNullException("SPNMRBHoldFlagDirectory environment variable not found");
+ string spnMRBHoldFlagFTPLogDirectory = ConfigurationManager.AppSettings["SPNMRBHoldFlagFTPLogDirectory"] ??
+ throw new ArgumentNullException("SPNMRBHoldFlagFTPLogDirectory environment variable not found");
+ string ssrSFolder = ConfigurationManager.AppSettings["SSRSFolder"] ??
+ throw new ArgumentNullException("SSRSFolder environment variable not found");
+ string ssrSBindingsByConfiguration = ConfigurationManager.AppSettings["SSRSBindingsByConfiguration"] ??
+ throw new ArgumentNullException("SSRSBindingsByConfiguration environment variable not found");
+ string ssrSBaseURL = ConfigurationManager.AppSettings["SSRSBaseURL"] ??
+ throw new ArgumentNullException("SSRSBaseURL environment variable not found");
+ string ssrSDomain = ConfigurationManager.AppSettings["SSRSDomain"] ??
+ throw new ArgumentNullException("SSRSDomain environment variable not found");
+ string ssrSUsername = ConfigurationManager.AppSettings["SSRSUsername"] ??
+ throw new ArgumentNullException("SSRSUsername environment variable not found");
+ string ssrSPassword = ConfigurationManager.AppSettings["SSRSPassword"] ??
+ throw new ArgumentNullException("SSRSPassword environment variable not found");
+ string testEmailRecipients = ConfigurationManager.AppSettings["Test Email Recipients"] ??
+ throw new ArgumentNullException("Test Email Recipients environment variable not found");
+ string? apiBaseUrl = ConfigurationManager.AppSettings["FabApprovalApiBaseUrl"]?.ToString();
+ string? attachmentUrl = ConfigurationManager.AppSettings["AttachmentUrl"]?.ToString();
+ string? company = ConfigurationManager.AppSettings["Company"]?.ToString();
+ string? smtpServer = ConfigurationManager.AppSettings["SMTP Server"]?.ToString();
+ string? urls = ConfigurationManager.AppSettings["URLs"]?.ToString();
+ string? workingDirectoryName = ConfigurationManager.AppSettings["WorkingDirectoryName"]?.ToString();
+ result = new(adminNotificationRecepient: adminNotificationRecepient,
+ apiBaseUrl: apiBaseUrl,
+ attachmentFolder: attachmentFolder,
+ attachmentUrl: attachmentUrl,
+ caBlankFormsLocation: Misc.GlobalVars.CA_BlankFormsLocation,
+ company: company,
+ dBConnection: Misc.GlobalVars.DBConnection,
+ dbConnectionString: Misc.GlobalVars.DB_CONNECTION_STRING,
+ emailTemplatesPath: emailTemplatesPath,
+ ftpPassword: ftpPassword,
+ ftpServer: ftpServer,
+ ftpSPNBatchFileName: ftpSPNBatchFileName,
+ ftpSPNBatchFileName_Test: ftpSPNBatchFileName_Test,
+ ftpUser: ftpUser,
+ holdFlagDirectory: holdFlagDirectory,
+ hostURL: Misc.GlobalVars.hostURL,
+ ifxContainer: ifxContainer,
+ ifxDomain: ifxDomain,
+ isInfineonDomain: Misc.GlobalVars.IS_INFINEON_DOMAIN,
+ lotTempPipeLine: lotTempPipeLine,
+ mesaTemplateFiles: Misc.GlobalVars.MesaTemplateFiles,
+ naContainer: naContainer,
+ naDomain: naDomain,
+ nDriveURL: Misc.GlobalVars.NDriveURL,
+ notificationSender: notificationSender,
+ senderEmail: Misc.GlobalVars.SENDER_EMAIL,
+ smtpServer: smtpServer,
+ spnMRBHoldFlagDirectory: spnMRBHoldFlagDirectory,
+ spnMRBHoldFlagFTPLogDirectory: spnMRBHoldFlagFTPLogDirectory,
+ testEmailRecipients: testEmailRecipients,
+ ssrSFolder: ssrSFolder,
+ ssrSBindingsByConfiguration: ssrSBindingsByConfiguration,
+ ssrSBaseURL: ssrSBaseURL,
+ ssrSDomain: ssrSDomain,
+ ssrSUsername: ssrSUsername,
+ ssrSPassword: ssrSPassword,
+ urls: urls,
+ userId: userId,
+ userIsAdmin: Misc.GlobalVars.USER_ISADMIN,
+ wsr_URL: Misc.GlobalVars.WSR_URL,
+ workingDirectoryName: workingDirectoryName);
+ return result;
+ } catch (Exception ex) {
+ Misc.Functions.WriteEvent(null, "LoadConfigurationManager - \r\n" + ex.Message.ToString(), System.Diagnostics.EventLogEntryType.Error);
+ throw;
+ }
}
}
\ No newline at end of file
diff --git a/Fab2ApprovalSystem/Models/ApprovalLogHistory.cs b/Fab2ApprovalSystem/Models/ApprovalLogHistory.cs
index a7e7231..472fc0d 100644
--- a/Fab2ApprovalSystem/Models/ApprovalLogHistory.cs
+++ b/Fab2ApprovalSystem/Models/ApprovalLogHistory.cs
@@ -9,7 +9,6 @@ public class ApprovalLogHistory {
public string Operation { get; set; }
public string SubRole { get; set; }
- //[Display(Name = "Operation Time")]
public DateTime OperationTime { get; set; }
public string Comments { get; set; }
diff --git a/Fab2ApprovalSystem/Models/Common.cs b/Fab2ApprovalSystem/Models/Common.cs
index db3022e..ea4c636 100644
--- a/Fab2ApprovalSystem/Models/Common.cs
+++ b/Fab2ApprovalSystem/Models/Common.cs
@@ -70,8 +70,6 @@ public class Lot {
[Display(Name = "Lot Dispos")]
public string OtherLotDispos { get; set; }
- //MRB Lot
- //[CustomDispoTypeValidationAttribute(ErrorMessage = "The values can only either A or B or C or D")]
public char? DispoType { get; set; }
[Display(Name = "Lot Dispos")]
public string LotDispositionsLinkedToLot { get; set; }
diff --git a/Fab2ApprovalSystem/Models/ECNModel.cs b/Fab2ApprovalSystem/Models/ECNModel.cs
index 76a66b9..4ca7168 100644
--- a/Fab2ApprovalSystem/Models/ECNModel.cs
+++ b/Fab2ApprovalSystem/Models/ECNModel.cs
@@ -33,7 +33,6 @@ public class ECN : object {
public bool IsEmergencyTECN { get; set; }
[DataType(DataType.Date)]
- //[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime? ExpirationDate { get; set; }
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
@@ -147,7 +146,6 @@ public class ECN : object {
return false;
// Return true if the fields match:
- //return (IsECN == p.IsECN) && (IsEmergencyTECN == p.IsEmergencyTECN);
}
}
diff --git a/Fab2ApprovalSystem/Models/LotDispositionModels.cs b/Fab2ApprovalSystem/Models/LotDispositionModels.cs
index fde5abd..d842f47 100644
--- a/Fab2ApprovalSystem/Models/LotDispositionModels.cs
+++ b/Fab2ApprovalSystem/Models/LotDispositionModels.cs
@@ -12,10 +12,9 @@ namespace Fab2ApprovalSystem.Models;
[Serializable]
public class LotDisposition {
- //[Editable(false)]
+
[Display(Name = "Issue Number")]
public int IssueID { get; set; }
- //[Editable(false)]
public string Title { get; set; }
public bool PERequired { get; set; }
public string IssueDescription { get; set; }
@@ -32,7 +31,7 @@ public class LotDisposition {
public byte CurrentStep { get; set; }
// Extra field Defined for Scraping wafer for a given lot
public Lot Lot { get; set; }
- //Extra field defined for Attachments
+ // Extra field defined for Attachments
public Attachment DocumentAttachment { get; set; }
// important!!make sure the id of the control matches the name of the field in the model it is being binded to,
@@ -58,7 +57,7 @@ public class LotDisposition {
DepartmentIDs = new List();
Lot = new Lot();
DocumentAttachment = new Attachment();
- //Lots = new List();
+ // Lots = new List();
Attachments = new List();
Approvals = new List();
ScrapLots = new List();
diff --git a/Fab2ApprovalSystem/Models/MRBModels.cs b/Fab2ApprovalSystem/Models/MRBModels.cs
index 42464a7..bdd1940 100644
--- a/Fab2ApprovalSystem/Models/MRBModels.cs
+++ b/Fab2ApprovalSystem/Models/MRBModels.cs
@@ -63,9 +63,6 @@ public class MRB {
}
}
- ///
- ///
- ///
public MRB() {
PartGroupIDs = new List();
ModuleIDs = new List();
@@ -106,7 +103,7 @@ public class Disposition {
public string DispositionName { get; set; }
public string DispositionNotes { get; set; }
- //Duplicated as the CloseToQDBOptionID is being used in the dropdown in the Grid kept the old code
+ // Duplicated as the CloseToQDBOptionID is being used in the dropdown in the Grid kept the old code
public int CloseToQDBOption_ID { get; set; }
[UIHint("CloseToQDBTemplate")]
@@ -151,7 +148,6 @@ public class ContainmentActionObj {
public int CurrentResponsibilityOwnerID { get; set; }
public string ResponsibilityOwner { get; set; }
- //[DataType(DataType.Date)]
public DateTime? ECD { get; set; }
[DataType(DataType.Date)]
diff --git a/Fab2ApprovalSystem/Models/WinEventLogModel.cs b/Fab2ApprovalSystem/Models/WinEventLogModel.cs
index 17d70ae..bcf2c7a 100644
--- a/Fab2ApprovalSystem/Models/WinEventLogModel.cs
+++ b/Fab2ApprovalSystem/Models/WinEventLogModel.cs
@@ -1,7 +1,6 @@
namespace Fab2ApprovalSystem.Models;
public class WinEventLog {
- //[Key]
public int SysDocumentID { get; set; }
public int IssueID { get; set; }
diff --git a/Fab2ApprovalSystem/PdfGenerator/PdfViewController.cs b/Fab2ApprovalSystem/PdfGenerator/PdfViewController.cs
index 07ae2f5..f55bdef 100644
--- a/Fab2ApprovalSystem/PdfGenerator/PdfViewController.cs
+++ b/Fab2ApprovalSystem/PdfGenerator/PdfViewController.cs
@@ -25,13 +25,6 @@ namespace Fab2ApprovalSystem.PdfGenerator {
this.standardPdfRenderer = new StandardPdfRenderer();
}
- ///
- ///
- ///
-
-
-
- ///
protected ActionResult ViewPdf(string pageTitle, string viewName, object model) {
// Render the view html to a string.
string htmlText = this.htmlViewRenderer.RenderViewToString(this, viewName, model);
@@ -43,12 +36,6 @@ namespace Fab2ApprovalSystem.PdfGenerator {
return new BinaryContentResult(buffer, "application/pdf");
}
- ///
- ///
- ///
-
-
-
protected void SavePdf(string fileName, string viewName, object model) {
// Render the view html to a string.
string htmlText = this.htmlViewRenderer.RenderViewToString(this, viewName, model);
diff --git a/Fab2ApprovalSystem/Utilities/FileUtilities.cs b/Fab2ApprovalSystem/Utilities/FileUtilities.cs
index ff850b8..8c3a03f 100644
--- a/Fab2ApprovalSystem/Utilities/FileUtilities.cs
+++ b/Fab2ApprovalSystem/Utilities/FileUtilities.cs
@@ -24,9 +24,6 @@ public class FileUtilities : Controller // => System.Web.Mvc.FileContentR
{
public T DownloadFilesFromServer