using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Web;
using Fab2ApprovalSystem.Models;
using Dapper;
using System.Transactions;
using Fab2ApprovalSystem.ViewModels;
using System.Reflection;
using Fab2ApprovalSystem.Misc;
namespace Fab2ApprovalSystem.DMO
{
public class LotTravelerDMO
{
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
WorkflowDMO wfDMO = new WorkflowDMO();
///
///
///
///
///
///
internal LTWorkRequest InsertWorkRequest(LTWorkRequest workRequest)
{
var parameters = new DynamicParameters();
parameters.Add("@ID", value: workRequest.ID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@OriginatorID", workRequest.OriginatorID);
this.db.Execute("LTInsertWorkRequest", parameters, commandType: CommandType.StoredProcedure);
workRequest.ID = parameters.Get("@ID");
return workRequest;
}
///
///
///
///
///
///
///
internal LTWorkRequest GetLTWorkRequestItem(int workRequestID, out int isITAR, int userID)
{
isITAR = 2;
var workRequestItem = new LTWorkRequest();
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", value: workRequestID);
parameters.Add("@UserID", userID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
using (var multipleResultItems = this.db.QueryMultiple("LTGetWorkRequestItem", parameters, commandType: CommandType.StoredProcedure))
{
workRequestItem = multipleResultItems.Read().SingleOrDefault();
var departments = multipleResultItems.Read().ToList();
if (workRequestItem != null && departments != null)
{
workRequestItem.DepartmentIDs.AddRange(departments);
}
var modules = multipleResultItems.Read().ToList();
if (workRequestItem != null && modules != null)
{
if (modules.Count > 0)
workRequestItem.ModuleIDs.AddRange(modules);
}
//var holdsteps = multipleResultItems.Read().SingleOrDefault();
//workRequestItem.LTHoldStep = holdsteps;
isITAR = parameters.Get("@IsITAR");
}
return workRequestItem;
}
internal WorkRequestPdf GetLTWorkRequestItemPDF(int workRequestID)
{
var workRequestItem = new WorkRequestPdf();
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", value: workRequestID);
using (var multipleResultItems = this.db.QueryMultiple("LTGetWorkRequestItemPDF", parameters, commandType: CommandType.StoredProcedure))
{
workRequestItem = multipleResultItems.Read().SingleOrDefault();
var departments = multipleResultItems.Read().ToList();
workRequestItem.AffectedDepartments = String.Join(", ", departments) ;
var modules = multipleResultItems.Read().ToList();
workRequestItem.AffectedModules = String.Join(", ", modules);
var materials = multipleResultItems.Read().ToList();
if (workRequestItem != null && materials != null)
{
if (materials.Count > 0)
workRequestItem.LTMaterial.AddRange(materials);
}
var holdsteps = multipleResultItems.Read().ToList();
if (workRequestItem != null && holdsteps != null)
{
if (holdsteps.Count > 0)
workRequestItem.LTHoldStep.AddRange(holdsteps);
}
}
return workRequestItem;
}
///
///
///
///
///
///
///
internal LTWorkRequest GetLTWorkRequestItemForRead(int workRequestID, out int isITAR, int userID)
{
isITAR = 2;
var workRequestItem = new LTWorkRequest();
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", value: workRequestID);
parameters.Add("@UserID", userID);
parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
using (var multipleResultItems = this.db.QueryMultiple("LTGetWorkRequestItemForRead", parameters, commandType: CommandType.StoredProcedure))
{
workRequestItem = multipleResultItems.Read().SingleOrDefault();
var departments = multipleResultItems.Read().ToList();
if (workRequestItem != null && departments != null)
{
workRequestItem.DepartmentIDs.AddRange(departments);
}
var modules = multipleResultItems.Read().ToList();
if (workRequestItem != null && modules != null)
{
if (modules.Count > 0)
workRequestItem.ModuleIDs.AddRange(modules);
}
//var holdsteps = multipleResultItems.Read().SingleOrDefault();
//workRequestItem.LTHoldStep = holdsteps;
isITAR = parameters.Get("@IsITAR");
}
return workRequestItem;
}
///
///
///
///
internal int UpdateWorkRequest(LTWorkRequest data, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
using (var transanction = new TransactionScope())
{
try
{
parameters.Add("@LTWorkRequestID", data.ID);
parameters.Add("@Title", data.Title);
parameters.Add("@LotType", data.LotType);
parameters.Add("@EngLotStartRequired", data.EngLotStartRequired);
parameters.Add("@LotTypeConversion", data.LotTypeConversion);
parameters.Add("@QualLot", data.QualLot);
parameters.Add("@PurposeOfRequest", data.PurposeOfRequest);
parameters.Add("@PlannedLotStartDate", data.PlannedLotStartDate);
parameters.Add("@PlannedScheduledCloseDate", data.PlannedScheduledCloseDate);
parameters.Add("@ChargeDepartment", data.ChargeDepartment);
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);
parameters.Add("@LotNumber", data.LotNumber);
parameters.Add("@WIPPartNumber", data.WIPPartNumber);
parameters.Add("@PartDescription", data.PartDescription);
parameters.Add("@DefaultEPISiliconPartNumber", data.DefaultEPISiliconPartNumber);
parameters.Add("@RecordSiliconLotInSPNTapeTagTotrav", data.RecordSiliconLotInSPNTapeTagTotrav);
parameters.Add("@SiliconLotNoCassette1", data.SiliconLotNoCassette1);
parameters.Add("@ProcessFlow", data.ProcessFlow);
parameters.Add("@EmployeeID", data.EmployeeID);
parameters.Add("@VerbComment", data.VerbComment);
parameters.Add("@SiliconOnHand", data.SiliconOnHand);
parameters.Add("@SiliconExpectedDueDate", data.SiliconExpectedDueDate);
parameters.Add("@SiliconComments", data.SiliconComments);
parameters.Add("@ReticleOnHand", data.ReticleOnHand);
parameters.Add("@ReticleExpectedDueDate", data.ReticleExpectedDueDate);
parameters.Add("@ReticleComments", data.ReticleComments);
parameters.Add("@SPNTransferOnHand", data.SPNTransferOnHand);
parameters.Add("@SPNTransferExpectedDueDate", data.SPNTransferExpectedDueDate);
parameters.Add("@SPNTransferComments", data.SPNTransferComments);
parameters.Add("@ProbeCardOnHand", data.ProbeCardOnHand);
parameters.Add("@ProbeCardExpectedDueDate", data.ProbeCardExpectedDueDate);
parameters.Add("@ProbeCardComments", data.ProbeCardComments);
parameters.Add("@ProbeRecipeOnHand", data.ProbeRecipeOnHand);
parameters.Add("@ProbeRecipeExpectedDueDate", data.ProbeRecipeExpectedDueDate);
parameters.Add("@ProbeRecipeComments", data.ProbeRecipeComments);
parameters.Add("@ProcessChangeDetailsOnHand", data.ProcessChangeDetailsOnHand);
parameters.Add("@ProcessChangeDetailsDueDate", data.ProcessChangeDetailsDueDate);
parameters.Add("@LotStartCheckListComments", data.LotStartCheckListComments);
parameters.Add("@PCRBNumber", data.PCRBNumber);
parameters.Add("@LastUpdateBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTUpdateWorkRequest", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@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");
}
parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", data.ID);
this.db.Execute("LTDeleteAffectedDepartments", parameters, commandType: CommandType.StoredProcedure);
List wrDepIDs = data.DepartmentIDs;
if (wrDepIDs != null)
{
foreach (int depId in wrDepIDs)
{
parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", data.ID);
parameters.Add("@DepartmentID", depId);
this.db.Execute("LTInsertAffectedDepartments", parameters, commandType: CommandType.StoredProcedure);
}
}
parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", data.ID);
this.db.Execute("LTDeleteAffectedModules", parameters, commandType: CommandType.StoredProcedure);
List wrModuleIDs = data.ModuleIDs;
if (wrModuleIDs != null)
{
foreach (int moduleID in wrModuleIDs)
{
parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", data.ID);
parameters.Add("@ModuleID", moduleID);
this.db.Execute("LTInsertAffectedModules", parameters, commandType: CommandType.StoredProcedure);
}
}
transanction.Complete();
}
catch (Exception ex)
{
transanction.Dispose();
throw new Exception(ex.Message + " " + ex.InnerException);
}
}
// have to do it outside of the Transaction scope because the OPENQUERY to TEMIRWAP019 LINKED server does not work
parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", data.ID);
this.db.Execute("LTUpdateIsITAR", parameters, commandType: CommandType.StoredProcedure);
return result;
}
///
///
///
///
///
internal LTWorkRequestAttachment GetWorkRequestAttachDetail(int wrAttachmentID)
{
var wrAttach = this.db.Query("SELECT ID, FileName ,DocType, Comments FROM LTWorkRequestAttachment WHERE ID = @wrAttachmentID ", new { wrAttachmentID = wrAttachmentID }, commandType: CommandType.Text).Single();
return wrAttach;
}
///
///
///
///
///
internal IEnumerable GetMaterialDetails(int workRequestID)
{
var parameters = new DynamicParameters();
parameters.Add("@workRequestID", value: workRequestID);
var data = this.db.Query("LTGetMaterialDetails", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
/// Update via the edit screen
///
///
internal void UpdateMaterialDetail(LTMaterialViewModel model, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LTMaterialID", model.ID);
parameters.Add("@EPISiliconPartNumber", model.@EPISiliconPartNumber);
parameters.Add("@Quantity", model.Quantity);
parameters.Add("@Source", model.Source);
parameters.Add("@Supplier", model.Supplier);
parameters.Add("@UpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTUpdateMaterialDetail", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@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");
}
}
///
/// Update via the revision screen
///
///
internal void UpdateMaterialDetail(LTMaterial model, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LTMaterialID", model.ID);
parameters.Add("@EPISiliconPartNumber", model.@EPISiliconPartNumber);
parameters.Add("@Quantity", model.Quantity);
parameters.Add("@Source", model.Source);
parameters.Add("@Supplier", model.Supplier);
parameters.Add("@UpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTUpdateMaterialDetail", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@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 UpdateMaterialDetailRevision(LTMaterial model, int previousMaterialID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTMaterialID", model.ID);
parameters.Add("@EPISiliconPartNumber", model.EPISiliconPartNumber);
parameters.Add("@Quantity", model.Quantity);
parameters.Add("@Source", model.Source);
parameters.Add("@Supplier", model.Supplier);
parameters.Add("@PreviousMaterialID", previousMaterialID);
this.db.Execute("LTUpdateMaterialDetailRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void InsertMaterialDetail(LTMaterialViewModel model, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LTMaterialID", model.ID, direction: ParameterDirection.InputOutput);
parameters.Add("@EPISiliconPartNumber", model.@EPISiliconPartNumber);
parameters.Add("@Quantity", model.Quantity);
parameters.Add("@Source", model.Source);
parameters.Add("@Supplier", model.Supplier);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTInsertMaterialDetail", parameters, commandType: CommandType.StoredProcedure);
int id = parameters.Get("@LTMaterialID");
model.ID = id;
result = parameters.Get("@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");
}
}
///
/// For Revisioing the data
///
///
internal void InsertMaterialDetail(LTMaterial model, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LTMaterialID", model.ID, direction: ParameterDirection.InputOutput);
parameters.Add("@EPISiliconPartNumber", model.@EPISiliconPartNumber);
parameters.Add("@Quantity", model.Quantity);
parameters.Add("@Source", model.Source);
parameters.Add("@Supplier", model.Supplier);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTInsertMaterialDetail", parameters, commandType: CommandType.StoredProcedure);
int id = parameters.Get("@LTMaterialID");
model.ID = id;
result = parameters.Get("@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 DeleteMaterialDetail(int LTMaterialID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTMaterialID", LTMaterialID);
this.db.Execute("LTDeleteMaterial", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void DeleteMaterialDetailRevision(int materialID)
{
var parameters = new DynamicParameters();
parameters.Add("@MaterialID", materialID);
this.db.Execute("LTDeleteMaterialRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
internal List GetBaseFlowLocations(string processFlow)
{
var baseFlowLocations = this.db.Query("SELECT DISTINCT LOC as Location FROM vSPNPDB_FLOWLOCS WHERE PROCESS = @ProcessFlow ORDER BY LOC ", new { ProcessFlow = processFlow }, commandType: CommandType.Text).ToList();
return baseFlowLocations;
}
///
///
///
///
///
internal LTMaterial GetMaterialRecord(int materialID)
{
var material = this.db.Query("SELECT * FROM LTMaterial WHERE ID = @materialID ", new { materialID }, commandType: CommandType.Text).Single();
return material;
}
///
///
///
///
///
///
internal List GetBaseFlowOperations(string processFlow, string loc)
{
var baseFlowOperations = this.db.Query(
"SELECT DISTINCT " +
" LTRIM(RTRIM(OPER)) + '-' + LTRIM(RTRIM(SEQ)) as Operation, " +
" LTRIM(RTRIM(OPER)) as OperCode, " +
" LTRIM(RTRIM(SEQ)) as SeqCode, " +
" LTRIM(RTRIM([OPDESC])) + ' (' + LTRIM(RTRIM([AREA])) + ')' AS 'OperationDesc' " +
"FROM vSPNPDB_FLOWLOCS " +
"WHERE PROCESS = @ProcessFlow AND LOC = @LOC " +
"ORDER BY Operation ",
new { ProcessFlow = processFlow, LOC = loc }, commandType: CommandType.Text).ToList();
return baseFlowOperations;
}
internal List GetPartNumbers()
{
var baseFlowOperations = this.db.Query("SELECT DISTINCT TOP 100 [MP_PART_NUMBER] AS PartNumber, MP_DESCRIPTION + ' ~ ' + MP_PART_NUMBER AS SiliconAndDesc FROM vFAB2SPN_MP_RECORD ORDER BY MP_PART_NUMBER ", commandType: CommandType.Text).ToList();
return baseFlowOperations;
}
///
///
///
///
///
internal IEnumerable GetHoldSteps(int workRequestID)
{
var parameters = new DynamicParameters();
parameters.Add("@workRequestID", value: workRequestID);
var data = this.db.Query("LTGetHoldSteps", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
internal void InsertHoldStep(LTHoldStep model)
{
int result = 0;
var parameters = new DynamicParameters();
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);
parameters.Add("@OperationDescription", model.OperationDescription);
parameters.Add("@ChangeInstruction", model.ChangeInstructions);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", model.UpdatedBy);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTInsertHoldStep", parameters, commandType: CommandType.StoredProcedure);
int id = parameters.Get("@LTHoldStepID");
model.ID = id;
result = parameters.Get("@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)
{
var parameters = new DynamicParameters();
parameters.Add("@LTHoldStepID", model.ID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
parameters.Add("@BaseFlow", model.BaseFlow);
parameters.Add("@BaseFlowOperationSeq", model.OperSequence);
parameters.Add("@BaseFlowLocation", model.Location);
parameters.Add("@BaseFlowOperation", model.Operation);
parameters.Add("@OperationDescription", model.OperationDescription);
parameters.Add("@ChangeInstruction", model.ChangeInstructions);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", model.UpdatedBy);
this.db.Execute("LTUpdateHoldStep", parameters, commandType: CommandType.StoredProcedure);
//int id = parameters.Get("@LTHoldStepID");
//model.ID = id;
}
///
///
///
///
internal void InsertHoldStepRevision(LTHoldStep model)
{
int result = 0;
var parameters = new DynamicParameters();
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);
parameters.Add("@OperationDescription", model.OperationDescription);
parameters.Add("@ChangeInstruction", model.ChangeInstructions);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", model.UpdatedBy);
this.db.Execute("LTInsertHoldStepRevision", parameters, commandType: CommandType.StoredProcedure);
int id = parameters.Get("@LTHoldStepID");
model.ID = id;
}
///
///
///
///
internal void UpdateHoldStepRevision(LTHoldStep model)
{
int result = 0;
var parameters = new DynamicParameters();
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);
parameters.Add("@OperationDescription", model.OperationDescription);
parameters.Add("@ChangeInstruction", model.ChangeInstructions);
parameters.Add("@LTWorkRequestID", model.LTWorkRequestID);
parameters.Add("@UpdatedBy", model.UpdatedBy);
//parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTUpdateHoldStepRevision", parameters, commandType: CommandType.StoredProcedure);
//result = parameters.Get("@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)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@HoldStepID", holdStepID);
parameters.Add("@UpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTDeleteHoldStep", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@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 DeleteHoldStepRevision(int holdStepID)
{
var parameters = new DynamicParameters();
parameters.Add("@HoldStepID", holdStepID);
this.db.Execute("LTDeleteHoldStepRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void DeleteLotTravHoldStep(int lotTravHoldStepID)
{
var parameters = new DynamicParameters();
parameters.Add("@LotTravHoldStepID", lotTravHoldStepID);
this.db.Execute("LTDeleteLotTravHoldStep", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void DeleteLotTravHoldStepRevision(int lotTravHoldStepID)
{
var parameters = new DynamicParameters();
parameters.Add("@LotTravHoldStepID", lotTravHoldStepID);
this.db.Execute("LTDeleteLotTravHoldStepRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
internal IEnumerable GetHoldStepAttachemnts(int holdStepID)
{
//var holdStepAttachments = this.db.Query("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
var parameters = new DynamicParameters();
parameters.Add("@HoldStepID", holdStepID);
var data = this.db.Query("LTGetHoldStepAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
internal IEnumerable GetLotTravHoldStepAttachemnts(int ltHoldStepID)
{
//var holdStepAttachments = this.db.Query("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
var parameters = new DynamicParameters();
parameters.Add("@LTHoldStepID", ltHoldStepID);
var data = this.db.Query("LTGetLotTravHoldStepAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
internal LTHoldStep GetHoldStep(int holdStepID)
{
var parameters = new DynamicParameters();
parameters.Add("@HoldStepID", value: holdStepID);
var data = this.db.Query("LTGetHoldStep", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
return data;
}
///
///
///
///
///
internal LTLotTravelerHoldSteps GetLotTravHoldStep(int ltHoldStepID)
{
var parameters = new DynamicParameters();
parameters.Add("@LotTravHoldStepID", value: ltHoldStepID);
var data = this.db.Query("LTGetLotTravHoldStep", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
return data;
}
///
///
///
///
internal void InsertLotHoldStepAttachment(LTWorkRequestAttachment attachment)
{
var parameters = new DynamicParameters();
parameters.Add("@HoldStepID", attachment.LTHoldStepID);
parameters.Add("@FileName", attachment.FileName);
parameters.Add("@FileGUID", attachment.FileGUID);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@UploadedByID", attachment.UploadedByID);
parameters.Add("@Comments", attachment.Comments);
this.db.Execute("LTInsertHoldStepAttachment", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void InsertLotHoldStepAttachmentRevision(LTWorkRequestAttachment attachment)
{
var parameters = new DynamicParameters();
parameters.Add("@HoldStepID", attachment.LTHoldStepID);
parameters.Add("@FileName", attachment.FileName);
parameters.Add("@FileGUID", attachment.FileGUID);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@UploadedByID", attachment.UploadedByID);
parameters.Add("@Comments", attachment.Comments);
this.db.Execute("LTInsertHoldStepAttachmentRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void InsertWorkRequestAttachment(LTWorkRequestAttachment attachment)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", attachment.WorkRequestID);
parameters.Add("@FileName", attachment.FileName);
parameters.Add("@FileGUID", attachment.FileGUID);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@UploadedByID", attachment.UploadedByID);
parameters.Add("@Comments", attachment.Comments);
this.db.Execute("LTInsertWorkRequestAttachment", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void InsertWorkRequestAttachmentRevision(LTWorkRequestAttachment attachment)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", attachment.WorkRequestID);
parameters.Add("@FileName", attachment.FileName);
parameters.Add("@FileGUID", attachment.FileGUID);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@UploadedByID", attachment.UploadedByID);
parameters.Add("@Comments", attachment.Comments);
this.db.Execute("LTInsertWorkRequestAttachmentRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
internal int GetRevisedWrkReqIDFromHoldStepID(int prevHoldStepID)
{
int workRequestID = this.db.Query("SELECT LTWorkRequestID FROM LTHoldStep WHERE PreviousHoldStepID = @PrevHoldStepID", new { PrevHoldStepID = prevHoldStepID }, commandType: CommandType.Text).Single();
return workRequestID;
}
///
///
///
///
///
internal int GetRevisedWrkReqIDFromPreviousWrkReqID(int prevWorkRequestID)
{
int workRequestID = this.db.Query("SELECT ID FROM LTWorkRequest WHERE PreviousWorkRequestID = @prevWorkRequestID", new { prevWorkRequestID = prevWorkRequestID }, commandType: CommandType.Text).Single();
return workRequestID;
}
///
///
///
///
///
internal IEnumerable GetWorkRequestAttachments(int workRequestID)
{
//var holdStepAttachments = this.db.Query("SELECT * FROM LTWorkRequestAttachment WHERE HoldStepID = @HoldStep ORDER BY UploadDateTime", new { holdStep }, commandType: CommandType.Text).ToList();
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", workRequestID);
var data = this.db.Query("LTGetWorkRequestAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
internal void UpdateWorkRequestAttachment(LTWorkRequestAttachment attachment)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestAttachmentID", attachment.ID);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@Comments", attachment.Comments);
this.db.Execute("LTUpdateWorkRequestAttachment", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void UpdateWorkRequestAttachmentRevision(LTWorkRequestAttachment attachment, int previousWorkRequestAttachmentID)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestAttachmentID", attachment.ID);
parameters.Add("@FileName", attachment.FileName);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@Comments", attachment.Comments);
parameters.Add("@PreviousWorkRequestAttachmentID", previousWorkRequestAttachmentID);
this.db.Execute("LTUpdateWorkRequestAttachmentRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void DeleteWorkRequestAttachment(int workRequestAttachmentID)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestAttachmentID", workRequestAttachmentID);
this.db.Execute("LTDeleteWorkRequestAttachment", parameters, commandType: CommandType.StoredProcedure);
}
internal void DeleteWorkRequestAttachmentRevision(int workRequestAttachmentID)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestAttachmentID", workRequestAttachmentID);
this.db.Execute("LTDeleteWorkRequestAttachmentRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
///
///
///
public int SubmitDocument(int workRequestID, int userID, int documentType, out int allowedITAR)
{
allowedITAR = 1;
string subRoles = "";
subRoles = wfDMO.GetSubRoleItems(workRequestID, documentType);
// bubble the error
int appoverCount = 0;
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", workRequestID);
parameters.Add("@UserID", userID);
parameters.Add("@DocumentTypeID", documentType);
parameters.Add("@SubRoleCategoriesClause", subRoles);
parameters.Add("@AppoverCount", appoverCount, dbType: DbType.Int32, direction: ParameterDirection.Output);
parameters.Add("@AllowedITAR", allowedITAR, dbType: DbType.Int32, direction: ParameterDirection.Output);
this.db.Execute("LTSubmitForApproval", parameters, commandType: CommandType.StoredProcedure);
appoverCount = parameters.Get("@AppoverCount");
allowedITAR = parameters.Get("@AllowedITAR");
return appoverCount;
}
///
/// Release lock on all the documents locked by the current user
///
///
public void ReleaseLockOnDocument(int userID, int workRequestID)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", workRequestID);
parameters.Add("@UserID", userID);
this.db.Execute("LTReleaseLockOnDocuments", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
public void ReleaseLockOnLotTravelerUpdateDoc(int userID, int ltLotID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
parameters.Add("@UserID", userID);
this.db.Execute("LTReleaseLockOnLTUpdateDoc", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
public List GetRejectionOrginatorEmailList(int workRequestID)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", workRequestID);
var emailList = this.db.Query("LTGetRejectionOrginatorEmailList", parameters, commandType: CommandType.StoredProcedure).ToList();
return emailList;
}
///
///
///
///
///
///
public int CreateWorkRequestRevision(LTWorkRequest data, int userID)
{
int newWorkRequestID = -1;
var parameters = new DynamicParameters();
parameters.Add("@UserID", userID);
parameters.Add("@ChangeComments", data.RevisionComments);
parameters.Add("@CurrentStep", data.CurrentStep);
parameters.Add("@LTWorkRequestID", data.ID);
parameters.Add("@Title", data.Title);
parameters.Add("@LotType", data.LotType);
parameters.Add("@EngLotStartRequired", data.EngLotStartRequired);
parameters.Add("@LotTypeConversion", data.LotTypeConversion);
parameters.Add("@QualLot", data.QualLot);
parameters.Add("@PurposeOfRequest", data.PurposeOfRequest);
parameters.Add("@PlannedLotStartDate", data.PlannedLotStartDate);
parameters.Add("@PlannedScheduledCloseDate", data.PlannedScheduledCloseDate);
parameters.Add("@ChargeDepartment", data.ChargeDepartment);
parameters.Add("@AllocationToUse", data.AllocationToUse);
parameters.Add("@PredictedCyleTime", data.PredictedCyleTime);
parameters.Add("@DeptChargedForRawWafers", data.ChargeDepartment);
parameters.Add("@StartQty", data.StartQty);
parameters.Add("@TotalQty", data.TotalQty);
parameters.Add("@WIPArea", data.WIPArea);
parameters.Add("@LotStartDate", data.LotStartDate);
parameters.Add("@LotNumber", data.LotNumber);
parameters.Add("@WIPPartNumber", data.WIPPartNumber);
parameters.Add("@PartDescription", data.PartDescription);
parameters.Add("@DefaultEPISiliconPartNumber", data.DefaultEPISiliconPartNumber);
parameters.Add("@ProcessFlow", data.ProcessFlow);
parameters.Add("@EmployeeID", data.EmployeeID);
parameters.Add("@VerbComment", data.VerbComment);
parameters.Add("@RecordSiliconLotInSPNTapeTagTotrav", data.RecordSiliconLotInSPNTapeTagTotrav);
parameters.Add("@SiliconLotNoCassette1", data.SiliconLotNoCassette1);
parameters.Add("@SiliconOnHand", data.SiliconOnHand);
parameters.Add("@SiliconExpectedDueDate", data.SiliconExpectedDueDate);
parameters.Add("@SiliconComments", data.SiliconComments);
parameters.Add("@ReticleOnHand", data.ReticleOnHand);
parameters.Add("@ReticleExpectedDueDate", data.ReticleExpectedDueDate);
parameters.Add("@ReticleComments", data.ReticleComments);
parameters.Add("@SPNTransferOnHand", data.SPNTransferOnHand);
parameters.Add("@SPNTransferExpectedDueDate", data.SPNTransferExpectedDueDate);
parameters.Add("@SPNTransferComments", data.SPNTransferComments);
parameters.Add("@ProbeCardOnHand", data.ProbeCardOnHand);
parameters.Add("@ProbeCardExpectedDueDate", data.ProbeCardExpectedDueDate);
parameters.Add("@ProbeCardComments", data.ProbeCardComments);
parameters.Add("@ProbeRecipeOnHand", data.ProbeRecipeOnHand);
parameters.Add("@ProbeRecipeExpectedDueDate", data.ProbeRecipeExpectedDueDate);
parameters.Add("@ProbeRecipeComments", data.ProbeRecipeComments);
parameters.Add("@LotStartCheckListComments", data.LotStartCheckListComments);
parameters.Add("@ProcessChangeDetailsOnHand", data.ProcessChangeDetailsOnHand);
parameters.Add("@ProcessChangeDetailsDueDate", data.ProcessChangeDetailsDueDate);
parameters.Add("@PCRBNumber", data.PCRBNumber);
parameters.Add("@LotStartCheckListComments", data.LotStartCheckListComments);
parameters.Add("@NewWorkRequestID", data.ID, direction: ParameterDirection.InputOutput);
this.db.Execute("LTCreateWorkRequestRevision", parameters, commandType: CommandType.StoredProcedure);
newWorkRequestID = parameters.Get("@NewWorkRequestID");
return newWorkRequestID;
}
///
///
///
///
///
public List GetWorkReqRevisions(int swrNumber)
{
var revisions = this.db.Query("SELECT ID, Revision AS RevisionNumber FROM LTWorkRequest WHERE SWRNumber = @SWRNUmber ORDER BY Revision ", new { SWRNUmber = swrNumber }, commandType: CommandType.Text).ToList();
return revisions;
}
///
///
///
///
///
public List GetLotTravRevisions(int ltLotID)
{
var revisions = this.db.Query("SELECT ID, RevisionNumber FROM LTLotTravelerRevisionAttrib WHERE LTLotID = @ltLotID ORDER BY RevisionNumber ", new { ltLotID = ltLotID }, commandType: CommandType.Text).ToList();
return revisions;
}
///
///
///
///
///
///
public void InsertLot(LTLot lot)
{
MiscDMO.GetLTLotInformation(lot);
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", lot.WorkRequestID);
parameters.Add("@LotNumber", lot.LotNumber);
parameters.Add("@WIPPartNumber", lot.WIPPartNumber);
parameters.Add("@WaferQty", lot.WaferQty);
parameters.Add("@PartDescription", lot.PartDescription);
parameters.Add("@Process", lot.Process);
parameters.Add("@Location", lot.Location);
parameters.Add("@Operation", lot.Operation);
parameters.Add("@LotStatus", lot.LotStatus);
parameters.Add("@UploadedBy", lot.LotUploadedBy);
parameters.Add("@WRWithExistingLot", dbType: DbType.Int32, direction: ParameterDirection.Output);
this.db.Execute("LTInsertLTLot", parameters, commandType: CommandType.StoredProcedure);
//int lotID = parameters.Get("@LotID");
if (parameters.Get("@WRWithExistingLot") != 0)
{
lot.WRWithExistingLot = parameters.Get("@WRWithExistingLot");
}
//return lotID;
}
///
///
///
///
///
public IEnumerable GetLotList(int workRequestID)
{
StringBuilder sql = new StringBuilder();
sql.Append("SELECT L.*, U.FirstName + ' ' + U.LastName AS UploadedByName,CASE WHEN TravelerClosed = 0 THEN 'Open' ELSE 'Closed' END AS TravelerStatus ");
sql.Append("FROM LTLot L LEFT JOIN Users U ON L.LotUploadedBy = U.UserID ");
sql.Append("WHERE WorkRequestID = @workRequestID ORDER BY LotNumber ");
var lots = this.db.Query(sql.ToString(), new { @workRequestID = workRequestID }, commandType: CommandType.Text).ToList();
return lots;
}
///
///
///
///
///
public IEnumerable GetLotListBasedOnSWRNumber(int swrNumber)
{
StringBuilder sql = new StringBuilder();
sql.Append("SELECT L.*, U.FirstName + ' ' + U.LastName AS UploadedByName,CASE WHEN TravelerClosed = 0 THEN 'Open' ELSE 'Closed' END AS TravelerStatus ");
sql.Append("FROM LTWorkRequest WR INNER JOIN LTLot L ON WR.ID = L.WorkRequestID AND WR.IsCurrentRevision = 1 ");
sql.Append("LEFT JOIN Users U ON L.LotUploadedBy = U.UserID ");
sql.Append("WHERE WR.SWRNumber = @SWRNumber ORDER BY LotNumber ");
var lots = this.db.Query(sql.ToString(), new { @SWRNumber = swrNumber }, commandType: CommandType.Text).ToList();
//var lots = this.db.Query("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;
}
///
///
///
///
///
public IEnumerable GetLotsWithTraveler(int workRequestID)
{
var lotList = this.db.Query("SELECT ID AS LotID, LotNumber FROM LTLot WHERE WorkRequestID = @workRequestID AND IsTravelerGenerated = 1 ORDER BY LotNumber ", new { workRequestID = workRequestID }, commandType: CommandType.Text).ToList();
return lotList;
}
///
///
///
///
///
///
public void CreateTraveler(int ltLotID, int workRequestID , int UserID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
parameters.Add("@WorkRequestID", workRequestID);
parameters.Add("@UserID", UserID);
this.db.Execute("LTCreateLotTraveler", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
public LTLotTravelerHeaderViewModel GetLotTravelerHeaderForUpdate(int ltLotID, int UserID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
parameters.Add("@UserID", UserID);
var data = this.db.Query("LTGetLotTravelerHeaderForUpdate", parameters, commandType: CommandType.StoredProcedure).Single();
return data;
}
///
///
///
///
///
///
public LTLotTravelerHeaderViewModel GetLotTravelerHeaderForReadOnly(int ltLotID, int revisionNumber)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
parameters.Add("@RevisionNumber", revisionNumber);
var data = this.db.Query("LTGetLotTravelerHeaderForReadOnly", parameters, commandType: CommandType.StoredProcedure).Single();
return data;
}
///
public IEnumerable GetLotTravHoldSteps(int ltLotID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
var data = this.db.Query("LTGetLotTravelerHoldSteps", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
public IEnumerable GetLotTravHoldStepsPending(int ltLotID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
var data = this.db.Query("LTGetLotTravelerHoldStepsPending", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
public IEnumerable GetLotTravHoldStepsCompleted(int ltLotID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
var data = this.db.Query("LTGetLotTravelerHoldStepsCompleted", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
///
public IEnumerable GetLotTravelerHolStepsByRevision(int ltLotID, int revisionNumber)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
parameters.Add("@RevisionNumber", revisionNumber);
var data = this.db.Query("LTGetLotTravelerHoldStepsByRevision", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
public int CreateLotTravelerRevision(LTLotTravelerHoldSteps model, int userID)
{
var parameters = new DynamicParameters();
parameters.Add("@CurrLotTravelerRevisionID", model.LotTravelerRevisionID);
parameters.Add("@LTLotID", model.LTLotID);
parameters.Add("@NewUpdatedBy", userID);
parameters.Add("@ChangeComments", model.RevisionComments);
parameters.Add("@NewLotTravelerRevisionID", model.ID, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
this.db.Execute("LTCreateLotTravHoldStepsRevision", parameters, commandType: CommandType.StoredProcedure);
int newLotTravRevisionID = parameters.Get("@NewLotTravelerRevisionID");
// model.ID = id;
return newLotTravRevisionID;
}
///
///
///
///
///
///
public int CanAddLocationOperation(LTLotTravelerHoldSteps model)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", model.LTLotID);
parameters.Add("@Location", model.Location);
parameters.Add("@OperSequence", model.OperSequence);
parameters.Add("@Operation", model.Operation);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTCanAddLocationOperation", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@Result");
return result;
}
///
///
///
///
///
///
public void RestoreLotTravToPrevRevision(int prevLotTravRevID, int newLotTravRevID)
{
var parameters = new DynamicParameters();
parameters.Add("@PrevLotTravelerRevisionID", prevLotTravRevID);
parameters.Add("@NewLotTravelerRevisionID", newLotTravRevID);
this.db.Execute("LTRestoreLotTravToPrevRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
public int UpdateRevisedLotTravelerHoldStep(LTLotTravelerHoldSteps model, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LotTravHoldStepID", model.ID);
parameters.Add("@NewLocation", model.Location);
parameters.Add("@NewOperSequence", model.OperSequence);
parameters.Add("@NewOperation", model.Operation);
parameters.Add("@NewOperationDescription", model.OperationDescription);
parameters.Add("@NewChangeInstructions", model.ChangeInstructions);
parameters.Add("@NewUpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTUpdateRevisedLotTravelerHoldStep", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@Result");
return result;
}
///
///
///
///
public int UpdateLotTravelerHoldStep(LTLotTravelerHoldSteps model, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LotTravHoldStepID", model.ID);
parameters.Add("@NewLocation", model.Location);
parameters.Add("@NewOperSequence", model.OperSequence);
parameters.Add("@NewOperation", model.Operation);
parameters.Add("@NewOperationDescription", model.OperationDescription);
parameters.Add("@NewChangeInstructions", model.ChangeInstructions);
parameters.Add("@NewUpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTUpdateLotTravelerHoldStep", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@Result");
return result;
}
///
///
///
///
//public void InsertLotTravelerRevision(LTLotTravelerHoldSteps model)
//{
// var parameters = new DynamicParameters();
// parameters.Add("@LotTravelerRevisionID", model.ID);
// parameters.Add("@NewLocation", model.Location);
// parameters.Add("@NewOperation", model.Operation);
// parameters.Add("@NewOperationDescription", model.OperationDescription);
// parameters.Add("@NewChangeInstruction", model.ChangeInstructions);
// this.db.Execute("LTInsertLotTravelerRevision", parameters, commandType: CommandType.StoredProcedure);
//}
///
///
///
///
public int InsertLotTravelerHoldStep(LTLotTravelerHoldSteps model, int userID)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LTLotTravHoldStepID", model.ID);
parameters.Add("@LTLotID", model.LTLotID);
parameters.Add("@Location", model.Location);
parameters.Add("@OperSequence", model.OperSequence);
parameters.Add("@Operation", model.Operation);
parameters.Add("@OperationDescription", model.OperationDescription);
parameters.Add("@ChangeInstructions", model.ChangeInstructions);
parameters.Add("@UpdatedBy", userID);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTInsertLotTravelerHoldStep", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@Result");
return result;
}
///
///
///
///
public void DeleteLot(int ltLotID)
{
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
this.db.Execute("LTDeleteLot", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
///
///
public void UpdateLotTravlerExecution(int lotTravHoldStepID, string taskComments, bool CompletedFlag, int userID)
{
var parameters = new DynamicParameters();
parameters.Add("@LotTravHoldStepID", lotTravHoldStepID);
parameters.Add("@TaskComments", taskComments);
parameters.Add("@CompletedFlag", CompletedFlag);
parameters.Add("@UserID", userID);
this.db.Execute("LTUpdateLotTravlerExecution", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
///
public LotTravelerPdf GetLotTravlerPdf(int ltLotID, int revisionNumber)
{
var data = new LotTravelerPdf();
var parameters = new DynamicParameters();
parameters.Add("@LTLotID", ltLotID);
parameters.Add("@RevisionNumber", revisionNumber);
using (var multipleResultItems = this.db.QueryMultiple("LTGetLotTravelerForPDF", parameters, commandType: CommandType.StoredProcedure))
{
data = multipleResultItems.Read().SingleOrDefault();
var ltTaskList = multipleResultItems.Read().ToList();
if (data != null && ltTaskList != null)
{
if (ltTaskList.Count > 0)
data.Tasklist.AddRange(ltTaskList);
}
}
//var data = this.db.Query("LTGetLotTravelerForPDF", parameters, commandType: CommandType.StoredProcedure).Single();
return data;
}
///
///
///
///
///
public IEnumerable GetWorkReqApprovalLogHistory(int swrNumber)
{
var parameters = new DynamicParameters();
parameters.Add("@SWRNumber", swrNumber);
var data = this.db.Query("LTGetWorkRequestApprovalLogHistory", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
public IEnumerable GetWorkReqRevisionHistory(int swrNumber)
{
var parameters = new DynamicParameters();
parameters.Add("@SWRNumber", swrNumber);
var data = this.db.Query("LTGetWorkRequestRevHistory", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
///
public IEnumerable GetLotTravelerRevisionHistory(int lotID)
{
var parameters = new DynamicParameters();
parameters.Add("@LotID", lotID);
var data = this.db.Query("LTGetLotTravelerRevHistory", parameters, commandType: CommandType.StoredProcedure).ToList();
return data;
}
///
///
///
///
internal void InsertLotTravLotHoldStepAttachment(LTLotTravAttachment attachment)
{
var parameters = new DynamicParameters();
parameters.Add("@LTHoldStepID", attachment.LTLotTravHoldStepID);
parameters.Add("@FileName", attachment.FileName);
parameters.Add("@FileGUID", attachment.FileGUID);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@UploadedByID", attachment.UploadedByID);
parameters.Add("@LotTravelerRevisionID", attachment.LotTravelerRevisionID);
this.db.Execute("LTInsertLotTravHoldStepAttachment", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
internal void InsertLotTravLotHoldStepAttachmentRevision(LTLotTravAttachment attachment)
{
var parameters = new DynamicParameters();
parameters.Add("@LTHoldStepID", attachment.LTLotTravHoldStepID);
parameters.Add("@FileName", attachment.FileName);
parameters.Add("@FileGUID", attachment.FileGUID);
parameters.Add("@DocType", attachment.DocType);
parameters.Add("@UploadedByID", attachment.UploadedByID);
parameters.Add("@LotTravelerRevisionID", attachment.LotTravelerRevisionID);
this.db.Execute("LTInsertLotTravHoldStepAttachmentRevision", parameters, commandType: CommandType.StoredProcedure);
}
///
///
///
///
///
internal int IsWorkRequestDocLockedByUser(int workRequestID, int userID)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", workRequestID);
parameters.Add("@UserID", userID);
var data = this.db.Query("LTIsWorkRequestDocLockedByUser", parameters, commandType: CommandType.StoredProcedure).Single();
return data;
}
///
///
///
///
///
internal int CloseTraveler(int ltLotID, int userID, string reason)
{
int result = 0;
var parameters = new DynamicParameters();
parameters.Add("@LtLotID", ltLotID);
parameters.Add("@UserID", userID);
parameters.Add("@Reason", reason);
parameters.Add("@Result", result, direction: ParameterDirection.InputOutput);
this.db.Execute("LTCloseTraveler", parameters, commandType: CommandType.StoredProcedure);
result = parameters.Get("@Result");
return result;
}
///
///
///
///
///
internal string GetFileName(string fileGUID, int typeOfDoc)
{
var parameters = new DynamicParameters();
parameters.Add("@FileGUID", fileGUID);
parameters.Add("@TypeOfDoc", typeOfDoc);
var fileName = this.db.Query("LTGetFileName", parameters, commandType: CommandType.StoredProcedure).Single();
return fileName;
}
public void ReassignOriginator(int workRequestID, int newOriginatorID, string comments, int userID)
{
var parameters = new DynamicParameters();
parameters.Add("@WorkRequestID", workRequestID);
parameters.Add("@NewOriginatorID", newOriginatorID);
parameters.Add("@Comments", comments);
parameters.Add("@UserID", userID);
this.db.Execute("LTReassignOriginator", parameters, commandType: CommandType.StoredProcedure);
}
}
}