Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            if (string.Equals(Configuration["CheckDependency:Enabled"], "true", System.StringComparison.OrdinalIgnoreCase))
            {
                NetworkPortCheck.Wait(Configuration["CheckDependency:Host"], 5);
            }

            var messageBrokerOptions = new MessageBrokerOptions {
                Provider = "Fake"
            };

            services.AddAuditLogModule(Configuration["ConnectionStrings:ClassifiedAds"],
                                       typeof(Startup).GetTypeInfo().Assembly.GetName().Name)
            .AddIdentityModule(Configuration["ConnectionStrings:ClassifiedAds"],
                               typeof(Startup).GetTypeInfo().Assembly.GetName().Name)
            .AddNotificationModule(messageBrokerOptions, Configuration["ConnectionStrings:ClassifiedAds"],
                                   typeof(Startup).GetTypeInfo().Assembly.GetName().Name)
            .AddProductModule(Configuration["ConnectionStrings:ClassifiedAds"],
                              typeof(Startup).GetTypeInfo().Assembly.GetName().Name)
            .AddStorageModule(new StorageOptions(),
                              messageBrokerOptions,
                              Configuration["ConnectionStrings:ClassifiedAds"],
                              typeof(Startup).GetTypeInfo().Assembly.GetName().Name)
            .AddApplicationServices();

            services.AddIdentityServer()
            .AddTokenProviderModule(Configuration.GetConnectionString("ClassifiedAds"),
                                    typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
        }
        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup <Startup>()
        .ConfigureAppConfiguration((ctx, builder) =>
        {
            var config      = builder.Build();
            var appSettings = new AppSettings();
            config.Bind(appSettings);

            if (appSettings.CheckDependency.Enabled)
            {
                NetworkPortCheck.Wait(appSettings.CheckDependency.Host, 5);
            }

            if (appSettings?.ConfigurationSources?.SqlServer?.IsEnabled ?? false)
            {
                builder.AddSqlConfigurationVariables(appSettings.ConfigurationSources.SqlServer);
            }

            if (ctx.HostingEnvironment.IsDevelopment())
            {
                return;
            }

            if (appSettings?.ConfigurationSources?.AzureKeyVault?.IsEnabled ?? false)
            {
                builder.AddAzureKeyVault(appSettings.ConfigurationSources.AzureKeyVault.VaultName);
            }
        })
        .UseClassifiedAdsLogger(configuration =>
        {
            var appSettings = new AppSettings();
            configuration.Bind(appSettings);
            return(appSettings.Logging);
        });
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <AppSettings>(Configuration);

            if (AppSettings.CheckDependency.Enabled)
            {
                var hosts = AppSettings.CheckDependency.Host.Split(',');
                foreach (var host in hosts)
                {
                    NetworkPortCheck.Wait(host, 5);
                }
            }

            services.AddHangfire(x =>
            {
                var options = new SqlServerStorageOptions
                {
                    PrepareSchemaIfNecessary = true,
                };
                x.UseSqlServerStorage(AppSettings.ConnectionStrings.ClassifiedAds, options);
            });

            services.AddDateTimeProvider();

            services.AddNotificationModule(AppSettings.MessageBroker, AppSettings.Notification, AppSettings.ConnectionStrings.ClassifiedAds)
            .AddApplicationServices();

            services.AddMessageBusReceiver <FileUploadedEvent>(AppSettings.MessageBroker);
            services.AddMessageBusReceiver <FileDeletedEvent>(AppSettings.MessageBroker);
            services.AddMessageBusReceiver <EmailMessageCreatedEvent>(AppSettings.MessageBroker);
            services.AddMessageBusReceiver <SmsMessageCreatedEvent>(AppSettings.MessageBroker);

            services.AddHostedService <ResendEmailHostedService>();
            services.AddHostedService <ResendSmsHostedService>();
        }
        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup <Startup>()
        .ConfigureAppConfiguration((ctx, builder) =>
        {
            var config      = builder.Build();
            var appSettings = new AppSettings();
            config.Bind(appSettings);

            builder.AddEFConfiguration(() =>
            {
                if (appSettings.CheckDependency.Enabled)
                {
                    NetworkPortCheck.Wait(appSettings.CheckDependency.Host, 5);
                }

                var dbContextOptionsBuilder = new DbContextOptionsBuilder <AdsDbContext>();
                dbContextOptionsBuilder.UseSqlServer(appSettings.ConnectionStrings.ClassifiedAds);
                return(new AdsDbContext(dbContextOptionsBuilder.Options));
            });

            //builder.AddSqlConfigurationVariables(appSettings.ConnectionStrings.ClassifiedAds);

            if (ctx.HostingEnvironment.IsDevelopment())
            {
                return;
            }

            builder.AddAzureKeyVault($"https://{appSettings.KeyVaultName}.vault.azure.net/");
        })
        .UseClassifiedAdsLogger();
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            if (string.Equals(Configuration["CheckDependency:Enabled"], "true", System.StringComparison.OrdinalIgnoreCase))
            {
                NetworkPortCheck.Wait(Configuration["CheckDependency:Host"], 5);
            }

            services.AddPersistence(Configuration["ConnectionStrings:ClassifiedAds"],
                                    typeof(Startup).GetTypeInfo().Assembly.GetName().Name);

            services.AddIdentityServer()
            .AddIdServerPersistence(Configuration.GetConnectionString("ClassifiedAds"),
                                    typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
        }
