Esempio n. 1
0
        public override void SeedContext(RioValleyChiliDataContext newContext)
        {
            new CompanyDbContactDataSeeder().SeedContext(newContext);

            var consoleTicker = new ConsoleTicker();

            using (var oldContext = ContextsHelper.GetOldContext())
            {
                var proxyCreation    = newContext.Configuration.ProxyCreationEnabled;
                var autoDetecChanges = newContext.Configuration.AutoDetectChangesEnabled;
                var lazyLoading      = newContext.Configuration.LazyLoadingEnabled;

                try
                {
                    newContext.Configuration.ProxyCreationEnabled     = false;
                    newContext.Configuration.AutoDetectChangesEnabled = false;
                    newContext.Configuration.LazyLoadingEnabled       = false;

                    Console.WriteLine("Loading Products");

                    var chileProducts = LoadProducts(newContext, new ChileProductEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.ChileProductLoadLoggerCallback), consoleTicker, "\tChile Products", c => c.Product);
                    LoadRecords(newContext, chileProducts.SelectMany(c => c.ProductAttributeRanges), "\t\tproduct attribute ranges", consoleTicker);
                    LoadRecords(newContext, new ChileProductIngredientsMother(oldContext, newContext, RVCDataLoadLoggerGate.ChileProductIngredientsLoadLoggerCallback), "\t\tingredients", consoleTicker);

                    LoadProducts(newContext, new PackagingProductEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.PackagingProductLoadLoggerCallback), consoleTicker, "\tPackaging Products", p => p.Product);
                    LoadProducts(newContext, new AdditiveProductEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.AdditiveProductLoadLoggerCallback), consoleTicker, "\tAdditive Products", a => a.Product);

                    LoadProducts(newContext, new NonInventoryProductEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.NonInventoryProductLoadLoggerCallback), consoleTicker, "\tNon-Inventory Products");

                    StartWatch();
                    var specs = new List <CustomerProductAttributeRange>();
                    ProcessedBirth(new CustomerProductSpecMother(oldContext, newContext, RVCDataLoadLoggerGate.CustomerSpecsLoadLoggerCallback), "Loading Customer Product Specs", consoleTicker, specs.Add);
                    consoleTicker.ReplaceCurrentLine("Loading Customer Product Specs");
                    LoadRecords(newContext, specs, "\tcustomer product attribute ranges", consoleTicker);
                    consoleTicker.WriteTimeElapsed(StopWatch());

                    StartWatch();
                    var codes = new List <CustomerProductCode>();
                    ProcessedBirth(new CustomerProductCodeMother(oldContext, newContext, RVCDataLoadLoggerGate.CustomerProductCodeLoadLoggerCallback), "Loading Customer Product Codes", consoleTicker, codes.Add);
                    consoleTicker.ReplaceCurrentLine("Loading Customer Product Codes");
                    LoadRecords(newContext, codes, "\tcustomer product codes", consoleTicker);
                    consoleTicker.WriteTimeElapsed(StopWatch());

                    oldContext.ClearContext();
                }
                finally
                {
                    newContext.Configuration.ProxyCreationEnabled     = proxyCreation;
                    newContext.Configuration.AutoDetectChangesEnabled = autoDetecChanges;
                    newContext.Configuration.LazyLoadingEnabled       = lazyLoading;
                }
            }
        }
