public static void Init(CustomConfiguration customConfiguration) { LogUtility.Log("MongoHelper init start"); _connectionString = Environment.GetEnvironmentVariable(Constants.MongoDbConnectionStringEnv) ?? customConfiguration.MongoDBConnectionInfo.ConnectionString; _database = Environment.GetEnvironmentVariable(Constants.MongoDbDatabaseEnv) ?? customConfiguration.MongoDBConnectionInfo.Database; _collection = Environment.GetEnvironmentVariable(Constants.MongoDbCollectionEnv) ?? customConfiguration.MongoDBConnectionInfo.Collection; _mongoClient = new MongoClient(_connectionString); CheckConnectionLoop(); LogUtility.Log("MongoHelper init end"); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime lifetime) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMiddleware(typeof(OperationContextMiddleware)); app.UseMiddleware(typeof(RequestLoggingMiddleware)); app.UseCors("MyPolicy"); app.UseMvc(); lifetime.ApplicationStopping.Register(() => { LogUtility.Log("Graceful shutdown."); }); }
public static void Main(string[] args) { IConfiguration Configuration; var builder = new ConfigurationBuilder().AddJsonFile($"appsettings.json", true, true); Configuration = builder.Build(); _customConfiguration = new CustomConfiguration(); Configuration.GetSection("CustomConfiguration").Bind(_customConfiguration); BikesHelper.Init(_customConfiguration); BillingHelper.Init(_customConfiguration); MongoHelper.Init(_customConfiguration); var host = WebHost.CreateDefaultBuilder <Startup>(args).Build(); host.Run(); LogUtility.Log("Reservation engine service running."); }
public static void Init(CustomConfiguration customConfiguration) { LogUtility.Log("BillingHelper init start"); _billingService = Environment.GetEnvironmentVariable(Constants.BillingMicroserviceEnv) ?? customConfiguration.Services.Billing; LogUtility.Log("BillingHelper init end"); }