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:
@ -1,45 +1,34 @@
|
||||
#pragma warning disable CS8019
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Fab2ApprovalSystem.Utilities
|
||||
{
|
||||
public class EmailUtilities
|
||||
{
|
||||
// GET: EmailUtilities
|
||||
public void SendNotification(string Recep, List<string> ccRecipients, string emailTitle, string email_body, string email_title)
|
||||
{
|
||||
SmtpClient client = new SmtpClient();
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.IsBodyHtml = true;
|
||||
msg.From = new MailAddress("MesaFabApproval@infineon.com", "Mesa Fab Approval");
|
||||
msg.Sender = new MailAddress("MesaFabApproval@infineon.com", "Mesa Fab Approval");
|
||||
msg.To.Add(Recep);
|
||||
//msg.To.Add("Jonathan.Ouellette@infineon.com");
|
||||
foreach (string ccRecipient in ccRecipients)
|
||||
{
|
||||
try
|
||||
{
|
||||
msg.CC.Add(ccRecipient);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Invalid Email Address detected: " + ccRecipient);
|
||||
}
|
||||
#pragma warning restore CS8019
|
||||
|
||||
}
|
||||
//msg.CC.Add(recipientCC);
|
||||
msg.Subject = email_title;
|
||||
msg.Body = email_body;
|
||||
namespace Fab2ApprovalSystem.Utilities;
|
||||
|
||||
SmtpClient SmtpMail = new SmtpClient("mailrelay-internal.infineon.com");
|
||||
public class EmailUtilities {
|
||||
|
||||
SmtpMail.Send(msg);
|
||||
|
||||
|
||||
public static void SendNotification(string to, List<string> ccRecipients, string subject, string body) {
|
||||
MailMessage msg = new();
|
||||
msg.To.Add(to);
|
||||
msg.IsBodyHtml = true;
|
||||
msg.From = new MailAddress("MesaFabApproval@infineon.com", "Mesa Fab Approval");
|
||||
msg.Sender = new MailAddress("MesaFabApproval@infineon.com", "Mesa Fab Approval");
|
||||
foreach (string ccRecipient in ccRecipients) {
|
||||
try {
|
||||
msg.CC.Add(ccRecipient);
|
||||
} catch {
|
||||
Console.WriteLine("Invalid Email Address detected: " + ccRecipient);
|
||||
}
|
||||
}
|
||||
msg.Body = body;
|
||||
msg.Subject = subject;
|
||||
SmtpClient smtpClient = new("mailrelay-internal.infineon.com");
|
||||
smtpClient.Send(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +1,50 @@
|
||||
#pragma warning disable CS8019
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
#if !NET8
|
||||
using System.Web.Mvc;
|
||||
#endif
|
||||
|
||||
using Fab2ApprovalSystem.DMO;
|
||||
using Fab2ApprovalSystem.Misc;
|
||||
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Fab2ApprovalSystem.Utilities
|
||||
#pragma warning restore CS8019
|
||||
|
||||
namespace Fab2ApprovalSystem.Utilities;
|
||||
|
||||
#if !NET8
|
||||
public class FileUtilities<T> : Controller // <T> => System.Web.Mvc.FileContentResult
|
||||
{
|
||||
public class FileUtilities : Controller
|
||||
{
|
||||
public ActionResult DownloadFilesFromServer(string pathToFile)
|
||||
{
|
||||
//string templatesPath = GlobalVars.CA_BlankFormsLocation;
|
||||
//string fullName = Server.MapPath("~" + filePath);
|
||||
|
||||
byte[] fileBytes = GetFile(pathToFile);
|
||||
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, pathToFile);
|
||||
}
|
||||
public T DownloadFilesFromServer<T>(string pathToFile) {
|
||||
//string templatesPath = GlobalVars.CA_BlankFormsLocation;
|
||||
//string fullName = Server.MapPath("~" + filePath);
|
||||
|
||||
public byte[] GetFile(string s)
|
||||
{
|
||||
System.IO.FileStream fs = System.IO.File.OpenRead(s);
|
||||
byte[] data = new byte[fs.Length];
|
||||
int br = fs.Read(data, 0, data.Length);
|
||||
if (br != fs.Length)
|
||||
throw new System.IO.IOException(s);
|
||||
return data;
|
||||
}
|
||||
byte[] fileBytes = GetFile(pathToFile);
|
||||
var result = File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, pathToFile);
|
||||
return (T)Convert.ChangeType(result, typeof(T));
|
||||
}
|
||||
}
|
||||
#else
|
||||
public class FileUtilities<T> {
|
||||
#endif
|
||||
|
||||
public byte[] GetFile(string s) {
|
||||
#if !NET8
|
||||
FileStream fs = System.IO.File.OpenRead(s);
|
||||
#else
|
||||
FileStream fs = File.OpenRead(s);
|
||||
#endif
|
||||
byte[] data = new byte[fs.Length];
|
||||
int br = fs.Read(data, 0, data.Length);
|
||||
if (br != fs.Length)
|
||||
throw new IOException(s);
|
||||
return data;
|
||||
}
|
||||
}
|
@ -1,48 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.DirectoryServices.AccountManagement;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
using Fab2ApprovalSystem.Models;
|
||||
|
||||
namespace Fab2ApprovalSystem.Utilities
|
||||
{
|
||||
public class UserUtilities
|
||||
{
|
||||
public List<AllUserModel> GetMesaUsers()
|
||||
{
|
||||
PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
|
||||
"infineon.com",
|
||||
"DC=infineon,DC=com",
|
||||
"MESfisharepoint",
|
||||
"GaN2020=BestWafers!");
|
||||
namespace Fab2ApprovalSystem.Utilities;
|
||||
|
||||
GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx,
|
||||
IdentityType.Name,
|
||||
"MES-IFX-Employees-Mesa");
|
||||
List<AllUserModel> MesaUsers = new List<AllUserModel>();
|
||||
if (grp != null)
|
||||
{
|
||||
foreach (Principal p in grp.GetMembers(true))
|
||||
{
|
||||
MesaUsers.Add(new AllUserModel
|
||||
{
|
||||
UserName = p.Name,
|
||||
DisplayName = p.DisplayName
|
||||
|
||||
}
|
||||
|
||||
);
|
||||
//Console.WriteLine(p.Name);
|
||||
}
|
||||
grp.Dispose();
|
||||
public class UserUtilities {
|
||||
|
||||
public static List<AllUserModel> GetMesaUsers() {
|
||||
PrincipalContext ctx = new(ContextType.Domain,
|
||||
"infineon.com",
|
||||
"DC=infineon,DC=com",
|
||||
"MESfisharepoint",
|
||||
"GaN2020=BestWafers!");
|
||||
|
||||
GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx,
|
||||
IdentityType.Name,
|
||||
"MES-IFX-Employees-Mesa");
|
||||
List<AllUserModel> MesaUsers = new();
|
||||
if (grp != null) {
|
||||
foreach (Principal p in grp.GetMembers(true)) {
|
||||
MesaUsers.Add(new AllUserModel {
|
||||
UserName = p.Name,
|
||||
DisplayName = p.DisplayName
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
ctx.Dispose();
|
||||
MesaUsers = (from a in MesaUsers orderby a.DisplayName ascending select a).ToList();
|
||||
|
||||
return MesaUsers;
|
||||
grp.Dispose();
|
||||
}
|
||||
|
||||
ctx.Dispose();
|
||||
MesaUsers = (from a in MesaUsers orderby a.DisplayName ascending select a).ToList();
|
||||
|
||||
return MesaUsers;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user