/// <summary> /// Get All Relevant Production Work Schedules an dpass them for each Order To /// </summary> private async Task GetSchedulesForOrderListAsync(IEnumerable <int> ordersParts) { foreach (var ordersPart in ordersParts) { var pows = _resultContext.SimulationOperations.Where(predicate: x => x.OrderId == "[" + ordersPart.ToString() + "]" && x.SimulationType == _simulationType && x.SimulationNumber == _simulationNumber && x.SimulationConfigurationId == _simulationConfigurationId) .OrderBy(keySelector: x => x.Machine).ThenBy(keySelector: x => x.ProductionOrderId).ThenBy(keySelector: x => x.Start); foreach (var pow in pows) { // check if head element is Created, GanttTask timeline = GetOrCreateTimeline(pow: pow, orderId: ordersPart); long start = 0, end = 0; DefineStartEnd(start: ref start, end: ref end, item: pow); // Add Item To Timeline _ganttContext.Tasks.Add( item: CreateGanttTask( item: pow, start: start, end: end, gc: timeline.color, parent: timeline.id ) ); var c = await _context.GetFollowerProductionOrderWorkSchedules(simulationWorkSchedule : pow, type : _simulationType, relevantItems : pows.ToList()); if (!c.Any()) { continue; } // create Links for this pow foreach (var link in c) { _ganttContext.Links.Add( item: new GanttLink { id = Guid.NewGuid().ToString(), type = LinkType.finish_to_start, source = pow.Id.ToString(), target = link.Id.ToString() } ); } // end foreach link } // emd pows } }
/// <summary> /// Get All Relevant Production Work Schedules an dpass them for each Order To /// </summary> private async Task GetSchedulesForOrderListAsync(IEnumerable <int> ordersParts) { foreach (var orderPart in ordersParts) { //var pows = await _context.GetProductionOrderBomRecursive(_context.ProductionOrders.FirstOrDefault(x => x.ArticleId == 1), 1); // get the corresponding Order Parts to Order var demands = _context.Demands.OfType <DemandOrderPart>() .Include(x => x.OrderPart) .Include(x => x.DemandProvider) .Where(o => o.OrderPart.OrderId == orderPart) .ToList(); var pows = new List <ProductionOrderWorkSchedule>(); foreach (var demand in demands) { var data = _context.GetWorkSchedulesFromDemand(demand, ref pows); } foreach (var pow in pows) { // check if head element is Created, GanttTask timeline = GetOrCreateTimeline(pow, orderPart); long start = 0, end = 0; DefineStartEnd(ref start, ref end, pow); // Add Item To Timeline _ganttContext.Tasks.Add( CreateGanttTask( pow, start, end, timeline.color, timeline.id ) ); var c = await _context.GetFollowerProductionOrderWorkSchedules(pow); if (!c.Any()) { continue; } // create Links for this pow foreach (var link in c) { _ganttContext.Links.Add( new GanttLink { id = Guid.NewGuid().ToString(), type = LinkType.finish_to_start, source = pow.Id.ToString(), target = link.Id.ToString() } ); } // end foreach link } // emd pows } // end foreach Order }