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 UseArchiveForGettersRevert() { if (_dbTransactionDataBackup == null) { return; } _dbTransactionData = _dbTransactionDataBackup; _aggregator = new Aggregator(_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; }
internal void Clone(ProductionDomainContext productionDomainContext) { DbTransactionData.InsertRange(_articles.GetAll(), productionDomainContext.Articles, productionDomainContext); DbTransactionData.InsertRange(_articleBoms.GetAll(), productionDomainContext.ArticleBoms, productionDomainContext); DbTransactionData.InsertRange(_articleToBusinessPartners.GetAll(), productionDomainContext.ArticleToBusinessPartners, productionDomainContext); DbTransactionData.InsertRange(_articleTypes.GetAll(), productionDomainContext.ArticleTypes, productionDomainContext); DbTransactionData.InsertRange(_businessPartners.GetAll(), productionDomainContext.BusinessPartners, productionDomainContext); DbTransactionData.InsertRange(_resources.GetAll(), productionDomainContext.Resources, productionDomainContext); DbTransactionData.InsertRange(_resourceSkills.GetAll(), productionDomainContext.ResourceSkills, productionDomainContext); DbTransactionData.InsertRange(_resourceTools.GetAll(), productionDomainContext.ResourceTools, productionDomainContext); DbTransactionData.InsertRange(_resourceSetups.GetAll(), productionDomainContext.ResourceSetups, productionDomainContext); DbTransactionData.InsertRange(_operations.GetAll(), productionDomainContext.Operations, productionDomainContext); DbTransactionData.InsertRange(_stocks.GetAll(), productionDomainContext.Stocks, productionDomainContext); DbTransactionData.InsertRange(_units.GetAll(), productionDomainContext.Units, productionDomainContext); productionDomainContext.SaveChanges(); }
public void UseArchiveForGetters() { _dbTransactionDataBackup = _dbTransactionData; _dbTransactionData = _dbTransactionDataArchive; _aggregator = new Aggregator(_dbTransactionDataArchive); }