Example #1
0
        public static void Main(string[] args)
        {
            var busoption = BusOptions.CreateFromEnvironment();
            var builder   = new DbContextOptionsBuilder <AuditContext>();

            builder.UseSqlServer(Environment.GetEnvironmentVariable("dbconnectionstring"));
            var options    = builder.Options;
            var eventRepo  = new EventRepository(options);
            var logService = new LogService(new DirectoryInfo(Path.Combine(Environment.GetEnvironmentVariable("logpath"), "RabbitMqLog")));

            while (true)
            {
                try
                {
                    using (var rabbit = new RabbitMqConnection(busoption))
                        using (var logger = new AuditLogger(eventRepo, rabbit, logService))
                        {
                            while (rabbit.Channel.IsOpen)
                            {
                                Thread.Sleep(60000);
                            }
                            logService.Log(new LogMessage("Lost connection with RabbitMq"));
                        }
                }
                catch (Exception e)
                {
                    logService.LogException(new LogMessage(e.Message, e.StackTrace));
                    Thread.Sleep(5000);
                }
            }
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddApplicationInsightsTelemetry(Configuration);

            services.AddMvc();

            Func <IServiceProvider, LogService> logServiceFactory =
                (provider) => new LogService(new DirectoryInfo(Environment.GetEnvironmentVariable("logpath")));

            Func <IServiceProvider, RabbitMqConnection> rabbitMqConnectionFactory =
                (provider) => new RabbitMqConnection(BusOptions.CreateFromEnvironment());

            Func <IServiceProvider, RdwApkAgent> rwdAgentFactory =
                (provider) => new RdwApkAgent(Environment.GetEnvironmentVariable("rdw-requesturl"));
            Func <IServiceProvider, RdwApkManager> apkManagerFactory =
                provider =>
                new RdwApkManager(
                    provider.GetService <IRdwApkAgent>(),
                    provider.GetService <IKeuringsVerzoekConverter>(),
                    provider.GetService <IRepository <ApkAanvraagLog, long> >(),
                    Environment.GetEnvironmentVariable("keuringsverzoek-xmlns"),
                    Environment.GetEnvironmentVariable("keuringsverzoek-apk"),
                    provider.GetService <IEventPublisher>()
                    )
            ;

            services.AddSingleton <ILogService, LogService>(logServiceFactory);
            services.AddScoped <IRabbitMqConnection, RabbitMqConnection>(rabbitMqConnectionFactory);
            services.AddScoped <IEventPublisher, EventPublisher>();
            services.AddScoped <IRdwApkAgent, RdwApkAgent>(rwdAgentFactory);
            services.AddScoped <IRdwApkManager, RdwApkManager>(apkManagerFactory);
            services.AddScoped <IKeuringsVerzoekConverter, KeuringsVerzoekConverter>();

            // Setup database with docker connectionstring

            var dockerConnectionString = Environment.GetEnvironmentVariable("dbconnectionstring");

            services.AddDbContext <RdwContext>
            (
                options => options.UseSqlServer(dockerConnectionString)
            );

            services.AddScoped <IRepository <ApkAanvraagLog, long>, ApkAanvraagLogRepository>();
            services.AddSwaggerGen();
            services.ConfigureSwaggerGen(options =>
            {
                options.SingleApiVersion(new Info
                {
                    Version        = "v1",
                    Title          = "RDW Integration Service",
                    Description    = "RDW Integration Service",
                    TermsOfService = "None"
                });
            });
        }
Example #3
0
        public static void Main(string[] args)
        {
            var options            = BusOptions.CreateFromEnvironment();
            var logger             = new LogService(new DirectoryInfo(Path.Combine(Environment.GetEnvironmentVariable("logpath"), "RabbitMqLog")));
            var dbConnectionString = Environment.GetEnvironmentVariable("dbconnectionstring");

            var eventListener = new MaRoWoEventListener(options, dbConnectionString, logger);

            eventListener.Start();
            var host = new WebHostBuilder()
                       .UseKestrel()
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .UseIISIntegration()
                       .UseStartup <Startup>()
                       .Build();

            host.Run();
        }
Example #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            Func<IServiceProvider, LogService> logServiceFactory =
                (provider) => new LogService(new DirectoryInfo(Environment.GetEnvironmentVariable("logpath")));

            // Setup database with docker connectionstring
            var dockerConnectionString = Environment.GetEnvironmentVariable("dbconnectionstring");
            services.AddDbContext<OnderhoudBeheerContext>
            (
                options => options.UseSqlServer(dockerConnectionString)
            );

            // DI
            services.AddSingleton<ILogService, LogService>(logServiceFactory);
            services.AddScoped<IRepository<Onderhoudsopdracht, long>, OnderhoudsopdrachtRepository>();

            // Eventbus
            var busOptions = BusOptions.CreateFromEnvironment();
            Func<IServiceProvider, EventPublisher> factory = (supplier) => new EventPublisher(new RabbitMqConnection(busOptions));
            services.AddScoped<IEventPublisher, EventPublisher>(factory);

            services.AddScoped<IOnderhoudsopdrachtService, OnderhoudsopdrachtService>();

            services.AddSwaggerGen();
            services.ConfigureSwaggerGen(options => 
            {
                options.SingleApiVersion(new Info 
                {
                    Version = "v1",
                    Title = "OnderhoudBeheer Service",
                    Description = "OnderhoudBeheer Service",
                    TermsOfService = "None"
                });
            });
        }