Ejemplo n.º 1
0
        private static void InitializeRepoDb()
        {
            var provider = MixService.GetEnumConfig <MixDatabaseProvider>(MixConstants.CONST_SETTING_DATABASE_PROVIDER);

            switch (provider)
            {
            case MixDatabaseProvider.MSSQL:
                SqlServerBootstrap.Initialize();
                break;

            case MixDatabaseProvider.MySQL:
                MySqlBootstrap.Initialize();
                break;

            case MixDatabaseProvider.PostgreSQL:
                PostgreSqlBootstrap.Initialize();
                break;

            case MixDatabaseProvider.SQLITE:
                SqLiteBootstrap.Initialize();
                break;

            default:
                SqLiteBootstrap.Initialize();
                break;
            }
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebAssemblyDebugging();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseBlazorFrameworkFiles();
            app.UseStaticFiles();

            PostgreSqlBootstrap.Initialize();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
                endpoints.MapFallbackToFile("index.html");
            });
        }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.

        public void ConfigureServices(IServiceCollection services)
        {
            SqlServerBootstrap.Initialize();
            PostgreSqlBootstrap.Initialize();
            MySqlBootstrap.Initialize();

            #region dependency injection

            services.AddTransient <IDatabaseConnectionFactory, NorthWindDbConnectionFactory>();
            services.AddTransient <IDatabaseConnectionFactory, AdemBlogDbConnectionFactory>();
            services.AddTransient <IDatabaseConnectionFactory, FinansDbConnectionFactory>();
            services.AddTransient <IDatabaseConnectionFactory, BookStoreDbConnectionFactory>();

            services.AddTransient <ICategoryService, CategoryManager>();
            services.AddTransient <ICategoryDal, CategoryDal>();

            services.AddTransient <ICashboxService, CashboxManager>();
            services.AddTransient <ICashboxDal, CashboxDal>();

            services.AddTransient <ITagService, TagManager>();
            services.AddTransient <ITagDal, TagDal>();

            services.AddTransient <IPostService, PostManager>();
            services.AddTransient <IPostDal, PostDal>();

            services.AddTransient <IBookService, BookManager>();
            services.AddTransient <IBookDal, BookDal>();

            #endregion dependency injection

            services.AddControllersWithViews();
        }
Ejemplo n.º 4
0
        public static void Initialize()
        {
            // Check the connection string
            var connectionStringForPosgres = Environment.GetEnvironmentVariable("REPODB_CONSTR_POSTGRESDB", EnvironmentVariableTarget.Process);
            var connectionString           = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process);

            // Master connection
            ConnectionStringForPosgres = (connectionStringForPosgres ?? "Server=127.0.0.1;Port=5432;Database=postgres;User Id=postgres;Password=Password123;");

            // RepoDb connection
            ConnectionString = (connectionString ?? "Server=127.0.0.1;Port=5432;Database=RepoDb;User Id=postgres;Password=Password123;");

            // For >= v6.0.0: To reutilize the legacy behavior
            // https://github.com/abpframework/abp/issues/10273
            AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);

            // Initialize PostgreSql
            PostgreSqlBootstrap.Initialize();

            // Create databases
            CreateDatabase();

            // Create tables
            CreateTables();
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            //initializes RepoDb ORM for PostgreSQl ...........
            PostgreSqlBootstrap.Initialize();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
        public void Init(string connectionString, DatabaseProvider databaseType)
        {
            DatabaseProvider = databaseType;
            conn             = DatabaseProvider.GetAndConfigureConnection(connectionString, (connection, dbType) =>
            {
                switch (dbType)
                {
                case DatabaseProvider.MySqlData:
                    MySqlBootstrap.Initialize();
                    break;

                case DatabaseProvider.Npgsql:
                    PostgreSqlBootstrap.Initialize();
                    break;

                case DatabaseProvider.SystemData:
                    {
                        var dbSetting = new SqlServerDbSetting();
                        DbSettingMapper.Add(typeof(System.Data.SqlClient.SqlConnection), dbSetting, true);

                        // Map the DbHelper
                        var dbHelper = new SqlServerDbHelper();
                        DbHelperMapper.Add(typeof(System.Data.SqlClient.SqlConnection), dbHelper, true);

                        // Map the Statement Builder
                        var statementBuilder = new SqlServerStatementBuilder(dbSetting);
                        StatementBuilderMapper.Add(typeof(System.Data.SqlClient.SqlConnection), statementBuilder, true);
                        break;
                    }

                case DatabaseProvider.MicrosoftData:
                    {
                        var dbSetting = new SqlServerDbSetting();
                        DbSettingMapper.Add(typeof(Microsoft.Data.SqlClient.SqlConnection), dbSetting, true);

                        // Map the DbHelper
                        var dbHelper = new SqlServerDbHelper();
                        DbHelperMapper.Add(typeof(Microsoft.Data.SqlClient.SqlConnection), dbHelper, true);

                        // Map the Statement Builder
                        var statementBuilder = new SqlServerStatementBuilder(dbSetting);
                        StatementBuilderMapper.Add(typeof(Microsoft.Data.SqlClient.SqlConnection), statementBuilder, true);
                        break;
                    }

                case DatabaseProvider.MySqlConnector:
                    MySqlConnectorBootstrap.Initialize();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                connection.Open();
                return(connection);
            });
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initialize the creation of the database.
        /// </summary>
        public static void Initialize()
        {
            // Set the connection string
            ConnectionStringForPosgres = Environment.GetEnvironmentVariable("REPODB_CONSTR_POSTGRESDB", EnvironmentVariableTarget.Process) ??
                                         "Server=127.0.0.1;Port=5432;Database=postgres;User Id=postgres;Password=Password123;";
            ConnectionStringForRepoDb = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process) ??
                                        "Server=127.0.0.1;Port=5432;Database=RepoDb;User Id=postgres;Password=Password123;";

            // Initialize PostgreSql
            PostgreSqlBootstrap.Initialize();

            // Create databases
            CreateDatabase();

            // Create tables
            CreateTables();
        }
Ejemplo n.º 8
0
 public void Initialize()
 {
     PostgreSqlBootstrap.Initialize();
 }
Ejemplo n.º 9
0
 public void Setup()
 {
     SqlServerBootstrap.Initialize();
     PostgreSqlBootstrap.Initialize();
 }
Ejemplo n.º 10
0
 public void Setup()
 {
     PostgreSqlBootstrap.Initialize();
     TypeMapper.Add(typeof(DateTime), DbType.DateTime2, true);
     BaseSetup();
 }