コード例 #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHangfireDashboard();

            app.UseHangfireServer();

            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute {
                Attempts = 0
            });

            //TODO: burada parametre verılmeden gıdebılır mıyız kontrol et
            HangfireScheduler.HangfireSchedulerJobs(_appSettings);

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
コード例 #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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            // Hangfire JobStorage.Current initialize
            app.UseHangfireServer(new BackgroundJobServerOptions
            {
                WorkerCount = 1
            });

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseSession();
            app.UseRouting();
            app.UseSerilogRequestLogging();

            // Auth BEFORE ENDPOINTS
            app.UseAuthentication();
            app.UseAuthorization();
            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // OpenAPI
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "CAM API V1");
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action}/{id?}",
                    defaults: new { controller = "home", Action = "index" }
                    );
                endpoints.MapControllerRoute(
                    name: "maintenance",
                    pattern: "maintenance/{controller}/{action}/{id?}",
                    defaults: new { controller = "workorders", Action = "index" }
                    );
                endpoints.MapRazorPages();
            });
            // Hangfire job scheduling
            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute {
                Attempts = 0
            });
            HangfireScheduler.ScheduleRecurringJobs();
        }
コード例 #3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHangfireServer(new BackgroundJobServerOptions
            {
                WorkerCount = 1
            });

            app.UseHttpsRedirection();
            app.UseMvc();
            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute {
                Attempts = 0
            });
            BackgroundJob.Enqueue <ITimesScraperJob>(j => j.Run(JobCancellationToken.Null)); // Setup one-time scraper job on start
            HangfireScheduler.ScheduleRecurringJobs();
        }