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

@ -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;
}
}