Exemplo n.º 1
0
        /// <summary>
        /// Bind the configuration services to the database
        /// </summary>
        /// <param name="kernel"></param>
        private static void BindConfigurationService(IKernel kernel)
        {
            // Bind services
            kernel.Bind <IConfigurationRepository>().To <DatabaseClientConfigurationRepository>().InSingletonScope()
            .WithConstructorArgument("database", new DataRepository(ConfigurationHelpers.GetConnectionString("Huddle")))
            .WithConstructorArgument("environment", USFS.Core.Configuration.Environment.GetEnvironment());

            kernel.Bind <IConfigurationServices>().To <ConfigurationServices>().InSingletonScope();
        }
Exemplo n.º 2
0
        private ServiceProvider CreateServiceProvider()
        {
            ServiceCollection services = new ServiceCollection();

            services.AddDbContextPool <ApplicationDbContext>(options =>
            {
                options.UseNpgsql(ConfigurationHelpers.GetConnectionString());
                //options.UseQueryTrackingBehavior(QueryTrackingBehavior.TrackAll);
                //options.EnableDetailedErrors();
            }, 5);

            services.AddIdentityCore <User>()
            .AddRoles <Role>()
            .AddEntityFrameworkStores <ApplicationDbContext>();

            services.AddLogging(l => l.AddConsole());


            return(services.BuildServiceProvider());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Start the ninject binding. Binds all of the required items in the project
        /// </summary>
        protected override void Setup()
        {
            var kernel = Kernel;

            Log = LogManager.GetLogger(typeof(Me2YouModule));
            HuddleConnectionString = ConfigurationHelpers.GetConnectionString("Huddle");

            Log.ErrorFormat("Reading configuration...  . . .   .  .  .");

            USFS.Core.Configuration.Environment currentEnvironment = USFS.Core.Configuration.Environment.GetEnvironment();
            Log.InfoFormat(" Environment: {0}", currentEnvironment);

            if (currentEnvironment == null)
            {
                Log.ErrorFormat("**** Unable to determine the Run Level for application.                     ****");
                Log.ErrorFormat("**** The application relies on the environment variable USFS_RUN_LEVEL to   ****");
                Log.ErrorFormat("**** PRODUCTION or TEST depending on the environment. If this is running    ****");
                Log.ErrorFormat("**** under IIS, reboot the machine after setting the environment variable.  ****");

                throw new ConfigurationErrorsException(" Unable to determine environment run-level. Application in an invalid state and cannot be started. See log for details. ");
            }

            //USFS Bindings
            BindDataRepository(kernel);
            BindEmailService(kernel);
            BindConfigurationService(kernel);
            BindSingleSignOnOnStartup(kernel);

            //Me2You Bindings
            BindPostRepository(kernel);
            BindCategoryRepository(kernel);
            BindUserRepository(kernel);
            BindTicketClaimsRepository(kernel);
            BindEventRepository(kernel);
            BindEmailRepository(kernel);

            //Extra Bindings
            BindHelpers(kernel);
        }
Exemplo n.º 4
0
        /// <summary>
        /// the dependency registrar
        /// </summary>
        public static void RegisterDependencies()
        {
            var maxMemory = 2500000000000;

            HealthCheckHandler.Timeout = TimeSpan.FromSeconds(3);

            GlobalHealthChecks.Build(builder =>
                                     builder
                                     .WithDefaultCacheDuration(TimeSpan.FromMinutes(1))
                                     .AddHealthCheckGroup(
                                         "Basic",
                                         group =>
                                         group
                                         .AddPrivateMemorySizeCheck(maxMemory)
                                         .AddVirtualMemorySizeCheck(maxMemory)
                                         .AddWorkingSetCheck(maxMemory))
                                     .AddHealthCheckGroup(
                                         "Databases",
                                         group =>
                                         group
                                         .AddSqlCheck("Destiny", ConfigurationHelpers.GetConnectionString("Destiny"))
                                         .AddSqlCheck("SecurityService", ConfigurationHelpers.GetConnectionString("SecurityService")))
                                     );
        }