protected void Application_Start() { AutoMapperConfig.Initialize(); var config = System.Web.Http.GlobalConfiguration.Configuration; config.EnableCors(new EnableCorsAttribute("*", "*", "*")); config.MapHttpAttributeRoutes(); // Redirect root to Swagger UI config.Routes.MapHttpRoute( name: "Swagger UI", routeTemplate: "", defaults: null, constraints: null, handler: new RedirectHandler(SwaggerDocsConfig.DefaultRootUrlResolver, "swagger")); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: API_Route_Prefix + "/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); config.Formatters.Remove(config.Formatters.XmlFormatter); config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; config.EnsureInitialized(); // Configure Hangfire www.hangfire.io Hangfire.GlobalConfiguration.Configuration.UseMemoryStorage(); _backgroundJobServer = new Hangfire.BackgroundJobServer(); SimpleLogger.Init(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); Hangfire.JobStorage.Current = new Hangfire.SqlServer.SqlServerStorage("DefaultConnection"); var server = new Hangfire.BackgroundJobServer(); }
protected void Application_Start() { AutoMapperConfig.Initialize(); RegisterRoutes(RouteTable.Routes); // Configure Hangfire www.hangfire.io Hangfire.GlobalConfiguration.Configuration.UseMemoryStorage(); _backgroundJobServer = new Hangfire.BackgroundJobServer(); SimpleLogger.Init(); }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureServices((hostContext, services) => { var configuration = hostContext.Configuration; services.RegisterDatabase(configuration); services.RegisterDependenciesScan(configuration); var connection = configuration.GetConnectionString("TibiaPostgres"); var serviceProvider = configuration.Get <IServiceProvider>(); HangfireServer = HangfireStartStatic.CreateBackgroundJobServer(serviceProvider, connection); services.AddHostedService <Worker>(); });