Ejemplo n.º 1
0
 private void UpdateStockExchangesWithInitialValues(int simulationId, int simulationNumber)
 {
     foreach (var stock in _context.Stocks.Where(a => a.Current > 0))
     {
         _context.Add(new StockExchange()
         {
             ExchangeType              = ExchangeType.Insert,
             Quantity                  = stock.Current,
             StockId                   = stock.Id,
             Time                      = 0,
             State                     = State.Finished,
             SimulationType            = SimulationType.Central,
             SimulationConfigurationId = simulationId,
             SimulationNumber          = simulationNumber
         });
     }
     _context.SaveChanges();
 }
        public async Task <IActionResult> Create([Bind("ArticleBomId,ArticleParentId,ArticleChildId,Quantity,Name")] M_ArticleBom articleBom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(entity: articleBom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(actionName: "Index"));
            }
            ViewData[index : "ArticleChildId"]  = new SelectList(items : _context.Articles, dataValueField : "Id", dataTextField : "Name", selectedValue : articleBom.ArticleChildId);
            ViewData[index : "ArticleParentId"] = new SelectList(items : _context.Articles, dataValueField : "Id", dataTextField : "Name", selectedValue : articleBom.ArticleParentId);
            return(View(model: articleBom));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ArticleBomId,ArticleParentId,ArticleChildId,Quantity,Name")] ArticleBom articleBom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(articleBom);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ArticleChildId"]  = new SelectList(_context.Articles, "Id", "Name", articleBom.ArticleChildId);
            ViewData["ArticleParentId"] = new SelectList(_context.Articles, "Id", "Name", articleBom.ArticleParentId);
            return(View(articleBom));
        }
Ejemplo n.º 4
0
        private void FillSimulationWorkSchedules(List <PowsSimulationItem> items, int simulationId, int simulationNumber, MrpTask task)
        {
            foreach (var item in items)
            {
                var po   = _context.ProductionOrders.Include(b => b.Article).Single(a => a.Id == item.ProductionOrderId);
                var pows = _context.ProductionOrderWorkSchedules.Single(a => a.Id == item.ProductionOrderWorkScheduleId);

                if (task == MrpTask.None)
                {
                    var schedule = new SimulationWorkschedule()
                    {
                        ParentId          = JsonConvert.SerializeObject(from parent in _context.GetParents(pows) select parent.Id),
                        ProductionOrderId = "[" + po.Id.ToString() + "]",
                        Article           = po.Article.Name,
                        DueTime           = po.Duetime,
                        End                       = pows.EndSimulation,
                        EstimatedEnd              = pows.End,
                        EstimatedStart            = pows.Start,
                        HierarchyNumber           = pows.HierarchyNumber,
                        Machine                   = pows.MachineId == null ? null : _context.Machines.Single(a => a.Id == pows.MachineId).Name,
                        Start                     = pows.StartSimulation,
                        OrderId                   = JsonConvert.SerializeObject(_context.GetOrderIdsFromProductionOrder(po)),
                        SimulationConfigurationId = simulationId,
                        WorkScheduleId            = pows.Id.ToString(),
                        WorkScheduleName          = pows.Name,
                        SimulationType            = SimulationType.Central,
                        SimulationNumber          = simulationNumber,
                    };
                    _context.Add(schedule);
                    //_evaluationContext.Add(schedule.CopyDbPropertiesWithoutId());
                }

                if (task == MrpTask.Backward || task == MrpTask.All)
                {
                    var backward = new SimulationWorkschedule()
                    {
                        ParentId          = JsonConvert.SerializeObject(from parent in _context.GetParents(pows) select parent.ProductionOrderId),
                        ProductionOrderId = "[" + po.Id.ToString() + "]",
                        Article           = po.Article.Name,
                        DueTime           = po.Duetime,
                        End                       = pows.EndBackward,
                        HierarchyNumber           = pows.HierarchyNumber,
                        Start                     = pows.StartBackward,
                        OrderId                   = JsonConvert.SerializeObject(_context.GetOrderIdsFromProductionOrder(po)),
                        SimulationConfigurationId = simulationId,
                        WorkScheduleId            = pows.Id.ToString(),
                        WorkScheduleName          = pows.Name,
                        SimulationType            = SimulationType.BackwardPlanning,
                        SimulationNumber          = simulationNumber,
                        Machine                   = pows.MachineGroupId.ToString()
                    };
                    _context.Add(backward);
                    _evaluationContext.Add(backward.CopyDbPropertiesWithoutId());
                }
                if (task == MrpTask.Forward || task == MrpTask.All)
                {
                    var forward = new SimulationWorkschedule()
                    {
                        ParentId          = JsonConvert.SerializeObject(from parent in _context.GetParents(pows) select parent.ProductionOrderId),
                        ProductionOrderId = "[" + po.Id.ToString() + "]",
                        Article           = po.Article.Name,
                        DueTime           = po.Duetime,
                        End                       = pows.EndForward,
                        HierarchyNumber           = pows.HierarchyNumber,
                        Start                     = pows.StartForward,
                        OrderId                   = JsonConvert.SerializeObject(_context.GetOrderIdsFromProductionOrder(po)),
                        SimulationConfigurationId = simulationId,
                        WorkScheduleId            = pows.Id.ToString(),
                        WorkScheduleName          = pows.Name,
                        SimulationType            = SimulationType.ForwardPlanning,
                        SimulationNumber          = simulationNumber,
                        Machine                   = pows.MachineGroupId.ToString()
                    };
                    _context.Add(forward);
                    _evaluationContext.Add(forward.CopyDbPropertiesWithoutId());
                }
            }
            _context.SaveChanges();
            _evaluationContext.SaveChanges();
        }