Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            var httpConfig = new HttpConfiguration();
            //register DI here
            var builder = AutofacConfig.Configuration(app);

            container = builder.Build();

            var resolver = new AutofacWebApiDependencyResolver(container);

            httpConfig.DependencyResolver = resolver;

            ConfigureAuth(app, resolver);
            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(httpConfig);
            app.UseWebApi(httpConfig);
            WebApiConfig.Register(httpConfig);
            //app.UseCookieAuthentication(httpConfig);
            Hangfire.GlobalConfiguration.Configuration
            .UseSqlServerStorage("HangfireContext", new SqlServerStorageOptions {
                QueuePollInterval = TimeSpan.FromSeconds(1)
            })
            .UseAutofacActivator(container)
            ;

            app.UseHangfireServer();
            app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
#pragma warning disable 618
                AuthorizationFilters = new[] { new MyRestrictiveAuthorizationFilter() }
#pragma warning restore 618
            });

            RecurringJob.RemoveIfExists(TaskType.ScheduleTask);
            RecurringJob.AddOrUpdate <ITaskService>(TaskType.ScheduleTask, p => p.ScheduleTask(), Cron.Minutely);
        }
Ejemplo n.º 2
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     AutofacConfig.Register();
 }