Ejemplo n.º 1
0
        public void ReceiveCarton(string scan, string palletId, int processId)
        {
            if (string.IsNullOrWhiteSpace(scan))
            {
                // Nothing to do
                return;
            }
            if (string.IsNullOrWhiteSpace(palletId))
            {
                throw new ArgumentNullException("palletId");
            }

            var cartonToReceive = _repos.GetIntransitCarton2(scan);

            if (cartonToReceive != null)
            {
                // Normal case
                if (cartonToReceive.IsShipmentClosed)
                {
                    // This carton is from an already closed shipment. check whether we can accept it.
                    if (!_repos.AcceptCloseShipmentCtn(scan, processId))
                    {
                        throw new ProviderException(string.Format("Carton {0} belongs to a closed shipment.Scan after carton for open shipment or use blind receiving.", scan));
                    }
                }
                var areaId = GetDestinationArea(processId, cartonToReceive);
                HandleDisposition(palletId, areaId, cartonToReceive.VwhId);
                // Unreceived carton.
                _repos.ReceiveCarton(palletId, cartonToReceive.CartonId, areaId, processId);
                return;
            }


            // See whether this carton has already been received
            var carton = _repos.GetReceivedCartons2(null, scan).FirstOrDefault();

            if (carton == null)
            {
                throw new ProviderException(string.Format("Carton {0} not part of ASN", scan));
            }
            //if (carton.InShipmentId != processId)
            //{
            //    //carton has already been received throw exception with pallet Id on which carton was put.
            //    throw new Exception(string.Format("Carton {0} has already been received by Receiving Process {1}", carton.CartonId, carton.InShipmentId));
            //}
            // Put carton on pallet and check disposition.
            HandleDisposition(palletId, carton.DestinationArea, carton.VwhId);
            // If we get here, Dipos ok put carton on pallet
            _repos.PutCartonOnPallet(palletId, scan);
        }