Example #1
0
 public void UpdateLink(MachineGroup[] machineGroups)
 {
     foreach (MachineGroup group in machineGroups)
     {
         if (group.Tiles.Contains(new Vector2(warp.TargetX, warp.TargetY)))
         {
             targetMachineGroup = group;
             break;
         }
     }
 }
Example #2
0
        private static MachineGroup parse_machine_group(Queue <string> lines)
        {
            MachineGroup mg = new MachineGroup();

            mg.ID = Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length));

            while (!lines.Peek().Contains("FINI") || (lines.Peek().Contains("$$Machine Group-") && (Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length)) == mg.ID)))
            {
                lines.Dequeue();
                mg.Operations.Add(parse_toolpath_group(lines));
            }

            return(mg);
        }
Example #3
0
        public async Task <Machine> GetDetailMachineByRegNumber(string regNumber)
        {
            var result =
                await _detailMachineByRegService.GetMachineByRegNumberAsync(new GetMachineByRegNumberRequest(regNumber));

            if (result?.oneMachineOut?.component == null)
            {
                return(new Machine());
            }

            var componentAttrs = result.oneMachineOut.component.componentAttributes;
            var groupNew       = new MachineGroup
            {
                Id   = componentAttrs.CmIndividType?.smdid ?? "0",
                Name = componentAttrs.CmIndividType?.Text?.FirstOrDefault() ?? "Ingen kategori",
                Key  = componentAttrs.CmIndividType?.smdkey ?? string.Empty
            };

            return(new Machine
            {
                Id = componentAttrs.SysId?.Text?.FirstOrDefault() ?? string.Empty,
                ModelName = componentAttrs.MvxSAMODC?.Text?.FirstOrDefault() ?? string.Empty,
                ModelDescription = componentAttrs.MvxSAMODE?.Text?.FirstOrDefault() ?? string.Empty,
                IndividualNumber = componentAttrs.MvxSAINNO?.Text?.FirstOrDefault() ?? string.Empty,
                LegalRegNumber = componentAttrs.MvxSAREBE?.Text?.FirstOrDefault() ?? string.Empty,
                OwnerNumber = componentAttrs.MvxSACUOW?.Text?.FirstOrDefault() ?? string.Empty,
                SerialNumber = componentAttrs.MvxSASERI?.Text?.FirstOrDefault() ?? string.Empty,
                DescriptionBrand = componentAttrs.CmHeader?.Text?.FirstOrDefault() ?? string.Empty,
                DescriptionModel = componentAttrs.CmSubHeader?.Text?.FirstOrDefault() ?? string.Empty,
                Brand = new MachineBrand
                {
                    Id = componentAttrs.CmOE?.smdid ?? string.Empty,
                    Key = componentAttrs.CmOE?.smdkey ?? string.Empty,
                    Name = componentAttrs.CmOE?.Text?.FirstOrDefault() ?? string.Empty
                },
                Model = new MachineModel
                {
                    Id = componentAttrs.CmModels?.smdid ?? string.Empty,
                    Key = componentAttrs.CmModels?.smdkey ?? string.Empty,
                    Name = componentAttrs.CmModels?.Text?.FirstOrDefault() ?? string.Empty
                },
                Group = groupNew
            });
        }
        public static void DbInitialize(MasterDBContext context)
        {
            context.Database.EnsureCreated();


            // Look for any Entrys.
            if (context.Articles.Any())
            {
                return;   // DB has been seeded
            }
            // Article Types
            var articleTypes = new ArticleType[]
            {
                new ArticleType {
                    Name = "Assembly"
                },
                new ArticleType {
                    Name = "Material"
                },
                new ArticleType {
                    Name = "Consumable"
                }
            };

            context.ArticleTypes.AddRange(articleTypes);
            context.SaveChanges();

            // Units
            var units = new Unit[]
            {
                new Unit {
                    Name = "Kilo"
                },
                new Unit {
                    Name = "Litre"
                },
                new Unit {
                    Name = "Pieces"
                }
            };

            context.Units.AddRange(units);
            context.SaveChanges();
            var cutting = new MachineGroup {
                Name = "Cutting", Stage = 1, ImageUrl = "/images/Production/saw.svg"
            };
            var drills = new MachineGroup {
                Name = "Drills", Stage = 2, ImageUrl = "/images/Production/drill.svg"
            };
            var assemblyUnit = new MachineGroup {
                Name = "AssemblyUnits", Stage = 3, ImageUrl = "/images/Production/assemblys.svg"
            };

            var machines = new Machine[] {
                new Machine {
                    Capacity = 1, Name = "Saw 1", Count = 1, MachineGroup = cutting
                },
                new Machine {
                    Capacity = 1, Name = "Saw 2", Count = 1, MachineGroup = cutting
                },
                new Machine {
                    Capacity = 1, Name = "Drill 1", Count = 1, MachineGroup = drills
                },
                new Machine {
                    Capacity = 1, Name = "AssemblyUnit 1", Count = 1, MachineGroup = assemblyUnit
                },
                new Machine {
                    Capacity = 1, Name = "AssemblyUnit 2", Count = 1, MachineGroup = assemblyUnit
                }
            };

            context.Machines.AddRange(machines);
            context.SaveChanges();

            var machineTools = new MachineTool[]
            {
                new MachineTool {
                    MachineId = machines.Single(m => m.Name == "Saw 1").Id, SetupTime = 1, Name = "Saw blade"
                },
                new MachineTool {
                    MachineId = machines.Single(m => m.Name == "Drill 1").Id, SetupTime = 1, Name = "M6 head"
                },
            };

            context.MachineTools.AddRange(machineTools);
            context.SaveChanges();

            // Articles
            var articles = new Article[]
            {
                // Final Product
                new Article {
                    Name = "Dump-Truck", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 20, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 45.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/05_Truck_final.jpg"
                },
                new Article {
                    Name = "Race-Truck", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 20, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 45.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/06_Race-Truck_final.jpg"
                },
                new Article {
                    Name = "Skeleton", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/01_Bodenplatte.jpg"
                },
                new Article {
                    Name = "Truck-Bed", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/03_Ladefläche.jpg"
                },
                new Article {
                    Name = "Chassis Type: Dump", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 15.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/02_Gehäuse.jpg"
                },
                new Article {
                    Name = "Chassis Type: Race", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 20.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/08_Race-Truck_Chassie.jpg"
                },
                new Article {
                    Name = "Race Wing", ArticleTypeId = articleTypes.Single(s => s.Name == "Assembly").Id, CreationDate = DateTime.Parse("2016-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 5.00, ToPurchase = false, ToBuild = true, PictureUrl = "/images/Product/07_Race-Wing.jpg"
                },

                // Chassies
                new Article {
                    Name = "Cabin", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1.75, ToPurchase = false, ToBuild = true
                },
                new Article {
                    Name = "Engine-Block", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 3.00, ToPurchase = false, ToBuild = true
                },

                // Truck Bed
                new Article {
                    Name = "Side wall long", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.35, ToPurchase = false, ToBuild = true
                },
                new Article {
                    Name = "Side wall short", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.25, ToPurchase = false, ToBuild = true
                },
                new Article {
                    Name = "Base plate Truck-Bed", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.40, ToPurchase = false, ToBuild = true
                },
                new Article {
                    Name = "Dump Joint" /*Kippgelenk*/, ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.90, ToPurchase = true, ToBuild = false
                },

                // Engine Extension and Race Wing
                new Article {
                    Name = "Engine Race Extension", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.50, ToPurchase = false, ToBuild = true
                },
                // Skeleton
                new Article {
                    Name = "Wheel", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 1.00, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Base plate", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.80, ToPurchase = false, ToBuild = true
                },
                new Article {
                    Name = "Semitrailer" /*Aufleger*/, ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.10, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Washer", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.02, ToPurchase = true, ToBuild = false
                },

                // base Materials
                new Article {
                    Name = "Timber Plate 1,5m x 3,0m", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.20, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Timber Block 0,20m x 0,20m", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 5, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.70, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Glue", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Litre").Id, Price = 0.01, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Pegs", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 3, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.01, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Pole", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Pieces").Id, Price = 0.25, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Button", ArticleTypeId = articleTypes.Single(s => s.Name == "Material").Id, CreationDate = DateTime.Parse("2002-09-01"), DeliveryPeriod = 10, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.05, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "Packing", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 4, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 2.15, ToPurchase = true, ToBuild = false
                },
                new Article {
                    Name = "User Manual", ArticleTypeId = articleTypes.Single(s => s.Name == "Consumable").Id, CreationDate = DateTime.Parse("2005-09-01"), DeliveryPeriod = 4, UnitId = units.Single(s => s.Name == "Kilo").Id, Price = 0.50, ToPurchase = true, ToBuild = false
                },
            };

            context.Articles.AddRange(articles);
            context.SaveChanges();

            // create Stock Entrys for each Article
            foreach (var article in articles)
            {
                var stock = new Stock
                {
                    ArticleForeignKey = article.Id,
                    Name       = "Stock: " + article.Name,
                    Min        = (article.ToPurchase) ? 1000 : 0,
                    Max        = (article.ToPurchase) ? 2000 : 0,
                    Current    = (article.ToPurchase) ? 1000 : 0,
                    StartValue = (article.ToPurchase) ? 1000 : 0,
                };
                context.Stocks.Add(stock);
                context.SaveChanges();
            }
            var workSchedule = new WorkSchedule[]
            {
                // assemble Truck
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Dump-Truck").Id, Name = "Wedding", Duration = 15, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Dump-Truck").Id, Name = "Glue Truck-Bed", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20
                },

                // assemble Truck
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Race-Truck").Id, Name = "Wedding", Duration = 15, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Race-Truck").Id, Name = "Glue Race Wing", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20
                },



                // assemble chassie
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Chassis Type: Dump").Id, Name = "Assemble Lamps", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Chassis Type: Dump").Id, Name = "Mount Engine to Cabin", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20
                },

                // assemble chassie
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Assemble Lamps", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Mount Engine Extension", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Mount Engine to Cabin", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 30
                },


                // assemble Skeleton
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Skeleton").Id, Name = "mount poles with wheels to Skeleton", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Screw wheels onto poles", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Glue Semitrailer", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 30
                },

                // assemble Truck Bed
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Truck-Bed").Id, Name = "Glue side walls and base plate together", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Truck-Bed").Id, Name = "Mount hatchback", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "AssemblyUnit 1").MachineGroupId, HierarchyNumber = 20
                },

                // assemble Race Wing
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Race Wing").Id, Name = "Cut shape", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Race Wing").Id, Name = "Drill Mount Holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },
                // Engine Race Extension
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Engine Race Extension").Id, Name = "Cut shape", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Engine Race Extension").Id, Name = "Drill Mount Holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },

                // side Walls for Truck-bed
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Side wall long").Id, Name = "Cut long side", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Side wall long").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },

                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Side wall short").Id, Name = "Cut short side", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Side wall short").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },

                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id, Name = "Cut Base plate Truck-Bed", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },
                // engin Block
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Cut Engine-Block", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },
                // cabin
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Cabin").Id, Name = "Cut Cabin", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Cabin").Id, Name = "Drill mount holes", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },
                // Base Plate
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Base plate").Id, Name = "Cut Base plate", Duration = 10, MachineGroupId = machines.Single(n => n.Name == "Saw 1").MachineGroupId, HierarchyNumber = 10
                },
                new WorkSchedule {
                    ArticleId = articles.Single(a => a.Name == "Base plate").Id, Name = "drill holes for axis mount", Duration = 5, MachineGroupId = machines.Single(n => n.Name == "Drill 1").MachineGroupId, HierarchyNumber = 20
                },
            };

            context.WorkSchedules.AddRange(workSchedule);
            context.SaveChanges();



            var articleBom = new List <ArticleBom>
            {
                // Final Products
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Dump-Truck").Id, Name = "Dump-Truck"
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Race-Truck").Id, Name = "Race-Truck"
                },
                // Bom For DumpTruck
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Skeleton", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "User Manual").Id, Name = "User Manual", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Chassis Type: Dump").Id, Name = "Chassis Type: Dump", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Truck-Bed").Id, Name = "Truck-Bed", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 5, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Packing").Id, Name = "Packing", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Dump-Truck").Id
                },

                // Bom For Race Truck
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Skeleton").Id, Name = "Skeleton", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "User Manual").Id, Name = "User Manual", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Chassis Type: Race").Id, Name = "Chassis Type: Race", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Race Wing").Id, Name = "Race Wing", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 5, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Packing").Id, Name = "Packing", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Race-Truck").Id
                },


                // Bom for Skeleton
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Base plate").Id, Name = "Base plate", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Wheel").Id, Name = "Wheel", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Semitrailer").Id, Name = "Semitrailer", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 5, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Washer").Id, Name = "Washer", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Skeleton").Id
                },

                // Bom For Chassis Dump
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Cabin").Id, Name = "Cabin", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Engine-Block", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 7, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Dump").Id
                },

                // Bom For Chassis Race
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Cabin").Id, Name = "Cabin", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Engine-Block").Id, Name = "Engine-Block", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Engine Race Extension").Id, Name = "Engine Race Extension", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 4, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 7, ArticleParentId = articles.Single(a => a.Name == "Chassis Type: Race").Id
                },


                // Bom for Truck-Bed
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Side wall long").Id, Name = "Side wall long", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Side wall short").Id, Name = "Side wall short", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id, Name = "Base plate Truck-Bed", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Dump Joint").Id, Name = "Dump Joint", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pegs").Id, Name = "Pegs", Quantity = 10, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Button").Id, Name = "Knop", Quantity = 2, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Glue").Id, Name = "Glue", Quantity = 7, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Pole").Id, Name = "Pole", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Truck-Bed").Id
                },

                // Bom for some Assemblies
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Side wall long").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Side wall short").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Base plate Truck-Bed").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Base plate").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Plate 1,5m x 3,0m").Id, Name = "Timber Plate 1,5m x 3,0m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Race Wing").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Block 0,20m x 0,20m").Id, Name = "Timber Block 0,20m x 0,20m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Cabin").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Block 0,20m x 0,20m").Id, Name = "Timber Block 0,20m x 0,20m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Engine-Block").Id
                },
                new ArticleBom {
                    ArticleChildId = articles.Single(a => a.Name == "Timber Block 0,20m x 0,20m").Id, Name = "Timber Block 0,20m x 0,20m", Quantity = 1, ArticleParentId = articles.Single(a => a.Name == "Engine Race Extension").Id
                },
            };

            context.ArticleBoms.AddRange(articleBom);
            context.SaveChanges();


            //create Businesspartner
            var businessPartner = new BusinessPartner()
            {
                Debitor = true, Kreditor = false, Name = "Toys'R'us toy department"
            };
            var businessPartner2 = new BusinessPartner()
            {
                Debitor = false, Kreditor = true, Name = "Material wholesale"
            };

            context.BusinessPartners.Add(businessPartner);
            context.BusinessPartners.Add(businessPartner2);
            context.SaveChanges();

            var artToBusinessPartner = new ArticleToBusinessPartner[]
            {
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Skeleton").Id, PackSize = 10, Price = 20.00, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Truck-Bed").Id, PackSize = 10, Price = 20.00, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Chassis Type: Dump").Id, PackSize = 10, Price = 20.00, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Chassis Type: Race").Id, PackSize = 10, Price = 25.00, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Cabin").Id, PackSize = 10, Price = 1.75, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Engine-Block").Id, PackSize = 10, Price = 0.40, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Engine Race Extension").Id, PackSize = 10, Price = 1.00, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Side wall long").Id, PackSize = 10, Price = 0.55, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Side wall short").Id, PackSize = 10, Price = 0.45, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Base plate Truck-Bed").Id, PackSize = 10, Price = 0.40, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Dump Joint").Id /*Kippgelenk*/, PackSize = 50, Price = 0.90, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Wheel").Id, PackSize = 150, Price = 0.35, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Base plate").Id, PackSize = 10, Price = 0.80, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Semitrailer" /*Aufleger*/).Id, PackSize = 25, Price = 0.10, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Race Wing").Id, PackSize = 10, Price = 1.50, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Washer").Id, PackSize = 150, Price = 0.02, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Timber Plate 1,5m x 3,0m").Id, PackSize = 100, Price = 0.20, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Timber Block 0,20m x 0,20m").Id, PackSize = 100, Price = 0.20, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Glue").Id, PackSize = 1000, Price = 0.01, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Pegs").Id, PackSize = 200, Price = 0.01, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Pole").Id, PackSize = 200, Price = 0.25, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Button").Id, PackSize = 500, Price = 0.05, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "Packing").Id, PackSize = 50, Price = 2.50, DueTime = 15
                },
                new ArticleToBusinessPartner {
                    BusinessPartnerId = businessPartner2.Id, ArticleId = articles.Single(x => x.Name == "User Manual").Id, PackSize = 50, Price = 0.20, DueTime = 15
                },
            };

            context.ArticleToBusinessPartners.AddRange(artToBusinessPartner);
            context.SaveChanges();

            var simConfigs = new List <SimulationConfiguration>();

            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 1
                Name               = "Lot 5, 24h, 24h, 0.2",
                Lotsize            = 5,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.2
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 2
                Name               = "Lot 10, 24h, 24h, 0.2",
                Lotsize            = 10,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.2
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 3
                Name               = "Lot 1, 8h, 8h, 0.2",
                Lotsize            = 1,
                MaxCalculationTime = 480,
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 480,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.2
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 4
                Name               = "Lot 1, 28h, 24h, 0.2",
                Lotsize            = 1,
                MaxCalculationTime = 1680, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.2
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 5
                Name               = "Lot 1, 24h, 24h, 0",
                Lotsize            = 1,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.0
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 6
                Name               = "Lot 1, 24h, 24h, 0.2",
                Lotsize            = 1,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.2
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 7
                Name               = "Lot 1, 24h, 24h, 0.4",
                Lotsize            = 1,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.4
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 8
                Name               = "decentral dev 0",
                Lotsize            = 1,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.0
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 9
                Name               = "decentral dev 0.2",
                Lotsize            = 1,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.2
            });
            simConfigs.Add(new SimulationConfiguration()
            {
                //simconfigId = 10
                Name               = "decentral dev 0.4",
                Lotsize            = 1,
                MaxCalculationTime = 1440, // test  // 10080, // 7 days
                OrderQuantity      = 600,
                Seed               = 1340,
                ConsecutiveRuns    = 1,
                OrderRate          = 0.25, //0.25
                Time               = 0,
                RecalculationTime  = 1440,
                SimulationEndTime  = 20160,
                DecentralRuns      = 0,
                CentralRuns        = 0,
                DynamicKpiTimeSpan = 480,
                SettlingStart      = 2880,
                WorkTimeDeviation  = 0.4
            });

            context.SimulationConfigurations.AddRange(simConfigs);
            context.SaveChanges();
        }
