private void SatisfyRequest(IDemandToProvider demand, int simulationId, ProductionDomainContext evaluationContext) { var amount = demand.Quantity; //if anything is in stock, create demand amount = TryAssignStockReservation(demand, amount); if (amount == 0) { return; } //search for purchase amount = TryAssignPurchase(demand, amount); if (amount == 0) { return; } //find matching productionOrders amount = TryFindProductionOrders(demand, amount); if (amount != 0) { SaveContext(evaluationContext); amount = TryAssignStockReservation(demand, amount); amount = TryAssignPurchase(demand, amount); amount = TryFindProductionOrders(demand, amount); throw new NotSupportedException("logical error: still unsatisfied Requests!"); } foreach (var dppo in demand.DemandProvider.OfType <DemandProviderProductionOrder>()) { CallChildrenSatisfyRequest(dppo.ProductionOrder, simulationId, evaluationContext); } }
public static IBehaviour Default(ProductionDomainContext productionDomainContext , IMessageHub messageHub , Configuration configuration , List <FSetEstimatedThroughputTime> estimatedThroughputTimes) { return(new Default(productionDomainContext, messageHub, configuration, estimatedThroughputTimes)); }
public void InitByReadingFromDatabase(string testConfiguration, bool addInitialStockLevels) { ProductionDomainContexts productionDomainContexts = Dbms.GetDbContext(); _productionDomainContext = productionDomainContexts.ProductionDomainContext; _productionDomainContextArchive = productionDomainContexts.ProductionDomainContextArchive; InitDb(testConfiguration, _productionDomainContext, true); InitDb(testConfiguration, _productionDomainContextArchive, false); _dbMasterDataCache = new DbMasterDataCache(_productionDomainContext); // duplicate masterData for archive _dbMasterDataCache.Clone(_productionDomainContextArchive); _dbTransactionData = new DbTransactionData(_productionDomainContext); _dbTransactionDataArchive = new DbTransactionData(_productionDomainContextArchive); if (addInitialStockLevels) { OpenDemandManager.AddInitialStockLevels(_dbTransactionData); } _aggregator = new Aggregator(_dbTransactionData); _openDemandManager = new OpenDemandManager(); }
public SimulationTimelineViewComponent(ProductionDomainContext context, ResultContext resultContext) { _context = context; _resultContext = resultContext; _today = DateTime.Now.GetEpochMilliseconds(); _ganttContext = new GanttContext(); }
public DbMasterDataCache(ProductionDomainContext productionDomainContext) { _productionDomainContext = productionDomainContext; // cache tables _articles = new MasterDataTable <M_Article>(_productionDomainContext.Articles .Include(x => x.ArticleType).ToList()); _articleBoms = new MasterDataTable <M_ArticleBom>(_productionDomainContext.ArticleBoms); _articleToBusinessPartners = new MasterDataTable <M_ArticleToBusinessPartner>(_productionDomainContext .ArticleToBusinessPartners); _articleTypes = new MasterDataTable <M_ArticleType>(_productionDomainContext.ArticleTypes); _businessPartners = new MasterDataTable <M_BusinessPartner>(_productionDomainContext.BusinessPartners); _resources = new MasterDataTable <M_Resource>(_productionDomainContext.Resources); _resourceSkills = new MasterDataTable <M_ResourceSkill>(_productionDomainContext.ResourceSkills); _resourceTools = new MasterDataTable <M_ResourceTool>(_productionDomainContext.ResourceTools); _resourceSetups = new MasterDataTable <M_ResourceSetup>(_productionDomainContext.ResourceSetups); _operations = new MasterDataTable <M_Operation>(_productionDomainContext.Operations); _stocks = new MasterDataTable <M_Stock>(_productionDomainContext.Stocks); _units = new MasterDataTable <M_Unit>(_productionDomainContext.Units); }
private static void ExtractWorkSchedules(MasterDBContext inMemmoryContext, ProductionDomainContext productionDomainContext) { var sw = inMemmoryContext.SimulationWorkschedules.AsNoTracking().ToList().Select(x => { x.Id = 0; return(x); }).ToList(); productionDomainContext.SimulationWorkschedules.AddRange(sw); productionDomainContext.SaveChanges(); }
/// <summary> /// Prepare Simulation Environment /// </summary> /// <param name="debug">Enables AKKA-Global message Debugging</param> public GanttSimulation(string ganttContextDbString, string productionContextDbString, IMessageHub messageHub) { _ganttContext = GanttPlanDBContext.GetContext(ganttContextDbString); _productionContext = ProductionDomainContext.GetContext(productionContextDbString); _messageHub = messageHub; _resourceDictionary = new ResourceDictionary(); }
private static void ExtractStockExchanges(MasterDBContext inMemmoryContext, ProductionDomainContext productionDomainContext) { var se = inMemmoryContext.StockExchanges.AsNoTracking().ToList().Select(x => { x.Id = 0; return(x); }).ToList(); productionDomainContext.StockExchanges.AddRange(se); productionDomainContext.SaveChanges(); }
public Supervisor(ActorPaths actorPaths , long time , bool debug , ProductionDomainContext productionDomainContext , IMessageHub messageHub , Configuration configuration , List <FSetEstimatedThroughputTime> estimatedThroughputTimes , IActorRef principal ) : base(actorPaths: actorPaths, time: time, debug: debug, principal: principal) { _productionDomainContext = productionDomainContext; _dataBaseConnection = _productionDomainContext.Database.GetDbConnection(); _articleCache = new ArticleCache(connectionString: _dataBaseConnection.ConnectionString); _messageHub = messageHub; _orderGenerator = new OrderGenerator(simConfig: configuration, productionDomainContext: _productionDomainContext , productIds: estimatedThroughputTimes.Select(x => x.ArticleId).ToList()); _orderCounter = new OrderCounter(maxQuantity: configuration.GetOption <OrderQuantity>().Value); _configID = configuration.GetOption <SimulationId>().Value; _simulationType = configuration.GetOption <SimulationKind>().Value; _transitionFactor = configuration.GetOption <TransitionFactor>().Value; estimatedThroughputTimes.ForEach(SetEstimatedThroughputTime); Send(instruction: Instruction.PopOrder.Create(message: "Pop", target: Self), waitFor: 1); Send(instruction: Instruction.EndSimulation.Create(message: true, target: Self), waitFor: configuration.GetOption <SimulationEnd>().Value); Send(instruction: Instruction.SystemCheck.Create(message: "CheckForOrders", target: Self), waitFor: 1); DebugMessage(msg: "Agent-System ready for Work"); }
static void Main(string[] args) { Console.WriteLine(value: "Welcome to AkkaSim Cli"); var masterDb = ProductionDomainContext.GetContext(defaultCon: ConfigurationManager.AppSettings[index: 0]); var validCommands = new Commands(); var command = validCommands.Single(predicate: x => x.ArgLong == "Help"); var lastArg = 0; var config = new SimulationCore.Environment.Configuration(); for (; lastArg < args.Length; lastArg++) { if (args[lastArg] == "-?" || args[lastArg] == "/?") { command.Action(arg1: null, arg2: null); return; } if (IsArg(validCommands: validCommands, argument: args[lastArg], command: ref command)) { if (command.HasProperty) { lastArg++; command.Action(arg1: config, arg2: args[lastArg]); } else { command.Action(arg1: config, arg2: null); } } } RunSimulationTask(masterDb: masterDb, config: config).Wait(); }
public AgentLiveController(AgentCore agentSimulator, ProductionDomainContext context, ResultContext resultCtx, IMessageHub messageHub) { _agentSimulator = agentSimulator; _resultCtx = resultCtx; _context = context; _messageHub = messageHub; }
public void TestGanttPlanApi() { ProductionDomainContext master40Context = ProductionDomainContext.GetContext(masterCtxString); GanttPlanDBContext ganttPlanContext = GanttPlanDBContext.GetContext(GanttPlanCtxString); var prod = ganttPlanContext.GptblProductionorder .Include(x => x.ProductionorderOperationActivities) .ThenInclude(x => x.ProductionorderOperationActivityMaterialrelation) .Include(x => x.ProductionorderOperationActivities) .ThenInclude(x => x.ProductionorderOperationActivityResources) .Include(x => x.ProductionorderOperationActivities) .ThenInclude(x => x.ProductionorderOperationActivityResources) .ThenInclude(x => x.ProductionorderOperationActivityResourceInterval) .Single(x => x.ProductionorderId == "000030"); // System.Diagnostics.Debug.WriteLine("First ID: " + prod.ProductionorderId); // var activity = prod.ProductionorderOperationActivities.ToArray()[1]; // System.Diagnostics.Debug.WriteLine("First Activity ID: " + activity.ActivityId); // var materialRelation = activity.ProductionorderOperationActivityMaterialrelation.ToArray()[0]; // System.Diagnostics.Debug.WriteLine("First Activity Material Relation ID: " + materialRelation.ChildId); // var ress = activity.ProductionorderOperationActivityResources.ToArray()[0]; // System.Diagnostics.Debug.WriteLine("First Resource: " + ress.Worker.Name); // System.Diagnostics.Debug.WriteLine("First Resource Intervall: " + ress.ProductionorderOperationActivityResourceInterval.DateFrom); var activities = ganttPlanContext.GptblProductionorderOperationActivity .Include(x => x.ProductionorderOperationActivityResources) .Where(x => x.ProductionorderId == "000029").ToList(); activities.ForEach(act => { System.Diagnostics.Debug.WriteLine("Activity:" + act.Name); act.ProductionorderOperationActivityResources.ForEach(res => { System.Diagnostics.Debug.WriteLine("Activity Resource:" + res.ResourceId); switch (res.ResourceType) { case 1: res.Resource = ganttPlanContext.GptblWorkcenter.Single(x => x.WorkcenterId == res.ResourceId); break; case 3: res.Resource = ganttPlanContext.GptblWorker.Single(x => x.WorkerId == res.ResourceId); break; case 5: res.Resource = ganttPlanContext.GptblPrt.Single(x => x.PrtId == res.ResourceId); break; } System.Diagnostics.Debug.WriteLine("Activity Resource Name:" + res.Resource.Name); }); } ); Assert.True(ganttPlanContext.GptblMaterial.Any()); }
public static IBehaviour Central(GanttPlanDBContext ganttContext , ProductionDomainContext productionDomainContext , IMessageHub messageHub , Configuration configuration , List <FSetEstimatedThroughputTime> estimatedThroughputTimes) { return(new Central(ganttContext, productionDomainContext, messageHub, configuration, estimatedThroughputTimes)); }
public ProcessMrp(ProductionDomainContext context, IScheduling scheduling, ICapacityScheduling capacityScheduling, IMessageHub messageHub, IRebuildNets rebuildNets) { _messageHub = messageHub; _context = context; _scheduling = scheduling; _capacityScheduling = capacityScheduling; _demandForecast = new DemandForecast(context, this); _rebuildNets = rebuildNets; }
public ArticleCheck() { _dbConnectionString = Dbms.getDbContextString().Replace("UnitTestDB", "TruckTest"); _masterDBContext = new ProductionDomainContext(options: new DbContextOptionsBuilder <MasterDBContext>() .UseSqlServer(connectionString: _dbConnectionString) .Options); _masterDBContext.Database.EnsureCreated(); MasterDBInitializerTruck.DbInitialize(context: _masterDBContext); }
public ArticleCache() { _dbConnectionString = Dbms.getDbContextString(); _masterDBContext = new ProductionDomainContext(options: new DbContextOptionsBuilder <MasterDBContext>() .UseSqlServer(connectionString: _dbConnectionString) .Options); _masterDBContext.Database.EnsureCreated(); MasterDbInitializerTable.DbInitialize(context: _masterDBContext); }
public void TestDropNonExistingDatabase() { ProductionDomainContext productionDomainContext = Dbms.GetNewMasterDataBase().DbContext; bool wasDropped = Dbms.DropDatabase("bla", productionDomainContext.Database.GetDbConnection().ConnectionString); Assert.False(wasDropped, "Db could be dropped, although it doesn't exist."); }
/// <summary> /// calls all implemented Kpi-calculating methods /// </summary> /// <param name="context"></param> /// <param name="simulationId"></param> /// <param name="simulationType"></param> /// <param name="simulationNumber"></param> /// <param name="final"></param> /// <param name="time"></param> public static void CalculateAllKpis(ProductionDomainContext context, int simulationId, SimulationType simulationType, int simulationNumber, bool final, int time = 0) { CalculateLeadTime(context, simulationId, simulationType, simulationNumber, final, time); CalculateMachineUtilization(context, simulationId, simulationType, simulationNumber, final, time); CalculateTimeliness(context, simulationId, simulationType, simulationNumber, final, time); ArticleStockEvolution(context, simulationId, simulationType, simulationNumber, final, time); CalculateLayTimes(context, simulationId, simulationType, simulationNumber, final, time); }
private void SaveContext(ProductionDomainContext _contextToSave) { //load Simulation Results to Main data Context. var simState = new DB.Models.Simulation { CreationDate = DateTime.Now, SimulationDbState = Newtonsoft.Json.JsonConvert.SerializeObject(_contextToSave.SaveSimulationState()), SimulationType = SimulationType.Central, }; }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="simulationId"></param> /// <param name="simulationType"></param> /// <param name="simulationNumber"></param> /// <param name="final"></param> /// <param name="time"></param> public static void CalculateTimeliness(ProductionDomainContext context, int simulationId, SimulationType simulationType, int simulationNumber, bool final, int time) { var simConfig = context.SimulationConfigurations.Single(a => a.Id == simulationId); /*var orderTimeliness = final ? context.SimulationOrders.Where(a => a.State == State.Finished * && a.CreationTime > simConfig.SettlingStart * && a.CreationTime < simConfig.SimulationEndTime * && a.SimulationType == simulationType) * .Select(x => new { x.Name, x.FinishingTime, x.DueTime }).ToList() : * context.SimulationOrders.Where(a => a.State == State.Finished * && a.FinishingTime >= time - simConfig.DynamicKpiTimeSpan * && a.SimulationType == simulationType) * .Select(x => new { x.Name, x.FinishingTime, x.DueTime }).ToList(); * * */ var orderTimeliness = final ? //then context.SimulationOrders .Where(x => x.SimulationConfigurationId == simulationId && x.SimulationType == simulationType) .Where(a => a.State == State.Finished && a.CreationTime >= simConfig.SettlingStart && a.FinishingTime <= simConfig.SimulationEndTime && a.CreationTime < simConfig.SimulationEndTime) .Select(x => new { x.Name, x.FinishingTime, x.DueTime }).ToList() // Else : context.SimulationOrders .Where(x => x.SimulationConfigurationId == simulationId && x.SimulationType == simulationType) .Where(a => a.State == State.Finished && a.FinishingTime >= time - simConfig.DynamicKpiTimeSpan) .Select(x => new { x.Name, x.FinishingTime, x.DueTime }).ToList(); if (!orderTimeliness.Any()) { return; } var kpis = orderTimeliness.GroupBy(g => g.Name).Select(o => new Kpi() { Name = o.Key, Value = Math.Round((o.Count(x => (x.DueTime - x.FinishingTime) >= 0) / (double)o.Count()), 2), ValueMin = Math.Round((double)o.Min(m => m.FinishingTime - m.DueTime), 2), ValueMax = Math.Round((double)o.Max(n => n.FinishingTime - n.DueTime), 2), Count = o.Count(c => c.Name == o.Key), IsKpi = final, KpiType = KpiType.Timeliness, SimulationConfigurationId = simulationId, SimulationType = simulationType, SimulationNumber = simulationNumber, Time = time, IsFinal = final }).ToList(); context.Kpis.AddRange(kpis); context.SaveChanges(); }
// public Constructor public static Props Props(ActorPaths actorPaths , long time , bool debug , ProductionDomainContext productionDomainContext , IMessageHub messageHub , Configuration configuration , List <FSetEstimatedThroughputTime> estimatedThroughputTimes , IActorRef principal) { return(Akka.Actor.Props.Create(factory: () => new Supervisor(actorPaths, time, debug, productionDomainContext, messageHub, configuration, estimatedThroughputTimes, principal))); }
public OrderSimulationItem(int start, int end, ProductionDomainContext context, List <int> articleIds, List <int> amounts, int duetime) { SimulationState = SimulationState.Waiting; Start = start; End = end; _context = context; ArticleIds = articleIds; Amounts = amounts; DueTime = duetime; AddOrder = false; }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="simulationId"></param> /// <param name="simulationType"></param> /// <param name="simulationNumber"></param> public static void MachineSattleTime(ProductionDomainContext context, int simulationId, SimulationType simulationType, int simulationNumber) { var simConfig = context.SimulationConfigurations.Single(a => a.Id == simulationId); var ts = simConfig.DynamicKpiTimeSpan; for (var i = ts; i < simConfig.SimulationEndTime; i = i + ts) { CalculateMachineUtilization(context, simulationId, simulationType, simulationNumber, false, i); } }
/* * public static void LoadInMemoryDb(this ProductionDomainContext targetContext, * SimulationDbState sourceContext) * { * targetContext.ArticleTypes.AddRange(sourceContext.ArticleTypes); * targetContext.SaveChanges(); * targetContext.Units.AddRange(sourceContext.Units); * targetContext.Machines.AddRange(sourceContext.Machines); * targetContext.MachineGroups.AddRange(sourceContext.MachineGroups); * targetContext.MachineTools.AddRange(sourceContext.MachineTools); * targetContext.Articles.AddRange(sourceContext.Articles); * targetContext.Stocks.AddRange(sourceContext.Stocks); * targetContext.StockExchanges.AddRange(sourceContext.StockExchanges); * targetContext.WorkSchedules.AddRange(sourceContext.WorkSchedules); * targetContext.ArticleBoms.AddRange(sourceContext.ArticleBoms); * targetContext.BusinessPartners.AddRange(sourceContext.BusinessPartners); * targetContext.ArticleToBusinessPartners.AddRange(sourceContext.ArticleToBusinessPartners); * targetContext.Orders.AddRange(sourceContext.Orders); * targetContext.OrderParts.AddRange(sourceContext.OrderParts); * targetContext.SimulationConfigurations.AddRange(sourceContext.SimulationConfigurations); * * // should be emty * /* * targetContext.ProductionOrders.AddRange(sourceContext.ProductionOrders); * targetContext.ProductionOrderBoms.AddRange(sourceContext.ProductionOrderBoms); * targetContext.ProductionOrderWorkSchedules.AddRange(sourceContext.ProductionOrderWorkSchedule); * targetContext.Demands.AddRange(sourceContext.Demands); * targetContext.Purchases.AddRange(sourceContext.Purchases); * targetContext.PurchaseParts.AddRange(sourceContext.PurchaseParts); */ /* * targetContext.SaveChanges(); * } */ public static SimulationDbState SaveSimulationState(this ProductionDomainContext sourceContext) { var targetContext = new SimulationDbState { ArticleTypes = sourceContext.ArticleTypes.ToList(), Units = sourceContext.Units.ToList(), Machines = sourceContext.Machines.ToList(), MachineTools = sourceContext.MachineTools.ToList(), MachineGroups = sourceContext.MachineGroups.ToList(), Articles = sourceContext.Articles.ToList(), Stocks = sourceContext.Stocks.ToList(), StockExchanges = sourceContext.StockExchanges.ToList(), WorkSchedules = sourceContext.WorkSchedules.ToList(), ArticleBoms = sourceContext.ArticleBoms.ToList(), BusinessPartners = sourceContext.BusinessPartners.ToList(), Orders = sourceContext.Orders.ToList(), OrderParts = sourceContext.OrderParts.ToList(), Kpi = sourceContext.Kpis.ToList(), ArticleToBusinessPartners = sourceContext.ArticleToBusinessPartners.ToList(), ProductionOrders = sourceContext.ProductionOrders.ToList(), ProductionOrderBoms = sourceContext.ProductionOrderBoms.ToList(), ProductionOrderWorkSchedule = sourceContext.ProductionOrderWorkSchedules.ToList(), Purchases = sourceContext.Purchases.ToList(), PurchaseParts = sourceContext.PurchaseParts.ToList(), Demands = sourceContext.Demands.ToList() }; return(targetContext); /* * var dbsets = _sourceContext.GetType().GetProperties().Where(x => x.DeclaringType == typeof(MasterDBContext)).ToList(); * foreach (var dbset in dbsets) * { * dynamic propValue = dbset.GetValue(_sourceContext); * Type type = Type.GetType("Master40.DB.DB.Models.Article"); * * var listType = typeof(List<>); * var constructedListType = listType.MakeGenericType(Type.GetType(dbset.Name)); * var instance = Activator.CreateInstance(constructedListType); * * var tolist = typeof(Enumerable).GetMethod("ToList"); * * * tolist = tolist.MakeGenericMethod(type); * var ret = tolist.Invoke(type, propValue); * * } */ // Units //_targetContext.SaveChanges(); }
public static void InsertRange <TEntity>(IEnumerable <TEntity> entities, DbSet <TEntity> dbSet, ProductionDomainContext productionDomainContext) where TEntity : BaseEntity { foreach (var entity in entities) { // e.g. if it is a PrBom which is toPurchase if (entity != null) { Insert(entity, dbSet, productionDomainContext); } } }
private void Debuglog(SimulationContext simulationContext, ProductionDomainContext productionDomainContextContext, int simNr, int simId) { _messageHub.SendToAllClients("Some statistics:"); var itemlist = from val in Agent.AgentStatistics group val by new { val.AgentType } into grouped select new { Agent = grouped.First().AgentType, ProcessingTime = grouped.Sum(x => x.ProcessingTime), Count = grouped.Count().ToString() }; foreach (var item in itemlist) { var count = Agent.AgentCounter.Count(x => x == item.Agent); Debug.WriteLine(" Agent (" + Agent.AgentCounter.Count(x => x == item.Agent) + "): " + item.Agent + " -> Runtime: " + item.ProcessingTime + " Milliseconds with " + item.Count + " Instructions Processed"); _productionDomainContext.Kpis.Add( new Kpi { SimulationType = SimulationType.Decentral, IsKpi = true, IsFinal = true, KpiType = KpiType.AgentStatistics, Name = item.Agent, Count = count, Value = Convert.ToDouble(item.Count), Time = Convert.ToInt32(item.ProcessingTime), SimulationNumber = simNr, SimulationConfigurationId = simId }); } _productionDomainContext.SaveChanges(); foreach (var machine in simulationContext.ActiveProcesses.Where(x => x.GetType() == typeof(MachineAgent))) { var item = ((MachineAgent)machine); Debug.WriteLine("Agent " + item.Name + " Queue Length:" + item.Queue.Count); _messageHub.SendToAllClients("Agent " + item.Name + " Queue Length:" + item.Queue.Count); } var jobs = SimulationWorkschedules.Count; Debug.WriteLine(jobs + " Jobs processed in {0} minutes", Agent.AgentStatistics.Max(x => x.Time)); _messageHub.SendToAllClients(jobs + " Jobs processed in " + Agent.AgentStatistics.Max(x => x.Time) + " minutes"); foreach (var stock in simulationContext.ActiveProcesses.Where(x => x.GetType() == typeof(StorageAgent))) { var item = ((StorageAgent)stock); var count = item.StockElement.StartValue + (item.StockElement.StockExchanges.Where(x => x.ExchangeType == ExchangeType.Insert) .Sum(x => x.Quantity) - item.StockElement.StockExchanges .Where(x => x.ExchangeType == ExchangeType.Withdrawal).Sum(x => x.Quantity)); Debug.WriteLine("Storage (" + item.Name + "): In: " + count); } }
private static void ExtractKpis(MasterDBContext inMemmoryContext, ProductionDomainContext productionDomainContext) { //List<Kpi> kpis = new List<Kpi>(); //inMemmoryContext.Kpis.AsNoTracking().ToList(); // foreach (var item in inMemmoryContext.Kpis.ToList()) // { // kpis.Add(item.CopyDbPropertiesWithoutId()); // } var kpis = inMemmoryContext.Kpis.AsNoTracking().ToList().Select(x => { x.Id = 0; return(x); }).ToList(); productionDomainContext.Kpis.AddRange(kpis); productionDomainContext.SaveChanges(); }
/// <summary> /// Plans all unplanned Orders with MRP I + II /// </summary> /// <param name="task"></param> /// <returns></returns> public async Task CreateAndProcessOrderDemand(MrpTask task, ProductionDomainContext context, int simulationId, ProductionDomainContext evaluationContext) { await Task.Run(() => { if (context != null) { _context = context; } var newOrdersAdded = false; _messageHub.SendToAllClients("Start full MRP cycle...", MessageType.info); //get all unplanned orderparts and iterate through them for MRP var simConfig = _context.SimulationConfigurations.Single(a => a.Id == simulationId); var maxAllowedTime = simConfig.Time + simConfig.MaxCalculationTime; //Todo: put together if problem is solved var orderParts3 = _context.OrderParts.Include(a => a.Order).Where(a => a.IsPlanned == false); var orderParts2 = orderParts3.Where(a => a.Order.CreationTime <= simConfig.Time); var orderParts = orderParts2.Where(a => a.Order.DueTime < maxAllowedTime).Include(a => a.Article).ToList(); if (orderParts.Any()) { newOrdersAdded = true; } foreach (var orderPart in orderParts.ToList()) { var demand = GetDemand(orderPart); _messageHub.SendToAllClients("running requirements for orderpart " + orderPart.Id); //run the requirements planning and backward/forward termination algorithm RunRequirementsAndTermination(demand, task, simulationId); } if (task == MrpTask.All || task == MrpTask.GifflerThompson || task == MrpTask.Capacity) { //run the capacity algorithm PlanCapacities(task, newOrdersAdded, simulationId, evaluationContext); _messageHub.SendToAllClients("Capacities are planned"); } //set all orderparts to be planned foreach (var orderPart in orderParts) { if (task == MrpTask.All || task == MrpTask.GifflerThompson) { orderPart.IsPlanned = true; } } _context.SaveChanges(); _messageHub.SendToAllClients("End of the latest calculated order: " + _context.ProductionOrderWorkSchedules?.Max(a => a.End)); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app , IWebHostEnvironment env , HangfireDBContext hangfireContext , MasterDBContext context , ResultContext contextResults , ProductionDomainContext productionDomainContext) { MasterDbInitializerTable.DbInitialize(context: context); ResultDBInitializerBasic.DbInitialize(context: contextResults); #region Hangfire HangfireDBInitializer.DbInitialize(context: hangfireContext); GlobalConfiguration.Configuration .UseFilter(filter: new AutomaticRetryAttribute { Attempts = 0 }) .UseSqlServerStorage(nameOrConnectionString: Configuration.GetConnectionString(name: "Hangfire")) .UseConsole(); app.UseHangfireDashboard(); #endregion var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(options: options.Value); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler(errorHandlingPath: "/Home/Error"); } app.UseCors("CorsPolicy"); app.UseFileServer(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(router => { router.MapHub <MessageHub>("/MessageHub"); }); app.UseMvc(configureRoutes: routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
static void Main(string[] args) { Console.WriteLine(value: "Welcome to AkkaSim Cli"); // has to be Installed here other wise it would attach a new log listener every time a simulation is called. LogConfiguration.LogTo(TargetTypes.Console, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info); //LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug); //LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AKKA, LogLevel.Trace); //LogConfiguration.LogTo(TargetTypes.Console, TargetNames.LOG_AKKA, LogLevel.Warn); //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AKKA, LogLevel.Warn); var masterDb = ProductionDomainContext.GetContext(ConfigurationManager.AppSettings[AgentCore.DEFAULT_CONNECTION]); var validCommands = Commands.GetAllValidCommands; var command = validCommands.Single(predicate: x => x.ArgLong == "Help"); var lastArg = 0; var config = new SimulationCore.Environment.Configuration(); for (; lastArg < args.Length; lastArg++) { if (args[lastArg] == "-?" || args[lastArg] == "/?") { command.Action(arg1: null, arg2: null); return; } if (ArgumentConverter.IsArg(validCommands: validCommands, argument: args[lastArg], command: ref command)) { if (command.HasProperty) { lastArg++; command.Action(arg1: config, arg2: args[lastArg]); } else { command.Action(arg1: config, arg2: null); } } } if (config.TryGetValue(typeof(StartHangfire), out object startHangfire)) { StartHangfire(((StartHangfire)startHangfire).Silent).Wait(); } else { RunSimulationTask(masterDb: masterDb, config: config).Wait(); Console.WriteLine(value: "Simulation Run Finished."); } }