Esempio n. 2
0
        private static void LoadLots(RioValleyChiliDataContext newContext, RioAccessSQLEntities oldContext, ConsoleTicker consoleTicker)
        {
            StartWatch();
            var lots                 = new List <Lot>();
            var chileLots            = new List <ChileLot>();
            var additiveLots         = new List <AdditiveLot>();
            var packagingLots        = new List <PackagingLot>();
            var lotAttributes        = new List <LotAttribute>();
            var lotDefects           = new List <LotDefect>();
            var lotAttributeDefects  = new List <LotAttributeDefect>();
            var lotDefectResolutions = new List <LotDefectResolution>();

            ProcessedBirth(new LotEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.LotLoadLoggerCallback), "Loading Lots", consoleTicker, lotResult =>
            {
                if (lotResult.ChileLot != null)
                {
                    chileLots.Add(lotResult.ChileLot);
                    lots.Add(lotResult.ChileLot.Lot);
                    lotAttributes.AddRange(lotResult.ChileLot.Lot.Attributes);

                    if (lotResult.ChileLot.Lot.LotDefects != null)
                    {
                        lotDefects.AddRange(lotResult.ChileLot.Lot.LotDefects);
                        lotDefectResolutions.AddRange(lotResult.ChileLot.Lot.LotDefects.Select(d => d.Resolution).Where(r => r != null));
                    }
                }
                else if (lotResult.AdditiveLot != null)
                {
                    additiveLots.Add(lotResult.AdditiveLot);
                    lots.Add(lotResult.AdditiveLot.Lot);
                    lotAttributes.AddRange(lotResult.AdditiveLot.Lot.Attributes);
                }
                else if (lotResult.PackagingLot != null)
                {
                    packagingLots.Add(lotResult.PackagingLot);
                    lots.Add(lotResult.PackagingLot.Lot);
                }

                if (lotResult.LotAttributeDefects != null)
                {
                    lotAttributeDefects.AddRange(lotResult.LotAttributeDefects);
                }
            });

            consoleTicker.ReplaceCurrentLine("Loading Lots");
            LoadRecords(newContext, lots, "\tlots", consoleTicker);
            LoadRecords(newContext, chileLots, "\tchile lots", consoleTicker);
            LoadRecords(newContext, lotAttributes, "\tchile lot attributes", consoleTicker);
            LoadRecords(newContext, additiveLots, "\tadditive lots", consoleTicker);
            LoadRecords(newContext, packagingLots, "\tpackaging lots", consoleTicker);
            LoadRecords(newContext, lotDefects, "\tlot defects", consoleTicker);
            LoadRecords(newContext, lotDefectResolutions, "\tlot defect resolutions", consoleTicker);
            LoadRecords(newContext, lotAttributeDefects, "\tlot attribute defects", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());
        }
Esempio n. 3
0
        private static void LoadLotAttributeHistory(RioValleyChiliDataContext newContext, RioAccessSQLEntities oldContext, ConsoleTicker consoleTicker)
        {
            StartWatch();
            var lots = new List <LotHistory>();

            ProcessedBirth(new LotHistoryEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.LotHistoryLoggerCallback), "Loading Lot History", consoleTicker, lots.Add);

            consoleTicker.ReplaceCurrentLine("Loading Lot Histories");
            LoadRecords(newContext, lots, "\tlotHistory", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());
        }
Esempio n. 4
0
        private static void LoadChileMaterialsReceived(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            StartWatch();
            var chileMaterialsReceived = Birth(new ChileMaterialsReceivedEntityMother(oldContext, newContext, RVCDataLoadLoggerGate.DehydratedMaterialsReceivedLoadLoggerCallback), "Loading Chile Materials Received", consoleTicker);

            consoleTicker.ReplaceCurrentLine("Loading Chile Materials Received");

            LoadRecords(newContext, chileMaterialsReceived, "\tchile materials received", consoleTicker);
            LoadRecords(newContext, chileMaterialsReceived.SelectMany(d => d.Items), "\tchile materials received items", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());
        }
Esempio n. 5
0
 private static void LoadInventory(RioValleyChiliDataContext newContext, RioAccessSQLEntities oldContext, ConsoleTicker consoleTicker)
 {
     StartWatch();
     Console.WriteLine("Loading Inventory");
     LoadRecords(newContext, new AdditiveLotInventoryEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.AdditiveLotInventoryLoadLogger), "\tAdditive", consoleTicker);
     LoadRecords(newContext, new PackagingLotInventoryItemEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.PackagingLotInventoryLoadLogger), "\tPackaging", consoleTicker);
     LoadRecords(newContext, new WIPChileLotInventoryItemEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.WIPChileLotInventoryLoadLogger), "\tChile WIP", consoleTicker);
     LoadRecords(newContext, new FinishedGoodsChileLotInventoryItemEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.FinishedGoodsChileLotInventoryLoadLogger), "\tChile Finished Goods", consoleTicker);
     LoadRecords(newContext, new DehyChileLotInventoryItemEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.DehyChileLotInventoryLoadLogger), "\tChile Dehydrated", consoleTicker);
     LoadRecords(newContext, new RawChileLotInventoryItemEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.RawChileLotInventoryLoadLogger), "\tChile Raw", consoleTicker);
     LoadRecords(newContext, new OtherChileLotInventoryItemEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.OtherChileLotInventoryLoadLogger), "\tChile Other", consoleTicker);
     LoadRecords(newContext, new GRPChileLotInventoryItemEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.GRPChileLotInventoryLoadLogger), "\tChile GRP", consoleTicker);
     consoleTicker.WriteTimeElapsed(StopWatch());
 }
