private Quantity SumReservedQuantity(IDemandOrProvider demandOrProvider)
 {
     if (demandOrProvider.GetNodeType().Equals(NodeType.Demand))
     {
         return(SumReservedQuantity(Demand.AsDemand(demandOrProvider)));
     }
     else
     {
         return(SumReservedQuantity(Provider.AsProvider(demandOrProvider)));
     }
 }
        private static void ArchiveArrowsToAndFrom(IDemandOrProvider demandOrProvider,
                                                   IDbTransactionData dbTransactionData, IDbTransactionData dbTransactionDataArchive,
                                                   IAggregator aggregator)
        {
            List <ILinkDemandAndProvider> demandAndProviderLinks =
                aggregator.GetArrowsToAndFrom(demandOrProvider);

            foreach (var demandAndProviderLink in demandAndProviderLinks)
            {
                dbTransactionDataArchive.AddA(demandAndProviderLink);
                dbTransactionData.DeleteA(demandAndProviderLink);
            }
        }
        public Quantity GetRemainingQuantity(IDemandOrProvider demandOrProvider)
        {
            Quantity reservedQuantity = demandOrProvider.GetQuantity()
                                        .Minus(SumReservedQuantity(demandOrProvider));

            if (reservedQuantity.IsNegative())
            {
                return(Quantity.Null());
            }
            else
            {
                return(reservedQuantity);
            }
        }
 public void AddA(IDemandOrProvider demandOrProvider)
 {
     if (demandOrProvider is Demand)
     {
         DemandsAdd((Demand)demandOrProvider);
     }
     else if (demandOrProvider is Provider)
     {
         ProvidersAdd((Provider)demandOrProvider);
     }
     else
     {
         throw new MrpRunException("This type is not expected.");
     }
 }
 public void DeleteA(IDemandOrProvider demandOrProvider)
 {
     if (demandOrProvider is Demand)
     {
         DemandsDelete((Demand)demandOrProvider);
     }
     else if (demandOrProvider is Provider)
     {
         ProvidersDelete((Provider)demandOrProvider);
     }
     else
     {
         throw new MrpRunException("This type is unknown.");
     }
 }
Esempio n. 6
0
 public List <ILinkDemandAndProvider> GetArrowsFrom(IDemandOrProvider demandOrProvider)
 {
     if (demandOrProvider is Demand)
     {
         return(GetArrowsFrom((Demand)demandOrProvider));
     }
     else if (demandOrProvider is Provider)
     {
         return(GetArrowsFrom((Provider)demandOrProvider));
     }
     else
     {
         throw new MrpRunException("This type is not expected.");
     }
 }
Esempio n. 7
0
 public static Demand AsDemand(IDemandOrProvider demandOrProvider)
 {
     if (demandOrProvider.GetType() == typeof(ProductionOrderBom))
     {
         return((ProductionOrderBom)demandOrProvider);
     }
     else if (demandOrProvider.GetType() == typeof(StockExchangeDemand))
     {
         return((StockExchangeDemand)demandOrProvider);
     }
     else if (demandOrProvider.GetType() == typeof(CustomerOrderPart))
     {
         return((CustomerOrderPart)demandOrProvider);
     }
     else
     {
         throw new MrpRunException("Unknown type implementing Demand");
     }
 }
 public static Provider AsProvider(IDemandOrProvider demandOrProvider)
 {
     if (demandOrProvider.GetType() == typeof(ProductionOrder))
     {
         return((ProductionOrder)demandOrProvider);
     }
     else if (demandOrProvider.GetType() == typeof(PurchaseOrderPart))
     {
         return((PurchaseOrderPart)demandOrProvider);
     }
     else if (demandOrProvider.GetType() == typeof(StockExchangeProvider))
     {
         return((StockExchangeProvider)demandOrProvider);
     }
     else
     {
         throw new MrpRunException("Unknown type implementing Provider");
     }
 }
        private static void ArchiveDemandOrProvider(IDemandOrProvider demandOrProvider,
                                                    IDbTransactionData dbTransactionData, IAggregator aggregator, bool includeArrows)
        {
            if (demandOrProvider == null)
            {
                throw new MrpRunException("Given demandOrProvider cannot be null.");
            }

            IDbTransactionData dbTransactionDataArchive =
                ZppConfiguration.CacheManager.GetDbTransactionDataArchive();

            if (includeArrows)
            {
                ArchiveArrowsToAndFrom(demandOrProvider, dbTransactionData,
                                       dbTransactionDataArchive, aggregator);
            }

            dbTransactionDataArchive.AddA(demandOrProvider);
            dbTransactionData.DeleteA(demandOrProvider);
        }
 public bool IsSatisfied(IDemandOrProvider demandOrProvider)
 {
     return(GetRemainingQuantity(demandOrProvider).Equals(Quantity.Null()));
 }