Example #5
0
        public List <Machine> GetAllMachinesForCustomerId(string customerId)
        {
            var result = _listMachineService.GetAllMachinesForCustomerId(new GetAllMachinesForCustomerIdRequest
            {
                CUNO = customerId
            });

            var listMachine = new List <Machine>();

            if (result?.allMachinesOut == null)
            {
                return(listMachine);
            }

            foreach (var t in result.allMachinesOut)
            {
                var componentAttrs = t.componentAttributes;
                if (componentAttrs == null)
                {
                    continue;
                }

                var groupNew = new MachineGroup
                {
                    Id   = componentAttrs.CmIndividType?.smdid ?? "0",
                    Key  = componentAttrs.CmIndividType?.smdkey ?? "0",
                    Name = componentAttrs.CmIndividType?.Text?.Length > 0
                        ? componentAttrs.CmIndividType?.Text[0]
                        : "Ingen kategori"
                };

                var images        = t.image;
                var machineImages = images?.Select(image => new MachineImage
                {
                    FileName  = image.CmFilename?.Text?.Length > 0 ? image.CmFilename?.Text[0] : string.Empty,
                    Name      = image.CmName?.Text?.Length > 0 ? image.CmName?.Text[0] : string.Empty,
                    Id        = image.SysId?.Text?.Length > 0 ? image.SysId?.Text[0] : string.Empty,
                    ImageType = image.CmImageType?.Text != null && image.CmImageType.Text.Length > 0 ? image.CmImageType.Text[0] : string.Empty
                });

                var brand = new MachineBrand
                {
                    Id   = componentAttrs.CmOE?.smdkey != null ? componentAttrs.CmOE?.smdid : string.Empty,
                    Key  = componentAttrs.CmOE?.smdkey ?? string.Empty,
                    Name = componentAttrs.CmOE?.Text?.Length > 0
                        ? (componentAttrs.CmOE.Text[0] != "Annan" ? componentAttrs.CmOE.Text[0] : string.Empty)
                        : string.Empty
                };

                var model = new MachineModel
                {
                    Id   = componentAttrs.CmModels?.smdkey != null ? componentAttrs.CmModels?.smdid : string.Empty,
                    Key  = componentAttrs.CmModels?.smdkey ?? string.Empty,
                    Name = componentAttrs.CmModels?.Text?.Length > 0
                        ? (componentAttrs.CmModels?.Text[0] != "Annan" ? componentAttrs.CmModels.Text[0] : string.Empty)
                        : string.Empty
                };

                var machine = new Machine
                {
                    LegalRegNumber   = componentAttrs.MvxSAREBE?.Text?.Length > 0 ? componentAttrs.MvxSAREBE?.Text[0] : string.Empty,
                    SerialNumber     = componentAttrs.MvxSASERI?.Text?.Length > 0 ? componentAttrs.MvxSASERI?.Text[0] : string.Empty,
                    Id               = componentAttrs.SysId?.Text?.Length > 0 ? componentAttrs.SysId.Text[0] : string.Empty,
                    ModelDescription = componentAttrs.MvxSAMODE?.Text?.Length > 0
                        ? componentAttrs.MvxSAMODE.Text[0]
                        : componentAttrs.CmSubHeader?.Text?.Length > 0
                            ? componentAttrs.CmSubHeader?.Text[0]
                            : string.Empty,
                    IndividualNumber = componentAttrs.MvxSAINNO?.Text?.Length > 0 ? componentAttrs.MvxSAINNO.Text[0] : string.Empty,
                    DescriptionBrand = componentAttrs.CmHeader?.Text?.Length > 0 ? componentAttrs.CmHeader.Text[0] : string.Empty,
                    Brand            = brand,
                    Group            = groupNew,
                    Model            = model,
                    Images           = machineImages?.ToList() ?? new List <MachineImage>()
                };

                listMachine.Add(machine);
            }
            return(listMachine);
        }
