Ejemplo 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;
                }
            }
        }
        private static void LoadSampleOrders(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var sampleOrders           = new List <SampleOrder>();
            var sampleJournalEntries   = new List <SampleOrderJournalEntry>();
            var sampleOrderItems       = new List <SampleOrderItem>();
            var sampleOrderItemSpecs   = new List <SampleOrderItemSpec>();
            var sampleOrderItemMatches = new List <SampleOrderItemMatch>();

            ProcessedBirth(new SampleOrderEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.SampleOrdersLoadLoggerCallback), "Loading Sample Orders", consoleTicker, result =>
            {
                sampleOrders.Add(result);
                sampleJournalEntries.AddRange(result.JournalEntries);
                sampleOrderItems.AddRange(result.Items);
                sampleOrderItemSpecs.AddRange(result.Items.Select(i => i.Spec).Where(s => s != null));
                sampleOrderItemMatches.AddRange(result.Items.Select(i => i.Match).Where(m => m != null));
            });

            consoleTicker.ReplaceCurrentLine("Loading SampleOrders");

            LoadRecords(newContext, sampleOrders, "\tsample orders", consoleTicker);
            LoadRecords(newContext, sampleJournalEntries, "\tsample order journal entries", consoleTicker);
            LoadRecords(newContext, sampleOrderItems, "\tsample order items", consoleTicker);
            LoadRecords(newContext, sampleOrderItemSpecs, "\tsample order item specs", consoleTicker);
            LoadRecords(newContext, sampleOrderItemMatches, "\tsample order item matches", consoleTicker);

            newContext.SaveChanges();
            oldContext.ClearContext();
        }
Ejemplo n.º 3
0
        public void SyncOldModels(IEnumerable <TNewModel> newModels)
        {
            var busyMessage = "";

            if (_consoleTicker != null)
            {
                busyMessage = Message + "...";
                Console.Write(busyMessage + "\r");
            }

            var oldSet = _oldContext.CreateObjectSet <TOldModel>();
            var count  = 0;

            foreach (var newModel in newModels)
            {
                if (_consoleTicker != null)
                {
                    _consoleTicker.TickConsole(busyMessage);
                }

                SyncOldContextModel(oldSet.First(GetOldModelPredicate(newModel)), newModel);
                count++;
            }
            _oldContext.SaveChanges();

            if (_consoleTicker != null)
            {
                _consoleTicker.ReplaceCurrentLine(string.Format("{0} Done - {1} records.", busyMessage, count));
            }
        }
        private static void LoadContracts(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var keySyncContracts = new List <Contract>();
            var contracts        = new List <Contract>();
            var contractItems    = new List <ContractItem>();
            var notebooks        = new List <Notebook>();
            var notes            = new List <Note>();

            ProcessedBirth(new ContractEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.ContractEntityObjectLoadLoggerCallback), "Loading Contracts", consoleTicker, result =>
            {
                if (result.RequiresKeySync)
                {
                    keySyncContracts.Add(result);
                }

                contracts.Add(result);
                contractItems.AddRange(result.ContractItems);
                notebooks.Add(result.Comments);
                notes.AddRange(result.Comments.Notes);
            });

            consoleTicker.ReplaceCurrentLine("Loading Contracts");

            LoadRecords(newContext, notebooks, "\tnotebooks", consoleTicker);
            LoadRecords(newContext, notes, "\tnotes", consoleTicker);
            LoadRecords(newContext, contracts, "\tcontracts", consoleTicker);
            LoadRecords(newContext, contractItems, "\tcontracts items", consoleTicker);

            newContext.SaveChanges();

            new ContractKeySync(oldContext, consoleTicker).SyncOldModels(keySyncContracts);

            oldContext.ClearContext();
        }
Ejemplo n.º 5
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());
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
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());
        }
        protected static void LoadRecords <T>(IBulkInsertContext context, List <T> records, string message, ConsoleTicker consoleTicker)
            where T : class
        {
            if (message != null)
            {
                Console.Write(message + "...\r");
            }

            consoleTicker.ResetTicker();
            var count = context.BulkAddAll(records, message != null ? () => consoleTicker.TickConsole(message + "...") : (Action)null);

            consoleTicker.ReplaceCurrentLine("{0}: {1} records.", message, count);
        }
