Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            IsDevelopment = env.IsDevelopment();
            //app.UsePathBase("/beursspel");
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }



            app.UseSession();
            app.UseHangfireServer();

            app.UseStaticFiles();

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            app.UseAuthentication();



            var types = Assembly.GetExecutingAssembly().GetTypes()
                        .Where(y => typeof(IRecurringTask).IsAssignableFrom(y));

            foreach (var type in types)
            {
                if (type.IsInterface)
                {
                    continue;
                }
                var o = (IRecurringTask)Activator.CreateInstance(type);
                if (o.Enabled)
                {
                    RecurringJob.AddOrUpdate(() => o.ExecuteAsync(), o.Cron, TimeZoneInfo.Local);
                }
            }

            app.UseMiddleware <CheckIfOpenMiddleware>();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            var task = CreateRoles(serviceProvider);

            task.Wait();
            var options = new DashboardOptions
            {
                Authorization = new [] { new HangfireAuthentication() }
            };

            app.UseHangfireDashboard("/hangfire", options);

            using (var context = new ApplicationDbContext())
            {
                context.Database.Migrate();
            }

            var t1 = GeplandeTelMomentenManager.CheckMarktSluiting();

            t1.Wait();
            var t2 = GeplandeTelMomentenManager.CheckMarktOpening();

            t2.Wait();
        }
Beispiel #2
0
 public async Task ExecuteAsync()
 {
     await GeplandeTelMomentenManager.CheckMarktOpening();
 }