private static void HandleProductionOrderIsInStateCreated(ProductionOrder productionOrder,
                                                                  IAggregator aggregator, IDbTransactionData dbTransactionData)
        {
            // delete all operations
            List <ProductionOrderOperation> operations =
                aggregator.GetProductionOrderOperationsOfProductionOrder(productionOrder);

            dbTransactionData.ProductionOrderOperationDeleteAll(operations);

            // collect entities and demandToProviders/providerToDemands to delete
            List <IDemandOrProvider> demandOrProvidersToDelete =
                CreateProductionOrderSubGraph(true, productionOrder, aggregator);

            // delete all collected entities
            IOpenDemandManager openDemandManager =
                ZppConfiguration.CacheManager.GetOpenDemandManager();

            foreach (var demandOrProvider in demandOrProvidersToDelete)
            {
                // don't forget to delete it from openDemands
                if (demandOrProvider.GetType() == typeof(StockExchangeDemand))
                {
                    if (openDemandManager.Contains((Demand)demandOrProvider))
                    {
                        openDemandManager.RemoveDemand((Demand)demandOrProvider);
                    }
                }

                List <ILinkDemandAndProvider> demandAndProviderLinks =
                    aggregator.GetArrowsToAndFrom(demandOrProvider);
                dbTransactionData.DeleteAllFrom(demandAndProviderLinks);

                dbTransactionData.DeleteA(demandOrProvider);
            }
        }
Example #2
0
        public void InitByReadingFromDatabase(string testConfiguration, bool addInitialStockLevels)
        {
            ProductionDomainContexts productionDomainContexts = Dbms.GetDbContext();

            _productionDomainContext = productionDomainContexts.ProductionDomainContext;

            _productionDomainContextArchive =
                productionDomainContexts.ProductionDomainContextArchive;

            InitDb(testConfiguration, _productionDomainContext, true);
            InitDb(testConfiguration, _productionDomainContextArchive, false);

            _dbMasterDataCache = new DbMasterDataCache(_productionDomainContext);
            // duplicate masterData for archive
            _dbMasterDataCache.Clone(_productionDomainContextArchive);

            _dbTransactionData        = new DbTransactionData(_productionDomainContext);
            _dbTransactionDataArchive = new DbTransactionData(_productionDomainContextArchive);

            if (addInitialStockLevels)
            {
                OpenDemandManager.AddInitialStockLevels(_dbTransactionData);
            }

            _aggregator        = new Aggregator(_dbTransactionData);
            _openDemandManager = new OpenDemandManager();
        }
Example #3
0
 public IDbTransactionData ReloadTransactionData()
 {
     _dbTransactionData        = new DbTransactionData(_productionDomainContext);
     _dbTransactionDataArchive = new DbTransactionData(_productionDomainContextArchive);
     _aggregator        = new Aggregator(_dbTransactionData);
     _openDemandManager = new OpenDemandManager();
     return(_dbTransactionData);
 }
Example #4
0
        public void Dispose()
        {
            _openDemandManager?.Dispose();
            _openDemandManager = null;
            _dbMasterDataCache = null;
            _testConfiguration = null;

            _productionDomainContext?.Database?.CloseConnection();
            _dbTransactionData?.Dispose();

            _productionDomainContextArchive?.Database?.CloseConnection();
            _dbTransactionDataArchive?.Dispose();

            _productionDomainContext        = null;
            _productionDomainContextArchive = null;

            _dbTransactionData        = null;
            _dbTransactionDataArchive = null;
        }
Example #5
0
 public EntityCollector CreateDependingDemands(IOpenDemandManager openDemandManager, Provider provider)
 {
     // NOT needed, since PurchaseOrderPart has never dependingDemands
     throw new System.NotImplementedException();
 }