Ejemplo n.º 9
0
        private static List <TEntity> LoadProducts <TEntity>(IBulkInsertContext newContext, IMother <TEntity> mother, ConsoleTicker consoleTicker, string message, Func <TEntity, Product> productSelector = null) where TEntity : class
        {
            var products = mother.BirthAll(() => consoleTicker.TickConsole(message + "...")).ToList();

            consoleTicker.ReplaceCurrentLine(message);

            if (productSelector != null)
            {
                LoadRecords(newContext, products.Select(productSelector), "\t\tproducts", consoleTicker);
            }
            LoadRecords(newContext, products, "\t" + message.ToLower(), consoleTicker);

            return(products);
        }
        protected static void LoadRecords <T>(IBulkInsertContext context, IEnumerable <T> records, string message, ConsoleTicker consoleTicker, int?takeLimit = null)
            where T : class
        {
            if (message != null)
            {
                Console.Write(message + "...\r");
            }

            var recordsList = takeLimit != null?records.Take(takeLimit.Value).ToList() : records.ToList();

            consoleTicker.ResetTicker();
            var count = context.BulkAddAll(recordsList, message != null ? () => consoleTicker.TickConsole(message + "...") : (Action)null);

            consoleTicker.ReplaceCurrentLine("{0}: {1} records.", message, count);
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
0
        public override void SeedContext(RioValleyChiliDataContext newContext)
        {
            var consoleTicker = new ConsoleTicker();

            using (var oldContext = ContextsHelper.GetOldContext())
            {
                InitializeOldContext();

                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;

                    CreateOldContextRecords(oldContext);

                    LoadRecords(newContext, new EmployeeObjectMother(oldContext, RVCDataLoadLoggerGate.EmployeeLoadLoggerCallback), "Loading Employees", consoleTicker);
                    LoadRecords(newContext, new NotebookMother(RVCDataLoadLoggerGate.LogSummaryEntry("Notebooks")), "Loading Notebooks", consoleTicker);
                    LoadRecords(newContext, new ChileTypeMother(), "Loading Chile Types", consoleTicker);
                    LoadRecords(newContext, new AdditiveTypeMother(), "Loading Additive Types", consoleTicker);
                    LoadRecords(newContext, new WorkTypeMother(), "Loading Work Types", consoleTicker);
                    LoadRecords(newContext, new AttributeNameMother(RVCDataLoadLoggerGate.LogSummaryEntry("Attribute Names")), "Loading Attribute Names", consoleTicker);
                    LoadRecords(newContext, new InventoryTreatmentMother(oldContext, RVCDataLoadLoggerGate.InventoryTreatmentLoadLoggerCallback), "Loading Inventory Treatment Types", consoleTicker);
                    LoadRecords(newContext, new InventoryTreatmentForAttributeMother(), "Loading inventory treatment valdiation rules", consoleTicker);

                    var message    = "Loading Facilities";
                    var facilities = new FacilityEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.WarehouseLoadLoggerCallback).BirthAll(() => consoleTicker.TickConsole(message + "...")).ToList();
                    consoleTicker.ReplaceCurrentLine(message);
                    LoadRecords(newContext, facilities, "\tfacilities", consoleTicker);
                    LoadRecords(newContext, facilities.SelectMany(w => w.Locations), "\tlocations", consoleTicker);

                    oldContext.ClearContext();
                }
                finally
                {
                    newContext.Configuration.ProxyCreationEnabled     = proxyCreation;
                    newContext.Configuration.AutoDetectChangesEnabled = autoDetecChanges;
                    newContext.Configuration.LazyLoadingEnabled       = lazyLoading;
                }
            }
        }
Ejemplo n.º 13
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();
        }
Ejemplo n.º 14
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());
        }
Ejemplo n.º 15
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();
        }
        private static void LoadTreatmentOrders(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var treatmentOrders         = new List <TreatmentOrder>();
            var inventoryShipmentOrders = new List <InventoryShipmentOrder>();
            var pickOrders           = new List <InventoryPickOrder>();
            var pickOrderItems       = new List <InventoryPickOrderItem>();
            var pickedInventories    = new List <PickedInventory>();
            var pickedInventoryItems = new List <PickedInventoryItem>();
            var shipmentInformations = new List <ShipmentInformation>();

            ProcessedBirth(new TreatmentOrdersMother(oldContext, newContext, RVCDataLoadLoggerGate.TreatmentOrdersLoadLoggerCallback), "Loading Treatment Orders", consoleTicker, result =>
            {
                treatmentOrders.Add(result);
                inventoryShipmentOrders.Add(result.InventoryShipmentOrder);
                pickOrders.Add(result.InventoryShipmentOrder.InventoryPickOrder);
                if (result.InventoryShipmentOrder.InventoryPickOrder.Items != null)
                {
                    pickOrderItems.AddRange(result.InventoryShipmentOrder.InventoryPickOrder.Items);
                }
                pickedInventories.Add(result.InventoryShipmentOrder.PickedInventory);
                if (result.InventoryShipmentOrder.PickedInventory.Items != null)
                {
                    pickedInventoryItems.AddRange(result.InventoryShipmentOrder.PickedInventory.Items);
                }
                shipmentInformations.Add(result.InventoryShipmentOrder.ShipmentInformation);
            });

            consoleTicker.ReplaceCurrentLine("Loading Treatment Orders");

            LoadRecords(newContext, treatmentOrders, "\ttreatment orders", consoleTicker);
            LoadRecords(newContext, inventoryShipmentOrders, "\tinventory shipment orders", consoleTicker);
            LoadRecords(newContext, pickOrders, "\tpick orders", consoleTicker);
            LoadRecords(newContext, pickOrderItems, "\tpick order items", consoleTicker);
            LoadRecords(newContext, pickedInventories, "\tpicked inventories", consoleTicker);
            LoadRecords(newContext, pickedInventoryItems, "\tpicked inventory items", consoleTicker);
            LoadRecords(newContext, shipmentInformations, "\tshipment informations", consoleTicker);

            newContext.SaveChanges();
            oldContext.ClearContext();
        }
