예제 #1
0
        public IResult SetPickedInventoryForSalesOrder(string salesOrderKey, ISetPickedInventoryParameters pickedInventory)
        {
            if (salesOrderKey == null)
            {
                throw new ArgumentNullException("salesOrderKey");
            }
            if (pickedInventory == null)
            {
                throw new ArgumentNullException("pickedInventory");
            }

            var orderKeyResult = KeyParserHelper.ParseResult <ISalesOrderKey>(salesOrderKey);

            if (!orderKeyResult.Success)
            {
                return(orderKeyResult);
            }

            var pickInventoryResult = new SetSalesOrderPickedInventoryConductor(_inventoryShipmentOrderUnitOfWork).Execute(_timeStamper.CurrentTimeStamp, orderKeyResult.ResultingObject, pickedInventory);

            if (!pickInventoryResult.Success)
            {
                return(pickInventoryResult);
            }

            _inventoryShipmentOrderUnitOfWork.Commit();

            var key = pickInventoryResult.ResultingObject.ToSalesOrderKey();

            return(SyncParameters.Using(new SuccessResult(), new SyncSalesOrderParameters
            {
                SalesOrderKey = key,
                New = false
            }));
        }
        public IResult SetPickedInventory(string contextKey, ISetPickedInventoryParameters parameters)
        {
            var orderKeyResult = KeyParserHelper.ParseResult <IInventoryShipmentOrderKey>(contextKey);

            if (!orderKeyResult.Success)
            {
                return(orderKeyResult);
            }
            var orderKey = orderKeyResult.ResultingObject.ToInventoryShipmentOrderKey();

            var parsedParameters = parameters.PickedInventoryItems.ToParsedParameters();

            if (!parsedParameters.Success)
            {
                return(parsedParameters);
            }

            var setResult = new SetInterWarehouseOrderPickedInventoryConductor(_inventoryShipmentOrderUnitOfWork)
                            .UpdatePickedInventory(orderKey, parameters, _timeStamper.CurrentTimeStamp, parsedParameters.ResultingObject);

            if (!setResult.Success)
            {
                return(setResult);
            }

            _inventoryShipmentOrderUnitOfWork.Commit();

            return(SyncParameters.Using(new SuccessResult(), new SyncInventoryShipmentOrderParameters
            {
                InventoryShipmentOrderKey = orderKey,
                New = false
            }));
        }
예제 #3
0
        public IResult PickInventoryForProductionBatch(string productionBatchKey, ISetPickedInventoryParameters pickedInventory)
        {
            if (productionBatchKey == null)
            {
                throw new ArgumentNullException("productionBatchKey");
            }
            if (pickedInventory == null)
            {
                throw new ArgumentNullException("pickedInventory");
            }

            var productionBatchKeyResult = KeyParserHelper.ParseResult <ILotKey>(productionBatchKey);

            if (!productionBatchKeyResult.Success)
            {
                return(productionBatchKeyResult);
            }
            var lotKey = productionBatchKeyResult.ResultingObject.ToLotKey();

            var result = new ProductionBatchPickInventoryConductor(_productionUnitOfWork).Execute(_timeStamper.CurrentTimeStamp, pickedInventory, lotKey);

            if (!result.Success)
            {
                return(result);
            }

            _productionUnitOfWork.Commit();

            return(SyncParameters.Using(new SuccessResult(), lotKey));
        }
