private void StartProductionAgent() { var firstToEnqueue = false; // check for Children if (!RequestItem.Article.ArticleBoms.Any()) { DebugMessage("Last leave in Bom"); firstToEnqueue = true; } // if item hase Workschedules Request ComClient for them if (RequestItem.Article.WorkSchedules != null) { // Ask the Directory Agent for Service RequestComunicationAgentFor(workSchedules: RequestItem.Article.WorkSchedules); // And Create workItems CreateWorkItemsFromRequestItem(firstItemToBuild: firstToEnqueue); } // Create Dispo Agents for Childs. foreach (var articleBom in RequestItem.Article.ArticleBoms) { var item = new RequestItem { Article = articleBom.ArticleChild, Quantity = Convert.ToInt32(articleBom.Quantity), DueTime = RequestItem.DueTime, OrderId = RequestItem.OrderId }; // create Dispo Agents for to Provide Required Articles var dispoAgent = new DispoAgent(creator: this, system: ((StorageAgent)Creator).Creator, name: RequestItem.Article.Name + " Child of(" + this.Name + ")", debug: DebugThis, requestItem: item); // add to childs ChildAgents.Add(dispoAgent); //RequestMaterials.Add(item); // add TO Context to process them this time Period. Context.ProcessesRemainingThisTimePeriod.Enqueue(dispoAgent); } }
/// <summary> /// Startup with Creating Dispo Agent for current Item. /// </summary> /// <param name="objects"></param> private void StartOrder(InstructionSet objects) { var orderItem = objects.ObjectToProcess as OrderPart; if (orderItem == null) { throw new InvalidCastException(); } // create Request Item requestItem = MapPropertiesToRequestItem(orderItem); // Create Dispo Agent var dispoAgent = new DispoAgent(creator: this, system: Creator, name: requestItem.Article.Name + " OrderPartId(" + orderItem.Id + ")", debug: DebugThis, requestItem: requestItem); ChildAgents.Add(dispoAgent); }