Ejemplo n.º 17
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());
        }
Ejemplo n.º 18
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();
        }
        private static void LoadSalesQuotes(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var salesQuotes          = new List <SalesQuote>();
            var shipmentInformations = new List <ShipmentInformation>();
            var salesQuoteItems      = new List <SalesQuoteItem>();

            ProcessedBirth(new SalesQuoteEntityObjectMother(newContext, oldContext, RVCDataLoadLoggerGate.SalesQuoteLoadLoggerCallback), "Loading Sales Quotes", consoleTicker, result =>
            {
                salesQuotes.Add(result);
                shipmentInformations.Add(result.ShipmentInformation);
                salesQuoteItems.AddRange(result.Items);
            });

            consoleTicker.ReplaceCurrentLine("Loading Sales Quotes");

            LoadRecords(newContext, salesQuotes, "\tsales quotes", consoleTicker);
            LoadRecords(newContext, shipmentInformations, "\tshipment informations", consoleTicker);
            LoadRecords(newContext, salesQuoteItems, "\tsales quote items", consoleTicker);

            newContext.SaveChanges();
            oldContext.ClearContext();
        }
        private static void LoadLotAllowances(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var customerAllowances      = new List <LotCustomerAllowance>();
            var contractAllowances      = new List <LotContractAllowance>();
            var customerOrderAllowances = new List <LotSalesOrderAllowance>();

            ProcessedBirth(new LotAllowancesEntityObjectMother(oldContext, newContext, RVCDataLoadLoggerGate.LotAllowancesLoadLoggerCallback), "Loading Lot Allowances", consoleTicker, result =>
            {
                customerAllowances.AddRange(result.CustomerAllowances);
                contractAllowances.AddRange(result.ContractAllowances);
                customerOrderAllowances.AddRange(result.CustomerOrderAllowances);
            });

            consoleTicker.ReplaceCurrentLine("Loading Lot Allowances");

            LoadRecords(newContext, customerAllowances, "\tlot customer allowances", consoleTicker);
            LoadRecords(newContext, contractAllowances, "\tlot contract allowances", consoleTicker);
            LoadRecords(newContext, customerOrderAllowances, "\tlot customer order allowances", consoleTicker);

            newContext.SaveChanges();
            oldContext.ClearContext();
        }
        private static void LoadIntraWarehouserOrders(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var intraWarehouseOrders = new List <IntraWarehouseOrder>();
            var pickedInventories    = new List <PickedInventory>();
            var pickedInventoryItems = new List <PickedInventoryItem>();

            ProcessedBirth(new IntraWarehouseOrdersMother(oldContext, newContext, RVCDataLoadLoggerGate.IntraWarehouseOrdersLoadLoggerCallback), "Loading IntraWarehouse Orders", consoleTicker, result =>
            {
                intraWarehouseOrders.Add(result);
                pickedInventories.Add(result.PickedInventory);
                pickedInventoryItems.AddRange(result.PickedInventory.Items);
            });

            consoleTicker.ReplaceCurrentLine("Loading IntraWarehouse Orders");

            LoadRecords(newContext, intraWarehouseOrders, "\tintrawarehouse orders", consoleTicker);
            LoadRecords(newContext, pickedInventories, "\tpicked inventories", consoleTicker);
            LoadRecords(newContext, pickedInventoryItems, "\tpicked inventory items", consoleTicker);

            newContext.SaveChanges();
            oldContext.ClearContext();
        }
