Beispiel #1
0
 /// <summary>
 /// Startup
 /// </summary>
 /// <param name="configuration"></param>
 public Startup(IConfiguration configuration)
 {
     logger = LoggerConfig.Configure();
     logger.Information("Logger configured");
     appConfig = configuration;
     solutionEnvironmentName = configuration["ENVIRONMENT"];
 }
Beispiel #2
0
        private void Init()
        {
            var configuration = GetConfiguration();

            LoggerConfig.Configure(configuration);

            InitAutoMapper();

            Ioc.Init(configuration);
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            IdentityConfig.ConfigureIdentity();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AutoMapperConfig.Configure();
            LoggerConfig.Configure();
        }
Beispiel #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                // Allow cross origin resource sharing for testing all development requests.
                // This should not be done for a production build.
                app.UseCors(builder =>
                {
                    builder.WithOrigins("*");
                });
            }
            else
            {
                // In a non-development environment, this adds middleware to the pipeline that
                // will catch exceptions, log them, and re-execute the request in an
                // alternate pipeline. The request will not be re-executed if the response has
                // already started.
                app.UseExceptionHandler(appBuilder =>
                {
                    appBuilder.Run(async context =>
                    {
                        context.Response.StatusCode = 500;
                        await context.Response.WriteAsync("There was an unexpected error.");
                    });
                });
            }

            // Add logging to the request pipeline
            LoggerConfig.Configure(loggerFactory);

            // Adds middleware for redirecting HTTP requests to HTTPS
            app.UseHttpsRedirection();

            // Marks the position in the middleware pipeline where a routing
            // decision is made (where an endpoint is selected)
            app.UseRouting();

            // Adds the Microsoft.AspNetCore.Authorization.AuthorizationMiddleware to the specified
            // Microsoft.AspNetCore.Builder.IApplicationBuilder, which enables authorization
            // capabilities.
            app.UseAuthorization();

            // Marks the position in the middleware pipeline where the selected
            // endpoint is executed
            app.UseEndpoints(endpoints =>
            {
                // Adds endpoints for our controller actions but no routes are specified
                // For a Web API, use attributes at controller and action level: [Route], [HttpGet], ...
                endpoints.MapControllers();
            });
        }
Beispiel #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IWebHostEnvironment env, ITaskScheduler taskScheduler)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Add logging to the request pipeline
            LoggerConfig.Configure(loggerFactory);

            app.UseHangfireDashboard();

            taskScheduler.ScheduleRecurringTasks();

            app.UseRouting();
        }
Beispiel #6
0
        public static IServiceProvider CreateContainer(string env)
        {
            var path = GetAppSettingPath();

            var configuration = GetConfiguration(path, env);

            LoggerConfig.Configure(configuration);

            MappingConfig.RegisterMappings();

            Ioc.Init(configuration);

            var services = new ServiceCollection();

            DbContextConfiguration.UseSqlDataBase <DataBase>(services, GetConfiguration(path, env));

            return(Ioc.Container.CreateServiceProvider(services));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            var logger = LoggerConfig.Configure();

            CreateWebHostBuilder(args).Build().Run();
            try
            {
                logger.Information("Appointments Web Api Starting up....!!!");
                CreateWebHostBuilder(args).Build().Run();
            }
            catch (Exception ex)
            {
                logger.Fatal(ex, $"Appointments Web Api start-up failed to Start because: {ex.Message}");
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
Beispiel #8
0
        public Startup(IHostingEnvironment env)
        {
            try
            {
                var configuration = AppSettingsFileProvider.LoadConfiguration(env.ContentRootPath, env.EnvironmentName);

                ConfigurationProvider = new AppConfigurationProvider(configuration, env.ContentRootPath);

                LoggerConfig.Configure(ConfigurationProvider);
            }
            catch (Exception e)
            {
                var message = $"Application failed to start. Message: {e.Message}, StackTrace: {e.StackTrace}";
                Console.WriteLine(message);
                Log.Logger().Error(e, message);

                throw;
            }
        }
        public static void Main(string[] args)
        {
            var appConfig = CommandLineParser.Configure(args);

            LoggerConfig.Configure(appConfig);

            var container = ContainerConfig.Configure(appConfig);

            using (var scope = container.BeginLifetimeScope())
            {
                var app = scope.Resolve <IApplication>();
                app.Run();
            }

            Log.CloseAndFlush();

            if (appConfig.WaitForEnter)
            {
                Console.ReadLine();
            }
        }
Beispiel #10
0
        public Startup(IHostingEnvironment env)
        {
            try
            {
                var builder = new ConfigurationBuilder()
                              .SetBasePath(env.ContentRootPath)
                              .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                              .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                              .AddEnvironmentVariables();
                var configuration = builder.Build();

                ConfigurationProvider = new CustomConfigurationProvider(configuration, env.ContentRootPath);

                LoggerConfig.Configure(ConfigurationProvider);
            }
            catch (Exception e)
            {
                Log.Logger().Error(e, "Application failed to start");
                throw;
            }
        }