Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogService logService)
        {
            DomainEvents.Configure(app.ApplicationServices);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                new ConfigurationBuilder().AddUserSecrets("faf3a1a4-4c57-48a4-91df-e775496e02d5").Build();
            }
            else
            {
                app.UseMiddleware <ExceptionHandler>();
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapHub <PartyHub>("/partyhub");
            });
        }
Beispiel #2
0
        public static void Init(IWindsorContainer container)
        {
            var adapter = new CastleWindsorContainerAdapter(container);
            var bus     = Configure.With(adapter)
                          .Logging(x => x.Log4Net())
                          .Transport(x => x.UseMsmq($"{EndpointName}.input"))
                          .Routing(t => t.TypeBased().AddEndpointMappingsFromAppConfig())
                          .SetupSubscriptions("endpoint", "AccountsServiceSubscriptions")
                          .SetupUnitOfWork(container)
                          .Options(x => x.SetNumberOfWorkers(5))
                          .Start();

            bus.Subscribe <ProductProvisioned>();

            DomainEvents.Configure(e => bus.Publish(e));
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogService logService)
        {
            DomainEvents.Configure(app.ApplicationServices);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                new ConfigurationBuilder().AddUserSecrets("faf3a1a4-4c57-48a4-91df-e775496e02d5").Build();
            }
            else
            {
                app.UseExceptionHandler(error =>
                {
                    error.Run(async context =>
                    {
                        context.Response.StatusCode  = (int)HttpStatusCode.InternalServerError;
                        context.Response.ContentType = "application/json";

                        var contextFeature = context.Features.Get <IExceptionHandlerFeature>();

                        if (contextFeature != null)
                        {
                            await logService.LogExceptionAsync(contextFeature.Error, "Error caught in global exception handler");
                        }
                    });
                });
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapHub <PartyHub>("/partyhub");
            });
        }
Beispiel #4
0
        static void Main()
        {
            LogUtility.Initialise();
            log = LogUtility.ForCurrentType();

            var autoResetEvent = new AutoResetEvent(false);

            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                // cancel the cancellation to allow the program to shutdown cleanly
                eventArgs.Cancel = true;
                autoResetEvent.Set();
            };


            using (var container = new ContainerInitialiser().Create())
            {
                RebusConfiguration.Init(container);
                Console.WriteLine("Application has started. Ctrl-C to end");
                autoResetEvent.WaitOne();
                log.InfoFormat("Shutting down service");
            }

            using (var container = new ContainerInitialiser().Create())
            {
                log.DebugFormat("Initialised container");
                var starter = container.Resolve <IBusStarter>();
                starter.Start();

                DomainEvents.Configure(e => starter.Bus.Publish(e));

                // main blocks here waiting for ctrl-C
                autoResetEvent.WaitOne();
                log.InfoFormat("Shutting down");
            }
        }