Example #6
0
        public async Task <Machine> GetDetailMachineById(string sysId)
        {
            var result = await _detailMachineBySysIdService.GetMachineBySysIdAsync(new GetMachineBySysIdRequest(sysId));

            if (result?.oneMachineOut?.component == null)
            {
                return(new Machine());
            }

            var componentAttrs = result.oneMachineOut.component.componentAttributes;
            var groupNew       = new MachineGroup
            {
                Id   = componentAttrs.CmIndividType?.smdid ?? "0",
                Name = componentAttrs.CmIndividType?.Text?.FirstOrDefault() ?? "Ingen kategori",
                Key  = componentAttrs.CmIndividType?.smdkey ?? string.Empty
            };

            var images        = result.oneMachineOut.component.image;
            var machineImages = images?.Select(i => new MachineImage
            {
                FileName  = i.CmFilename?.Text?.Length > 0 ? i.CmFilename?.Text[0] : string.Empty,
                Name      = i.CmName?.Text?.Length > 0 ? i.CmName?.Text[0] : string.Empty,
                Id        = i.SysId?.Text?.Length > 0 ? i.SysId?.Text[0] : string.Empty,
                ImageType = i.CmImageType?.Text != null && i.CmImageType.Text.Length > 0 ? i.CmImageType.Text[0] : string.Empty
            });

            var documents        = result.oneMachineOut.component.document;
            var machineDocuments = documents?.Select(md => new MachineDocument()
            {
                FileName = md.CmFilename?.Text?.Length > 0 ? md.CmFilename?.Text[0] : string.Empty,
                Name     = md.CmName?.Text?.Length > 0 ? md.CmName?.Text[0] : string.Empty,
                Id       = md.SysId?.Text?.Length > 0 ? md.SysId?.Text[0] : string.Empty,
                Url      = md.CmUrl?.Text?.Length > 0 ? md.CmUrl?.Text[0] : string.Empty
            });

            var videos        = result.oneMachineOut.component.video;
            var machineVideos = videos?.Select(i => new MachineVideo()
            {
                FileName = i.CmFilename?.Text?.Length > 0 ? i.CmFilename?.Text[0] : string.Empty,
                Name     = i.CmName?.Text?.Length > 0 ? i.CmName?.Text[0] : string.Empty,
                Id       = i.SysId?.Text?.Length > 0 ? i.SysId?.Text[0] : string.Empty,
                Url      = i.CmUrl?.Text?.Length > 0 ? i.CmUrl?.Text[0] : string.Empty
            });

            return(new Machine
            {
                Id = componentAttrs.SysId?.Text?.Length > 0 ? componentAttrs.SysId?.Text[0] : string.Empty,
                Type = result.oneMachineOut.component.type,
                Unique = result.oneMachineOut.component.unique,
                ModelName = componentAttrs.MvxSAMODC?.Text?.Length > 0 ? componentAttrs.MvxSAMODC?.Text[0] : string.Empty,
                ModelDescription = componentAttrs.MvxSAMODE?.Text?.Length > 0 ? componentAttrs.MvxSAMODE?.Text[0] : string.Empty,
                IndividualNumber = componentAttrs.MvxSAINNO?.Text?.Length > 0 ? componentAttrs.MvxSAINNO?.Text[0] : string.Empty,
                IndvidualType = componentAttrs.MvxSAINTY?.Text?.Length > 0 ? componentAttrs.MvxSAINTY?.Text[0] : string.Empty,
                LegalRegNumber = componentAttrs.MvxSAREBE?.Text?.Length > 0 ? componentAttrs.MvxSAREBE?.Text[0] : string.Empty,
                OwnerNumber = componentAttrs.MvxSACUOW?.Text?.Length > 0 ? componentAttrs.MvxSACUOW?.Text[0] : string.Empty,
                Fabric = componentAttrs.MvxSABRAN?.value,
                ModelYear = componentAttrs.MvxSAMLYR?.Text?.Length > 0 ? componentAttrs.MvxSAMLYR?.Text[0] : string.Empty,
                ItemGroup = componentAttrs.MvxSAITGR?.Text?.Length > 0 ? componentAttrs.MvxSAITGR?.Text[0] : string.Empty,
                Status = componentAttrs.MvxSAISTS?.Text?.Length > 0 ? componentAttrs.MvxSAISTS?.Text[0] : string.Empty,
                SerialNumber = componentAttrs.MvxSASERI?.Text?.Length > 0 ? componentAttrs.MvxSASERI?.Text[0] : string.Empty,
                DeliveryDate = componentAttrs.MvxSADEDA?.Text?.Length > 0 ? componentAttrs.MvxSADEDA?.Text[0] : string.Empty,
                WarrantyDateSales = componentAttrs.MvxSAGDT1?.Text?.Length > 0 ? componentAttrs.MvxSAGDT1?.Text[0] : string.Empty,
                ItemNumber = componentAttrs.MvxMMITNO?.Text?.Length > 0 ? componentAttrs.MvxMMITNO?.Text[0] : string.Empty,
                ReceiptDate = componentAttrs.MvxSAREDA?.Text?.Length > 0 ? componentAttrs.MvxSAREDA?.Text[0] : string.Empty,
                WarrantyDateSupplier = componentAttrs.MvxSAGDT2?.Text?.Length > 0 ? componentAttrs.MvxSAGDT2?.Text[0] : string.Empty,
                InstallationDate = componentAttrs.MvxSAINDA?.Text?.Length > 0 ? componentAttrs.MvxSAINDA?.Text[0] : string.Empty,
                DateDisposed = componentAttrs.MvxSADDAT?.Text?.Length > 0 ? componentAttrs.MvxSADDAT?.Text[0] : string.Empty,
                Name = componentAttrs.MvxOKCUNM?.Text?.Length > 0 ? componentAttrs.MvxOKCUNM?.Text[0] : string.Empty,
                DescriptionBrand = componentAttrs.CmHeader?.Text?.Length > 0 ? componentAttrs.CmHeader?.Text[0] : string.Empty,
                DescriptionModel = componentAttrs.CmSubHeader?.Text?.Length > 0 ? componentAttrs.CmSubHeader?.Text[0] : string.Empty,
                Images = machineImages?.ToList() ?? new List <MachineImage>(),
                Documents = machineDocuments?.ToList() ?? new List <MachineDocument>(),
                Videos = machineVideos?.ToList() ?? new List <MachineVideo>(),
                Brand = new MachineBrand
                {
                    Id = componentAttrs.CmOE?.smdid ?? string.Empty,
                    Key = componentAttrs.CmOE?.smdkey ?? string.Empty,
                    Name = componentAttrs.CmOE?.Text?.Length > 0 ? componentAttrs.CmOE?.Text[0] : string.Empty
                },
                Model = new MachineModel
                {
                    Id = componentAttrs.CmModels?.smdid ?? string.Empty,
                    Key = componentAttrs.CmModels?.smdkey ?? string.Empty,
                    Name = componentAttrs.CmModels?.Text?.Length > 0 ? componentAttrs.CmModels?.Text[0] : string.Empty
                },
                Group = groupNew
            });
        }
