Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IEntranceControl entranceControl,
                              IEventConsumer eventConsumer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }
            app.UseStaticFiles();

            app.UseRouting();
            app.UseCors(DefaultCorsPolicy);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
            });

            _ = Task.Run(() => eventConsumer.Listen());
            entranceControl.OpenPark();
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IEventConsumer eventConsumer,
                              IRideControl rideControl)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseCors(DefaultCorsPolicy);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            _ = Task.Run(() => eventConsumer.Listen());

            _ = Task.Run(() =>
            {
                while (true)
                {
                    rideControl.HandleOpenRides();
                    Task.Delay(1000).Wait();
                }
            });
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              IEventConsumer eventConsumer, IVisitorControl visitorControl, ILocationTypeStrategy locationTypeStrategy,
                              IEventProducer producer, IFairyTaleClient fairyTaleClient, IRideClient rideClient, IStandClient standClient)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            locationTypeStrategy.Register(LocationType.FAIRYTALE,
                                          new VisitorFairyTaleStrategy(producer, fairyTaleClient));
            locationTypeStrategy.Register(LocationType.RIDE,
                                          new VisitorRideStrategy(producer, rideClient));
            locationTypeStrategy.Register(LocationType.STAND,
                                          new VisitorStandStrategy(producer, standClient));

            app.UseRouting();
            app.UseCors(DefaultCorsPolicy);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            _ = Task.Run(() => eventConsumer.Listen());

            _ = Task.Run(() =>
            {
                while (true)
                {
                    visitorControl.HandleIdleVisitors();

                    Task.Delay(300).Wait();
                }
            });

            _ = Task.Run(() =>
            {
                Random random       = new Random();
                int maxVisitors     = 2000;
                int currentVisitors = 0;
                while (currentVisitors <= maxVisitors)
                {
                    int newVisitors = random.Next(5, 15);

                    visitorControl.AddVisitors(newVisitors);
                    currentVisitors += newVisitors;
                    Task.Delay(2000).Wait();
                }
            });
        }