Esempio n. 6
0
        private static void LoadInventoryTransactions(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var          transactions   = new List <InventoryTransaction>();
            const string loadingMessage = "Loading InventoryTransactions";

            StartWatch();

            ProcessedBirth(new InventoryTransactionsMother(oldContext, newContext, RVCDataLoadLoggerGate.InventoryTransactionsLoadLoggerCallback), loadingMessage, consoleTicker, transactions.Add);

            consoleTicker.ReplaceCurrentLine(loadingMessage);
            LoadRecords(newContext, transactions, "\tinventory transactions", consoleTicker);

            newContext.SaveChanges();
            consoleTicker.WriteTimeElapsed(StopWatch());

            oldContext.ClearContext();
        }
Esempio n. 7
0
        private static void LoadPackSchedules(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            StartWatch();
            var packScheduleKeySync = new List <PackSchedule>();
            var packSchedules       = new List <PackSchedule>();
            var productionBatches   = new List <ProductionBatch>();
            var notebooks           = new List <Notebook>();
            var productions         = new List <ChileLotProduction>();
            var pickedInventories   = new List <PickedInventory>();

            ProcessedBirth(new PackScheduleEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.PackScheduleLoadLoggerCallback), "Loading Pack Schedules", consoleTicker, result =>
            {
                if (result.RequiresKeySync)
                {
                    packScheduleKeySync.Add(result);
                }

                packSchedules.Add(result);
                foreach (var batch in result.ProductionBatches)
                {
                    productionBatches.Add(batch);
                    notebooks.Add(batch.InstructionNotebook);
                    productions.Add(batch.Production);
                    pickedInventories.Add(batch.Production.PickedInventory);
                }
            });

            consoleTicker.ReplaceCurrentLine("Loading Pack Schedules");

            LoadRecords(newContext, packSchedules, "\tpack schedules", consoleTicker);
            LoadRecords(newContext, productionBatches, "\tproduction batches", consoleTicker);
            LoadRecords(newContext, notebooks, "\tnotebooks", consoleTicker);
            LoadRecords(newContext, productions, "\tchile lot productions", consoleTicker);
            LoadRecords(newContext, pickedInventories, "\tpicked inventories", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());

            new PackScheduleKeySync(oldContext, consoleTicker).SyncOldModels(packScheduleKeySync);

            oldContext.ClearContext();
        }
Esempio n. 8
0
        private static void LoadInstructions(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var instructions = new List <Instruction>();
            var notes        = new List <Note>();

            ProcessedBirth(new InstructionEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.InstructionLoadLoggerCallback), "Loading Instructions", consoleTicker, result =>
            {
                notes.Add(result.Note);
                if (result.Instruction != null)
                {
                    instructions.Add(result.Instruction);
                }
            });

            consoleTicker.ReplaceCurrentLine("Loading Instructions");

            LoadRecords(newContext, instructions, "\tinstructions", consoleTicker);
            LoadRecords(newContext, notes, "\tnotes", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());
        }
Esempio n. 9
0
        private static void LoadProductionBatches(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            StartWatch();

            var productionResults     = new List <LotProductionResults>();
            var productionResultItems = new List <LotProductionResultItem>();
            var pickedInventories     = new List <PickedInventory>();
            var pickedInventoryItems  = new List <PickedInventoryItem>();
            var productions           = new List <ChileLotProduction>();
            var productionBatches     = new List <ProductionBatch>();
            var notebooks             = new List <Notebook>();

            ProcessedBirth(new ProductionBatchEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.ProductionBatchLoadLoggerCallback), "Loading Production Batches", consoleTicker, productionBatch =>
            {
                if (productionBatch.Production.Results != null)
                {
                    productionResults.Add(productionBatch.Production.Results);
                    productionResultItems.AddRange(productionBatch.Production.Results.ResultItems);
                }
                pickedInventories.Add(productionBatch.Production.PickedInventory);
                pickedInventoryItems.AddRange(productionBatch.Production.PickedInventory.Items);
                productions.Add(productionBatch.Production);
                productionBatches.Add(productionBatch);
                notebooks.Add(productionBatch.InstructionNotebook);
            });

            consoleTicker.ReplaceCurrentLine("Loading Production Batches");

            LoadRecords(newContext, productionResults, "\tproduction results", consoleTicker);
            LoadRecords(newContext, productionResultItems, "\tproduction result items", consoleTicker);
            LoadRecords(newContext, pickedInventories, "\tpicked inventories", consoleTicker);
            LoadRecords(newContext, pickedInventoryItems, "\tpicked inventory items", consoleTicker);
            LoadRecords(newContext, productions, "\tchile lot productions", consoleTicker);
            LoadRecords(newContext, productionBatches, "\tproduction batches", consoleTicker);
            LoadRecords(newContext, notebooks, "\tnotebooks", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());

            oldContext.ClearContext();
        }
