Tasks 184281, 184799, 184800, 184801 and 184802

Align .editorconfig files

Move Controller logic to DMO classes

GlobalVars.AppSettings = Models.AppSettings.GetFromConfigurationManager();

Question EditorConfig
Project level editorconfig
Format White Spaces
AppSetting when EnvironmentVariable not set
Corrective Actions Tests
Schedule Actions Tests
DMO Tests
Controller Tests

Get ready to use VSCode IDE
This commit is contained in:
2024-12-04 11:58:13 -07:00
parent 538b1f817e
commit b1c6903c1c
150 changed files with 29146 additions and 33456 deletions

View File

@ -1,39 +1,32 @@
using Fab2ApprovalSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.Generic;
namespace Fab2ApprovalSystem.Misc
{
public class DemoHelper
{
public static List<string> GetCountries()
{
return new List<string>
{
"USA", "England", "Belguim", "France", "Italy"
};
}
using Fab2ApprovalSystem.Models;
public List<TestModel> ListOfModels = new List<TestModel>();
namespace Fab2ApprovalSystem.Misc;
private static DemoHelper m_dHelper = new DemoHelper();
public static DemoHelper Instance
{
get { return m_dHelper; }
}
private DemoHelper()
{
TestModel A1 = new TestModel();
A1.Name = "Eran";
A1.Countries = new List<string>();
A1.Countries.Add("England");
A1.Countries.Add("Belguim");
ListOfModels.Add(A1);
}
public class DemoHelper {
public static List<string> GetCountries() {
return new List<string>
{
"USA", "England", "Belguim", "France", "Italy"
};
}
public List<TestModel> ListOfModels = new();
private static readonly DemoHelper m_dHelper = new();
public static DemoHelper Instance {
get { return m_dHelper; }
}
private DemoHelper() {
TestModel A1 = new();
A1.Name = "Eran";
A1.Countries = new List<string>();
A1.Countries.Add("England");
A1.Countries.Add("Belguim");
ListOfModels.Add(A1);
}
}

View File

@ -1,168 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Fab2ApprovalSystem.Misc;
//using DFClib.DfException;
//using DFCLib.DfId;
//using DFCLib.IDfId;
//using DFCLib.IDfList;
//using DFCLib.IDfLoginInfo;
//using DFCLib.IDfClient;
//using DFCLib.IDfDocument;
//using DFCLib.IDfSession;
//using DFCLib.IDfSessionManager;
//using DFCLib.DfClientX;
//using DFCLib.IDfClientX;
//using DFCLib.IDfFile;
//using DFCLib.IDfImportNode;
//using DFCLib.IDfImportOperation;
namespace Fab2ApprovalSystem.Misc
{
public class Documentum
{
//public static void Process(string m_fileName)
//{
// String username = "rkotian1";
// String password = "";
// String repoName = "globaldocudms";
// String filename = m_fileName; // for example {"C:\\devprog\\ECN12345.zip"};
// String destFldrId = "0c00359980061536";
// try
// {
// DFCLib.IDfSessionManager sessMgr = createSessionManager();
// addIdentity(sessMgr, username, password, repoName);
// importFiles(sessMgr, repoName, filename, destFldrId);
// }
// catch (Exception ex)
// {
// //string s = ex.InnerException.ToString();
// }
//}
///**
// * Imports a single file in the repository
// *
// */
//private static void importFiles(DFCLib.IDfSessionManager sessMgr, String repoName, String filename, String destFldrId)
//{
// DFCLib.IDfSession sess = null;
// try
// {
// DFCLib.IDfClientX clientX = new DFCLib.DfClientX();
// DFCLib.IDfImportOperation impOper = clientX.getImportOperation();
// //DFCLib.IDfId destId = new DfId(destFldrId);
// DFCLib.IDfId destId = clientX.getId(destFldrId);
// //This will import all files to a single destination.
// //To import each file to a different destination
// //set call this method on the import node.
// //impOper.setDestinationFolderId(destId);
// DFCLib.IDfFile localFile = clientX.getFile(filename);
// DFCLib.IDfImportNode impNode = (DFCLib.IDfImportNode)impOper.add(localFile);
// //You can set different destination ids here for each import node
// //This way files get imported to different destinations.
// impNode.setDestinationFolderId(destId);
// //set custom object type. If not called dm_document is used.
// impNode.setDocbaseObjectType("dp_text");
// int randomName = ((int)(new Random().Next(int.MinValue, int.MaxValue) * 100));
// //set custom object name.
// impNode.setNewObjectName(localFile.getName() + "" + randomName.ToString());
// //The import operation determines the file format.
// //It is also possible to explicitly set the format.
// //impNode.setFormat("");
// sess = sessMgr.getSession(repoName);
// impOper.setSession(sess);
// if (impOper.execute())
// {
// Console.WriteLine("Import Operation Succeeded");
// DFCLib.IDfList newObjLst = impOper.getNewObjects();
// for (int i = 0; i < newObjLst.getCount(); i++)
// {
// DFCLib.IDfDocument newObj = (DFCLib.IDfDocument)newObjLst.get(i);
// //you can set any custom/standard attr values on the document now
// //newObj.setString("my_attr","someValue");
// //newObj.save();
// Console.WriteLine("Created Object: " + newObj.getObjectId());
// }
// }
// else
// {
// Console.WriteLine("Import Operation Failed");
// DFCLib.IDfList errList = impOper.getErrors();
// for (int i = 0; i < errList.getCount(); i++)
// {
// DFCLib.IDfOperationError err = (DFCLib.IDfOperationError)errList.get(i);
// Console.WriteLine(err.getMessage());
// }
// }
// }
// finally
// {
// if (sess != null)
// {
// sessMgr.release(sess);
// }
// }
//}
///**
// * Creates a new session manager instance. The session manager does not have
// * any identities associated with it.
// * @return a new session manager object.
//*/
//private static DFCLib.IDfSessionManager createSessionManager()
//{
// DFCLib.IDfClientX clientX = new DFCLib.DfClientX();
// DFCLib.IDfClient localClient = clientX.getLocalClient();
// DFCLib.IDfSessionManager sessMgr = localClient.newSessionManager();
// return sessMgr;
//}
///**
// * Adds a new identity to the session manager.
// *
// */
//private static void addIdentity(DFCLib.IDfSessionManager sm, String username,
// String password, String repoName)
//{
// DFCLib.IDfClientX clientX = new DFCLib.DfClientX();
// DFCLib.IDfLoginInfo li = clientX.getLoginInfo();
// li.setUser(username);
// li.setPassword(password);
// // check if session manager already has an identity.
// // if yes, remove it.
// if (sm.hasIdentity(repoName))
// {
// sm.clearIdentity(repoName);
// }
// sm.setIdentity(repoName, li);
//}
}
}
public class Documentum { }

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,7 @@
using Excel;
#if !NET8
using Excel;
using System;
using System.Collections.Generic;
using System.Data;
@ -6,18 +9,15 @@ using System.IO;
using System.Linq;
using System.Web;
namespace Fab2ApprovalSystem.Misc
{
public class ExcelData
{
namespace Fab2ApprovalSystem.Misc {
public class ExcelData {
string _path;
public ExcelData(string path)
{
public ExcelData(string path) {
_path = path;
}
public IExcelDataReader getExcelReader()
{
public IExcelDataReader getExcelReader() {
// ExcelDataReader works with the binary Excel file, so it needs a FileStream
// to get started. This is how we avoid dependencies on ACE or Interop:
@ -25,27 +25,21 @@ namespace Fab2ApprovalSystem.Misc
// We return the interface, so that
IExcelDataReader reader = null;
try
{
if (_path.EndsWith(".xls"))
{
try {
if (_path.EndsWith(".xls")) {
reader = ExcelReaderFactory.CreateBinaryReader(stream);
}
if (_path.EndsWith(".xlsx"))
{
if (_path.EndsWith(".xlsx")) {
reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
}
return reader;
}
catch (Exception)
{
} catch (Exception) {
throw;
}
}
public class ExcelLotInfo
{
public class ExcelLotInfo {
public string LotNo { get; set; }
public string LotDispo { get; set; }
}
@ -54,57 +48,44 @@ namespace Fab2ApprovalSystem.Misc
///
/// </summary>
/// <returns></returns>
public IEnumerable<ExcelLotInfo> ReadData()
{
public IEnumerable<ExcelLotInfo> ReadData() {
var r = new List<ExcelLotInfo>();
var excelData = new ExcelData(_path);
var lots = excelData.getData().ToList();
int lotDispoColumnIndex = -1;
foreach (DataColumn col in lots[0].Table.Columns)
{
if (col.ColumnName.ToLower().Contains("dispo"))
{
foreach (DataColumn col in lots[0].Table.Columns) {
if (col.ColumnName.ToLower().Contains("dispo")) {
lotDispoColumnIndex = col.Ordinal;
break;
}
}
foreach (var row in lots)
{
foreach (var row in lots) {
string temValue = row[0].ToString();
if (temValue.Trim().Length > 0 && temValue.Trim().Length <= 10 )
{
r.Add(new ExcelLotInfo()
{
if (temValue.Trim().Length > 0 && temValue.Trim().Length <= 10) {
r.Add(new ExcelLotInfo() {
LotNo = row[0].ToString(),
LotDispo = (lotDispoColumnIndex >= 0 ? row[lotDispoColumnIndex].ToString() : "")
});
}
}
return r;
}
public IEnumerable<string> ReadQDBFlagData()
{
public IEnumerable<string> ReadQDBFlagData() {
List<string> s = new List<string>();
// 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)
{
foreach (var row in lotNos) {
string temValue = row[0].ToString();
if (temValue.Trim().Length > 0 && temValue.Trim().Length == 9)
{
if (row[2].ToString().ToUpper() != "YES" && row[2].ToString().ToUpper() != "NO")
{
if (temValue.Trim().Length > 0 && temValue.Trim().Length == 9) {
if (row[2].ToString().ToUpper() != "YES" && row[2].ToString().ToUpper() != "NO") {
throw new Exception("Invalid data in the file");
}
else
{
} else {
s.Add(row[0].ToString() + "~" + row[1] + "~" + row[2]);
}
}
@ -113,23 +94,12 @@ namespace Fab2ApprovalSystem.Misc
return s;
}
//public IEnumerable<DataRow> getData(string sheet, bool firstRowIsColumnNames = true)
//{
// var reader = this.getExcelReader();
// reader.IsFirstRowAsColumnNames = firstRowIsColumnNames;
// var workSheet = reader.AsDataSet().Tables[sheet];
// var rows = from DataRow a in workSheet.Rows select a;
// return rows;
//}
/// <summary>
///
/// </summary>
/// <param name="firstRowIsColumnNames"></param>
/// <returns></returns>
public IEnumerable<DataRow> getData(bool firstRowIsColumnNames = true)
{
public IEnumerable<DataRow> getData(bool firstRowIsColumnNames = true) {
var reader = this.getExcelReader();
reader.IsFirstRowAsColumnNames = firstRowIsColumnNames;
var workSheet = reader.AsDataSet().Tables[0];
@ -138,7 +108,7 @@ namespace Fab2ApprovalSystem.Misc
}
}
}
}
#endif

View File

@ -1,59 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Fab2ApprovalSystem.Misc
{
class FTPWrapper
{
string m_OutputFile;
string m_DestinationFileName;
//Functions functions = new Functions();
public FTPWrapper(string outputFile, string destinationFileName)
{
m_OutputFile = outputFile;
m_DestinationFileName = destinationFileName;
using Fab2ApprovalSystem.Models;
namespace Fab2ApprovalSystem.Misc;
internal class FTPWrapper {
private readonly string _OutputFile;
private readonly string _DestinationFileName;
private readonly AppSettings _AppSettings;
public FTPWrapper(AppSettings appSettings, string outputFile, string destinationFileName) {
_OutputFile = outputFile;
_AppSettings = appSettings;
_DestinationFileName = destinationFileName;
}
/// <summary>
///
/// </summary>
public void FTPToSPN() {
FTP ftpLib = new();
//Connect to the FTP server
try {
ftpLib.Connect(_AppSettings.FTPServer, _AppSettings.FTPUser, _AppSettings.FTPPassword);
} catch (Exception ec) {
Functions.WriteEvent(_AppSettings, "Listener - ProcessFile(): FTP Connection Error " + _OutputFile + " - " + ec.Source +
": " + ec.Message, System.Diagnostics.EventLogEntryType.Error);
}
/// <summary>
///
/// </summary>
public void FTPToSPN()
{
FTP ftpLib = new FTP();
//Connect to the FTP server
try
{
ftpLib.Connect(Functions.FTPServer(), Functions.FTPUser(), Functions.FTPPassword());
}
catch (Exception ec)
{
Functions.WriteEvent("Listener - ProcessFile(): FTP Connection Error " + m_OutputFile + " - " + ec.Source +
": " + ec.Message, System.Diagnostics.EventLogEntryType.Error);
}
//Upload the file
try
{
int pct = 0;
ftpLib.OpenUpload(m_OutputFile, m_DestinationFileName);
while (ftpLib.DoUpload() > 0)
pct = (int)((ftpLib.BytesTotal * 100) / ftpLib.FileSize);
Functions.WriteEvent(m_OutputFile + " was sucessfully FTPed to SPN.", System.Diagnostics.EventLogEntryType.Information);
}
catch (Exception eu)
{
Functions.WriteEvent("MRB - FTPToSPN(): FTP Upload Error " + m_OutputFile + " - " + eu.Source +
": " + eu.Message, System.Diagnostics.EventLogEntryType.Error);
throw new Exception(eu.Source + ": " + eu.Message);
}
//Upload the file
try {
int pct = 0;
ftpLib.OpenUpload(_OutputFile, _DestinationFileName);
while (ftpLib.DoUpload() > 0)
pct = (int)((ftpLib.BytesTotal * 100) / ftpLib.FileSize);
Functions.WriteEvent(_AppSettings, _OutputFile + " was sucessfully FTPed to SPN.", System.Diagnostics.EventLogEntryType.Information);
} catch (Exception eu) {
Functions.WriteEvent(_AppSettings, "MRB - FTPToSPN(): FTP Upload Error " + _OutputFile + " - " + eu.Source +
": " + eu.Message, System.Diagnostics.EventLogEntryType.Error);
throw new Exception(eu.Source + ": " + eu.Message);
}
}
}

View File

@ -1,261 +1,199 @@
#pragma warning disable CS8019
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.Web;
#if !NET8
using System.Web.Security;
#endif
using System.IO;
using System.Net.Mail;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
namespace Fab2ApprovalSystem.Misc {
public static class Functions {
/// <summary>
/// Writes to the Application Event Log and sends an email notification if appropriate
/// </summary>
/// <param name="logtext"></param>
/// <param name="eventType"></param>
public static void WriteEvent(string logtext, System.Diagnostics.EventLogEntryType eventType) {
//#if(!DEBUG)
EmailNotification en = new EmailNotification();
EventLog ev = new EventLog("Application");
ev.Source = "Fab Approval System";
#pragma warning restore CS8019
try {
//Write to the Event Log
ev.WriteEntry(logtext, eventType);
using Fab2ApprovalSystem.Models;
////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
if (eventType == System.Diagnostics.EventLogEntryType.Error)
en.SendNotificationEmailToAdmin(ev.Source + " - Error Notification", logtext, MailPriority.High);
//else if (eventType == System.Diagnostics.EventLogEntryType.Warning)
// SendEmailNotification(ErrorRecipient(), ev.Source + " Warning Event Logged", logtext, NORMAL_PRI);
}
} catch {
//throw;
} finally {
ev = null;
namespace Fab2ApprovalSystem.Misc;
public static class Functions {
/// <summary>
/// Writes to the Application Event Log and sends an email notification if appropriate
/// </summary>
public static void WriteEvent(AppSettings? appSettings, string logtext, EventLogEntryType eventType) {
//#if(!DEBUG)
#if !NET8
EmailNotification? en = appSettings is null ? null : new EmailNotification(appSettings);
#endif
EventLog ev = new("Application");
ev.Source = "Fab Approval System";
try {
//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
if (!logtext.Contains("SendEmailNotification()")) {
//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);
}
}
/// <summary>
/// Returns the FTP Server Name
/// </summary>
/// <returns></returns>
public static string FTPServer() {
ConfigurationManager.RefreshSection("appSettings");
return ConfigurationManager.AppSettings["FTP Server"];
}
/// <summary>
/// Returns the FTP User Name
/// </summary>
/// <returns></returns>
public static string FTPUser() {
ConfigurationManager.RefreshSection("appSettings");
return ConfigurationManager.AppSettings["FTP User"];
}
/// <summary>
/// Returns the FTP Password
/// </summary>
/// <returns></returns>
public static string FTPPassword() {
ConfigurationManager.RefreshSection("appSettings");
return ConfigurationManager.AppSettings["FTP Password"];
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static string GetAttachmentFolder() {
ConfigurationManager.RefreshSection("appSettings");
return ConfigurationManager.AppSettings["AttachmentFolder"];
}
/// <summary>
///
/// </summary>
/// <param name="oldECNNumber"></param>
/// <param name="newECNNumber"></param>
public static void CopyAttachments(int oldECNNumber, int newECNNumber) {
// The Name of the Upload component is "files"
string oldFolderPath = Functions.GetAttachmentFolder() + "ECN\\" + oldECNNumber.ToString();
string newFolderPath = Functions.GetAttachmentFolder() + "ECN\\" + newECNNumber.ToString();
DirectoryInfo newdi = new DirectoryInfo(newFolderPath);
if (!newdi.Exists)
newdi.Create();
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));
}
}
/// <summary>
///
/// </summary>
/// <param name="userID"></param>
/// <param name="pwd"></param>
/// <returns></returns>
public static bool NA_ADAuthenticate(string userID, string pwd) {
string naContainer = ConfigurationManager.AppSettings["NAContainer"];
string naDomain = ConfigurationManager.AppSettings["NADomain"];
try {
PrincipalContext contextUser = new PrincipalContext(ContextType.Domain,
naDomain,
naContainer,
ContextOptions.Negotiate, userID, pwd);
UserPrincipal up = UserPrincipal.FindByIdentity(contextUser, userID);
if (null == up)
return false;
else
return true;
} catch {
return false;
}
}
/// <summary>
///
/// </summary>
/// <param name="userID"></param>
/// <param name="pwd"></param>
/// <returns></returns>
public static bool IFX_ADAuthenticate(string userID, string pwd) {
string container = ConfigurationManager.AppSettings["IFXContainer"];
string domain = ConfigurationManager.AppSettings["IFXDomain"];
try {
PrincipalContext contextUser = new PrincipalContext(ContextType.Domain,
domain,
container,
ContextOptions.Negotiate, userID, pwd);
UserPrincipal up = UserPrincipal.FindByIdentity(contextUser, userID);
if (null == up)
return false;
else
return true;
} catch {
return false;
}
}
public static string FTPSPNBatch() {
ConfigurationManager.RefreshSection("appSettings");
return ConfigurationManager.AppSettings["FTPSPNBatchFileName"];
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static string FTPSPNBatch_Test() {
ConfigurationManager.RefreshSection("appSettings");
return ConfigurationManager.AppSettings["FTPSPNBatchFileName_Test"];
}
/// <summary>
///
/// </summary>
/// <param name="casection"></param>
/// <returns></returns>
public static string CASectionMapper(GlobalVars.CASection casection) {
switch (casection) {
case GlobalVars.CASection.Main:
return "Main";
case GlobalVars.CASection.D1:
return "D1";
case GlobalVars.CASection.D2:
return "D2";
case GlobalVars.CASection.D3:
return "D3";
case GlobalVars.CASection.D4:
return "D4";
case GlobalVars.CASection.D5:
return "D5";
case GlobalVars.CASection.D6:
return "D6";
case GlobalVars.CASection.D7:
return "D7";
case GlobalVars.CASection.D8:
return "D8";
case GlobalVars.CASection.CF: // CA Findings
return "CF";
}
return "";
}
public static string DocumentTypeMapper(GlobalVars.DocumentType docType) {
switch (docType) {
case GlobalVars.DocumentType.Audit:
return "Audit";
case GlobalVars.DocumentType.ChangeControl:
return "ChangeControl";
case GlobalVars.DocumentType.CorrectiveAction:
return "CorrectiveAction";
case GlobalVars.DocumentType.ECN:
return "ECN";
case GlobalVars.DocumentType.EECN:
return "EECN";
case GlobalVars.DocumentType.LotDisposition:
return "LotDisposition";
case GlobalVars.DocumentType.MRB:
return "MRB";
case GlobalVars.DocumentType.TECNCancelledExpired:
return "TECNCancelledExpired";
}
return "";
}
/// <summary>
/// Converts the CA No to the C00000 format
/// </summary>
/// <param name="caNo"></param>
/// <returns></returns>
public static string ReturnCANoStringFormat(int caNo) {
string caNoString = "";
if (caNo == 0)
return "";
caNoString = "C" + caNo.ToString().PadLeft(5, '0');
return caNoString;
}
public static string ReturnAuditNoStringFormat(int auditNo) {
string auditNoString = "";
if (auditNo == 0)
return "";
auditNoString = "A" + auditNo.ToString().PadLeft(5, '0');
return auditNoString;
}
public static string ReturnPartsRequestNoStringFormat(int PRNumber) {
if (PRNumber == 0)
return "";
return String.Format("PR{0:000000}", PRNumber);
} catch {
//throw;
} finally {
ev = null;
}
}
}
public static void CopyAttachments(AppSettings appSettings, int oldECNNumber, int newECNNumber) {
// The Name of the Upload component is "files"
string oldFolderPath = appSettings.AttachmentFolder + "ECN\\" + oldECNNumber.ToString();
string newFolderPath = appSettings.AttachmentFolder + "ECN\\" + newECNNumber.ToString();
DirectoryInfo newdi = new(newFolderPath);
if (!newdi.Exists)
newdi.Create();
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));
}
}
public static bool NA_ADAuthenticate(AppSettings appSettings, string userID, string pwd) {
string naContainer = appSettings.NAContainer;
string naDomain = appSettings.NADomain;
try {
PrincipalContext contextUser = new(ContextType.Domain,
naDomain,
naContainer,
ContextOptions.Negotiate, userID, pwd);
UserPrincipal up = UserPrincipal.FindByIdentity(contextUser, userID);
if (null == up)
return false;
else
return true;
} catch {
return false;
}
}
public static bool IFX_ADAuthenticate(AppSettings appSettings, string userID, string pwd) {
string container = appSettings.IFXContainer;
string domain = appSettings.IFXDomain;
try {
PrincipalContext contextUser = new(ContextType.Domain,
domain,
container,
ContextOptions.Negotiate, userID, pwd);
UserPrincipal up = UserPrincipal.FindByIdentity(contextUser, userID);
if (null == up)
return false;
else
return true;
} catch {
return false;
}
}
public static string CASectionMapper(GlobalVars.CASection casection) {
switch (casection) {
case GlobalVars.CASection.Main:
return "Main";
case GlobalVars.CASection.D1:
return "D1";
case GlobalVars.CASection.D2:
return "D2";
case GlobalVars.CASection.D3:
return "D3";
case GlobalVars.CASection.D4:
return "D4";
case GlobalVars.CASection.D5:
return "D5";
case GlobalVars.CASection.D6:
return "D6";
case GlobalVars.CASection.D7:
return "D7";
case GlobalVars.CASection.D8:
return "D8";
case GlobalVars.CASection.CF: // CA Findings
return "CF";
}
return "";
}
public static string DocumentTypeMapper(GlobalVars.DocumentType docType) {
switch (docType) {
case GlobalVars.DocumentType.Audit:
return "Audit";
case GlobalVars.DocumentType.ChangeControl:
return "ChangeControl";
case GlobalVars.DocumentType.CorrectiveAction:
return "CorrectiveAction";
case GlobalVars.DocumentType.ECN:
return "ECN";
case GlobalVars.DocumentType.EECN:
return "EECN";
case GlobalVars.DocumentType.LotDisposition:
return "LotDisposition";
case GlobalVars.DocumentType.MRB:
return "MRB";
case GlobalVars.DocumentType.TECNCancelledExpired:
return "TECNCancelledExpired";
}
return "";
}
/// <summary>
/// Converts the CA No to the C00000 format
/// </summary>
public static string ReturnCANoStringFormat(int caNo) {
string caNoString = "";
if (caNo == 0)
return "";
caNoString = "C" + caNo.ToString().PadLeft(5, '0');
return caNoString;
}
public static string ReturnAuditNoStringFormat(int auditNo) {
string auditNoString = "";
if (auditNo == 0)
return "";
auditNoString = "A" + auditNo.ToString().PadLeft(5, '0');
return auditNoString;
}
public static string ReturnPartsRequestNoStringFormat(int PRNumber) {
if (PRNumber == 0)
return "";
return string.Format("PR{0:000000}", PRNumber);
}
}

View File

@ -1,118 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Fab2ApprovalSystem.Models;
namespace Fab2ApprovalSystem.Misc
{
public class GlobalVars
{
public int USER_ID;
public const string SESSION_USERNAME = "UserName";
public const string ApplicationName = "LotDisposition";
public const string SESSION_USERID = "UserID";
public const string ECN_VIEW_OPTION = "ECN_ViewOption";
public const string IS_ADMIN = "IsAdmin";
public const string IS_MANAGER = "IsManager";
public const string OOO = "OOO";
public const string SUCCESS = "Success";
public const string CAN_CREATE_PARTS_REQUEST = "CanCreatePartsRequest";
namespace Fab2ApprovalSystem.Misc;
public static bool USER_ISADMIN = false;
public static bool IS_INFINEON_DOMAIN = false;
public static string hostURL = "";
public static string DBConnection = "TEST";
public static string DB_CONNECTION_STRING = "";
#if !NET8
public class GlobalVars {
public static string AttachmentUrl = "";
public static string NDriveURL = "";
public static string WSR_URL = "";
public static string CA_BlankFormsLocation = "";
public static string MesaTemplateFiles = "D:\\WebSites\\FabApprovalAttachments\\Template5Why";
public int USER_ID;
#else
public static class GlobalVars {
//public static string DevWebSiteUrl = "";
//public static string ProdWebSiteUrl = "";
public static int USER_ID = 0;
#endif
public const string SESSION_USERNAME = "UserName";
public const string ApplicationName = "LotDisposition";
public const string SESSION_USERID = "UserID";
public const string ECN_VIEW_OPTION = "ECN_ViewOption";
public const string IS_ADMIN = "IsAdmin";
public const string IS_MANAGER = "IsManager";
public const string OOO = "OOO";
public const string SUCCESS = "Success";
public const string CAN_CREATE_PARTS_REQUEST = "CanCreatePartsRequest";
public const string LOT_NO = "LotNo";
public const string LOCATION = "Location";
//public static string DevAttachmentUrl = "";
//public static string ProdAttachmentUrl = "";
public static AppSettings? AppSettings = null;
public static bool USER_ISADMIN = false;
public static bool IS_INFINEON_DOMAIN = false;
public static string hostURL = "";
public static string DBConnection = "TEST";
public static string DB_CONNECTION_STRING = "";
public static string LOT_NO = "LotNo";
public static string LOCATION = "Location";
public static string SENDER_EMAIL = "MesaFabApproval@infineon.com";
//public static List<UserProfileDTO> UserProfileDTO { get; set; }
public enum LotStatusOption
{
Release = 1,
Scrap,
NotAvailable,
M_Suffix,
Select_Wafers,
CloseToQDB,
SplitOffHold
}
public enum ApprovalOption
{
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
Closed = 7,
Recalled = 8
}
public enum WorkFLowStepNumber
{
Step1 = 1,
Step2,
Step3
}
public enum DocumentType
{
LotDisposition = 1,
MRB=2,
ECN=3,
EECN = 4,
TECNCancelledExpired = 5,
LotTraveler = 6,
ChangeControl = 7,
Audit = 8,
CorrectiveAction = 9,
PartsRequest = 10,
CorrectiveActionSection = 12
}
public enum TECNExpirationCancellation
{
Cancellation = 1,
Expiration = 2
}
public enum Colors { None = 0, Red = 1, Green = 2, Blue = 4 };
public enum NotificationType
{
WorkRequest = 1,
LotTraveler = 2
}
public enum CASection
{
Main, D1, D2, D3, D4, D5,D6, D7, D8, CF
}
public static string AttachmentUrl = "";
public static string NDriveURL = "";
public static string WSR_URL = "";
public static string CA_BlankFormsLocation = "";
public static string SENDER_EMAIL = "MesaFabApproval@infineon.com";
public static string MesaTemplateFiles = "D:\\WebSites\\FabApprovalAttachments\\Template5Why";
public enum LotStatusOption {
Release = 1,
Scrap,
NotAvailable,
M_Suffix,
Select_Wafers,
CloseToQDB,
SplitOffHold
}
}
public enum ApprovalOption {
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
Closed = 7,
Recalled = 8
}
public enum WorkFLowStepNumber {
Step1 = 1,
Step2,
Step3
}
public enum DocumentType {
LotDisposition = 1,
MRB = 2,
ECN = 3,
EECN = 4,
TECNCancelledExpired = 5,
LotTraveler = 6,
ChangeControl = 7,
Audit = 8,
CorrectiveAction = 9,
PartsRequest = 10,
CorrectiveActionSection = 12
}
public enum TECNExpirationCancellation {
Cancellation = 1,
Expiration = 2
}
public enum Colors { None = 0, Red = 1, Green = 2, Blue = 4 };
public enum NotificationType {
WorkRequest = 1,
LotTraveler = 2
}
public enum CASection {
Main, D1, D2, D3, D4, D5, D6, D7, D8, CF
}
}

View File

@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Fab2ApprovalSystem.Misc;
public class LotNoTemplate {
public string LotNo { get; set; }
namespace Fab2ApprovalSystem.Misc
{
public class LotNoTemplate
{
public string LotNo { get; set; }
}
}

View File

@ -1,26 +1,22 @@
using System;
#if !NET8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Fab2ApprovalSystem.Misc {
namespace Fab2ApprovalSystem.Misc
{
public class SessionExpireFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
public class SessionExpireFilterAttribute : ActionFilterAttribute {
public override void OnActionExecuting(ActionExecutingContext filterContext) {
HttpSessionStateBase session = filterContext.HttpContext.Session;
HttpContext ctx = HttpContext.Current;
// check if session is supported
if (session[GlobalVars.SESSION_USERNAME] == null)
{
if (session[GlobalVars.SESSION_USERNAME] == null) {
// check if a new session id was generated
// this will force MVC to use the standard login redirect, enabling ReturnURL functionality
@ -30,10 +26,11 @@ namespace Fab2ApprovalSystem.Misc
return;
}
base.OnActionExecuting(filterContext);
}
}
}
}
#endif

View File

@ -1,27 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Fab2ApprovalSystem.Misc
{
//public class UserProfileDTO
//{
// public int SysUserId { get; set; }
// public string UserName { get; set; }
// public string FullName { get; set; }
//}
namespace Fab2ApprovalSystem.Misc;
public static class CollectionExtensions
{
public static IEnumerable<T> SetValue<T>(this IEnumerable<T> items, Action<T> updateMethod)
{
foreach (T item in items)
{
updateMethod(item);
}
return items;
public static class CollectionExtensions {
public static IEnumerable<T> SetValue<T>(this IEnumerable<T> items, Action<T> updateMethod) {
foreach (T item in items) {
updateMethod(item);
}
return items;
}
}

View File

@ -1,99 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
namespace Fab2ApprovalSystem.Misc;
public class Zipper {
namespace Fab2ApprovalSystem.Misc
{
/// <summary>
///
/// Compresses the files in the nominated folder, and creates a zip file on disk named as outPathname.
/// </summary>
public class Zipper
{
/// <summary>
/// Compresses the files in the nominated folder, and creates a zip file on disk named as outPathname.
/// </summary>
/// <param name="outPathname"></param>
/// <param name="folderName"></param>
public void CreateZip(string outPathname, string folderName) {
// TODO Try and Catch block
Directory.CreateDirectory(Path.GetDirectoryName(outPathname));
public void CreateZip(string outPathname, string folderName) {
// TODO Try and Catch block
Directory.CreateDirectory(Path.GetDirectoryName(outPathname));
FileStream fsOut = File.Create(outPathname);
ZipOutputStream zipStream = new ZipOutputStream(fsOut);
FileStream fsOut = File.Create(outPathname);
ZipOutputStream zipStream = new(fsOut);
zipStream.SetLevel(3); //0-9, 9 being the highest level of compression
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.Password = password; // optional. Null is the same as not setting. Required if using AES.
// This setting will strip the leading part of the folder path in the entries, to
// make the entries relative to the starting folder.
// To include the full path for each entry up to the drive root, assign folderOffset = 0.
int folderOffset = folderName.Length + (folderName.EndsWith("\\") ? 0 : 1);
// This setting will strip the leading part of the folder path in the entries, to
// make the entries relative to the starting folder.
// To include the full path for each entry up to the drive root, assign folderOffset = 0.
int folderOffset = folderName.Length + (folderName.EndsWith("\\") ? 0 : 1);
CompressFolder(folderName, zipStream, folderOffset);
zipStream.IsStreamOwner = true; // Makes the Close also Close the underlying stream
zipStream.Close();
}
/// <summary>
/// Recurses down the folder structure
/// </summary>
/// <param name="path"></param>
/// <param name="zipStream"></param>
/// <param name="folderOffset"></param>
private void CompressFolder(string path, ZipOutputStream zipStream, int folderOffset)
{
// TODO Try and Catch block
string[] files = Directory.GetFiles(path);
foreach (string filename in files)
{
FileInfo fi = new FileInfo(filename);
string entryName = filename.Substring(folderOffset); // Makes the name in zip based on the folder
entryName = ZipEntry.CleanName(entryName); // Removes drive from name and fixes slash direction
ZipEntry newEntry = new ZipEntry(entryName);
newEntry.DateTime = fi.LastWriteTime; // Note the zip format stores 2 second granularity
// Specifying the AESKeySize triggers AES encryption. Allowable values are 0 (off), 128 or 256.
// A password on the ZipOutputStream is required if using AES.
// newEntry.AESKeySize = 256;
// To permit the zip to be unpacked by built-in extractor in WinXP and Server2003, WinZip 8, Java, and other older code,
// you need to do one of the following: Specify UseZip64.Off, or set the Size.
// If the file may be bigger than 4GB, or you do not need WinXP built-in compatibility, you do not need either,
// but the zip will be in Zip64 format which not all utilities can understand.
// zipStream.UseZip64 = UseZip64.Off;
newEntry.Size = fi.Length;
zipStream.PutNextEntry(newEntry);
// Zip the file in buffered chunks
// the "using" will close the stream even if an exception occurs
byte[] buffer = new byte[4096];
using (FileStream streamReader = File.OpenRead(filename))
{
StreamUtils.Copy(streamReader, zipStream, buffer);
}
zipStream.CloseEntry();
}
string[] folders = Directory.GetDirectories(path);
foreach (string folder in folders)
{
CompressFolder(folder, zipStream, folderOffset);
}
}
CompressFolder(folderName, zipStream, folderOffset);
zipStream.IsStreamOwner = true; // Makes the Close also Close the underlying stream
zipStream.Close();
}
}
/// <summary>
/// Recurses down the folder structure
/// </summary>
private void CompressFolder(string path, ZipOutputStream zipStream, int folderOffset) {
// TODO Try and Catch block
string[] files = Directory.GetFiles(path);
foreach (string filename in files) {
FileInfo fi = new(filename);
string entryName = filename.Substring(folderOffset); // Makes the name in zip based on the folder
entryName = ZipEntry.CleanName(entryName); // Removes drive from name and fixes slash direction
ZipEntry newEntry = new(entryName);
newEntry.DateTime = fi.LastWriteTime; // Note the zip format stores 2 second granularity
// Specifying the AESKeySize triggers AES encryption. Allowable values are 0 (off), 128 or 256.
// A password on the ZipOutputStream is required if using AES.
// newEntry.AESKeySize = 256;
// To permit the zip to be unpacked by built-in extractor in WinXP and Server2003, WinZip 8, Java, and other older code,
// you need to do one of the following: Specify UseZip64.Off, or set the Size.
// If the file may be bigger than 4GB, or you do not need WinXP built-in compatibility, you do not need either,
// but the zip will be in Zip64 format which not all utilities can understand.
// zipStream.UseZip64 = UseZip64.Off;
newEntry.Size = fi.Length;
zipStream.PutNextEntry(newEntry);
// Zip the file in buffered chunks
// the "using" will close the stream even if an exception occurs
byte[] buffer = new byte[4096];
using (FileStream streamReader = File.OpenRead(filename)) {
StreamUtils.Copy(streamReader, zipStream, buffer);
}
zipStream.CloseEntry();
}
string[] folders = Directory.GetDirectories(path);
foreach (string folder in folders) {
CompressFolder(folder, zipStream, folderOffset);
}
}
}

File diff suppressed because it is too large Load Diff