Beispiel #1
0
        public void Configuration(IAppBuilder app)
        {
            ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;

            var moduloRMConfig = new ModuloRiskManagerConfig()
            {
                BaseUri = new Uri("https://build.dev.modulo.com/RM_EN_FULL"),
                Id      = "3a998f2dc04a46d9a85312164b048e55",
                Key     = "f877dfe7752c44318d2c5dd4a74eb501"
            };

            var unity = new UnityContainer();

            unity.RegisterInstance <int>(42);
            unity.RegisterInstance <ModuloRiskManagerConfig>(moduloRMConfig);
            unity.RegisterInstance <HttpClient>(new HttpClient());
            unity.RegisterInstance <ToPhysicalPath>(new ToPhysicalPath(x =>
            {
                return(System.Web.Hosting.HostingEnvironment.MapPath(x));
            }));
            unity.RegisterInstance <ToAbsolutePath>(new ToAbsolutePath(x =>
            {
                var host = HttpContext.Current.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.UriEscaped);
                return(host + VirtualPathUtility.ToAbsolute(x));
            }));

            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.AppSettings()
                         .CreateLogger();

            var webApiConfiguration = System.Web.Http.GlobalConfiguration.Configuration;

            webApiConfiguration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly;
            webApiConfiguration.Services.Add(typeof(IExceptionLogger), new SerilogExceptionLogger());
            webApiConfiguration.DependencyResolver = new UnityDependencyResolver(unity);
            webApiConfiguration.MapHttpAttributeRoutes();
            webApiConfiguration.Formatters.Add(new FormUrlEncodedMediaTypeFormatter());
            webApiConfiguration.Formatters.Add(new RazorViewFormatter());
            webApiConfiguration.EnsureInitialized();

            var hangfireConfiguration = Hangfire.GlobalConfiguration.Configuration;

            hangfireConfiguration.UseMemoryStorage(new MemoryStorageOptions()
            {
            });
            hangfireConfiguration.UseActivator(new UnityJobActivator(unity));
            hangfireConfiguration.UseSerilogLogProvider();
            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute {
                Attempts = 3
            });

            app.UseHangfireDashboard("/admin/hangfire", new DashboardOptions()
            {
                AuthorizationFilters = new Hangfire.Dashboard.IAuthorizationFilter[] { new LocalhostOnlyAuthorizeAttribute() }
            });
            app.UseHangfireServer(new BackgroundJobServerOptions()
            {
                WorkerCount = 1
            });
        }
 public LoginController(ModuloRiskManagerConfig config, ToAbsolutePath toAbsolute)
 {
     Config     = config;
     ToAbsolute = toAbsolute;
 }