Exemple #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            if (string.Equals(Configuration["CheckDependency:Enabled"], "true", StringComparison.OrdinalIgnoreCase))
            {
                NetworkPortCheck.Wait(Configuration["CheckDependency:Host"], 5);
            }

            services.AddHangfire(x =>
            {
                var options = new SqlServerStorageOptions
                {
                    PrepareSchemaIfNecessary = true,
                };
                x.UseSqlServerStorage(Configuration.GetConnectionString("ClassifiedAds"), options);
            });
        }
Exemple #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            if (string.Equals(Configuration["CheckDependency:Enabled"], "true", System.StringComparison.OrdinalIgnoreCase))
            {
                NetworkPortCheck.Wait(Configuration["CheckDependency:Host"], 5);
            }

            services.AddDateTimeProvider();

            services.AddAuditLogModule(opt =>
            {
                Configuration.GetSection("Modules:AuditLog").Bind(opt);
                opt.ConnectionStrings.MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
            })
            .AddConfigurationModule(opt =>
            {
                Configuration.GetSection("Modules:Configuration").Bind(opt);
                opt.ConnectionStrings.MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
            })
            .AddIdentityModuleCore(opt =>
            {
                Configuration.GetSection("Modules:Identity").Bind(opt);
                opt.ConnectionStrings.MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
            })
            .AddNotificationModule(opt =>
            {
                Configuration.GetSection("Modules:Notification").Bind(opt);
                opt.ConnectionStrings.MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
            })
            .AddProductModule(opt =>
            {
                Configuration.GetSection("Modules:Product").Bind(opt);
                opt.ConnectionStrings.MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
            })
            .AddStorageModule(opt =>
            {
                Configuration.GetSection("Modules:Storage").Bind(opt);
                opt.ConnectionStrings.MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
            })
            .AddApplicationServices();

            services.AddIdentityServer()
            .AddIdServerPersistence(Configuration["Modules:Auth:ConnectionStrings:Default"],
                                    typeof(Startup).GetTypeInfo().Assembly.GetName().Name);

            services.AddScoped <ICurrentUser, CurrentWebUser>();
        }
Exemple #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            if (string.Equals(Configuration["CheckDependency:Enabled"], "true", System.StringComparison.OrdinalIgnoreCase))
            {
                NetworkPortCheck.Wait(Configuration["CheckDependency:Host"], 5);
            }

            services.AddDateTimeProvider();

            services.AddPersistence(Configuration["ConnectionStrings:ClassifiedAds"],
                                    typeof(Startup).GetTypeInfo().Assembly.GetName().Name);

            services.AddIdentityServer()
            .AddIdServerPersistence(Configuration.GetConnectionString("ClassifiedAds"),
                                    typeof(Startup).GetTypeInfo().Assembly.GetName().Name);

            services.AddDbContext <MiniProfilerDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ClassifiedAds"), sql =>
            {
                sql.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
            }));
        }
Exemple #9
0
        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup <Startup>()
        .ConfigureAppConfiguration((ctx, builder) =>
        {
            var config      = builder.Build();
            var appSettings = new AppSettings();
            config.Bind(appSettings);

            if (appSettings.CheckDependency.Enabled)
            {
                NetworkPortCheck.Wait(appSettings.CheckDependency.Host, 5);
            }

            builder.AddAppConfiguration(appSettings.ConfigurationProviders);
        })
        .UseClassifiedAdsLogger(configuration =>
        {
            var appSettings = new AppSettings();
            configuration.Bind(appSettings);
            return(appSettings.Logging);
        });
Exemple #10
0
        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup <Startup>()
        .ConfigureAppConfiguration((ctx, builder) =>
        {
            var config = builder.Build();

            builder.AddEFConfiguration(() =>
            {
                if (string.Equals(config["CheckDependency:Enabled"], "true", System.StringComparison.OrdinalIgnoreCase))
                {
                    NetworkPortCheck.Wait(config["CheckDependency:Host"], 5);
                }

                var dbContextOptionsBuilder = new DbContextOptionsBuilder <AdsDbContext>();
                dbContextOptionsBuilder.UseSqlServer(config.GetConnectionString("ClassifiedAds"));
                return(new AdsDbContext(dbContextOptionsBuilder.Options));
            });

            //builder.AddSqlConfigurationVariables(config.GetConnectionString("ClassifiedAds"));

            if (ctx.HostingEnvironment.IsDevelopment())
            {
                return;
            }

            builder.AddAzureKeyVault($"https://{config["KeyVaultName"]}.vault.azure.net/");
        })
        .ConfigureLogging(logging =>
        {
            //logging.AddEventLog(new EventLogSettings
            //{
            //    LogName = "ClassifiedAds",
            //    SourceName = "WebMVC",
            //    Filter = (a, b) => b >= LogLevel.Information
            //});
        })
        .UseSerilog();
