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