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); } }
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(); }
public IDbTransactionData ReloadTransactionData() { _dbTransactionData = new DbTransactionData(_productionDomainContext); _dbTransactionDataArchive = new DbTransactionData(_productionDomainContextArchive); _aggregator = new Aggregator(_dbTransactionData); _openDemandManager = new OpenDemandManager(); return(_dbTransactionData); }
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; }
public EntityCollector CreateDependingDemands(IOpenDemandManager openDemandManager, Provider provider) { // NOT needed, since PurchaseOrderPart has never dependingDemands throw new System.NotImplementedException(); }