Exemple #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            var appSettings = new AppSettings();

            Configuration.Bind(appSettings);
            AppSettings = appSettings;

            var validationResult = appSettings.Validate();

            if (validationResult.Failed)
            {
                throw new Exception(validationResult.FailureMessage);
            }

            services.Configure <AppSettings>(Configuration);

            if (appSettings.CheckDependency.Enabled)
            {
                var hosts = appSettings.CheckDependency.Host.Split(',');
                foreach (var host in hosts)
                {
                    NetworkPortCheck.Wait(host, 5);
                }
            }

            services.AddHangfire(x =>
            {
                var options = new SqlServerStorageOptions
                {
                    PrepareSchemaIfNecessary = true,
                };
                x.UseSqlServerStorage(appSettings.ConnectionStrings.ClassifiedAds, options);
            });

            services.AddTransient <IWebNotification, SignalRNotification>();
        }
Exemple #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <AppSettings>(Configuration);

            if (AppSettings.CheckDependency.Enabled)
            {
                var hosts = AppSettings.CheckDependency.Host.Split(',');
                foreach (var host in hosts)
                {
                    NetworkPortCheck.Wait(host, 5);
                }
            }

            services.AddHangfire(x =>
            {
                var options = new SqlServerStorageOptions
                {
                    PrepareSchemaIfNecessary = true,
                };
                x.UseSqlServerStorage(AppSettings.ConnectionStrings.ClassifiedAds, options);
            });

            services.AddTransient <IWebNotification, SignalRNotification>();
        }
Exemple #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            if (string.Equals(Configuration["CheckDependency:Enabled"], "true", System.StringComparison.OrdinalIgnoreCase))
            {
                NetworkPortCheck.Wait(Configuration["CheckDependency:Host"], 5);
            }

            services.AddDateTimeProvider();

            var messageBrokerOptions = new MessageBrokerOptions
            {
                Provider = "Fake",
            };

            var notificationOptions = new NotificationOptions
            {
                Email = new EmailOptions {
                    Provider = "Fake"
                },
                Sms = new SmsOptions {
                    Provider = "Fake"
                },
                Web = new WebOptions {
                    Provider = "Fake"
                },
            };

            services.AddAuditLogModule(new Modules.AuditLog.ConfigurationOptions.AuditLogModuleOptions
            {
                ConnectionStrings = new Modules.AuditLog.ConfigurationOptions.ConnectionStringsOptions
                {
                    Default            = Configuration["ConnectionStrings:ClassifiedAds"],
                    MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name,
                },
            })
            .AddConfigurationModule(new ConfigurationModuleOptions
            {
                ConnectionStrings = new Modules.Configuration.ConfigurationOptions.ConnectionStringsOptions
                {
                    Default            = Configuration["ConnectionStrings:ClassifiedAds"],
                    MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name,
                },
            })
            .AddIdentityModule(new IdentityModuleOptions
            {
                ConnectionStrings = new Modules.Identity.ConfigurationOptions.ConnectionStringsOptions
                {
                    Default            = Configuration["ConnectionStrings:ClassifiedAds"],
                    MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name,
                },
            })
            .AddNotificationModule(new Modules.Notification.ConfigurationOptions.NotificationModuleOptions
            {
                ConnectionStrings = new Modules.Notification.ConfigurationOptions.ConnectionStringsOptions
                {
                    Default            = Configuration["ConnectionStrings:ClassifiedAds"],
                    MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name,
                },
                MessageBroker = messageBrokerOptions,
                Notification  = notificationOptions,
            })
            .AddProductModule(new Modules.Product.ConfigurationOptions.ProductModuleOptions
            {
                ConnectionStrings = new Modules.Product.ConfigurationOptions.ConnectionStringsOptions
                {
                    Default            = Configuration["ConnectionStrings:ClassifiedAds"],
                    MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name,
                },
            })
            .AddStorageModule(new Modules.Storage.ConfigurationOptions.StorageModuleOptions
            {
                ConnectionStrings = new Modules.Storage.ConfigurationOptions.ConnectionStringsOptions
                {
                    Default            = Configuration["ConnectionStrings:ClassifiedAds"],
                    MigrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name,
                },
                Storage       = new StorageOptions(),
                MessageBroker = messageBrokerOptions,
            })
            .AddApplicationServices();

            services.AddIdentityServer()
            .AddTokenProviderModule(Configuration.GetConnectionString("ClassifiedAds"),
                                    typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
        }