Moved System.IO references from DMO classes to Static Helpers

Removed nugetSource from pipeline
Removed more comments
Created Static Classes for most DMO / Controller Classes
Push ConfigurationManager.AppSettings to controller
Align Tests with other Projects
This commit is contained in:
2024-12-11 09:29:01 -07:00
parent b1c6903c1c
commit b99b721458
86 changed files with 2961 additions and 4432 deletions

View File

@ -71,8 +71,6 @@ public class AdminDMO {
if (!lookup.TryGetValue(parent.RoleID, out role)) {
lookup.Add(parent.RoleID, role = parent);
}
//if (role.RoleID == null)
// role.SubRoles = new List<SubRole>();
role.SubRoles.Add(child);
return role;
},
@ -80,7 +78,7 @@ public class AdminDMO {
return data;
}
///
public List<UserSubRoles> GetUserSubRoles(int userId) {
DynamicParameters parameters = new();
parameters.Add("@UserId", userId);
@ -130,14 +128,17 @@ public class AdminDMO {
}
}
#if !NET8
public List<TrainingReportUser> GetTrainingReportUsers() {
List<TrainingReportUser> CurrentReportUsers = (from a in FabApprovalDB.TrainingReportUsers select a).ToList();
return CurrentReportUsers;
}
#else
public List<TrainingReportUser> GetTrainingReportUsers() => throw new NotImplementedException();
public List<TrainingReportUser> GetTrainingReportUsers() =>
throw new NotImplementedException();
#endif
#if !NET8
public List<TECNNotificationsUser> GetTECNNotificationUsers() {
List<TECNNotificationsUser> currentTECNNotificationUsers = (from a in FabApprovalDB.TECNNotificationsUsers select a).ToList();
@ -164,8 +165,6 @@ public class AdminDMO {
public void TrainingReportDeleteUser(int userId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@UserID", userId);
db.Execute("DeleteUserFromTrainingReport", parameters, commandType: CommandType.StoredProcedure);
@ -174,25 +173,14 @@ public class AdminDMO {
public void TECNExpirationDeleteUser(int userId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@UserID", userId);
db.Execute("DeleteUserFromTECNReport", parameters, commandType: CommandType.StoredProcedure);
return;
}
#if !NET8
public List<TrainingGroup> GetTrainingGroups() {
//StringBuilder sql = new StringBuilder();
//sql.Append(
// "SELECT 'TrainingGroupID', TrainingGroupName " +
// "FROM TrainingGroups " +
// "ORDER BY TrainingGroupID ");
//db.Open();
//var lookup = new Dictionary<int, TrainingGroup>();
////List<TrainingGroup> data = this.db.Query<TrainingGroup>(sql.ToString()
//return this.db.Query<TrainingGroup>(sql.ToString()).ToList();
var TrainingGroups = from a in FabApprovalDB.TrainingGroups select a;
List<TrainingGroup> GroupsToReturn = TrainingGroups.ToList();
@ -201,16 +189,14 @@ public class AdminDMO {
public void AddNewTrainingGroup(string groupName) {
TrainingGroup existing = null;
//Check to see that the group name doesn't exist.
// Check to see that the group name doesn't exist.
try {
existing = (from a in FabApprovalDB.TrainingGroups where a.TrainingGroupName == groupName select a).FirstOrDefault();
} catch {
// string test = "";
}
if (existing == null) {
//string sql = new StringBuilder();
string sql = "INSERT INTO TrainingGroups (TrainingGroupName) " + "VALUES ('" + groupName + "') ";
this.db.Open();
@ -234,6 +220,7 @@ public class AdminDMO {
} catch {
}
}
#if !NET8
public List<TrainingGroupMember> GetTrainingGroupMembers(int GroupID) {
return (from a in FabApprovalDB.TrainingGroupMembers where a.TrainingGroupID == GroupID select a).ToList();
@ -259,34 +246,10 @@ public class AdminDMO {
throw new Exception("The user already exists in this training group.");
}
//if (existing == null)
//{
// //string sql = new StringBuilder();
// string sql = "INSERT INTO TrainingGroupMembers (TrainingGroupID, UserID, FullName) " + "VALUES ('" + groupId + "','" + userId + "','" + userFullName + "') ";
// try
// {
// this.db.Open();
// this.db.Execute(sql);
// }
// catch(Exception e)
// {
// return;
// }
// return;
//}
//else
//{
// return;
}
#endif
public void DeleteFromGroup(int userId, int groupId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@GroupID", groupId);
parameters.Add("@UserID", userId);
@ -298,35 +261,35 @@ public class AdminDMO {
public void DeleteUser(UserAccountDMO userDMO, TrainingDMO trainingDMO, LoginModel loginModel) {
if (loginModel != null) {
userDMO.DeleteUser(loginModel);
//Remove open trainings
//Get a list of all user assigned trainings.
// Remove open trainings
// Get a list of all user assigned trainings.
List<TrainingAssignment> trainingAssignments = trainingDMO.GetTrainingAssignmentsByUserID(loginModel.UserID);
//Go Through that list.
// Go Through that list.
foreach (var trainingAssignment in trainingAssignments) {
//Delete Any document acknowledgements.
// Delete Any document acknowledgements.
trainingDMO.DeleteTrainingDocAck(trainingAssignment.ID);
//Delete the training assignment itself
// Delete the training assignment itself
trainingDMO.DeleteTrainingAssignment(trainingAssignment.ID);
//Check the parent Training task to set to to complete if applicable.
// Check the parent Training task to set to to complete if applicable.
if (trainingDMO.CheckTrainingStatus(trainingAssignment.ID)) {
int TrainingID = trainingAssignment.TrainingID;
//Set Training status to complete
// Set Training status to complete
trainingDMO.UpdateTrainingStatus(TrainingID);
}
}
//Remove user from any Training Groups
// Remove user from any Training Groups
DeleteUserFromAllTrainingGroups(loginModel.UserID);
//Remove User from training report notifications
// Remove User from training report notifications
TrainingReportDeleteUser(loginModel.UserID);
//Remove user from TECN Expiration Notifications
// Remove user from TECN Expiration Notifications
TECNExpirationDeleteUser(loginModel.UserID);
//Get user subroles
// Get user subroles
List<UserSubRoles> userSubRoles = GetUserSubRoles(loginModel.UserID);
//Delete user from any subroles
// Delete user from any subroles
foreach (var userSubRole in userSubRoles) {
DeleteUserRoles(userSubRole.SubRoleID, loginModel.UserID.ToString());
}

View File

@ -17,8 +17,6 @@ using System.Transactions;
using Fab2ApprovalSystem.Misc;
using Fab2ApprovalSystem.Utilities;
using System.IO;
namespace Fab2ApprovalSystem.DMO;
public class AuditDMO {
@ -31,8 +29,6 @@ public class AuditDMO {
public Audit InsertAudit(Audit audit) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@AuditNo", value: audit.AuditNo, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@OriginatorID", audit.OriginatorID);
@ -45,14 +41,11 @@ public class AuditDMO {
public Audit GetAuditItem(int auditNo, int userID) {
Audit audit = new();
//isITAR = 2;
// isITAR = 2;
DynamicParameters parameters = new();
parameters.Add("@AuditNo", value: auditNo);
parameters.Add("@UserID", userID);
//parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//audit = this.db.Query<Audit>("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure)) {
audit = multipleResultItems.Read<Audit>().SingleOrDefault();
@ -76,29 +69,15 @@ public class AuditDMO {
audit.AuditedAreaIDs.AddRange(auditorAreas);
}
}
//FabApprovalSystemEntitiesAll auditDb = new FabApprovalSystemEntitiesAll();
//var auditedStandardIDs = (from a in auditDb.C_8DAuditedStandardByAudit where a.AuditNo == audit.AuditNo select a.AuditedStandardID).ToList();
//foreach (var id in auditedStandardIDs)
//{
// audit.AuditedStandardIDs.Add(id);
//}
return audit;
}
public Audit GetAuditItemReadOnly(int auditNo, int userID) {
Audit audit = new();
//isITAR = 2;
DynamicParameters parameters = new();
parameters.Add("@AuditNo", value: auditNo);
parameters.Add("@UserID", userID);
//parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//audit = this.db.Query<Audit>("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("_8DGetAuditItemReadOnly", parameters, commandType: CommandType.StoredProcedure)) {
audit = multipleResultItems.Read<Audit>().SingleOrDefault();
@ -164,11 +143,9 @@ public class AuditDMO {
try {
parameters.Add("AuditNo", audit.AuditNo);
parameters.Add("Title", audit.AuditTitle);
//parameters.Add("AuditTypeID", audit.AuditTypeID);
parameters.Add("AuditDate", audit.AuditDate);
parameters.Add("AuditStatus", audit.AuditStatus);
parameters.Add("AuditScore", audit.AuditScore);
//parameters.Add("AuditedAreaID", audit.AuditedAreaID);
parameters.Add("Auditees", audit.Auditees);
db.Execute("_8DUpdateAudit", param: parameters, commandType: CommandType.StoredProcedure);
@ -218,31 +195,6 @@ public class AuditDMO {
throw new Exception(ex.Message + " " + ex.InnerException);
}
}
//FabApprovalSystemEntitiesAll auditDb = new FabApprovalSystemEntitiesAll();
//List<int> auditedStandards = audit.AuditedStandardIDs;
//if (auditedStandards != null)
//{
// foreach (int auditedStandard in auditedStandards)
// {
// var auditStandardExists = (from a in auditDb.C_8DAuditedStandardByAudit where a.AuditNo == audit.AuditNo && a.AuditedStandardID == auditedStandard select a).ToList();
// if (auditStandardExists.Count() <= 0)
// {
// C_8DAuditedStandardByAudit standard = new C_8DAuditedStandardByAudit
// {
// AuditNo = audit.AuditNo,
// AuditedStandardID = auditedStandard
// };
// auditDb.C_8DAuditedStandardByAudit.Add(standard);
// auditDb.SaveChanges();
// }
// }
//}
//parameters = new DynamicParameters();
//parameters.Add("AuditNo", audit.AuditNo);
//this.db.Execute("_8DUpdateAuditScore", parameters, commandType: CommandType.StoredProcedure);
}
public IEnumerable<AuditReportAttachment> GetAuditReportAttachments(int auditNo) {
@ -450,7 +402,7 @@ public class AuditDMO {
}
audit = GetAuditItem(issueID, userId);
//transform audit users from string to list, delimited by a comma.
// transform audit users from string to list, delimited by a comma.
if (audit.Auditees == null) {
result.AuditeeNames = new List<string>();
} else {
@ -468,7 +420,7 @@ public class AuditDMO {
result.IsAdmin = true;
}
if ((audit.RecordLockIndicator && audit.RecordLockedBy != userId)
|| audit.AuditStatus != 0) //open
|| audit.AuditStatus != 0) // open
{
result.RedirectToAction = true;
}
@ -486,33 +438,16 @@ public class AuditDMO {
return result;
}
public List<string> GetFileNameAndDocument(string fileGuid, int auditNo) {
List<string> results = new();
string fileName = GetAuditReportAttachmentFileName(fileGuid);
string fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
string ecnFolderPath = _AppSettings.AttachmentFolder + "Audit\\" + auditNo.ToString();
string sDocument = Path.Combine(ecnFolderPath, fileGuid + fileExtension);
string FDir_AppData = _AppSettings.AttachmentFolder;
if (!sDocument.StartsWith(FDir_AppData)) {
sDocument = string.Empty;
}
results.Add(fileName);
results.Add(sDocument);
return results;
}
public Audit InsertAndGetAudit(CorrectiveActionDMO caDMO, AuditFindings data, int userID) {
Audit audit = new();
InsertAuditFindingsItem(data);
audit = GetAuditItem(data.AuditNo, userID);
//Transfer Finding Details to CA
// Transfer Finding Details to CA
if (data.CANo != 0) {
CorrectiveAction ca = caDMO.GetCAItem(data.CANo, userID);
ca.CATitle = data.Title;
ca.CASourceID = 1;//Audit
ca.CASourceID = 1; // Audit
caDMO.UpdateCorrectiveAction(ca);
}
@ -524,11 +459,11 @@ public class AuditDMO {
UpdateAuditFindingsItem(data);
audit = GetAuditItem(data.AuditNo, userID);
//Transfer Finding Details to CA
// Transfer Finding Details to CA
if (data.CANo != 0) {
CorrectiveAction ca = caDMO.GetCAItem(data.CANo, userID);
ca.CATitle = data.Title;
ca.CASourceID = 1;//Audit
ca.CASourceID = 1; // Audit
caDMO.UpdateCorrectiveAction(ca);
}
@ -542,72 +477,9 @@ public class AuditDMO {
return audit;
}
public void AuditReportAttachSave(int auditNo, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"Audit\" + auditNo;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"Audit\" + auditNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
AuditReportAttachment attach = new() {
AuditNo = auditNo,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId
};
//ccDMO.InsertCCAttachment(attach);
InsertAuditReportAttachment(attach);
}
public void SaveAndInsert(int caFindingsID, int auditNo, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"Audit\" + auditNo;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"Audit\" + auditNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
AuditReportAttachment attach = new() {
CAFindingsID = caFindingsID,
AuditNo = auditNo,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId
};
InsertAuditReportAttachment(attach);
}
public string NotifyActionItemOwner(int issueID, DateTime? dueDate, int? responsibleOwnerID, string emailTemplatesPath) {
string emailSentList = "";
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
string email = MiscDMO.GetEmail(responsibleOwnerID);
string emailTemplate = "CorrectiveActionFindingAssigned.txt";

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Transactions;
@ -16,12 +15,8 @@ namespace Fab2ApprovalSystem.DMO;
public class ChangeControlDMO {
private readonly AppSettings _AppSettings;
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
public ChangeControlDMO(AppSettings appSettings) =>
_AppSettings = appSettings;
internal ChangeControlViewModel InsertChangeControl(ChangeControlViewModel cc) {
DynamicParameters parameters = new();
parameters.Add("@PlanNumber", value: cc.PlanNumber, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
@ -40,42 +35,14 @@ public class ChangeControlDMO {
parameters.Add("@planNumber", planNumber);
parameters.Add("@UserID", userID);
//parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//cc = this.db.Query<ChangeControlViewModel>("CCGetChangeControl", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
using (var multipleResultItems = db.QueryMultiple("CCGetChangeControl", parameters, commandType: CommandType.StoredProcedure)) {
ccItem = multipleResultItems.Read<ChangeControlViewModel>().SingleOrDefault();
List<int> gens = multipleResultItems.Read<int>().ToList();
//if (ccItem != null && gens != null)
//{
// if (gens.Count > 0)
// ccItem.GenerationIDs.AddRange(gens);
//}
List<int> logis = multipleResultItems.Read<int>().ToList();
//if (ccItem != null && logis != null)
//{
// if (logis.Count > 0)
// ccItem.LogisticsIDs.AddRange(logis);
//}
List<int> procs = multipleResultItems.Read<int>().ToList();
//if (ccItem != null && procs != null)
//{
// if (procs.Count > 0)
// ccItem.ProcessIDs.AddRange(procs);
//}
//var parts = multipleResultItems.Read<string>().ToList();
//if (ccItem != null && parts != null)
//{
// if (parts.Count > 0)
// ccItem.PartNumberIDs.AddRange(parts);
//}
}
return ccItem;
}
@ -87,49 +54,14 @@ public class ChangeControlDMO {
parameters.Add("@planNumber", planNumber);
parameters.Add("@UserID", userID);
//parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//cc = this.db.Query<ChangeControlViewModel>("CCGetChangeControl", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
using (var multipleResultItems = db.QueryMultiple("CCGetChangeControlRead", parameters, commandType: CommandType.StoredProcedure)) {
ccItem = multipleResultItems.Read<ChangeControlViewModel>().SingleOrDefault();
List<int> gens = multipleResultItems.Read<int>().ToList();
//if (ccItem != null && gens != null)
//{
// if (gens.Count > 0)
// ccItem.GenerationIDs.AddRange(gens);
//}
List<int> logis = multipleResultItems.Read<int>().ToList();
//if (ccItem != null && logis != null)
//{
// if (logis.Count > 0)
// ccItem.LogisticsIDs.AddRange(logis);
//}
List<int> procs = multipleResultItems.Read<int>().ToList();
//if (ccItem != null && procs != null)
//{
// if (procs.Count > 0)
// ccItem.ProcessIDs.AddRange(procs);
//}
//var tools = multipleResultItems.Read<int>().ToList();
//if (ccItem != null && tools != null)
//{
// if (tools.Count > 0)
// ccItem.ToolTypeIDs.AddRange(tools);
//}
//var parts = multipleResultItems.Read<string>().ToList();
//if (ccItem != null && parts != null)
//{
// if (parts.Count > 0)
// ccItem.PartNumberIDs.AddRange(parts);
//}
canViewITAR = parameters.Get<int>("@CanViewITAR");
}
@ -147,13 +79,6 @@ public class ChangeControlDMO {
return db.Query<CCLogistics>("CCGetLogistics", commandType: CommandType.StoredProcedure).ToList();
}
/// <returns></returns>
//internal List<CCToolType> GetToolTypes()
//{
// var parameters = new DynamicParameters();
// return this.db.Query<CCToolType>("CCGetToolTypes", commandType: CommandType.StoredProcedure).ToList();
//}
internal List<CCProcess> GetProcesses() {
DynamicParameters parameters = new();
return db.Query<CCProcess>("CCGetProcesses", commandType: CommandType.StoredProcedure).ToList();
@ -175,73 +100,12 @@ public class ChangeControlDMO {
parameters.Add("@IsMedical", model.IsMedical);
parameters.Add("@IsRadHard", model.IsRadHard);
parameters.Add("@Notes", model.Notes);
//parameters.Add("@PartNumbers", model.PartNumbers);
parameters.Add("@IsAutomotive", model.IsAutomotive);
//parameters.Add("@ToolTypes", model.ToolTypes);
parameters.Add("@Title", model.Title);
parameters.Add("@ReasonForChange", model.ReasonForChange);
parameters.Add("@ChangeDescription", model.ChangeDescription);
db.Execute("CCUpdateChangeControl", param: parameters, commandType: CommandType.StoredProcedure);
//parameters = new DynamicParameters();
//parameters.Add("@PlanNumber", model.PlanNumber);
//this.db.Execute("CCDeleteGenerations", parameters, commandType: CommandType.StoredProcedure);
//List<int> gens = model.GenerationIDs;
//if (gens != null)
//{
// foreach (int genId in gens)
// {
// parameters = new DynamicParameters();
// parameters.Add("@PlanNumber", model.PlanNumber);
// parameters.Add("@GenerationID", genId);
// this.db.Execute("CCInsertGeneration", parameters, commandType: CommandType.StoredProcedure);
// }
//}
//parameters = new DynamicParameters();
//parameters.Add("@PlanNumber", model.PlanNumber);
//this.db.Execute("CCDeleteLogistics", parameters, commandType: CommandType.StoredProcedure);
//List<int> logistics = model.LogisticsIDs;
//if (logistics != null)
//{
// foreach (int logisticsId in logistics)
// {
// parameters = new DynamicParameters();
// parameters.Add("@PlanNumber", model.PlanNumber);
// parameters.Add("@LogisticsID", logisticsId);
// this.db.Execute("CCInsertLogistics", parameters, commandType: CommandType.StoredProcedure);
// }
//}
//parameters = new DynamicParameters();
//parameters.Add("@PlanNumber", model.PlanNumber);
//this.db.Execute("CCDeleteProcesses", parameters, commandType: CommandType.StoredProcedure);
//List<int> processes = model.ProcessIDs;
//if (processes != null)
//{
// foreach (int processId in processes)
// {
// parameters = new DynamicParameters();
// parameters.Add("@PlanNumber", model.PlanNumber);
// parameters.Add("@ProcessID", processId);
// this.db.Execute("CCInsertProcess", parameters, commandType: CommandType.StoredProcedure);
// }
//}
//parameters = new DynamicParameters();
//parameters.Add("@PlanNumber", model.PlanNumber);
//this.db.Execute("CCDeletePartNumbers", parameters, commandType: CommandType.StoredProcedure);
//if (model.PartNumbers != null)
//{
// string[] parts = model.PartNumbers.Split(new char[] { ',' });
// foreach (string part in parts)
// {
// parameters = new DynamicParameters();
// parameters.Add("@PlanNumber", model.PlanNumber);
// parameters.Add("@PartNumber", part);
// this.db.Execute("CCInsertPartNumber", parameters, commandType: CommandType.StoredProcedure);
// }
//}
transaction.Complete();
} catch (Exception ex) {
transaction.Dispose();
@ -330,7 +194,6 @@ public class ChangeControlDMO {
parameters.Add("@UserID", userID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//ccMeeting = this.db.Query<CCMeeting>("CCGetMeeting", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("CCGetMeetingRead", parameters, commandType: CommandType.StoredProcedure)) {
ccMeeting = multipleResultItems.Read<CCMeeting>().SingleOrDefault();
List<string> pcrvalues = multipleResultItems.Read<string>().ToList();
@ -351,7 +214,6 @@ public class ChangeControlDMO {
parameters.Add("@UserID", userID);
parameters.Add("@CanViewITAR", value: canViewITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//ccMeeting = this.db.Query<CCMeeting>("CCGetMeetingRead", parameters, commandType: CommandType.StoredProcedure).Single();
using (var multipleResultItems = db.QueryMultiple("CCGetMeetingRead", parameters, commandType: CommandType.StoredProcedure)) {
ccMeeting = multipleResultItems.Read<CCMeeting>().SingleOrDefault();
List<string> pcrvalues = multipleResultItems.Read<string>().ToList();
@ -376,7 +238,6 @@ public class ChangeControlDMO {
int result = 0;
DynamicParameters parameters = new();
parameters.Add("@MeetingID", meeting.MeetingID);
//parameters.Add("@PCRB", meeting.PCRB.ToUpper() == "SELECT" ? null : meeting.PCRB);
parameters.Add("@Decision", meeting.Decision);
parameters.Add("@MeetingDate", meeting.MeetingDate);
parameters.Add("@Notes", meeting.Notes);
@ -526,9 +387,6 @@ public class ChangeControlDMO {
parameters.Add("@Site", siteName);
db.Execute("CCInsertNewMeetingAttendee", parameters, commandType: CommandType.StoredProcedure);
}
/// <summary>
/// /
/// </summary>
internal void UpdateMeetingAttendee(int id, string attendeeName, string jobTitle, string siteName) {
DynamicParameters parameters = new();
@ -538,9 +396,6 @@ public class ChangeControlDMO {
parameters.Add("@Site", siteName);
db.Execute("CCUpdateMeetingAttendee", parameters, commandType: CommandType.StoredProcedure);
}
/// <summary>
/// /
/// </summary>
internal void UpdatePCRBAttendee(int id, int attendeeID, string jobTitle, string siteName) {
DynamicParameters parameters = new();
@ -593,10 +448,6 @@ public class ChangeControlDMO {
db.Execute("CCUpdateMeetingActionItem_All", parameters, commandType: CommandType.StoredProcedure);
}
/// <summary>
/// /
/// </summary>
internal void InsertMeetingActionItem(CCMeetingActionItem meetingActionItem) {
DynamicParameters parameters = new();
parameters.Add("@MeetingID", meetingActionItem.MeetingID);
@ -626,10 +477,6 @@ public class ChangeControlDMO {
db.Execute("CCInsertPCRBActionItem", parameters, commandType: CommandType.StoredProcedure);
}
/// <summary>
/// /
/// </summary>
internal void UpdateMeetingActionItem(CCMeetingActionItem meetingActionItem) {
DynamicParameters parameters = new();
parameters.Add("@ID", meetingActionItem.ID);
@ -659,20 +506,6 @@ public class ChangeControlDMO {
db.Execute("CCUpdateMeetingActionItemRespPersons", parameters, commandType: CommandType.StoredProcedure);
}
///// <summary>
/////
///// </summary>
//
//internal void UpdateMeetingActionItemAll(CCMeetingActionItemAll meetingActionItem)
//{
// var parameters = new DynamicParameters();
// parameters.Add("@ID", meetingActionItem.ID);
// parameters.Add("@Updates", meetingActionItem.Updates);
// parameters.Add("@ClosedStatus", meetingActionItem.ClosedStatus);
// parameters.Add("@UserID", meetingActionItem.ClosedBy);
// this.db.Execute("CCUpdateMeetingActionItem_All", parameters, commandType: CommandType.StoredProcedure);
//}
internal void DeleteMeetingActionItem(CCMeetingActionItem meetingAttendee) {
DynamicParameters parameters = new();
parameters.Add("@ID", meetingAttendee.ID);
@ -730,9 +563,6 @@ public class ChangeControlDMO {
return fileName;
}
/// <summary>
///
/// </summary>
internal List<UserList> GetUsers() {
DynamicParameters parameters = new();
return db.Query<UserList>("CCGetUsers", commandType: CommandType.StoredProcedure).ToList();
@ -778,97 +608,4 @@ public class ChangeControlDMO {
db.Execute("CCReassignOwner", parameters, commandType: CommandType.StoredProcedure);
}
public void AttachSaveCC(int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
CCAttachment attach = new() {
ID = attachID,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId
// Title = title,
// RequirementsNotes = requirementsNotes
};
// InsertCCAttachment(attach);
UpdateCCAttachmentDocument(attach);
}
public void AttachSaveMeeting(int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
CCMeetingAttachment attach = new() {
ID = attachID,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId
};
// InsertCCAttachment(attach);
UpdateMeetingAttachmentDocument(attach);
}
public void AttachSaveActionItem(int planNumber, int attachID, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"ChangeControl\" + planNumber + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
CCMeetingActionItemAll attach = new() {
ID = attachID,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId
};
// InsertCCAttachment(attach);
UpdateActionItemAttachment(attach);
}
}

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Transactions;
@ -16,17 +15,12 @@ namespace Fab2ApprovalSystem.DMO;
public class CorrectiveActionDMO {
private readonly AppSettings _AppSettings;
private readonly WorkflowDMO wfDMO = new();
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
public CorrectiveActionDMO(AppSettings appSettings) =>
_AppSettings = appSettings;
public CorrectiveAction InsertCA(CorrectiveAction ca) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@CANo", value: ca.CANo, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@RequestorID", ca.RequestorID);
@ -151,8 +145,6 @@ public class CorrectiveActionDMO {
public CorrectiveAction GetCAItem(int caNo, int userID) {
CorrectiveAction ca = new();
//isITAR = 2;
DynamicParameters parameters = new();
parameters.Add("@CANo", value: caNo);
parameters.Add("@UserID", userID);
@ -185,8 +177,6 @@ public class CorrectiveActionDMO {
public CorrectiveAction GetCAItemReadOnly(int caNo, int userID) {
CorrectiveAction ca = new();
//isITAR = 2;
DynamicParameters parameters = new();
parameters.Add("@CANo", value: caNo);
parameters.Add("@UserID", userID);
@ -512,8 +502,6 @@ public class CorrectiveActionDMO {
}
public void StartSectionApproval(int issueID, int userID, string DSection) {
//string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
// bubble the error
DynamicParameters parameters = new();
parameters.Add("@CANo", issueID);
@ -524,8 +512,6 @@ public class CorrectiveActionDMO {
}
public void ApproveSection(int issueID, int userID, string DSection) {
//string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
// bubble the error
DynamicParameters parameters = new();
parameters.Add("@UserID", userID);
@ -550,8 +536,6 @@ public class CorrectiveActionDMO {
}
public void RejectSection(int issueID, int userID, string DSection, string comments) {
//string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
// bubble the error
DynamicParameters parameters = new();
parameters.Add("@UserID", userID);
@ -643,131 +627,4 @@ public class CorrectiveActionDMO {
return ecnList;
}
public void AttachSave(int caNo, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
CA_Attachment attach = new() {
CANo = caNo,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId,
Section = Functions.CASectionMapper(GlobalVars.CASection.Main)
};
// InsertCCAttachment(attach);
InsertCAAttachment(attach);
}
public void D4FilesAttachSave(int caNo, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
CA_Attachment attach = new() {
CANo = caNo,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId,
Section = Functions.CASectionMapper(GlobalVars.CASection.D4)
};
//InsertCCAttachment(attach);
InsertCAAttachment(attach);
}
public void SaveD7PA_Attachemnt(int d7PAID, int caNo, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
CA_Attachment attach = new() {
D7PAID = d7PAID,
CANo = caNo,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId,
Section = Functions.CASectionMapper(GlobalVars.CASection.D7)
};
InsertCAAttachment(attach);
}
public void SaveD5D6CA_Attachemnt(int d5d6CAID, int caNo, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var ccPhysicalPath = _AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo;
di = new DirectoryInfo(ccPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"CorrectiveAction\" + caNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
CA_Attachment attach = new() {
D5D6CAID = d5d6CAID,
CANo = caNo,
FileGUID = guid,
FileName = fileName,
UploadedByID = userId,
Section = Functions.CASectionMapper(GlobalVars.CASection.D5)
};
InsertCAAttachment(attach);
}
}

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Transactions;
@ -21,8 +20,6 @@ public class ECN_DMO {
internal ECN InsertECN(ECN ecn) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@ECNNumber", value: ecn.ECNNumber, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@OriginatorID", ecn.OriginatorID);
@ -33,12 +30,6 @@ public class ECN_DMO {
}
internal void UpdateECN(ECN ecn) {
//ECN temp = GetECN(ecn.ECNNumber);
//if (temp.Equals(ecn))
//{
// string s = "good to go...";
//}
DynamicParameters parameters = new();
using (TransactionScope transanction = new()) {
parameters = new DynamicParameters();
@ -82,7 +73,7 @@ public class ECN_DMO {
parameters.Add("@FIChangeRequired", ecn.FIChangeRequired);
parameters.Add("@NumberOfLotsAffected", ecn.NumberOfLotsAffected);
parameters.Add("@RecipeChange", ecn.RecipeChange);
//RJK ITAR/EC
// RJK ITAR/EC
parameters.Add("@IsDocEC", ecn.IsDocEC);
db.Execute("ECNUpdate", parameters, commandType: CommandType.StoredProcedure);
@ -203,11 +194,8 @@ public class ECN_DMO {
DynamicParameters parameters = new();
parameters.Add("@ECNNumber", value: ecnNumber);
parameters.Add("@UserID", userID);
//parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//StringBuilder query = new StringBuilder("ECNGetItem");
using (var multipleResultItems = db.QueryMultiple("ECNGetItem", parameters, commandType: CommandType.StoredProcedure)) {
ecnItem = multipleResultItems.Read<ECN>().SingleOrDefault();
@ -285,11 +273,8 @@ public class ECN_DMO {
DynamicParameters parameters = new();
parameters.Add("@ECNNumber", value: ecnNumber);
parameters.Add("@UserID", userID);
//parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//StringBuilder query = new StringBuilder("ECNGetItem");
using (var multipleResultItems = db.QueryMultiple("ECNGetItemForRead", parameters, commandType: CommandType.StoredProcedure)) {
ecnItem = multipleResultItems.Read<ECN>().SingleOrDefault();
@ -347,25 +332,11 @@ public class ECN_DMO {
DynamicParameters parameters = new();
parameters.Add("@ECNNumber", value: ecnNumber);
//StringBuilder query = new StringBuilder("ECNGetItem");
using (var multipleResultItems = db.QueryMultiple("ECNGetPdfItem", parameters, commandType: CommandType.StoredProcedure)) {
ecnItem = multipleResultItems.Read<ECNPdf>().SingleOrDefault();
List<string> departments = multipleResultItems.Read<string>().ToList();
//if (ecnItem != null && departments != null)
//{
// if (departments.Count > 0)
// ecnItem.AffectedDepartments.AddRange(departments);
//}
List<string> modules = multipleResultItems.Read<string>().ToList();
//if (ecnItem != null && modules != null)
//{
// if (modules.Count > 0)
// ecnItem.AffectedModules.AddRange(modules);
//}
List<string> attachments = multipleResultItems.Read<string>().ToList();
if (ecnItem != null && attachments != null) {
if (attachments.Count > 0)
@ -426,17 +397,6 @@ public class ECN_DMO {
return db.Query<ECNArea>(query.ToString()).ToList();
}
/// <returns></returns>
//internal List<ECNTechnology> GetECNTechnology(int? areaId)
//{
// var parameters = new DynamicParameters();
// parameters.Add("@AreaId", value: areaId);
// StringBuilder query = new StringBuilder("SELECT TechnologyID, Technology FROM ECNTechnology WHERE AreaID = @AreaId ORDER BY Technology");
// return this.db.Query<ECNTechnology>(query.ToString(), parameters ).ToList();
//}
internal List<ECNTechnology> GetECNTechnologies() {
DynamicParameters parameters = new();
@ -540,7 +500,6 @@ public class ECN_DMO {
db.Execute("ECNReSubmitForApproval", parameters, commandType: CommandType.StoredProcedure);
appoverCount = parameters.Get<int>("@AppoverCount");
//allowedITAR = parameters.Get<int>("@AllowedITAR");
newECNNumber = parameters.Get<int>("@NewECNNumber");
return appoverCount;
}
@ -751,42 +710,4 @@ public class ECN_DMO {
return r;
}
public string AttachSave(AppSettings appSettings, int ecnNumber, string returnString, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
string ecnFolderPath = appSettings.AttachmentFolder + "ECN\\" + ecnNumber.ToString();
DirectoryInfo di = new(ecnFolderPath);
if (!di.Exists)
try {
di.Create();
} catch {
returnString = "Error creating ECN directory.";
}
if (returnString == "") {
var physicalPath = Path.Combine(ecnFolderPath, fileName);
if (!File.Exists(physicalPath)) {
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
ECNAttachment attach = new() {
ECNNumber = ecnNumber,
FileName = fileName,
UserID = userId,
};
if (File.Exists(physicalPath)) {
InsertECNAttachment(attach);
} else {
returnString = "File was not uploaded to server.";
}
} else {
returnString = "Cannot have duplicate file names.";
}
}
return returnString;
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
@ -18,16 +16,11 @@ namespace Fab2ApprovalSystem.DMO;
public class LotDispositionDMO {
private readonly AppSettings _AppSettings;
private readonly WorkflowDMO wfDMO = new();
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
public LotDispositionDMO(AppSettings appSettings) =>
_AppSettings = appSettings;
public IEnumerable<IssuesViewModel> GetTaskList(int userID) {
// eventually, the View Model will refer to a generic task list instead of the just Lot Disposition Items
//var lotDispostions = this.db.Query<IssuesViewModel>("GetLotDispositionsByUser", new { UserID = userID }, commandType: CommandType.StoredProcedure).ToList();
DynamicParameters parameters = new();
parameters.Add("@UserID", userID);
@ -121,7 +114,6 @@ public class LotDispositionDMO {
DynamicParameters parameters = new();
parameters.Add("@IssueID", value: issueID);
parameters.Add("@UserID", userID);
//parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
using (var multipleResultItems = db.QueryMultiple("GetLotDispositionItem", parameters, commandType: CommandType.StoredProcedure)) {
@ -149,7 +141,6 @@ public class LotDispositionDMO {
DynamicParameters parameters = new();
parameters.Add("@IssueID", value: issueID);
parameters.Add("@UserID", userID);
//parameters.Add("@UserID", GlobalVars.USER_ID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
using (var multipleResultItems = db.QueryMultiple("GetLotDispositionItemForRead", parameters, commandType: CommandType.StoredProcedure)) {
@ -168,7 +159,6 @@ public class LotDispositionDMO {
public int GetRHLotCount(int issueID) {
StringBuilder query = new("SELECT COUNT(*) FROM dbo.fnGetLot_RH(@IssueID) ");
//query.Append("WHERE UserID = @UserID AND AND EmployeeStatus = 'Active'");
return db.Query<int>(query.ToString(), new { IssueID = issueID }).SingleOrDefault();
}
@ -200,35 +190,6 @@ public class LotDispositionDMO {
// Lot Update
//parameters = new DynamicParameters();
//IEnumerable<Lot> lots = lotDispo.Lots;
//foreach (Lot lot in lots)
//{
// parameters = new DynamicParameters();
// parameters.Add("@LotNumber", lot.LotNumber);
// parameters.Add("@IssueID", lotDispo.IssueID);
// parameters.Add("@Description", lot.Description);
// parameters.Add("@NewPartNo", lot.NewPartNo);
// parameters.Add("@WipPartNo", lot.WipPartNo);
// parameters.Add("@DiePartNo", lot.DiePartNo);
// parameters.Add("@ProductFamily", lot.ProductFamily);
// parameters.Add("@Gen", lot.Gen);
// parameters.Add("@Channel", lot.Channel);
// parameters.Add("@Hexsize", lot.Hexsize);
// parameters.Add("@Voltage", lot.Voltage);
// parameters.Add("@WaferCount", lot.WaferCount);
// parameters.Add("@DieCount", lot.DieCount);
// parameters.Add("@Location", lot.Location);
// parameters.Add("@TotalCost", lot.TotalCost);
// parameters.Add("@LotStatusOptionID", lot.LotStatusOption.LotStatusOptionID);
// this.db.Execute("InsertLot", parameters, commandType: CommandType.StoredProcedure);
//}
// LotDispoDepartment
List<int> lotDispDepIDs = lotDispo.DepartmentIDs;
@ -443,123 +404,10 @@ public class LotDispositionDMO {
lot.ScrapCount = 0;
lot.ReleaseCount = 0;
}
//else if (lot.LotStatusOption.LotStatusOptionID == (int)GlobalVars.LotStatusOption.NotAvailable)
//{
// sl.ScrapCount = 0;
// sl.ReleaseCount = 0;
// lot.ScrapCount = 0;
// lot.ReleaseCount = 0;
//}
UpdateLotScrapReleaseStatus(sl);
}
/// <summary>
/// Updates the Lot object with additional info based on Lot data downlaoded from SPN
/// </summary>
//void GetLotInformation(Lot lot)
//{
// string qryLotInfo = "SELECT WP_LOT_NO, WP_PART_NUMBER, MP_PRODUCT_FAMILY, MP_DESCRIPTION, WP_CURRENT_QTY, WP_CURRENT_LOCATION, DieLotNumber, DiePartNo, DieCount FROM SPNLot WHERE WP_Lot_No = @LotNumber ";
// var lotInfoRow = this.db.Query<dynamic>(qryLotInfo, new { lot.LotNumber }).ToList();
// //lot.LotNumber = lotInfoRow.Get<string>("@WP_LOT_NO");
// //lot.WipPartNo = lotInfoRow.Get<int>("@WP_Part_Number");
// ////lotInfoRow.WP_LOT_NO;
// //lot.WipPartNo = lotInfoRow.WP_Part_Number;
// foreach (dynamic lotInfoColumn in lotInfoRow)
// {
// lot.LotNumber = lotInfoColumn.WP_LOT_NO;
// lot.DieLotNumber = lotInfoColumn.DieLotNumber;
// if (lotInfoColumn.WP_PART_NUMBER != null)
// lot.WipPartNo = lotInfoColumn.WP_PART_NUMBER.Trim();
// if (lotInfoColumn.WP_CURRENT_LOCATION != null)
// {
// lot.Location = lotInfoColumn.WP_CURRENT_LOCATION;
// }
// if (lotInfoColumn.MP_DESCRIPTION != null)
// {
// lot.Description = lotInfoColumn.MP_DESCRIPTION;
// if (lot.Description.Length > 0)
// {
// string[] temp = lot.Description.Split(new char[] { ',' });
// if (temp.Length > 0)
// {
// try
// {
// lot.ProductFamily = temp[0];
// }
// catch { } // ignore the error
// try
// {
// lot.Gen = double.Parse(temp[2].Substring(1,temp[2].Length - 1));
// }
// catch { }// ignore the error
// try
// {
// lot.Hexsize = double.Parse(temp[6]);
// }
// catch { }// ignore the error
// }
// }
// }
// if (lotInfoColumn.DieCount != null)
// lot.DieCount = int.Parse(lotInfoColumn.DieCount.ToString());
// if (lotInfoColumn.DiePartNo != null)
// lot.DiePartNo = lotInfoColumn.DiePartNo.Trim();
// if (lotInfoColumn.WP_CURRENT_QTY != null)
// lot.WaferCount = lotInfoColumn.WP_CURRENT_QTY;
// if (lot.WipPartNo.Length > 0 || lot.DiePartNo.Length > 0)
// {
// qryLotInfo = "SELECT DiePartNo, SourceFAB, Diameter, Silicon, Gen, Layers,HexSize,Voltage,Channel, Type AS ProductFamily, WaferCost, DieCost FROM FabApprovalSystem.dbo.StdCost WHERE WIPWaferNo = @WIPPartNo OR DiePartNo = @DiePartNo ";
// var moreLotInfoRow = this.db.Query<dynamic>(qryLotInfo, new { lot.WipPartNo, lot.DiePartNo }).ToList();
// foreach (var moreLotInfoColumn in moreLotInfoRow)
// {
// lot.DieCost = double.Parse(moreLotInfoColumn.DieCost.ToString());
// lot.WaferCost = double.Parse(moreLotInfoColumn.WaferCost.ToString());
// if (moreLotInfoColumn.Channel != null)
// lot.Channel = moreLotInfoColumn.Channel;
// //if (moreLotInfoColumn.ProductFamily != null)
// // lot.ProductFamily = moreLotInfoColumn.ProductFamily;
// if (moreLotInfoColumn.Hexsize != null)
// lot.Hexsize = moreLotInfoColumn.Hexsize;
// if (moreLotInfoColumn.Voltage != null)
// lot.Voltage = moreLotInfoColumn.Voltage;
// //if (moreLotInfoColumn.Gen != null)
// // lot.Gen = moreLotInfoColumn.Gen;
// if (lot.DieCount == 0)
// lot.TotalCost = Math.Round(lot.WaferCount * lot.WaferCost,2);
// else
// lot.TotalCost = Math.Round(lot.DieCount * lot.DieCost,2);
// }
// }
// }
// //return lotStatusOption;
//}
#endregion
public IEnumerable<LotStatusOptionViewModel> GetLotStatusOptions() {
@ -571,86 +419,6 @@ public class LotDispositionDMO {
// NOTE: Any new fields that needs to be added to select list , needs to be referenced prior to the "LS.LotStatusOptionID , LS.LotStatusOption" fields
db.Open();
#region Commented Code
/*
StringBuilder sql = new StringBuilder();
sql.Append("SELECT DISTINCT SQ.IssueIDs AS MRBsLinkedToLot , DispoType.MRBDispoType, SQP.IssueIDs AS IssueIDWithoutMRB, ");
sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 1 ");
sql.Append("WHEN PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2 THEN 0 ");
sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 0 ");
sql.Append("WHEN (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
sql.Append(" AND LS.LotStatusOptionID <> 6 ) ");
sql.Append(" AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB') THEN 0 ");
sql.Append("ELSE 1 ");
sql.Append("END AS GoodToSubmit, ");
sql.Append("CASE WHEN L.LotStatusOptionID = 2 THEN 'NA' ");
sql.Append("WHEN (PATINDEX('%B%', DispoType.MRBDispoType) > 0 AND L.LotStatusOptionID <> 2) ");
sql.Append("OR ( ");
sql.Append(" (PATINDEX('%D%', DispoType.MRBDispoType) > 0 ");
sql.Append(" AND PATINDEX('%X%', DispoType.MRBDispoType) = 0 ");
sql.Append(" AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 ");
sql.Append(" AND LS.LotStatusOptionID <> 6 AND (LTRIM(RTRIM(Location)) <> 'QDB' AND LTRIM(RTRIM(Location)) <> 'EDB')) ");
sql.Append(" )");
sql.Append(" THEN 'MRB Disposition different from Lot Dispostion' ");
sql.Append("WHEN PATINDEX('%X%', DispoType.MRBDispoType) > 0 AND PATINDEX('%B%', DispoType.MRBDispoType) = 0 THEN 'MRB Dispo missing' ");
sql.Append("ELSE 'NA' ");
sql.Append("END AS SubmitErrorMessage, ");
sql.Append(" ");
sql.Append("L.LotID, L.LotNumber, L.IssueID ,L.DieLotNumber ,L.Description ,L.NewPartNo ,L.WipPartNo ,L.DiePartNo ,L.ProductFamily, ");
sql.Append("L.Gen ,L.Channel, L.HexSize, L.Voltage, L.WaferCount, L.DieCount, L.Location, L.TotalCost, L.LotStatusOptionID,");
sql.Append("S.ReleaseCount, S.ScrapCount, L.QualityCode, LS.LotStatusOptionID , LS.LotStatusOption FROM Lot L ");
sql.Append("INNER JOIN LotStatusOption LS ON L.LotStatusOptionID = LS.LotStatusOptionID ");
sql.Append("LEFT JOIN ScrapLot S ON L.LotNumber = S.LotNo AND L.IssueID = S.IssueID ");
sql.Append("LEFT JOIN ");
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
// Code changed 12/11/2019 RJK
//sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) + '_' + CAST(ISNULL(ML.DispoType,'') AS varchar(512)) ");
sql.Append("FROM vMRBLot ML ");
//sql.Append("WHERE SUBSTRING(LTRIM(RTRIM(L.LotNumber)),1,7) = SUBSTRING(LTRIM(RTRIM(ML.LotNumber)),1,7) ");
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
sql.Append("FROM Lot L) AS SQ ");
sql.Append("ON L.LotID = SQ.LotID ");
sql.Append("LEFT JOIN ");
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
sql.Append("((SELECT DISTINCT ',' + CAST(ML.MRBNumber AS varchar(512)) ");
sql.Append("FROM vMRBLot ML ");
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
sql.Append("FOR XML PATH('')), 1, 1, '') AS IssueIDs ");
sql.Append("FROM Lot L) AS SQP ");
sql.Append("ON L.LotID = SQP.LotID ");
sql.Append("LEFT JOIN ");
sql.Append("(SELECT DISTINCT L.LotID, STUFF ");
sql.Append("((SELECT DISTINCT ',' + CAST(ISNULL(ML.DispoType, 'X') AS varchar(512)) ");
sql.Append("FROM vMRBLot ML ");
sql.Append("WHERE LTRIM(RTRIM(L.LotNumber)) = LTRIM(RTRIM(ML.LotNumber)) ");
sql.Append("FOR XML PATH('')), 1, 1, '') AS MRBDispoType ");
sql.Append("FROM Lot L) AS DispoType ");
sql.Append("ON L.LotID = DispoType.LotID ");
sql.Append("WHERE L.IssueID = " + issueID);
var data = this.db.Query<Lot, LotStatusOptionViewModel, Lot>
(sql.ToString(), (lot, lotstatusoption) =>
{
lot.LotStatusOption = lotstatusoption;
return lot;
},
splitOn: "LotStatusOptionID").ToList();
*/
#endregion
DynamicParameters parameters = new();
parameters.Add("@IssueID", issueID, DbType.Int32);
@ -786,7 +554,7 @@ public class LotDispositionDMO {
}
public void UpdateLotStatus(ScrapLot lotStatus) {
//if all the wafers in a lot is either "RELEASE" or "SCRAP" from the "SELECT WAFERS SCREEN" set the Lot Status Option accodingly for the particula lot
// if all the wafers in a lot is either "RELEASE" or "SCRAP" from the "SELECT WAFERS SCREEN" set the Lot Status Option accodingly for the particula lot
int tempLotStatus;
if ((lotStatus.ReleaseCount == lotStatus.WaferCount || lotStatus.ScrapCount == lotStatus.WaferCount) && (lotStatus.ReleaseCount > 0 || lotStatus.WaferCount > 0)) {
// set the LotStatus appropriately because the entire lot either is set to "RELEASE" or "SCRAP"'
@ -951,16 +719,12 @@ public class LotDispositionDMO {
totalReleaseCost += releaseCost;
}
//}
return new LotDispositionLotSummaryViewModel() {
LotCount = lotCount,
ReleaseCost = string.Format("{0:C}", totalReleaseCost),
//Math.Round(totalReleaseCost, 2).ToString(,
ReleaseWaferCount = totalWaferReleaseCount,
ReleaseDieCount = totalDieReleaseCount,
ScrapCost = string.Format("{0:C}", totalScrapCost),
//Math.Round(totalScrapCost, 2),
ScrapWaferCount = totalWaferScrapCount,
ScrapDieCount = totalDieScrapCount
@ -1036,61 +800,4 @@ public class LotDispositionDMO {
return fileName;
}
public void AttachSave(int issueID, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
var 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,
};
InsertLotDispositionAttachment(attach);
}
public string ExcelLotOpen(int issueID, string userIdentityName, string lotTempPipeLine, string fullFileName, Stream stream) {
string physicalPath;
var 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);
}
#if !NET8
ExcelData x = new ExcelData(physicalPath);
var lotNumbers = x.ReadData();
foreach (var lotInfo in lotNumbers) {
Lot l = new Lot();
l.LotNumber = lotInfo.LotNo;
l.IssueID = issueID;
if (l.LotStatusOptionID == 0)
l.LotStatusOption.LotStatusOptionID = (int)GlobalVars.LotStatusOption.Release;
InsertLot(l, true);
//if (!mrbDMO.DoesMRBLotExist(lotInfo.LotNo))
//{
// //get All the MRBs associated to the Parent lot
// //insert the lot into the MRBChildLotNotInMRB table and NOT in the MRB Lot table for each MRB
// InsertChildLot_NotInTheMRB(lotInfo.LotNo);
//}
}
#endif
FileInfo f = new(physicalPath);
if (f.Exists)
f.Delete();
return physicalPath;
}
}

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Transactions;
@ -17,13 +16,9 @@ namespace Fab2ApprovalSystem.DMO;
public class LotTravelerDMO {
private readonly AppSettings _AppSettings;
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
private readonly WorkflowDMO wfDMO = new();
public LotTravelerDMO(AppSettings appSettings) =>
_AppSettings = appSettings;
/// <returns></returns>
///
internal LTWorkRequest InsertWorkRequest(LTWorkRequest workRequest) {
@ -59,9 +54,6 @@ public class LotTravelerDMO {
workRequestItem.ModuleIDs.AddRange(modules);
}
//var holdsteps = multipleResultItems.Read<LTHoldStep>().SingleOrDefault();
//workRequestItem.LTHoldStep = holdsteps;
isITAR = parameters.Get<int>("@IsITAR");
}
@ -121,9 +113,6 @@ public class LotTravelerDMO {
workRequestItem.ModuleIDs.AddRange(modules);
}
//var holdsteps = multipleResultItems.Read<LTHoldStep>().SingleOrDefault();
//workRequestItem.LTHoldStep = holdsteps;
isITAR = parameters.Get<int>("@IsITAR");
}
@ -149,7 +138,6 @@ public class LotTravelerDMO {
parameters.Add("@AllocationToUse", data.AllocationToUse);
parameters.Add("@PredictedCyleTime", data.PredictedCyleTime);
parameters.Add("@DeptChargedForRawWafers", data.ChargeDepartment);
//parameters.Add("@EstimatedBinCLoseDate", data.EstimatedBinCLoseDate);
parameters.Add("@TotalQty", data.TotalQty);
parameters.Add("@WIPArea", data.WIPArea);
parameters.Add("@LotStartDate", data.LotStartDate);
@ -422,11 +410,6 @@ public class LotTravelerDMO {
result = parameters.Get<int>("@Result");
//if (result == -1)
//{
// throw new Exception("In order to do the UPDATE or SUBMIT operation the record needs to exclusively locked by you.\nThe record was unlocked by the system due to inactivity for more than 30 minutes, hence the update was not successful");
//}
}
internal void UpdateHoldStep(LTHoldStep model) {
@ -443,8 +426,6 @@ public class LotTravelerDMO {
db.Execute("LTUpdateHoldStep", parameters, commandType: CommandType.StoredProcedure);
//int id = parameters.Get<int>("@LTHoldStepID");
//model.ID = id;
}
internal void InsertHoldStepRevision(LTHoldStep model) {
@ -470,7 +451,6 @@ public class LotTravelerDMO {
int result = 0;
DynamicParameters parameters = new();
parameters.Add("@LTHoldStepID", model.ID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
//parameters.Add("@BaseFlow", model.BaseFlow);
parameters.Add("@BaseFlowLocation", model.Location);
parameters.Add("@BaseFlowOperationSeq", model.OperSequence);
parameters.Add("@BaseFlowOperation", model.Operation);
@ -478,16 +458,8 @@ public class LotTravelerDMO {
parameters.Add("@ChangeInstruction", model.ChangeInstructions);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", model.UpdatedBy);
//parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
db.Execute("LTUpdateHoldStepRevision", parameters, commandType: CommandType.StoredProcedure);
//result = parameters.Get<int>("@Result");
//if (result == -1)
//{
// throw new Exception("Cannot add the Hold Step as the step has already been passed in the Mfg Process.");
//}
}
internal void DeleteHoldStep(int holdStepID, int userID) {
@ -524,7 +496,6 @@ public class LotTravelerDMO {
}
internal IEnumerable<LTWorkRequestAttachment> GetHoldStepAttachemnts(int holdStepID) {
//var holdStepAttachments = this.db.Query<LTWorkRequestAttachment>("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
DynamicParameters parameters = new();
parameters.Add("@HoldStepID", holdStepID);
List<LTWorkRequestAttachment> data = db.Query<LTWorkRequestAttachment>("LTGetHoldStepAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
@ -532,7 +503,6 @@ public class LotTravelerDMO {
}
internal IEnumerable<LTWorkRequestAttachment> GetLotTravHoldStepAttachemnts(int ltHoldStepID) {
//var holdStepAttachments = this.db.Query<LTWorkRequestAttachment>("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
DynamicParameters parameters = new();
parameters.Add("@LTHoldStepID", ltHoldStepID);
List<LTWorkRequestAttachment> data = db.Query<LTWorkRequestAttachment>("LTGetLotTravHoldStepAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
@ -612,7 +582,6 @@ public class LotTravelerDMO {
}
internal IEnumerable<LTWorkRequestAttachment> GetWorkRequestAttachments(int workRequestID) {
//var holdStepAttachments = this.db.Query<LTWorkRequestAttachment>("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
DynamicParameters parameters = new();
parameters.Add("@WorkRequestID", workRequestID);
List<LTWorkRequestAttachment> data = db.Query<LTWorkRequestAttachment>("LTGetWorkRequestAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
@ -786,12 +755,10 @@ public class LotTravelerDMO {
db.Execute("LTInsertLTLot", parameters, commandType: CommandType.StoredProcedure);
//int lotID = parameters.Get<int>("@LotID");
if (parameters.Get<int>("@WRWithExistingLot") != 0) {
lot.WRWithExistingLot = parameters.Get<int>("@WRWithExistingLot");
}
//return lotID;
}
public IEnumerable<LTLot> GetLotList(int workRequestID) {
@ -810,7 +777,6 @@ public class LotTravelerDMO {
sql.Append("LEFT JOIN Users U ON L.LotUploadedBy = U.UserID ");
sql.Append("WHERE WR.SWRNumber = @SWRNumber ORDER BY LotNumber ");
List<LTLot> lots = db.Query<LTLot>(sql.ToString(), new { @SWRNumber = swrNumber }, commandType: CommandType.Text).ToList();
//var lots = this.db.Query<LTLot>("SELECT L.*, U.FirstName + ' ' + U.LastName AS UploadedByName FROM LTWorkRequest WR INNER JOIN LTLot L ON WR.ID = L.WorkRequestID AND WR.IsCurrentRevision = 1 LEFT JOIN Users U ON L.LotUploadedBy = U.UserID WHERE WR.SWRNumber = @SWRNumber ORDER BY LotNumber ", new { swrNumber }, commandType: CommandType.Text).ToList();
return lots;
}
@ -999,7 +965,6 @@ public class LotTravelerDMO {
}
//var data = this.db.Query<LotTravelerPdf>("LTGetLotTravelerForPDF", parameters, commandType: CommandType.StoredProcedure).Single();
return data;
}
@ -1088,220 +1053,4 @@ public class LotTravelerDMO {
db.Execute("LTReassignOriginator", parameters, commandType: CommandType.StoredProcedure);
}
public void HoldStepAttachSave(int holdStepID, int swrNo, string docType, string comments, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
// TODO
//int currentRevision = 1;
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWRPhysicalPath);
if (!di.Exists)
di.Create();
//var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWR_RevPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
//var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision + @"\", guid + fileExtension);
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
LTWorkRequestAttachment attach = new() {
FileGUID = guid,
LTHoldStepID = holdStepID,
FileName = fileName,
UploadedByID = userId,
DocType = docType,
Comments = comments
};
InsertLotHoldStepAttachment(attach);
}
public void HoldStepAttachSaveRev(int holdStepID, int swrNo, string docType, string comments, bool newRevision, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
// TODO
//int currentRevision = 1;
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWRPhysicalPath);
if (!di.Exists)
di.Create();
//var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWR_RevPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
//var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision + @"\", guid + fileExtension);
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
LTWorkRequestAttachment attach = new() {
FileGUID = guid,
LTHoldStepID = holdStepID,
FileName = fileName,
UploadedByID = userId,
DocType = docType,
Comments = comments
};
if (newRevision)
InsertLotHoldStepAttachmentRevision(attach);
else
InsertLotHoldStepAttachment(attach);
}
public void AttachSaveWorkRequestRevision(int workRequestID, int swrNo, string docType, string attachComments, bool newRevision, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
// TODO
//int currentRevision = 1;
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWRPhysicalPath);
if (!di.Exists)
di.Create();
//var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWR_RevPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
LTWorkRequestAttachment attach = new() {
WorkRequestID = workRequestID,
FileGUID = guid,
LTHoldStepID = -1,
FileName = fileName,
UploadedByID = userId,
DocType = docType,
Comments = attachComments
};
// InsertWorkRequestAttachment(attach);
if (newRevision)
InsertWorkRequestAttachmentRevision(attach);
else
InsertWorkRequestAttachment(attach);
}
public void AttachSaveWorkRequest(int workRequestID, int swrNo, string comments, string docType, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
// TODO
//int currentRevision = 1;
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWRPhysicalPath);
if (!di.Exists)
di.Create();
//var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWR_RevPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
LTWorkRequestAttachment attach = new() {
WorkRequestID = workRequestID,
FileGUID = guid,
LTHoldStepID = -1,
FileName = fileName,
UploadedByID = userId,
DocType = docType,
Comments = comments
};
InsertWorkRequestAttachment(attach);
}
public void LotTravHoldStepAttachSaveRev(int ltHoldStepID, int swrNo, string docType, int prevLotTravRevID, int newLotTravRevID, bool newRevision, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
// TODO
//int currentRevision = 1;
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
//var physicalPath = Path.Combine(Server.MapPath("~/UserUploads"), fileName);
DirectoryInfo di;
var SWRPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWRPhysicalPath);
if (!di.Exists)
di.Create();
//var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision;
var SWR_RevPhysicalPath = _AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo;
di = new DirectoryInfo(SWR_RevPhysicalPath);
if (!di.Exists)
di.Create();
var guid = Guid.NewGuid().ToString();
//var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\Rev" + currentRevision + @"\", guid + fileExtension);
var physicalPath = Path.Combine(_AppSettings.AttachmentFolder + @"LotTraveler\" + swrNo + @"\", guid + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
LTLotTravAttachment attach = new() {
FileGUID = guid,
LTLotTravHoldStepID = ltHoldStepID,
LotTravelerRevisionID = newLotTravRevID,
FileName = fileName,
UploadedByID = userId,
DocType = docType
};
if (newRevision) {
try {
InsertLotTravLotHoldStepAttachmentRevision(attach);
} catch {
//roll back the revision creation
RestoreLotTravToPrevRevision(prevLotTravRevID, newLotTravRevID);
throw new Exception("There was a problem while creating the revision, Please logout and log back and then retry. \n If the problem persist please contact the Site Administrator");
}
} else
InsertLotTravLotHoldStepAttachment(attach);
}
}

View File

@ -2,11 +2,8 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Transactions;
using Dapper;
@ -28,8 +25,6 @@ public class MRB_DMO {
internal MRB InsertMRB(MRB mrb) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@MRBNumber", value: mrb.MRBNumber, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@OriginatorID", mrb.OriginatorID);
@ -116,28 +111,12 @@ public class MRB_DMO {
}
//List<int> dispositionIDs = mrb.DispositionIDs;
//if (dispositionIDs != null)
//{
// parameters = new DynamicParameters();
// parameters.Add("@MRBNumber", mrb.MRBNumber);
// this.db.Execute("MRBDeleteDispositionsByMRB", parameters, commandType: CommandType.StoredProcedure);
// foreach (int dispositionID in dispositionIDs)
// {
// parameters = new DynamicParameters();
// parameters.Add("@MRBNumber", mrb.MRBNumber);
// parameters.Add("@DispositionID", dispositionID);
// this.db.Execute("MRBInsertDispositionsByMRB", parameters, commandType: CommandType.StoredProcedure);
// }
//}
transanction.Complete();
}
}
internal MRB GetMRBItem(int mrbNumber, out int isITAR, int userID) {
//IsITAR
// IsITAR
// 0 = false
// 1 = true
// 2 = not required
@ -208,10 +187,6 @@ public class MRB_DMO {
}
internal IEnumerable<Disposition> GetDispositions(int mrbNumber) {
//var disposition = this.db.Query<Disposition>("MRBGetDispositionsByMRB", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure).ToList();
// StringBuilder sql = new StringBuilder();
db.Open();
List<Disposition> disposition = db.Query<Disposition, CloseToQDBOptionViewModel, Disposition>
(
@ -266,8 +241,6 @@ public class MRB_DMO {
}
internal IEnumerable<MRBHoldFlagReport> GetMRBHoldFlagReport(int mrbNumber) {
//db.Open();
string sql = "SELECT * FROM MRBHoldFlagReport WHERE MRBNumber = @MRBNumber ORDER BY LotNo";
List<MRBHoldFlagReport> data = db.Query<MRBHoldFlagReport>(sql, new { MRBNumber = mrbNumber }).ToList();
@ -275,8 +248,6 @@ public class MRB_DMO {
}
internal IEnumerable<MRBLotsTobeSentToSPN> GetMRHoldFlagSentHistory(int mrbNumber) {
//db.Open();
string sql = "SELECT * FROM MRBLotsToBeSentToSPN WHERE MRBNumber = @MRBNumber ORDER BY LotNumber";
List<MRBLotsTobeSentToSPN> data = db.Query<MRBLotsTobeSentToSPN>(sql, new { MRBNumber = mrbNumber }).ToList();
@ -284,7 +255,6 @@ public class MRB_DMO {
}
internal IEnumerable<string> GetTools() =>
//return db.Query<string>("SELECT DISTINCT RTRIM(WO_STATION_ID) AS ToolID from vFAB2SPN_WO_RECORD ORDER BY 1").ToList();
db.Query<string>("SELECT 'NA', '1' UNION SELECT DISTINCT LTRIM(RTRIM(ToolID)),LTRIM(RTRIM(ToolID)) FROM [TEMIRWAP019].[SPNPDB].[dbo].[tblToolGroups2] ORDER BY 2").ToList();
internal MRB GetToolIssueStartEndDateData(int mrbNumber, IDbTransaction dbTrans = null) {
@ -322,17 +292,6 @@ public class MRB_DMO {
var analysisTime = DateTime.Now;
// get mrb info
//var mrbInfo = db.Query(
// "SELECT ToolCSV, IssueStartDate, IssueEndDate FROM MRB WHERE MRBNumber = @mrbNo",
// new { mrbNo = mrbNumber }).First();
//var tools = ((string)mrbInfo.ToolCSV).Split(',');
//DateTime? issueStartDate = mrbInfo.IssueStartDate;
//DateTime? issueEndDate = mrbInfo.IssueEndDate;
//if (issueStartDate.HasValue == false) throw new Exception("MRB Issue Start Date cannot be blank");
//if (issueEndDate.HasValue == false) throw new Exception("MRB Issue End Date cannot be blank");
// search WO for MRB tools between incident start+end to find the earliest WO record for this lot and use the Out time
DateTime? incidentTime = null;
@ -340,7 +299,6 @@ public class MRB_DMO {
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
incidentTime = db.Query<DateTime?>(
"SELECT MIN(OutTime) FROM WO_RECORD_MJ " +
//"SELECT MIN(OutTime) FROM vFAB2SPN_WO_RECORD " +
"WHERE WO_LOT_NO = @LotNo " +
"AND WO_STATION_ID IN @Tools " +
"AND (InTime BETWEEN @StartDate AND @EndDate " +
@ -377,14 +335,12 @@ public class MRB_DMO {
string parmsXML =
new System.Xml.Linq.XElement("IssueStartDate", issueStartDate).ToString() +
new System.Xml.Linq.XElement("IssueEndDate", issueEndDate).ToString() +
//new System.Xml.Linq.XElement("ToolCSV", (string)mrbInfo.ToolCSV).ToString();
new System.Xml.Linq.XElement("ToolCSV", toolCSV).ToString();
IEnumerable<LotSplitAnalysisResult> analysisResults = null;
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
analysisResults = db.Query<LotSplitAnalysisResult>(
"AnalyzeLotAncestry_TEST",
//"AnalyzeLotAncestry",
new {
LotNo = incidentLotNo,
IncidentTime = incidentTime,
@ -524,15 +480,11 @@ public class MRB_DMO {
/// </summary>
internal bool ChildLotsUpdateInSPNWithNewDispoType(Lot parentLot, MRB mrb) {
//db.Open();
//var dbTrans = db.BeginTransaction();
var analysisTime = DateTime.Now;
DateTime? incidentTime = null;
//var tools = ((string)mrb.ToolCSV).Split(',');
//This is the "time", when the lot was first uploaded into the system
//Get the child lots that were split after this datetime
// This is the "time", when the lot was first uploaded into the system
// Get the child lots that were split after this datetime
incidentTime = db.Query<DateTime?>(
"SELECT InsertDateTimeStamp FROM MRBLot " +
@ -583,10 +535,6 @@ public class MRB_DMO {
db.Open();
var dbTrans = db.BeginTransaction();
//var newAnalysisResults = from r in analysisResults
// where r.IsAffected.HasValue && r.IsAffected == true
// select r;
IEnumerable<LotSplitAnalysisResult> newAnalysisResults = analysisResults.Where(r => r.IsAffected.HasValue && r.IsAffected == true).ToList();
try {
// insert lots
@ -744,31 +692,9 @@ public class MRB_DMO {
db.Execute("MRBUpdateLot", parameters, commandType: CommandType.StoredProcedure, transaction: dbTrans);
////routine to cascade the "dispo type" to all the child lots in SPN (Lot that are not present in FAb App Sys,)
//MRB mrbInfo = GetToolIssueStartEndDateData(lot.MRBNumber, dbTrans);
// routine to cascade the "dispo type" to all the child lots in SPN (Lot that are not present in FAb App Sys,)
// MRB mrbInfo = GetToolIssueStartEndDateData(lot.MRBNumber, dbTrans);
//if (!mrbInfo.ToolCSV.ToUpper().Equals("NA"))
//{
// bool existingLotUpdated;
// Lot l = new Lot();
// l.LotNumber = lot.LotNumber;
// if (lot.DispoType.ToString().Trim().Length == 1)
// {
// l.DispoType = lot.DispoType;
// }
// l.MRBNumber = lot.MRBNumber;
// // check if the lot was sent to SPN
// bool lotSentToSPN = IsLotSentToSPN(l.LotNumber, l.MRBNumber, dbTrans);
// //only get the child lots if it has been sent to SPN to set the MRB Flag
// if (lotSentToSPN)
// {
// if (!GetChildLotsFromSPNForDispoTypeUpdate(lot.MRBNumber, lot.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate, lot.DispoType, dbTrans))
// {
// //warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n", l.LotNumber);
// }
// }
//}
dbTrans.Commit();
} catch {
@ -817,18 +743,6 @@ public class MRB_DMO {
return db.Query<MRBAttachment>(sql.ToString(), new { AttachmentID = attachmentID }).SingleOrDefault();
}
//internal IEnumerable<MRBAttachment> GetMRBAttachmentsByFilename(string fileName)
//{
// StringBuilder sql = new StringBuilder();
// sql.Append("SELECT A.AttachmentID, A.MRBNumber, A.FileName, A.UserID, CONVERT(VARCHAR(10), A.UploadDate, 101) AS UploadDate, ");
// sql.Append("U.FirstName + ' ' + U.LastName AS FullName ");
// sql.Append("FROM MRBAttachment A INNER JOIN Users U ON A.UserID = U.UserID ");
// sql.Append("WHERE A.Filename = @filename");
// var attachments = this.db.Query<MRBAttachment>(sql.ToString(), new { filename = fileName }).ToList();
// return attachments;
//}
internal void DeleteMRBAttachment(int attachmentID) {
DynamicParameters parameters = new();
parameters.Add("@AttachmentID", attachmentID);
@ -846,11 +760,6 @@ public class MRB_DMO {
}
internal IEnumerable<ContainmentActionObj> GetContainmentActions(int mrbNumber) {
//db.Open();
//string sql = "SELECT * FROM MRBContainmentAction WHERE MRBNumber = " + mrbNumber;
//var data = this.db.Query<ContainmentActionObj>(sql).ToList();
DynamicParameters parameters = new();
parameters.Add("@MRBNumber", mrbNumber);
@ -864,7 +773,6 @@ public class MRB_DMO {
parameters.Add("@ContainmentActionID", model.ContainmentActionID, DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@MRBNumber", model.MRBNumber);
parameters.Add("@ContainmentAction", model.ContainmentAction);
//parameters.Add("@ResponsibilityOwner", model.ResponsibilityOwner);
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
parameters.Add("@ECD", model.ECD);
parameters.Add("@ImplementedDate", model.ImplementedDate);
@ -880,7 +788,6 @@ public class MRB_DMO {
parameters.Add("@ContainmentActionID", model.ContainmentActionID);
parameters.Add("@ContainmentAction", model.ContainmentAction);
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
//parameters.Add("@ResponsibilityOwner", model.ResponsibilityOwner);
parameters.Add("@ECD", model.ECD);
parameters.Add("@ImplementedDate", model.ImplementedDate);
@ -914,9 +821,6 @@ public class MRB_DMO {
db.Execute("UPDATE MRB SET ApprovalStatus = " + (int)GlobalVars.ApprovalOption.Closed + ", CloseDate = GETDATE() WHERE MRBNumber = " + mrbNumber, commandType: CommandType.Text);
internal void SetDispositionTypeForAllLots(int mrbNumber, string dispoType) =>
//var sql = "UPDATE MRBLot SET DispoType = '" + dispoType + "' WHERE MRBNumber = " + mrbNumber;
//this.db.Execute(sql, commandType: CommandType.Text);
db.Execute("MRBSetDispositionTypeForAllLots", new { @MRBNumber = mrbNumber, @DispoType = dispoType }, commandType: CommandType.StoredProcedure);
internal void GetLotWaferDieCount(int mrbNumber, out int lotCount, out int waferCount, out int dieCount) {
@ -945,18 +849,6 @@ public class MRB_DMO {
internal void LogHoldFlagSentToSPNHistory(int mrbNumber) =>
db.Execute("MRBLogHoldFlagSentToSPNHistory", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure);
//internal IEnumerable<string> GetSPN_MRB_HoldFlagLots(int mrbNumber)
//{
// var disposition = this.db.Query<string>("MRBGet_SPN_HoldLots", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure).ToList();
// return disposition;
//}
//internal void InsertSPN_MRB_HoldFlagLots(int mrbNumber)
//{
// var disposition = this.db.Query<string>("MRBInsertSPN_HoldFlagLots", new { @MRBNumber = mrbNumber }, commandType: CommandType.StoredProcedure).ToList();
// //return disposition;
//}
internal void InsertMRB_QDB_HoldFlag(string guid, string data, string operation) {
string[] tempData = data.Split(new char[] { '~' });
@ -981,12 +873,6 @@ public class MRB_DMO {
db.Execute("MRBUpdateQDB_HoldProcessedFlag", parameters, commandType: CommandType.StoredProcedure);
}
//internal IEnumerable<string> GetLotsForMRBHoldFlags(string guid)
//{
// var data = this.db.Query<string>("MRBGetMRB_QDB_HoldFlags", new { @Guid = guid }, commandType: CommandType.StoredProcedure).ToList();
// return data;
//}
public IEnumerable<CAUserList> GetUserList() {
DynamicParameters parameters = new();
List<CAUserList> userList = db.Query<CAUserList>("_8DGetUserList", parameters, commandType: CommandType.StoredProcedure).ToList();
@ -1013,319 +899,4 @@ public class MRB_DMO {
return sb.ToString();
}
public string ImportRemoveQDBFlag(string operation, out string physicalPath, string userIdentityName, string a, string b, string c, string fullFileName, Stream stream) {
IEnumerable<string> lotDataList = null;
var guid = Guid.NewGuid().ToString();
var fileExtension = Path.GetExtension(fullFileName);
physicalPath = Path.Combine(_AppSettings.LotTempPipeLine, guid + "." + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
#if !NET8
ExcelData x = new ExcelData(physicalPath);
lotDataList = x.ReadQDBFlagData();
foreach (string lotData in lotDataList) {
InsertMRB_QDB_HoldFlag(guid, lotData, operation);
}
#endif
FileInfo f = new(physicalPath);
if (f.Exists)
f.Delete();
//Send the data to SPN
if (SendQDBFlagToSPN(guid, userIdentityName, a, b, c))
UpdateMRB_QDB_HoldFlag(guid, true);
else {
UpdateMRB_QDB_HoldFlag(guid, false);
return "Problems while uploading to SPN";
}
return string.Empty;
}
public bool BatchFTP(string sourceFile, string destFile, string ftpLogDirectory, string userIdentityName, string a, string b, string c) {
FileInfo sourcefile = new(sourceFile);
//FileInfo sourcefile = new FileInfo(@"C:\Websites\ECNViewerAckResultToSPN\S15122017102017.ecn");
try {
//Functions.WriteEvent("HR Emp", "SPNData - Start Send(): FTPing " + sourceFile + " to SPN server.", System.Diagnostics.EventLogEntryType.Information);
//System.Security.SecureString ss = new System.Security.SecureString();
//foreach (char c in credentialsStorage.Password)
// ss.AppendChar(c);
ProcessStartInfo psiFab1 = new();
Process procFab1 = new();
StringBuilder sb = new();
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
psiFab1.FileName = a; // Server.MapPath("/FTPBatch/" + @Functions.FTPSPNBatch_Test());
} else {
psiFab1.FileName = b; // Server.MapPath("/FTPBatch/" + @Functions.FTPSPNBatch());
}
psiFab1.Arguments = sourcefile.FullName + " " + destFile;
psiFab1.RedirectStandardOutput = true;
psiFab1.UseShellExecute = false;
psiFab1.WorkingDirectory = c; // Server.MapPath("/FTPBatch/");
//credentialsStorage = MiscDMO.GetCredentialsInfo("TEMSA01EC", "LocalAdmin");
//psiFab1.UserName = credentialsStorage.UserName;
//psiFab1.Password = ss;
procFab1.StartInfo = psiFab1;
procFab1.OutputDataReceived += (sender, args) => sb.AppendLine(args.Data);
;
procFab1.Start();
procFab1.BeginOutputReadLine();
procFab1.WaitForExit(4000);
File.WriteAllText(Path.Combine(ftpLogDirectory, sourcefile.Name + ".txt"), sb.ToString());
//procFab1.StartInfo = psiFab1;
//procFab1.Start();
//Functions.WriteEvent("HR Emp", "SPNData - Finish FTPing to SPN server.", System.Diagnostics.EventLogEntryType.Information);
return true;
} catch (Exception e) {
Functions.WriteEvent(_AppSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
return false;
}
}
public bool SendQDBFlagToSPN(string guid, string userIdentityName, string a, string b, string c) {
StringBuilder output = new();
try {
IEnumerable<string> data = GetMRB_QDB_HoldFlags(guid);
foreach (string tempData in data) {
//output = new StringBuilder();
output.Append(tempData.Trim() + Environment.NewLine);
}
try {
if (output.Length > 0) {
DateTime dt = DateTime.Now;
string newsourceFileName = "S" + dt.Day.ToString("00") + dt.Month.ToString("00") + dt.Year.ToString("00") + dt.Hour.ToString("00") + dt.Minute.ToString("00") + dt.Second.ToString("00") + ".mrb";
string newDestFileName = "S" + dt.Hour.ToString("00") + dt.Minute.ToString("00") + dt.Second.ToString("00") + ".mrb";
//string outputFile = @"C:\Websites\SPNLotHoldFlag\" + newsourceFileName;
string outputFile = _AppSettings.HoldFlagDirectory + newsourceFileName;
File.WriteAllText(outputFile, output.ToString());
#if (DEBUG)
Thread.Sleep(1000);
#endif
try {
//#if (!DEBUG)
//FTPWrapper spfSPN = new FTPWrapper(outputFile, newDestFileName);
//spfSPN.FTPToSPN();
if (BatchFTP(outputFile, newDestFileName, _AppSettings.SPNMRBHoldFlagFTPLogDirectory, userIdentityName, a, b, c)) {
UpdateMRB_QDB_HoldFlag(guid, true);
} else {
UpdateMRB_QDB_HoldFlag(guid, false);
}
//#endif
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + guid.ToString() + " FTPToSPN(): FTP Upload Error " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return false;
}
}
return true;
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "MRB =" + guid.ToString() + " SPN Hold Flag(SendToSPN) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return false;
}
} catch (Exception e) {
string exceptionString = e.Message.ToString().Trim().Length > 500 ? "GUID =" + guid.ToString() + " SPN Hold Flag(SendToSPN) " + e.Message.ToString().Substring(0, 250) : e.Message.ToString();
Functions.WriteEvent(_AppSettings, userIdentityName + "\r\n Approve\r\n" + e.Message.ToString(), EventLogEntryType.Error);
EventLogDMO.Add(new WinEventLog() { IssueID = -1, UserID = userIdentityName, DocumentType = "MRB", OperationType = "Error", Comments = exceptionString });
return false;
}
}
public string ImportAddQDBFlag(string operation, out string physicalPath, string userIdentityName, string a, string b, string c, string fullFileName, Stream stream) {
IEnumerable<string> lotDataList = null;
var guid = Guid.NewGuid().ToString();
var fileExtension = Path.GetExtension(fullFileName);
physicalPath = Path.Combine(_AppSettings.LotTempPipeLine, guid + "." + fileExtension);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
#if !NET8
ExcelData x = new ExcelData(physicalPath);
lotDataList = x.ReadQDBFlagData();
foreach (string lotData in lotDataList) {
InsertMRB_QDB_HoldFlag(guid, lotData, operation);
}
#endif
FileInfo f = new(physicalPath);
if (f.Exists)
f.Delete();
if (SendQDBFlagToSPN(guid, userIdentityName, a, b, c))
UpdateMRB_QDB_HoldFlag(guid, true);
else {
UpdateMRB_QDB_HoldFlag(guid, false);
return "Problems while uploading to SPN";
}
return string.Empty;
}
public void AttachSave(int mrbNumber, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
string physicalFileName;
string physicalPath;
// Check to see if this filename is in use
var attachments = GetMRBAttachments(mrbNumber);
if (attachments.Count() > 0) {
if (attachments.Count(a => string.Equals(a.FileName, fileName, StringComparison.OrdinalIgnoreCase)) > 0) {
// This filename is used on this MRB
// So we want to delete those records so the new record replaces them
foreach (var a in attachments) {
DeleteMRBAttachment(a.AttachmentID);
physicalFileName = a.Path;
if (string.IsNullOrEmpty(physicalFileName))
physicalFileName = a.FileName;
physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "MRB", physicalFileName);
if (File.Exists(physicalPath))
File.Delete(physicalPath);
}
}
}
physicalFileName = mrbNumber.ToString() + "_" + Guid.NewGuid().ToString() + Path.GetExtension(fileName);
physicalPath = Path.Combine(_AppSettings.AttachmentFolder + "MRB", physicalFileName);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
MRBAttachment attach = new() {
MRBNumber = mrbNumber,
FileName = fileName,
Path = physicalFileName,
#if (DEBUG)
UserID = 114,
#endif
#if (!DEBUG)
UserID = userId,
#endif
};
InsertMRBAttachment(attach);
}
public string ExcelLotOpen(int mrbNumber, StringBuilder warnings, IEnumerable<Disposition> dispos, string userIdentityName, string lotTempPipeLine, string fullFileName, Stream stream) {
var fileName = Path.GetFileName(fullFileName);
var fileExtension = Path.GetExtension(fullFileName);
string fName = userIdentityName + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
string physicalPath = Path.Combine(lotTempPipeLine, fName + "." + fileExtension);
#if !NET8
IEnumerable<ExcelData.ExcelLotInfo> lotNumbers;
try {
using (var fileStream = new FileStream(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
ExcelData x = new ExcelData(physicalPath);
lotNumbers = x.ReadData();
} catch (Exception ex) {
throw new Exception(String.Format("Invalid file format for {0}: {1}", fileName, ex.Message));
}
// Get Tool, Issue Start and End Date
MRB mrbInfo = GetToolIssueStartEndDateData(mrbNumber, null);
foreach (var lotInfo in lotNumbers) {
if (lotInfo.LotDispo.Length == 1) {
if (dispos.Count(d => d.DispositionType.Trim().ToUpper() == lotInfo.LotDispo.Trim().ToUpper()) == 0) {
throw new Exception(String.Format("Invalid lot disposition {0} for lot no {1}",
lotInfo.LotDispo, lotInfo.LotNo));
}
}
}
// RJK - 12/17
// Only find the child Splits when a Tool or a list of Tools is provided
if (!mrbInfo.ToolCSV.ToUpper().Equals("NA")) {
foreach (var lotInfo in lotNumbers) {
bool existingLotUpdated;
Lot l = new Lot();
l.LotNumber = lotInfo.LotNo;
if (lotInfo.LotDispo.Length == 1) {
l.DispoType = lotInfo.LotDispo[0];
}
l.MRBNumber = mrbNumber;
InsertLot(l, true, out existingLotUpdated);
// cannot do the check below , because what if the parent lot had splits after the prior lot split analysis
//if (!existingLotUpdated)
//{
if (!InsertLotSplitsAffectedByIncident(mrbNumber, l.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate)) {
warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n Uploaded without Lot Genealogy tracing", l.LotNumber);
}
//}
}
// Not required - Will be using each lot's Insert Date time stamp,
// as lot could be added using search functionality
// UpdateLastLotSplitAnalysisTime(mrbNumber);
} else {
// RJK - 12/17
// Only find the child Splits when a Tool or a list of Tools is provided
foreach (var lotInfo in lotNumbers) {
bool existingLotUpdated;
Lot l = new Lot();
l.LotNumber = lotInfo.LotNo;
if (lotInfo.LotDispo.Length == 1) {
l.DispoType = lotInfo.LotDispo[0];
}
l.MRBNumber = mrbNumber;
// do not insert any new lots when importing from excel
InsertLot(l, true, out existingLotUpdated);
//UpdateLotDispoType(mrbNumber, l.LotNumber, l.DispoType);
//if (!existingLotUpdated)
//{
// if (!InsertLotSplitsAffectedByIncident(mrbNumber, l.LotNumber, mrbInfo.ToolCSV, mrbInfo.IssueStartDate, mrbInfo.IssueEndDate))
// {
// warnings.AppendFormat("Lot number {0} is not affected by these tools and issue start/end time.\n", l.LotNumber);
// }
//}
}
}
#endif
FileInfo f = new(physicalPath);
if (f.Exists)
f.Delete();
return physicalPath;
}
}

View File

@ -22,7 +22,6 @@ public class MiscDMO {
string sql = "";
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY") {
if (searchBy == GlobalVars.LOT_NO)
//sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM WP_RECORD_MJ WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
else if (searchBy == GlobalVars.LOCATION) {
sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM SPNLot WHERE WP_CURRENT_LOCATION = '" + searchText.Trim() + "' AND WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') IS NOT NULL";
@ -73,13 +72,6 @@ public class MiscDMO {
sql.Append("SELECT PartNumber + '~' + SiliconPart + '~' + ProcessFlow + '~' + PartDescription AS WIPPartData ");
sql.Append("FROM vWIPPartData WHERE PartNumber LIKE '%" + searchText + "%' ORDER BY PartNumber");
//StringBuilder sql = new StringBuilder();
//sql.Append("SELECT TO_PART AS PartNumber, FROM_PART AS SiliconPart, P.MP_DESCRIPTION AS PartDescirption, ");
//sql.Append("RTRIM(LTRIM(SUBSTRING(TO_PART_PROC, PATINDEX('% %', TO_PART_PROC), LEN(TO_PART_PROC)))) AS ProcessFlow ");
//sql.Append("FROM TEMIRWAP019.FAB2SPN.dbo.PG_RECORD W ");
//sql.Append("INNER JOIN TEMIRWAP019.Fab2SPN.dbo.MP_RECORD P ON W.TO_PART = P.MP_PART_NUMBER ");
//sql.Append("WHERE PartNumber LIKE '%" + searchText + "%' ORDER BY PartNumber ");
List<WIPPart> parList = db.Query<WIPPart>(sql.ToString()).ToList();
db.Close();
return parList;
@ -92,7 +84,6 @@ public class MiscDMO {
qryLotInfo.Append("WP_CURRENT_QTY, WP_CURRENT_LOCATION, DieLotNumber, DiePartNo, DieCount, MP_QUALITY_CODE FROM SPNLot ");
qryLotInfo.Append("WHERE WP_Lot_No = @LotNumber ");
//var tempLotNumber = lot.LotNumber.Substring(0, 9);
var tempLotNumber = "";
if (lot.LotNumber.IndexOf('/') >= 0) {
tempLotNumber = lot.LotNumber.Substring(0, lot.LotNumber.IndexOf('/'));
@ -113,7 +104,7 @@ public class MiscDMO {
// The data is returned from a view which is a combination from various sources and at times when the
// Lot is at the QDB location, which is extracted out of SAP, it also shows up at the 6600 location in SPN.
// There is a duplication.
//if the result returns 2 records , QDB overrides the other location (6600)
// if the result returns 2 records , QDB overrides the other location (6600)
if (lot.Location == "QDB" && lotInfoColumn.WP_CURRENT_LOCATION == "6600")
lot.Location = "QDB";
else
@ -130,14 +121,13 @@ public class MiscDMO {
} catch { } // ignore the error
try {
//lot.Gen = double.Parse(temp[2].Substring(1, temp[2].Length - 1));
if (lot.Description.StartsWith("MA,"))
lot.Gen = temp[2];
else
lot.Gen = temp[2].Substring(1, temp[2].Length - 1);
} catch { }// ignore the error
try {
//lot.Hexsize = double.Parse(temp[6]);
// lot.Hexsize = double.Parse(temp[6]);
lot.Hexsize = temp[6];
} catch { }// ignore the error
@ -184,8 +174,6 @@ public class MiscDMO {
}
// added this code if the data shows up at the 6600 location and also at QDB for a lot.
//if (lot.DieCost > 0)
// lot.Location = "QDB";
if (lotInfoColumn.MP_QUALITY_CODE != null)
lot.QualityCode = lotInfoColumn.MP_QUALITY_CODE.Trim();
@ -193,12 +181,8 @@ public class MiscDMO {
}
db.Close();
//return lotStatusOption;
}
/// <summary>
/// /
/// </summary>
public static IEnumerable<UserProfile> GetUserList() {
IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
@ -358,14 +342,6 @@ public class MiscDMO {
public static void GetLTLotInformation(LTLot lot) {
IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
StringBuilder qryLotInfo = new();
//qryLotInfo.Append("SELECT DISTINCT ");
//qryLotInfo.Append("WP_LOT_NO, WP_CURRENT_QTY, WP.WP_PART_NUMBER, MP_DESCRIPTION, WP_PROCESS, WO_LOCATION, WO_OPER_NO, WP_STATUS ");
//qryLotInfo.Append("FROM TEMIRWAP019.FAB2SPN.dbo.WO_RECORD WO ");
//qryLotInfo.Append("INNER JOIN TEMIRWAP019.FAB2SPN.dbo.WP_RECORD WP ");
//qryLotInfo.Append("ON WO.WO_LOT_NO = WP.WP_LOT_NO AND WO.InTime = (SELECT MAX(InTime) FROM TEMIRWAP019.FAB2SPN.dbo.WO_RECORD WHERE WO_LOT_NO = @LotNumber) ");
//qryLotInfo.Append("LEFT JOIN TEMIRWAP019.FAB2SPN.dbo.MP_RECORD MP ");
//qryLotInfo.Append("ON WP.WP_PART_NUMBER = MP.MP_PART_NUMBER ");
//qryLotInfo.Append("WHERE WO_LOT_NO = @LotNumber ");
qryLotInfo.Append("SELECT DISTINCT ");
qryLotInfo.Append("WP_LOT_NO, WP_CURRENT_QTY, WP.WP_PART_NUMBER, MP_DESCRIPTION, WP_PROCESS, WP_CURRENT_LOCATION, WP_OPER_NO, WP_STATUS ");
@ -374,8 +350,6 @@ public class MiscDMO {
qryLotInfo.Append("ON WP.WP_PART_NUMBER = MP.MP_PART_NUMBER ");
qryLotInfo.Append("WHERE WP_LOT_NO = @LotNumber ");
//var tempLotNumber = lot.LotNumber.Substring(0, 9);
var tempLotNumber = "";
if (lot.LotNumber.IndexOf('/') >= 0) {
tempLotNumber = lot.LotNumber.Substring(0, lot.LotNumber.IndexOf('/'));
@ -437,7 +411,6 @@ public class MiscDMO {
DynamicParameters parameters = new();
parameters.Add("@ApprovalId", approvalId);
db.Query<CredentialsStorage>("UpdateApprovalLastNotifyDate", param: parameters, commandType: CommandType.StoredProcedure).Single();
//return data;
}
//================================================================== End of Class
}

View File

@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using Dapper;
@ -13,12 +12,8 @@ namespace Fab2ApprovalSystem.DMO;
public class PartsRequestDMO {
private readonly AppSettings _AppSettings;
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
public PartsRequestDMO(AppSettings appSettings) =>
_AppSettings = appSettings;
public IEnumerable<PartsRequestList> GetPartsRequestList() {
List<PartsRequestList> r = db.Query<PartsRequestList>("PartsRequestGetList", commandType: CommandType.StoredProcedure).ToList();
return r;
@ -114,28 +109,4 @@ public class PartsRequestDMO {
db.Execute("PartsRequestDelete", parameters, commandType: CommandType.StoredProcedure);
}
public void AttachSave(int prNumber, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
string prFolderPath = _AppSettings.AttachmentFolder + "PartsRequest\\" + prNumber.ToString();
DirectoryInfo di = new(prFolderPath);
if (!di.Exists)
di.Create();
var physicalPath = Path.Combine(prFolderPath, fileName);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
PartsRequestAttachment attach = new() {
PRNumber = prNumber,
FileName = fileName,
UserID = userId,
};
InsertAttachment(attach);
}
}

View File

@ -13,7 +13,6 @@ public class SAM_DMO {
public int HasITARAccess(string userID) {
StringBuilder query = new("SELECT COUNT(*) FROM dbo.fnIsUserITARCompliant(@UserID) ");
//query.Append("WHERE UserID = @UserID AND AND EmployeeStatus = 'Active'");
return db.Query<int>(query.ToString(), new { UserID = userID }).SingleOrDefault();
}

View File

@ -19,8 +19,6 @@ public class TrainingDMO {
public int Create(int issueId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@TrainingId", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@ECNNumber", issueId);
@ -32,9 +30,6 @@ public class TrainingDMO {
public int CreateAssignment(int trainingId, int userId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
//parameters.Add("@TrainingId", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@TrainingID", trainingId);
parameters.Add("@UserID", userId);
parameters.Add("@AssignmentID", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
@ -147,9 +142,6 @@ public class TrainingDMO {
public void AddTrainingGroupToECN(int ECNNumber, int groupId) {
#if !NET8
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
//ECNTrainingBy ecnTraining = new ECNTrainingBy();
//ecnTraining.AcknowledgementTrainingByID = groupId;
//ecnTraining.ECNNumber = ECNNumber;
var parameters = new DynamicParameters();
parameters.Add("@ECNNumber", ECNNumber);
@ -157,7 +149,6 @@ public class TrainingDMO {
this.db.Execute("ECNInsertTrainingBy", parameters, commandType: CommandType.StoredProcedure);
//db.ECNTrainingBies.Add(ecnTraining);
#else
throw new NotImplementedException();
#endif
@ -166,16 +157,11 @@ public class TrainingDMO {
public void SetTrainingFlag(int ECNNumber) {
#if !NET8
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
//ECNTrainingBy ecnTraining = new ECNTrainingBy();
//ecnTraining.AcknowledgementTrainingByID = groupId;
//ecnTraining.ECNNumber = ECNNumber;
var parameters = new DynamicParameters();
parameters.Add("@ECNNumber", ECNNumber);
this.db.Execute("ECNSetTrainingFlag", parameters, commandType: CommandType.StoredProcedure);
//db.ECNTrainingBies.Add(ecnTraining);
#else
throw new NotImplementedException();
#endif
@ -235,10 +221,7 @@ public class TrainingDMO {
public void AcknowledgeDocument(int trainingDocAckID) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@TrainingDocAckID", trainingDocAckID);
//parameters.Add("@AttachmentID", attachmentID);
db.Execute("TrainingAcknowledgeDocument", parameters, commandType: CommandType.StoredProcedure);
}
@ -337,7 +320,7 @@ public class TrainingDMO {
#if !NET8
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
bool isFinished = true;
//TrainingDocAck docsAssigned = null;
// TrainingDocAck docsAssigned = null;
var docsAssigned = from a in db.TrainingDocAcks where a.TrainingAssignmentID == trainingAssignmentID && a.Deleted != true select a;
@ -447,7 +430,6 @@ public class TrainingDMO {
foreach (TrainingAssignment trainingAssignment in trainingAssignments) {
DeleteTrainingAssignment(trainingAssignment.ID);
DeleteTrainingDocAck(trainingAssignment.ID);
//db.SaveChanges();
}
#else
throw new NotImplementedException();
@ -461,9 +443,9 @@ public class TrainingDMO {
var userAssignments = (from a in db.TrainingAssignments where a.UserID == userId select a).ToList();
foreach (var item in userAssignments) {
//get document assignments
// get document assignments
var docAssignments = (from a in db.TrainingDocAcks where a.TrainingAssignmentID == item.TrainingID select a).ToList();
//delete each docAssignment
// delete each docAssignment
foreach (var docAssignment in docAssignments) {
DeleteTrainingDocAck(docAssignment.ID);
}
@ -479,15 +461,15 @@ public class TrainingDMO {
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
TrainingDocAck ack = (from a in db.TrainingDocAcks where a.ID == docAckId select a).FirstOrDefault();
//TODO Check the user is valid
// TODO Check the user is valid
//Check that the assignment exists
// Check that the assignment exists
if (ack != null) {
//Check that the assignment isn't deleted
// Check that the assignment isn't deleted
if (ack.Deleted == true) {
return false;
}
//Check that the assignment isn't completed
// Check that the assignment isn't completed
else if (ack.Reviewed == true) {
return false;
} else {

View File

@ -17,11 +17,6 @@ public class UserAccountDMO {
public IEnumerable<LoginModel> GetAllUsers() {
StringBuilder sql = new();
//sql.Append("SELECT U.FirstName + ' ' + U.LastName AS FullName, U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName, U.* ");
//sql.Append("FROM Users U LEFT JOIN Users U1 ");
//sql.Append("ON U.UserID = U1.DelegatedTo ORDER BY FirstName ");
//sql.Append("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users ORDER BY FirstName ");
sql.Append(" SELECT U.FirstName + ' ' + U.LastName AS FullName, U.* , U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName ");
sql.Append("FROM Users U LEFT JOIN Users U1 ON U.DelegatedTo = U1.UserID ");
sql.Append("ORDER BY FirstName ");
@ -31,11 +26,6 @@ public class UserAccountDMO {
public IEnumerable<LoginModel> GetAllActiveUsers() {
StringBuilder sql = new();
//sql.Append("SELECT U.FirstName + ' ' + U.LastName AS FullName, U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName, U.* ");
//sql.Append("FROM Users U LEFT JOIN Users U1 ");
//sql.Append("ON U.UserID = U1.DelegatedTo ORDER BY FirstName ");
//sql.Append("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users ORDER BY FirstName ");
sql.Append(" SELECT U.FirstName + ' ' + U.LastName AS FullName, U.* , U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName ");
sql.Append("FROM Users U LEFT JOIN Users U1 ON U.DelegatedTo = U1.UserID ");
sql.Append("WHERE U.IsActive = 1 ");
@ -45,9 +35,6 @@ public class UserAccountDMO {
}
public LoginModel GetUser(string loginID) =>
//StringBuilder sql = new StringBuilder();
//sql.Append("SELECT * FROM Users WHERE LoginID = '" + loginID + "'");
//return this.db.Query<LoginModel>(sql.ToString()).SingleOrDefault();
db.Query<LoginModel>("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users WHERE LoginID = @loginID AND IsActive = 1 ", new { loginID = loginID }).Take(1).SingleOrDefault();
public LoginModel GetUserByID(int userID) {
@ -79,7 +66,6 @@ public class UserAccountDMO {
internal void DeleteUser(LoginModel model) {
string sql;
//sql = "DELETE Users WHERE UserID = @UserID";
sql = "UPDATE Users SET IsActive = 0 WHERE UserID = @UserID";
DynamicParameters parameters = new();
parameters.Add("@UserID", model.UserID);
@ -88,8 +74,6 @@ public class UserAccountDMO {
}
internal void InsertUser(LoginModel model) {
//string sql;
//sql = "INSERT Users (LoginID, FirstName, LastName, IsAdmin) VALUES (@LoginID, @FirstName, @LastName, @IsAdmin )";
DynamicParameters parameters = new();
parameters.Add("@UserID", model.UserID, DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@LoginID", model.LoginID);

View File

@ -15,18 +15,6 @@ namespace Fab2ApprovalSystem.DMO;
public class WorkflowDMO {
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
//delegate TResult MathFunction<T1, T2, TResult>(T1 var1, T2 var2);
//static void PrintResult<T1, T2, TResult>(MathFunction<T1, T2,
// TResult> mathFunction, T1 var1, T2 var2)
//{
// TResult result = mathFunction(var1, var2);
// Console.WriteLine(String.Format("Result is {0}", result));
//}
//PrintResult((x, y) => x / y, 2, 8);
//GenericDelegateNumber<int, int> e = new GenericDelegateNumber<int, int>(AddInt);
public string GetSubRoleItems(int issueID, int docType) {
List<string> subRoleItems = new();
StringBuilder sqlString = new();
@ -240,19 +228,10 @@ public class WorkflowDMO {
/* ===== Remove the code for Director Approval Loop - Changed per Dixie's request 08/06/2018
*/
//If Location = "QDB" OR PRRequired or MRB Required OR(Product = MA / RH AND Location = Probe) Get "Director" Role for all departments, except "Facilities"
sqlString = new StringBuilder();
//sqlString.Append("SELECT COUNT(*) FROM LotDisposition LD INNER JOIN Lot L ON LD.IssueID = L.IssueID ");
//sqlString.Append("WHERE ( ((L.ProductFamily = 'RH' OR L.ProductFamily = 'MA') ");
//sqlString.Append("AND (Location = '6300' OR Location = '6400' OR Location = '6600')) ");
//sqlString.Append("OR Location = 'QDB' OR Location = 'EDB' OR LD.PERequired = 1 OR LD.MRBRequired = 1) AND LD.IssueID = @IssueID ");
// 09/01/2020 -
// Per Hans, do not include directors if PE required is checked
//sqlString.Append("SELECT COUNT(*) FROM LotDisposition LD INNER JOIN Lot L ON LD.IssueID = L.IssueID ");
//sqlString.Append("WHERE (LD.PERequired = 1 OR Location = 'QDB' OR Location = 'EDB' ) ");
//sqlString.Append("AND LD.IssueID = @IssueID ");
// 09/01/2020
// Per Hans, do not include directors if PE required is checked
@ -300,7 +279,6 @@ public class WorkflowDMO {
int recordCount = 0;
// EMERGENCY TECNS ==============================================================================================
if (GlobalVars.DocumentType.EECN == (GlobalVars.DocumentType)documentType) {
//subRoleItems.Add("'QA Pre Approver'");
qryString.Clear();
qryString.Append("SELECT DISTINCT SRC.SubRoleCategoryItem FROM DocumentType D ");
qryString.Append("INNER JOIN Workflows W ON D.DocumentTypeID = W.DocumentTypeID ");
@ -309,25 +287,13 @@ public class WorkflowDMO {
qryString.Append("INNER JOIN SubRole SR ON R.RoleID = SR.RoleID ");
qryString.Append("INNER JOIN SubRoleCategory SRC ON SR.SubRoleCategoryID = SRC.SubRoleCategoryID ");
qryString.Append("WHERE D.DocumentTypeID = @DocumentType");
//qryString.Append("WHERE D.DocumentTypeID = 3");
//subRoleItems.Add("'QA_Admin'");
List<dynamic> dataRows = db.Query<dynamic>(qryString.ToString(), new { DocumentType = documentType }).ToList();
foreach (var dataRow in dataRows) {
subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
}
//subRoleItems.Add("'QA Final Approver'");
} //===============================================================================================================
else {
} else {
subRoleItems.Add("'QA Pre Approver'");
// get the affected Department: Removed by JRO per Jeanne
//qryString.Clear();
//qryString.Append("SELECT ModuleName FROM ECNModule E INNER JOIN ECNAffectedModule AM ON E.ModuleID = AM.ModuleID WHERE AM.ECNNumber= @ECNNumber");
//var dataRows = this.db.Query<dynamic>(qryString.ToString(), new { ECNNumber = ecnNumber }).ToList();
//foreach (var dataRow in dataRows)
//{
// subRoleItems.Add("'" + dataRow.ModuleName.ToString() + "'");
//}
// get the approvers
qryString.Clear();
qryString.Append("SELECT SubRoleCategoryItem FROM SubRoleCategory S INNER JOIN ECNAffectedDepartment AD ON S.SubRoleCategoryID = AD.DepartmentID WHERE AD.ECNNumber= @ECNNumber");
List<dynamic> dataRows = db.Query<dynamic>(qryString.ToString(), new { ECNNumber = ecnNumber }).ToList();
@ -346,13 +312,6 @@ public class WorkflowDMO {
recordCount = db.Query<int>(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
subRoleItems.Add("'Environment'");
//qryString.Clear();
//qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'Environment' ");
//dataRows = this.db.Query<dynamic>(qryString.ToString()).ToList();
//foreach (var dataRow in dataRows)
//{
// subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
//}
}
// Get the "Capacity" Impact SubRole
@ -361,13 +320,6 @@ public class WorkflowDMO {
recordCount = db.Query<int>(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
subRoleItems.Add("'Capacity'");
//qryString.Clear();
//qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'Capacity' ");
//dataRows = this.db.Query<dynamic>(qryString.ToString()).ToList();
//foreach (var dataRow in dataRows)
//{
// subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
//}
}
// Get the "MaterialConsumptionChangeRequired" Impact SubRole
@ -376,13 +328,6 @@ public class WorkflowDMO {
recordCount = db.Query<int>(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
subRoleItems.Add("'MaterialConsumption'");
//qryString.Clear();
//qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'MaterialConsumption' ");
//dataRows = this.db.Query<dynamic>(qryString.ToString()).ToList();
//foreach (var dataRow in dataRows)
//{
// subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
//}
}
// Get the "NewPartFlow" Impact SubRole
@ -392,21 +337,12 @@ public class WorkflowDMO {
if (recordCount > 0) {
subRoleItems.Add("'NewPartFlow'");
subRoleItems.Add("'SPN-Execution'");
//subRoleItems.Add("'TestProgram'");
subRoleItems.Add("'Metrology Change'");
subRoleItems.Add("'SPC'");
//qryString.Clear();
//qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'NewPartFlow' ");
//dataRows = this.db.Query<dynamic>(qryString.ToString()).ToList();
//foreach (var dataRow in dataRows)
//{
// subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
//}
}
subRoleItems.Add("'Document Control Admin'");
subRoleItems.Add("'Training Notification'");
//=======================================================================================================================
// Execution level========================================================================================================
// Get the "SPN" SubRole
@ -414,15 +350,6 @@ public class WorkflowDMO {
qryString.Append("SELECT COUNT(*) FROM ECN WHERE ECNNumber= @ECNNumber AND (SPNChangeRequired = 1) ");
recordCount = db.Query<int>(qryString.ToString(), new { ECNNumber = ecnNumber }).Single();
if (recordCount > 0) {
//subRoleItems.Add("'SPN-Execution'");
//qryString.Clear();
//qryString.Append("SELECT SubRoleCategoryItem FROM [SubRoleCategory] WHERE SubRoleCategoryItem = 'SPN' ");
//dataRows = this.db.Query<dynamic>(qryString.ToString()).ToList();
//foreach (var dataRow in dataRows)
//{
// subRoleItems.Add("'" + dataRow.SubRoleCategoryItem.ToString() + "'");
//}
}
// Get the "Metrology Change" SubRole
@ -622,11 +549,9 @@ public class WorkflowDMO {
public string ReAssignApproval(int issueID, int assignedFromUser, int assignedToUser, byte step, int docType) {
string email = "";
//string emailArray = "";
string emailIDArray = "";
DynamicParameters parameters = new();
;
email = "";
parameters = new DynamicParameters();
parameters.Add("@IssueID", issueID);
@ -644,11 +569,9 @@ public class WorkflowDMO {
public string DelegateDocumentApproval(int issueID, int delegateFromUser, int delegateToUser) {
string email = "";
//string emailArray = "";
string emailID = "";
DynamicParameters parameters = new();
;
email = "";
parameters = new DynamicParameters();
parameters.Add("@IssueID", issueID);
@ -664,13 +587,11 @@ public class WorkflowDMO {
public string AddAdditionalApproval(int issueID, string userIDs, byte step, int documentType) {
string email = "";
//string emailArray = "";
string emailIDArray = "";
string[] arrayOfUsers = userIDs.Split(new char[] { '~' });
DynamicParameters parameters = new();
;
for (int i = 0; i < arrayOfUsers.Length; i++) {
email = "";
parameters = new DynamicParameters();
@ -689,14 +610,12 @@ public class WorkflowDMO {
public string AddEECNApproval(int ecnNumber, byte step, int documentType, string engUserIDs, string opUserIDs) {
string email = "";
//string emailArray = "";
string emailIDArray = "";
string[] arrayOfUsers = engUserIDs.Split(new char[] { '~' });
//Engineering SubRole
// Engineering SubRole
DynamicParameters parameters = new();
;
for (int i = 0; i < arrayOfUsers.Length; i++) {
email = "";
parameters = new DynamicParameters();
@ -714,7 +633,6 @@ public class WorkflowDMO {
// Operations SubRole
arrayOfUsers = opUserIDs.Split(new char[] { '~' });
parameters = new DynamicParameters();
;
for (int i = 0; i < arrayOfUsers.Length; i++) {
email = "";
parameters = new DynamicParameters();