public bool GetProductByDataMatrix(string dataMatrix, out ProductProcessWithDetails productProcess) { productProcess = new ProductProcessWithDetails(); if (!_traceabilityEnabled) { return(false); } return(_thisMachine.GetProductLastProcessWithDetails(dataMatrix, out productProcess)); }
public bool GetProductLastProcessWithDetails(string productFullName, out ProductProcessWithDetails lastProcessedInMachine) { lastProcessedInMachine = new ProductProcessWithDetails(); var check = CheckIfInitialized(); if (!check) { return(false); } var parameters = new[] { new SqlParameter("@productFullName", SqlDbType.NVarChar, 50) { SqlValue = productFullName } }; try { var dbMachine = SqlHelper.ExecuteDataset(_dbConnection, CommandType.StoredProcedure, "usp_GetProductLastMachineProcessDetails", parameters); if (dbMachine?.Tables.Count > 0) { if (dbMachine.Tables[0].Rows.Count > 0) { var row = dbMachine.Tables[0].Rows[0]; lastProcessedInMachine = new ProductProcessWithDetails() { Id = row.Field <int>("Id"), DateTime = row.Field <DateTime>("DateTime"), DataMatrix = row.Field <string>("FullName"), MachineName = row.Field <string>("MachineName"), Reference = row.Field <string>("Reference"), Remarks = row.Field <string>("Remarks"), Result = row.Field <ProcessResult>("Result"), WorkOrderNumber = row.Field <string>("WorkOrderNumber") }; if (lastProcessedInMachine.Id > 0) { return(true); } } } } catch (Exception exception) { MachineHookException?.Invoke(exception.Message); } return(false); }