Added just one approval back in after removing the method call from bug 239935 Added IExcelDataReader support into MK Project Changed instructions below the ECN Title field to align with Windchill Related work items: #225480, #244087
165 lines
6.7 KiB
C#
165 lines
6.7 KiB
C#
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<string> 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<string> 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.
|
|
string fileName = Path.GetFileName(fullFileName);
|
|
string 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;
|
|
|
|
string 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);
|
|
}
|
|
|
|
ExcelData x = new (physicalPath);
|
|
IEnumerable<ExcelData.ExcelLotInfo> lotNumbers = x.ReadData();
|
|
|
|
foreach (ExcelData.ExcelLotInfo lotInfo in lotNumbers) {
|
|
Lot l = new();
|
|
l.LotNumber = lotInfo.LotNo ?? string.Empty;
|
|
l.IssueID = issueID;
|
|
if (l.LotStatusOptionID == 0)
|
|
l.LotStatusOption.LotStatusOptionID = (int)GlobalVars.LotStatusOption.Release;
|
|
|
|
lotDispositionDMO.InsertLot(l, true);
|
|
}
|
|
|
|
FileInfo f = new(physicalPath);
|
|
if (f.Exists)
|
|
f.Delete();
|
|
|
|
return physicalPath;
|
|
}
|
|
|
|
} |