Ejemplo n.º 22
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());
        }
        public override void SeedContext(RioValleyChiliDataContext newContext)
        {
            new CoreDbContextDataSeeder().SeedContext(newContext);

            var consoleTicker = new ConsoleTicker();

            using (var oldContext = ContextsHelper.GetOldContext())
            {
                var companyResults = new CompanyAndContactsMother(oldContext, newContext, RVCDataLoadLoggerGate.CompanyAndContactsLoadLoggerCallback).BirthAll(() => consoleTicker.TickConsole("Loading Companies...")).ToList();
                consoleTicker.ReplaceCurrentLine("Loading Companies");
                var companies        = new List <Models.Company>();
                var contacts         = new List <Models.Contact>();
                var contactAddresses = new List <ContactAddress>();
                var customers        = new List <Customer>();
                var customerNotes    = new List <CustomerNote>();
                foreach (var result in companyResults)
                {
                    companies.Add(result.Company);
                    contacts.AddRange(result.Company.Contacts);
                    contactAddresses.AddRange(result.Company.Contacts.SelectMany(c => c.Addresses));

                    if (result.Customer != null)
                    {
                        customers.Add(result.Customer);
                        customerNotes.AddRange(result.Customer.Notes);
                    }
                }

                LoadRecords(newContext, companies, "\tcompanies", consoleTicker);
                LoadRecords(newContext, companies.SelectMany(c => c.CompanyTypes), "\tcompany types", consoleTicker);
                LoadRecords(newContext, contacts, "\tcontacts", consoleTicker);
                LoadRecords(newContext, contactAddresses, "\tcontact addresses", consoleTicker);
                LoadRecords(newContext, customers, "\tcustomers", consoleTicker);
                LoadRecords(newContext, customerNotes, "\tcustomer notes", consoleTicker);
            }
        }
        private static void LoadSalesOrders(RioAccessSQLEntities oldContext, RioValleyChiliDataContext newContext, ConsoleTicker consoleTicker)
        {
            var keySyncOrders           = new List <SalesOrder>();
            var orders                  = new List <SalesOrder>();
            var inventoryShipmentOrders = new List <InventoryShipmentOrder>();
            var salesOrderItems         = new List <SalesOrderItem>();
            var orderItems              = new List <InventoryPickOrderItem>();
            var salesOrderPickedItems   = new List <SalesOrderPickedItem>();
            var pickedItems             = new List <PickedInventoryItem>();
            var pickedInventories       = new List <PickedInventory>();
            var inventoryPickOrders     = new List <InventoryPickOrder>();
            var shipmentInformations    = new List <ShipmentInformation>();

            ProcessedBirth(new SalesOrderEntityObjectMother(newContext, oldContext, RVCDataLoadLoggerGate.SalesOrderLoadLoggerCallback), "Loading SalesOrders", consoleTicker, result =>
            {
                if (result.RequiresKeySync)
                {
                    keySyncOrders.Add(result);
                }

                orders.Add(result);
                inventoryShipmentOrders.Add(result.InventoryShipmentOrder);
                pickedInventories.Add(result.InventoryShipmentOrder.PickedInventory);
                inventoryPickOrders.Add(result.InventoryShipmentOrder.InventoryPickOrder);
                shipmentInformations.Add(result.InventoryShipmentOrder.ShipmentInformation);
                if (result.SalesOrderItems != null)
                {
                    foreach (var item in result.SalesOrderItems)
                    {
                        salesOrderItems.Add(item);
                        orderItems.Add(item.InventoryPickOrderItem);
                    }
                }
                if (result.SalesOrderPickedItems != null)
                {
                    foreach (var item in result.SalesOrderPickedItems)
                    {
                        salesOrderPickedItems.Add(item);
                        pickedItems.Add(item.PickedInventoryItem);
                    }
                }
            });

            consoleTicker.ReplaceCurrentLine("Loading SalesOrders");

            try
            {
                LoadRecords(newContext, orders, "\tsales orders", consoleTicker);
                LoadRecords(newContext, inventoryShipmentOrders, "\tinventory shipment orders", consoleTicker);
                LoadRecords(newContext, pickedInventories, "\tpicked inventories", consoleTicker);
                LoadRecords(newContext, inventoryPickOrders, "\tinventory pick orders", consoleTicker);
                LoadRecords(newContext, shipmentInformations, "\tshipment informations", consoleTicker);
                LoadRecords(newContext, salesOrderItems, "\tsales order items", consoleTicker);
                LoadRecords(newContext, orderItems, "\tinventory pick order items", consoleTicker);
                LoadRecords(newContext, salesOrderPickedItems, "\tsales order picked items", consoleTicker);
                LoadRecords(newContext, pickedItems, "\tpicked inventory items", consoleTicker);

                newContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception("Exception during SalesOrders loading - possibly caused by reserved PickedInventory key having being previously assigned.", ex);
            }

            new SalesOrderKeySync(oldContext, consoleTicker).SyncOldModels(keySyncOrders);

            oldContext.ClearContext();
        }