예제 #4
0
 IResult IPickInventoryServiceComponent.SetPickedInventory(string contextKey, ISetPickedInventoryParameters parameters)
 {
     try
     {
         return(_productionServiceProvider.PickInventoryForProductionBatch(contextKey, parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult(ex.GetInnermostException().Message));
     }
 }
예제 #5
0
 public IResult SetPickedInventory(string contextKey, ISetPickedInventoryParameters parameters)
 {
     try
     {
         return(_warehouseOrderServiceProvider.SetPickedInventory(contextKey, parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult(ex.Message));
     }
 }
예제 #6
0
 IResult IPickInventoryServiceComponent.SetPickedInventory(string contextKey, ISetPickedInventoryParameters parameters)
 {
     try
     {
         return(_treatmentOrderServiceProvider.SetPickedInventory(contextKey, parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult(ex.Message));
     }
 }
예제 #7
0
 public IResult SetPickedInventory(string contextKey, ISetPickedInventoryParameters parameters)
 {
     try
     {
         return(_salesServiceProvider.SetPickedInventoryForSalesOrder(contextKey, parameters));
     }
     catch (Exception ex)
     {
         ex = ex.GetBaseException();
         _exceptionLogger.LogException(ex);
         return(new FailureResult(ex.Message));
     }
 }
예제 #8
0
        public IResult <LotKey> Execute(DateTime timeStamp, ISetPickedInventoryParameters pickedInventory, LotKey batchKey)
        {
            var productionBatch = UnitOfWork.ProductionBatchRepository.FindByKey(batchKey,
                                                                                 b => b.Production.ResultingChileLot.Lot.Attributes.Select(a => a.AttributeName),
                                                                                 b => b.Production.PickedInventory.Items.Select(i => i.CurrentLocation));

            if (productionBatch == null)
            {
                return(new InvalidResult <LotKey>(null, string.Format(UserMessages.ProductionBatchNotFound, batchKey.KeyValue)));
            }

            if (productionBatch.ProductionHasBeenCompleted)
            {
                return(new InvalidResult <LotKey>(null, string.Format(UserMessages.ProductionBatchAlreadyComplete, batchKey.KeyValue)));
            }

            var employeeResult = new GetEmployeeCommand(UnitOfWork).GetEmployee(pickedInventory);

            if (!employeeResult.Success)
            {
                return(employeeResult.ConvertTo <LotKey>());
            }

            var parsedPicked = pickedInventory.PickedInventoryItems.ToParsedParameters();

            if (!parsedPicked.Success)
            {
                return(parsedPicked.ConvertTo <LotKey>());
            }

            var pickResult = UpdatePickedInventory(PickedInventoryValidator.ForProductionBatch, employeeResult.ResultingObject, timeStamp, productionBatch.Production.PickedInventory, parsedPicked.ResultingObject);

            if (!pickResult.Success)
            {
                return(pickResult.ConvertTo <LotKey>());
            }

            var setWeightedAttributes = new SetLotWeightedAttributesConductor(UnitOfWork).Execute(productionBatch.Production.ResultingChileLot, productionBatch.Production.PickedInventory.Items.ToList(), timeStamp);

            if (!setWeightedAttributes.Success)
            {
                return(setWeightedAttributes.ConvertTo <LotKey>());
            }

            return(new SuccessResult <LotKey>(batchKey));
        }
        internal IResult <SalesOrder> Execute(DateTime timestamp, ISalesOrderKey salesOrderKey, ISetPickedInventoryParameters setPickedInventory)
        {
            if (salesOrderKey == null)
            {
                throw new ArgumentNullException("salesOrderKey");
            }
            if (setPickedInventory == null)
            {
                throw new ArgumentNullException("setPickedInventory");
            }

            var employeeResult = new GetEmployeeCommand(_salesUnitOfWork).GetEmployee(setPickedInventory);

            if (!employeeResult.Success)
            {
                return(employeeResult.ConvertTo <SalesOrder>());
            }

            var customerOrderResult = GetSalesOrder(salesOrderKey);

            if (!customerOrderResult.Success)
            {
                return(customerOrderResult);
            }
            var salesOrder = customerOrderResult.ResultingObject;

            salesOrder.InventoryShipmentOrder.PickedInventory.EmployeeId = employeeResult.ResultingObject.EmployeeId;
            salesOrder.InventoryShipmentOrder.PickedInventory.TimeStamp  = timestamp;

            var parsedPickedInventory = new List <PickedInventoryParameters>();

            foreach (var item in setPickedInventory.PickedInventoryItems)
            {
                var itemParseResult = item.ToParsedParameters(true);
                if (!itemParseResult.Success)
                {
                    return(itemParseResult.ConvertTo <SalesOrder>());
                }
                parsedPickedInventory.Add(itemParseResult.ResultingObject);
            }

            var pickedInventoryModifications = PickedInventoryHelper.CreateModifyCustomerOrderPickedInventoryItemParameters(salesOrder, parsedPickedInventory);
            var validatorResult = ValidateModifyPickedInventoryItems(salesOrder, pickedInventoryModifications);

            if (!validatorResult.Success)
            {
                return(validatorResult.ConvertTo <SalesOrder>());
            }

            var modifyPickedResult = new ModifySalesOrderPickedItemsCommand(_salesUnitOfWork).Execute(new PickedInventoryKey(salesOrder.InventoryShipmentOrder), pickedInventoryModifications);

            if (!modifyPickedResult.Success)
            {
                return(modifyPickedResult.ConvertTo <SalesOrder>());
            }

            var inventoryModifications = pickedInventoryModifications.Select(p => p.ToModifySourceInventoryParameters());
            var modifyInventoryResult  = new ModifyInventoryCommand(_salesUnitOfWork).Execute(inventoryModifications, null);

            if (!modifyInventoryResult.Success)
            {
                return(modifyInventoryResult.ConvertTo <SalesOrder>());
            }

            return(new SuccessResult <SalesOrder>(salesOrder));
        }
예제 #10
0
 public IResult SetPickedInventoryForProductionBatch(string productionBatchKey, ISetPickedInventoryParameters parameters)
 {
     return(((IPickInventoryServiceComponent)this).SetPickedInventory(productionBatchKey, parameters));
 }