MRB webassembly
This commit is contained in:
@ -10,57 +10,44 @@ using System.Net.Mail;
|
||||
using System.DirectoryServices;
|
||||
using System.DirectoryServices.AccountManagement;
|
||||
|
||||
namespace Fab2ApprovalSystem.Misc
|
||||
{
|
||||
public static class Functions
|
||||
{
|
||||
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)
|
||||
{
|
||||
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";
|
||||
|
||||
try
|
||||
{
|
||||
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()"))
|
||||
{
|
||||
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
|
||||
{
|
||||
} catch {
|
||||
//throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
} finally {
|
||||
ev = null;
|
||||
}
|
||||
//#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the FTP Server Name
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string FTPServer()
|
||||
{
|
||||
public static string FTPServer() {
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
return ConfigurationManager.AppSettings["FTP Server"];
|
||||
}
|
||||
@ -69,8 +56,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// Returns the FTP User Name
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string FTPUser()
|
||||
{
|
||||
public static string FTPUser() {
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
return ConfigurationManager.AppSettings["FTP User"];
|
||||
}
|
||||
@ -79,8 +65,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// Returns the FTP Password
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string FTPPassword()
|
||||
{
|
||||
public static string FTPPassword() {
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
return ConfigurationManager.AppSettings["FTP Password"];
|
||||
}
|
||||
@ -89,41 +74,32 @@ namespace Fab2ApprovalSystem.Misc
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetAttachmentFolder()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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() ;
|
||||
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()))
|
||||
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>
|
||||
@ -132,13 +108,11 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public static bool NA_ADAuthenticate(string userID, string pwd)
|
||||
{
|
||||
public static bool NA_ADAuthenticate(string userID, string pwd) {
|
||||
|
||||
string naContainer = ConfigurationManager.AppSettings["NAContainer"];
|
||||
string naDomain = ConfigurationManager.AppSettings["NADomain"];
|
||||
try
|
||||
{
|
||||
try {
|
||||
PrincipalContext contextUser = new PrincipalContext(ContextType.Domain,
|
||||
naDomain,
|
||||
naContainer,
|
||||
@ -149,12 +123,9 @@ namespace Fab2ApprovalSystem.Misc
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -163,13 +134,11 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IFX_ADAuthenticate(string userID, string pwd)
|
||||
{
|
||||
public static bool IFX_ADAuthenticate(string userID, string pwd) {
|
||||
|
||||
string container = ConfigurationManager.AppSettings["IFXContainer"];
|
||||
string domain = ConfigurationManager.AppSettings["IFXDomain"];
|
||||
try
|
||||
{
|
||||
try {
|
||||
PrincipalContext contextUser = new PrincipalContext(ContextType.Domain,
|
||||
domain,
|
||||
container,
|
||||
@ -180,18 +149,12 @@ namespace Fab2ApprovalSystem.Misc
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string FTPSPNBatch()
|
||||
{
|
||||
public static string FTPSPNBatch() {
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
return ConfigurationManager.AppSettings["FTPSPNBatchFileName"];
|
||||
}
|
||||
@ -200,8 +163,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string FTPSPNBatch_Test()
|
||||
{
|
||||
public static string FTPSPNBatch_Test() {
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
return ConfigurationManager.AppSettings["FTPSPNBatchFileName_Test"];
|
||||
}
|
||||
@ -211,50 +173,44 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// </summary>
|
||||
/// <param name="casection"></param>
|
||||
/// <returns></returns>
|
||||
public static string CASectionMapper(GlobalVars.CASection casection)
|
||||
{
|
||||
switch (casection)
|
||||
{
|
||||
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:
|
||||
public static string DocumentTypeMapper(GlobalVars.DocumentType docType) {
|
||||
switch (docType) {
|
||||
case GlobalVars.DocumentType.Audit:
|
||||
return "Audit";
|
||||
case GlobalVars.DocumentType.ChangeControl:
|
||||
return "ChangeControl";
|
||||
@ -280,17 +236,15 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReturnCANoStringFormat(int caNo)
|
||||
{
|
||||
public static string ReturnCANoStringFormat(int caNo) {
|
||||
string caNoString = "";
|
||||
if(caNo == 0)
|
||||
if (caNo == 0)
|
||||
return "";
|
||||
caNoString = "C" + caNo.ToString().PadLeft(5, '0');
|
||||
return caNoString;
|
||||
}
|
||||
|
||||
public static string ReturnAuditNoStringFormat(int auditNo)
|
||||
{
|
||||
public static string ReturnAuditNoStringFormat(int auditNo) {
|
||||
string auditNoString = "";
|
||||
if (auditNo == 0)
|
||||
return "";
|
||||
@ -298,12 +252,10 @@ namespace Fab2ApprovalSystem.Misc
|
||||
return auditNoString;
|
||||
}
|
||||
|
||||
public static string ReturnPartsRequestNoStringFormat(int PRNumber)
|
||||
{
|
||||
public static string ReturnPartsRequestNoStringFormat(int PRNumber) {
|
||||
if (PRNumber == 0)
|
||||
return "";
|
||||
return String.Format("PR{0:000000}", PRNumber);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user