Example #7
0
        //private-----------------------------------------------------------------
        private MetaData parseMastercamAPT(Queue <string> lines)
        {
            string   line;
            Indirv   current_indirv   = new Indirv();
            Point    current_position = new Point(0.0, 0.0, 0.0);
            int      current_tool     = -1;
            MetaData metadata         = new MetaData();

            while (!lines.Peek().Contains("FINI"))//data parsing
            {
                if (lines.Peek().Contains("$$Machine Group-"))
                {
                    MachineGroup mg = new MachineGroup();
                    mg.ID = Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length));

                    while (!lines.Peek().Contains("FINI") || (lines.Peek().Contains("$$Machine Group-") && (Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length)) == mg.ID)))
                    {
                        lines.Dequeue();
                        ToolpathGroup tpg = new ToolpathGroup();
                        tpg.ID++;

                        while (!lines.Peek().Contains("$$Machine Group-") && !lines.Peek().Contains("FINI"))
                        {
                            line = lines.Dequeue();
                            if (line.Contains("PARTNO/"))
                            {
                                metadata.PartNo = line.Substring("PARTNO/".Length);
                                continue;
                            }

                            if (line.Contains("UNITS/"))
                            {
                                metadata.Units = line.Substring("UNITS/".Length);
                                metadata.Units = metadata.Units.Replace(" ", string.Empty);
                                continue;
                            }

                            if (line.Contains("MULTAX/"))
                            {
                                metadata.Multax = line.Substring("MULTAX/".Length);
                                metadata.Multax = metadata.Multax.Replace(" ", string.Empty);
                                continue;
                            }

                            //if (line.Contains("MACHIN/"))
                            //{
                            //    string[] substrings = Regex.Split(line.Substring("MACHIN/".Length), ",");
                            //    metadata.Machin = substrings[0].Replace(" ", string.Empty);
                            //    continue;
                            //}

                            if (line.Contains("CUTTER/"))
                            {
                                Cutter   tool       = new Cutter();
                                string[] substrings = Regex.Split(line.Substring("CUTTER/".Length), ",");
                                tool.Diameter = Convert.ToDouble(substrings[0].Replace(" ", string.Empty));
                                //tpg.tpgtool.length = Convert.ToDouble(substrings[1].Replace(" ", string.Empty));

                                line      = lines.Dequeue();
                                tool.Name = line.Substring("TPRINT/".Length);

                                line = lines.Dequeue();
                                string[] substrings2 = Regex.Split(line.Substring("LOAD/".Length), ",");
                                current_tool = tpg.Tool = tool.ID = Convert.ToInt32(substrings2[1].Replace(" ", string.Empty).Replace(".", string.Empty));

                                if (!metadata.CutterTools.ContainsKey(tool.ID))
                                {
                                    metadata.CutterTools.Add(tool.ID, tool);
                                }

                                continue;
                            }

                            if (line.Contains("RAPID"))
                            {
                                tpg.MachiningData.Add(new Rapid());
                                continue;
                            }

                            if (line.Contains("GOTO/"))
                            {
                                GoTo gotoxyz = new GoTo();
                                gotoxyz.parseGoto(line);
                                tpg.MachiningData.Add(gotoxyz);
                                current_position = gotoxyz.point;
                                continue;
                            }

                            if (line.Contains("INDIRV/"))
                            {
                                Indirv indirv = new Indirv();
                                indirv.parseIndirv(line);
                                tpg.MachiningData.Add(indirv);
                                current_indirv = indirv;
                                continue;
                            }

                            if (line.Contains("CIRCLE/"))
                            {
                                Circle circle = new Circle();
                                circle.parseCircle(current_indirv, current_position, line, lines.Dequeue(), lines.Dequeue());
                                tpg.MachiningData.Add(circle);
                                current_position = circle.endpoint;
                                continue;
                            }

                            if (line.Contains("FEDRAT/"))
                            {
                                Feedrate fedrat = new Feedrate();
                                fedrat.parseFedrat(line);
                                tpg.MachiningData.Add(fedrat);
                                continue;
                            }

                            if (line.Contains("SPINDL/"))
                            {
                                SpindleSpeed spindle = new SpindleSpeed();
                                spindle.parseSpindleSpeed(line);
                                tpg.MachiningData.Add(spindle);
                                continue;
                            }

                            if (line.Contains("COOLNT/"))
                            {
                                Coolant coolant = new Coolant();
                                coolant.parseCoolant(line);
                                tpg.MachiningData.Add(coolant);
                                continue;
                            }
                        }
                        if (tpg.Tool == -1)
                        {
                            tpg.Tool = current_tool;
                        }

                        mg.Operations.Add(tpg);     //add toolpath to list
                    }
                    metadata.MachineGroups.Add(mg); //add current machine group to list
                }
                else
                {
                    lines.Dequeue();
                }
            }
            lines.Dequeue();
            return(metadata);
        }