Exemple #1
0
        /// <summary>
        ///     Ensure a bin exists in the destination warehouse with the same ID as the source bin.
        ///     Update deactivation list.
        /// </summary>
        private static void CheckBinConfiguration(TransOrderReceiptDataSet.PlantTranRow plantTran, TransferOrderEntryDataSet order, string trayKey,
                                                  string replenishmentBin, List <Bin> traysToInactivate)
        {
            try {
                var toWarehouse           = order.TFOrdHed[0].ShortChar10;
                var toWarehouseZone       = order.TFOrdHed[0].ShortChar02;
                var fromWarehouse         = plantTran.FromWarehouseCode;
                var binNum                = plantTran.BinNum;
                var packNum               = plantTran.PackNum.ToString();
                var usingReplenishmentBin = true;

                // If trayKey is specified, we use the replenishment bin or fall back to "1".
                if (string.IsNullOrEmpty(trayKey))
                {
                    binNum = !string.IsNullOrEmpty(replenishmentBin) ? replenishmentBin : "1";
                    usingReplenishmentBin = false;
                }

                logger.Info($"Validating bins. Going from {fromWarehouse}/{binNum} to {toWarehouse}/{binNum}.");

                // Look up the source bin so we can copy properties to destination.
                var fromBinDS = whseBin.GetRows($@"WarehouseCode = '{fromWarehouse}' and BinNum = '{binNum}'", "", 0, 1, out _);

                UpsertBin(toWarehouse, binNum, toWarehouseZone, packNum, usingReplenishmentBin, fromBinDS);

                // Make sure the fromBin is in our deactivation list. (Unless it's a replenishment bin.)
                // It's going to be empty and obsolete after receipt.
                if (!usingReplenishmentBin && !traysToInactivate.Any(t => t.BinNum == binNum && t.WarehouseCode == fromWarehouse))
                {
                    traysToInactivate.Add(new Bin {
                        BinNum        = binNum,
                        WarehouseCode = fromWarehouse
                    });
                }

                plantTran.ReceiveToBinNum = binNum;
            } catch (Exception ex) {
                logger.Error($"Failed to validate bin configuration. Error: {ex.Message}");
            }
        }
Exemple #2
0
        private static void ProcessLine(List <Bin> traysToInactivate, TransferOrderEntryDataSet order, TransOrderReceiptDataSet.PlantTranRow line,
                                        string warehouseCode, TransOrderReceiptDataSet receipt)
        {
            try {
                // Get the order line that matches this transaction to retrieve replenishment info.
                // Make sure this isn't case sensitive. The cases aren't consistent.
                var ordLineDS = order.TFOrdDtl.Cast <TransferOrderEntryDataSet.TFOrdDtlRow>().FirstOrDefault(
                    o => string.Equals(o.TFOrdNum, line.TFOrdNum, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(o.TFLineNum, line.TFLineNum, StringComparison.OrdinalIgnoreCase));

                if (ordLineDS == null)
                {
                    throw new Exception("Unable to locate matching order line.");
                }

                var trayKey          = ordLineDS.Character10;
                var replenishmentBin = ordLineDS.ShortChar04;

                logger.Info($"Line: {line.TFLineNum}. TrayKey: {trayKey} Replenishment bin: {replenishmentBin}");

                /*
                 * Set the receiving bin!
                 * If someone specified a 'trayKey' and replenishment bin, use that.
                 * Otherwise, ensure a duplicate of the source bin exists in the destination DB and use that.
                 */
                if (string.IsNullOrEmpty(trayKey))
                {
                    line.ReceiveToBinNum = !string.IsNullOrEmpty(replenishmentBin) ? replenishmentBin : "1";
                }
                else
                {
                    CheckBinConfiguration(line, order, trayKey, replenishmentBin, traysToInactivate);
                }

                // Update line!
                line.ReceiveToWhseCode = warehouseCode;
                line.RecTranDate       = DateTime.Now;
                line.PlntTranReference = $"Consign Order: {line.TFOrdNum}";

                transOrderReceipt.PreUpdate(receipt, out _);
                transOrderReceipt.Update(receipt);
            } catch (Exception ex) {
                logger.Error($"Error on line {line.TFLineNum}. Error: {ex.Message}");
            }
        }