MRB webassembly
This commit is contained in:
@ -6,10 +6,8 @@ using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Web;
|
||||
|
||||
namespace Fab2ApprovalSystem.Misc
|
||||
{
|
||||
public class EmailNotification
|
||||
{
|
||||
namespace Fab2ApprovalSystem.Misc {
|
||||
public class EmailNotification {
|
||||
#region Variabls
|
||||
protected string _subject = null;
|
||||
protected string _TemplatesPath = null;
|
||||
@ -18,10 +16,8 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <summary>
|
||||
/// Email subject
|
||||
/// </summary>
|
||||
public string EmailSubject
|
||||
{
|
||||
public string EmailSubject {
|
||||
set { _subject = value; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -29,11 +25,9 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// </summary>
|
||||
/// <param name="FileName">File Name</param>
|
||||
/// <returns>String: Containing the Entire content of the file</returns>
|
||||
protected string ReadEmailFile(string FileName)
|
||||
{
|
||||
protected string ReadEmailFile(string FileName) {
|
||||
string retVal = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
//setting the file name path
|
||||
string path = _TemplatesPath + FileName;
|
||||
FileInfo TheFile = new FileInfo(System.Web.HttpContext.Current.Server.MapPath(path));
|
||||
@ -46,17 +40,12 @@ namespace Fab2ApprovalSystem.Misc
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
throw new Exception("Error Reading File." + ex.Message);
|
||||
|
||||
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// this function will send email. it will read the mail setting from the web.config
|
||||
/// </summary>
|
||||
@ -66,8 +55,8 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="cc">CC ids</param>
|
||||
/// <param name="email_title">Email Subject</param>
|
||||
/// <param name="email_body">Email Body</param>
|
||||
protected void SendEmail(string SenderEmail, string SenderName, string Recep, string cc, string email_title, string email_body)
|
||||
{
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
protected void SendEmail(string SenderEmail, string SenderName, string Recep, string cc, string email_title, string email_body) {
|
||||
// creating email message
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.IsBodyHtml = true;// email body will allow html elements
|
||||
@ -87,27 +76,18 @@ namespace Fab2ApprovalSystem.Misc
|
||||
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
|
||||
SmtpClient SmtpMail = new SmtpClient("mailrelay-internal.infineon.com");
|
||||
//create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
|
||||
SmtpClient SmtpMail = new SmtpClient("mailrelay-internal.infineon.com");
|
||||
|
||||
// sending the message.
|
||||
try
|
||||
{
|
||||
try {
|
||||
SmtpMail.Send(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine("Exception caught in CreateTestMessage2(): {0}",
|
||||
ex.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -119,8 +99,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="email_title"></param>
|
||||
/// <param name="email_body"></param>
|
||||
/// <param name="attachmentPath"></param>
|
||||
protected void SendEmailWithAttachment(string SenderEmail, string SenderName, string Recep, string cc, string email_title, string email_body, string attachmentPath)
|
||||
{
|
||||
protected void SendEmailWithAttachment(string SenderEmail, string SenderName, string Recep, string cc, string email_title, string email_body, string attachmentPath) {
|
||||
// creating email message
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.IsBodyHtml = true;// email body will allow html elements
|
||||
@ -140,22 +119,14 @@ namespace Fab2ApprovalSystem.Misc
|
||||
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
|
||||
SmtpClient SmtpMail = new SmtpClient();
|
||||
#if(!DEBUG)
|
||||
// sending the message.
|
||||
SmtpMail.Send(msg);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -165,8 +136,8 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="cc"></param>
|
||||
/// <param name="email_title"></param>
|
||||
/// <param name="email_body"></param>
|
||||
protected void SendEmail(string SenderEmail, string SenderName, List<string> RecepientList, string cc, string email_title, string email_body)
|
||||
{
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
protected void SendEmail(string SenderEmail, string SenderName, List<string> RecepientList, string cc, string email_title, string email_body) {
|
||||
// creating email message
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.IsBodyHtml = true;// email body will allow html elements
|
||||
@ -175,8 +146,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
//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)
|
||||
{
|
||||
foreach (string recepient in RecepientList) {
|
||||
msg.To.Add(recepient);
|
||||
}
|
||||
|
||||
@ -188,26 +158,18 @@ namespace Fab2ApprovalSystem.Misc
|
||||
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
|
||||
SmtpClient SmtpMail = new SmtpClient();
|
||||
//create a Smtp Mail which will automatically get the smtp server details from web.config mailSettings section
|
||||
SmtpClient SmtpMail = new SmtpClient();
|
||||
|
||||
// sending the message.
|
||||
try
|
||||
{
|
||||
try {
|
||||
SmtpMail.Send(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine("Exception caught in CreateTestMessage2(): {0}",
|
||||
ex.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -219,8 +181,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="email_title"></param>
|
||||
/// <param name="email_body"></param>
|
||||
/// <param name="attachmentPath"></param>
|
||||
protected void SendEmailWithAttachment(string SenderEmail, string SenderName, List<string> RecepientList, string cc, string email_title, string email_body, string attachmentPath)
|
||||
{
|
||||
protected void SendEmailWithAttachment(string SenderEmail, string SenderName, List<string> RecepientList, string cc, string email_title, string email_body, string attachmentPath) {
|
||||
// creating email message
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.IsBodyHtml = true;// email body will allow html elements
|
||||
@ -229,8 +190,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
msg.From = new MailAddress(SenderEmail, SenderName);
|
||||
|
||||
// adding the Recepient Email ID
|
||||
foreach (string recepient in RecepientList)
|
||||
{
|
||||
foreach (string recepient in RecepientList) {
|
||||
if (recepient != null)
|
||||
msg.To.Add(recepient);
|
||||
}
|
||||
@ -244,19 +204,13 @@ namespace Fab2ApprovalSystem.Misc
|
||||
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
|
||||
SmtpClient SmtpMail = new SmtpClient();
|
||||
|
||||
// sending the message.
|
||||
SmtpMail.Send(msg);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -267,8 +221,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="email_title"></param>
|
||||
/// <param name="email_body"></param>
|
||||
/// <param name="attachments"></param>
|
||||
protected void SendEmailWithAttachments(string SenderEmail, string SenderName, string Recep, string cc, string email_title, string email_body, List<string> attachments)
|
||||
{
|
||||
protected void SendEmailWithAttachments(string SenderEmail, string SenderName, string Recep, string cc, string email_title, string email_body, List<string> attachments) {
|
||||
// creating email message
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.IsBodyHtml = true;// email body will allow html elements
|
||||
@ -286,35 +239,29 @@ namespace Fab2ApprovalSystem.Misc
|
||||
//setting email subject and body
|
||||
msg.Subject = email_title;
|
||||
msg.Body = email_body;
|
||||
foreach (string attachment in attachments)
|
||||
{
|
||||
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
|
||||
SmtpClient SmtpMail = new SmtpClient();
|
||||
#if(!DEBUG)
|
||||
// sending the message.
|
||||
SmtpMail.Send(msg);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="SenderEmail"></param>
|
||||
/// <param name="SenderName"></param>
|
||||
/// <param name="RecepientList"></param>
|
||||
/// <param name="cc"></param>
|
||||
/// <param name="email_title"></param>
|
||||
/// <param name="email_body"></param>
|
||||
/// <param name="attachments"></param>
|
||||
protected void SendEmailWithAttachments(string SenderEmail, string SenderName, List<string> RecepientList, string cc, string email_title, string email_body, List<string> attachments)
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="SenderEmail"></param>
|
||||
/// <param name="SenderName"></param>
|
||||
/// <param name="RecepientList"></param>
|
||||
/// <param name="cc"></param>
|
||||
/// <param name="email_title"></param>
|
||||
/// <param name="email_body"></param>
|
||||
/// <param name="attachments"></param>
|
||||
protected void SendEmailWithAttachments(string SenderEmail, string SenderName, List<string> RecepientList, string cc, string email_title, string email_body, List<string> attachments) {
|
||||
// creating email message
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.IsBodyHtml = true;// email body will allow html elements
|
||||
@ -323,8 +270,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
msg.From = new MailAddress(SenderEmail, SenderName);
|
||||
|
||||
// adding the Recepient Email ID
|
||||
foreach (string recepient in RecepientList)
|
||||
{
|
||||
foreach (string recepient in RecepientList) {
|
||||
if (recepient != null)
|
||||
msg.To.Add(recepient);
|
||||
}
|
||||
@ -337,44 +283,32 @@ namespace Fab2ApprovalSystem.Misc
|
||||
msg.Subject = email_title;
|
||||
msg.Body = email_body;
|
||||
|
||||
foreach (string attachment in attachments)
|
||||
{
|
||||
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
|
||||
SmtpClient SmtpMail = new SmtpClient();
|
||||
|
||||
// sending the message.
|
||||
SmtpMail.Send(msg);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EmailNotification()
|
||||
{
|
||||
public EmailNotification() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The Constructor Function
|
||||
/// </summary>
|
||||
/// <param name="EmailHeaderSubject">Email Header Subject</param>
|
||||
/// <param name="TemplatesPath">Emails Files Templates</param>
|
||||
public EmailNotification(string EmailHeaderSubject, string TemplatesPath)
|
||||
{
|
||||
public EmailNotification(string EmailHeaderSubject, string TemplatesPath) {
|
||||
_subject = EmailHeaderSubject;
|
||||
_TemplatesPath = TemplatesPath;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This function will send the email notification by reading the email template and substitute the arguments
|
||||
/// </summary>
|
||||
@ -386,43 +320,33 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="Subject">EMail Subject</param>
|
||||
/// <param name="Args">Arguments</param>
|
||||
/// <returns>String: Return the body of the email to be send</returns>
|
||||
public string SendNotificationEmail(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, params string[] Args)
|
||||
{
|
||||
public string SendNotificationEmail(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, params string[] Args) {
|
||||
string retVal = null;
|
||||
|
||||
//reading the file
|
||||
string FileContents = ReadEmailFile(EmailTemplateFile);
|
||||
|
||||
|
||||
string emailBody = FileContents;
|
||||
|
||||
//setting formatting the string
|
||||
retVal = string.Format(emailBody, Args);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//check if we are in debug mode or not. to send email
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY")
|
||||
{
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
|
||||
SendEmail(SenderEmail, SenderName, GetTestRecipientsList(), CC, (!string.IsNullOrEmpty(Subject) ? Subject + " for: " + RecepientEmail : _subject), retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if(!DEBUG)
|
||||
SendEmail(SenderEmail, SenderName, RecepientEmail, CC, (!string.IsNullOrEmpty(Subject) ? Subject : _subject), retVal);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This function will send the email notification by reading the email template and substitute the arguments along with the attachments
|
||||
/// </summary>
|
||||
@ -435,8 +359,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="attachmentPath"></param>
|
||||
/// <param name="Args"></param>
|
||||
/// <returns></returns>
|
||||
public string SendNotificationEmailWithAttachment(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, string attachmentPath, params string[] Args)
|
||||
{
|
||||
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
|
||||
@ -447,32 +370,22 @@ namespace Fab2ApprovalSystem.Misc
|
||||
//setting formatting the string
|
||||
retVal = string.Format(emailBody, Args);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//check if we are in debug mode or not. to send email
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY")
|
||||
{
|
||||
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
|
||||
{
|
||||
} else {
|
||||
#if(!DEBUG)
|
||||
SendEmailWithAttachment(SenderEmail, SenderName, RecepientEmail, CC, (!string.IsNullOrEmpty(Subject) ? Subject : _subject), retVal, attachmentPath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -485,8 +398,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="attachmentPath"></param>
|
||||
/// <param name="Args"></param>
|
||||
/// <returns></returns>
|
||||
public string SendNotificationEmailWithAttachment(string EmailTemplateFile, string SenderEmail, string SenderName, List<string> RecepientEmail, string CC, string Subject, string attachmentPath, params string[] Args)
|
||||
{
|
||||
public string SendNotificationEmailWithAttachment(string EmailTemplateFile, string SenderEmail, string SenderName, List<string> RecepientEmail, string CC, string Subject, string attachmentPath, params string[] Args) {
|
||||
string retVal = null;
|
||||
|
||||
//reading the file
|
||||
@ -497,41 +409,28 @@ namespace Fab2ApprovalSystem.Misc
|
||||
//setting formatting the string
|
||||
retVal = string.Format(emailBody, Args);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//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)
|
||||
{
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
|
||||
foreach (string email in RecepientEmail) {
|
||||
Subject += email + ";";
|
||||
}
|
||||
|
||||
RecepientEmail.Clear();
|
||||
SendEmailWithAttachment(SenderEmail, SenderName, GetTestRecipientsList(), CC, (!string.IsNullOrEmpty(Subject) ? " TESTING ONLY -IGNORE : " + Subject : _subject), retVal, attachmentPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if (!DEBUG)
|
||||
SendEmailWithAttachment(SenderEmail, SenderName, RecepientEmail, CC, (!string.IsNullOrEmpty(Subject) ? Subject : _subject), retVal, attachmentPath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////============================================================
|
||||
|
||||
public string SendNotificationEmailWithAttachments(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, List<string> attachments, params string[] Args)
|
||||
{
|
||||
public string SendNotificationEmailWithAttachments(string EmailTemplateFile, string SenderEmail, string SenderName, string RecepientEmail, string CC, string Subject, List<string> attachments, params string[] Args) {
|
||||
string retVal = null;
|
||||
|
||||
//reading the file
|
||||
@ -542,32 +441,22 @@ namespace Fab2ApprovalSystem.Misc
|
||||
//setting formatting the string
|
||||
retVal = string.Format(emailBody, Args);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//check if we are in debug mode or not. to send email
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY")
|
||||
{
|
||||
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
|
||||
{
|
||||
} else {
|
||||
#if(!DEBUG)
|
||||
SendEmailWithAttachments(SenderEmail, SenderName, RecepientEmail, CC, (!string.IsNullOrEmpty(Subject) ? Subject : _subject), retVal, attachments);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -580,8 +469,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="attachmentPath"></param>
|
||||
/// <param name="Args"></param>
|
||||
/// <returns></returns>
|
||||
public string SendNotificationEmailWithAttachments(string EmailTemplateFile, string SenderEmail, string SenderName, List<string> RecepientEmail, string CC, string Subject, List<string> attachments, params string[] Args)
|
||||
{
|
||||
public string SendNotificationEmailWithAttachments(string EmailTemplateFile, string SenderEmail, string SenderName, List<string> RecepientEmail, string CC, string Subject, List<string> attachments, params string[] Args) {
|
||||
string retVal = null;
|
||||
|
||||
//reading the file
|
||||
@ -592,39 +480,27 @@ namespace Fab2ApprovalSystem.Misc
|
||||
//setting formatting the string
|
||||
retVal = string.Format(emailBody, Args);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//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)
|
||||
{
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
|
||||
foreach (string email in RecepientEmail) {
|
||||
Subject += email + ";";
|
||||
}
|
||||
|
||||
RecepientEmail.Clear();
|
||||
SendEmailWithAttachments(SenderEmail, SenderName, GetTestRecipientsList(), CC, (!string.IsNullOrEmpty(Subject) ? " TESTING ONLY -IGNORE : " + Subject : _subject), retVal, attachments);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if (!DEBUG)
|
||||
SendEmailWithAttachments(SenderEmail, SenderName, RecepientEmail, CC, (!string.IsNullOrEmpty(Subject) ? Subject : _subject), retVal, attachments);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -636,8 +512,7 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="Subject"></param>
|
||||
/// <param name="Args"></param>
|
||||
/// <returns></returns>
|
||||
public string SendNotificationEmail(string EmailTemplateFile, string SenderEmail, string SenderName, List<string> RecepientEmail, string CC, string Subject, params string[] Args)
|
||||
{
|
||||
public string SendNotificationEmail(string EmailTemplateFile, string SenderEmail, string SenderName, List<string> RecepientEmail, string CC, string Subject, params string[] Args) {
|
||||
string retVal = null;
|
||||
|
||||
//reading the file
|
||||
@ -648,33 +523,24 @@ namespace Fab2ApprovalSystem.Misc
|
||||
//setting formatting the string
|
||||
retVal = string.Format(emailBody, Args);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//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)
|
||||
{
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
|
||||
foreach (string email in RecepientEmail) {
|
||||
Subject += email + ";";
|
||||
}
|
||||
RecepientEmail.Clear();
|
||||
SendEmail(SenderEmail, SenderName, GetTestRecipientsList(), CC, (!string.IsNullOrEmpty(Subject) ? Subject : _subject), retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if (!DEBUG)
|
||||
SendEmail(SenderEmail, SenderName, RecepientEmail, CC, (!string.IsNullOrEmpty(Subject) ? Subject : _subject), retVal);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -683,10 +549,8 @@ namespace Fab2ApprovalSystem.Misc
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="body"></param>
|
||||
/// <param name="importance"></param>
|
||||
public void SendNotificationEmailToAdmin(string subject, string body, MailPriority importance)
|
||||
{
|
||||
try
|
||||
{
|
||||
public void SendNotificationEmailToAdmin(string subject, string body, MailPriority importance) {
|
||||
try {
|
||||
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
|
||||
|
||||
SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings["SMTP Server"]);
|
||||
@ -704,30 +568,23 @@ namespace Fab2ApprovalSystem.Misc
|
||||
msg.Subject = subject;
|
||||
msg.Body = temp;
|
||||
msg.Priority = importance;
|
||||
//#if(!DEBUG)
|
||||
//#if(!DEBUG)
|
||||
client.Send(msg);
|
||||
//#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//#endif
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> GetTestRecipientsList()
|
||||
{
|
||||
var r = new List<string>();
|
||||
try
|
||||
{
|
||||
public List<string> GetTestRecipientsList() {
|
||||
List<string> r = new List<string>();
|
||||
try {
|
||||
string emails = ConfigurationManager.AppSettings["Test Email Recipients"];
|
||||
foreach (string s in emails.Split(';', ','))
|
||||
{
|
||||
foreach (string s in emails.Split(';', ',')) {
|
||||
if (!String.IsNullOrWhiteSpace(s))
|
||||
r.Add(s);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
} catch {
|
||||
r.Add("dhuang2@infineon.com");
|
||||
}
|
||||
return r;
|
||||
|
@ -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