Esempio n. 10
0
        private static void LoadInventoryAdjustments(RioValleyChiliDataContext newContext, RioAccessSQLEntities oldContext, ConsoleTicker consoleTicker)
        {
            StartWatch();
            var adjustments     = new List <InventoryAdjustment>();
            var adjustmentItems = new List <InventoryAdjustmentItem>();
            var notebooks       = new List <Notebook>();
            var notes           = new List <Note>();

            ProcessedBirth(new InventoryAdjustmentsMother(oldContext, newContext, RVCDataLoadLoggerGate.InventoryAdjustmentsLoadLoggerCallback), "Loading Inventory Adjustments", consoleTicker, adjustment =>
            {
                adjustments.Add(adjustment);
                adjustmentItems.AddRange(adjustment.Items);
                notebooks.Add(adjustment.Notebook);
                notes.AddRange(adjustment.Notebook.Notes);
            });
            consoleTicker.ReplaceCurrentLine("Loading Inventory Adjustments");
            LoadRecords(newContext, notebooks, "\tNotebooks", consoleTicker);
            LoadRecords(newContext, notes, "\tNotes", consoleTicker);
            LoadRecords(newContext, adjustments, "\tInventory Adjustments", consoleTicker);
            LoadRecords(newContext, adjustmentItems, "\tInventory Adjustments Items", consoleTicker);
            consoleTicker.WriteTimeElapsed(StopWatch());
        }
Esempio n. 11
0
        private static void LoadProductionSchedules(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            StartWatch();

            var productionSchedules     = new List <ProductionSchedule>();
            var productionScheduleItems = new List <ProductionScheduleItem>();

            ProcessedBirth(new ProductionScheduleEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.ProductionScheduleLoadLoggerCallback), "Loading Production Schedules", consoleTicker, result =>
            {
                productionSchedules.Add(result);
                productionScheduleItems.AddRange(result.ScheduledItems);
            });

            consoleTicker.ReplaceCurrentLine("Loading Production Schedules");

            LoadRecords(newContext, productionSchedules, "\tproduction schedules", consoleTicker);
            LoadRecords(newContext, productionScheduleItems, "\tproduction schedule items", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());

            oldContext.ClearContext();
        }
Esempio n. 12
0
        private static void LoadMillAndWetdown(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            StartWatch();
            var productions = new List <ChileLotProduction>();
            var picked      = new List <PickedInventory>();
            var pickedItems = new List <PickedInventoryItem>();
            var results     = new List <LotProductionResults>();
            var resultItems = new List <LotProductionResultItem>();

            ProcessedBirth(new MillAndWetdownMother(oldContext, newContext, RVCDataLoadLoggerGate.MillAndWetdownLoadLoggerCallback), "Loading Mill And Wetdown Records", consoleTicker, production =>
            {
                productions.Add(production);

                picked.Add(production.PickedInventory);
                if (production.PickedInventory.Items != null)
                {
                    pickedItems.AddRange(production.PickedInventory.Items);
                }

                results.Add(production.Results);
                if (production.Results.ResultItems != null)
                {
                    resultItems.AddRange(production.Results.ResultItems);
                }
            });

            consoleTicker.ReplaceCurrentLine("Loading Mill And Wetdown Records");

            LoadRecords(newContext, productions, "\tchile lot productions", consoleTicker);
            LoadRecords(newContext, picked, "\tpicked inventories", consoleTicker);
            LoadRecords(newContext, pickedItems, "\tpicked inventory items", consoleTicker);
            LoadRecords(newContext, results, "\tlot production results", consoleTicker);
            LoadRecords(newContext, resultItems, "\tlot production result items", consoleTicker);

            consoleTicker.WriteTimeElapsed(StopWatch());
        }