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:
@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user