示例#1
0
        /// <summary>
        /// Sets the Engine to use PostgreSql as its datastore.
        /// </summary>
        public EngineSetup UsePostgreSql(PostgresConfig config)
        {
            if (string.IsNullOrEmpty(config.Host))
            {
                throw new ArgumentException("PostgreSql hostname must be provided in the config.");
            }
            if (string.IsNullOrEmpty(config.DatabaseName))
            {
                throw new ArgumentException("PostgreSql database name must be provided in the config.");
            }

            _dbProviderFactory = logger => new PostgresDbProvider(config, logger);
            return(this);
        }
示例#2
0
        static void Main(string[] args)
        {
            IConfiguration config             = LoadConfiguration();
            PostgresConfig pgconf             = config.GetSection("PostgreSQL").Get <PostgresConfig>();
            SqlFolders     sqlFolders         = config.GetSection("SqlFolders").Get <SqlFolders>();
            string         pgConnectionString = BuildConnectionString(pgconf);

            List <string> scripts = GetOrderedScriptPaths(sqlFolders);

            foreach (string s in scripts)
            {
                ExecuteSqlScript(s, pgConnectionString);
            }
        }
示例#3
0
        public string Start(IRuntimeConfig runtimeConfig,
                            int port, string dbName,
                            string user, string password,
                            IReadOnlyCollection <string> additionalParams)
        {
            var newConfig = new PostgresConfig(config.Distribution,
                                               port,
                                               dbName, config.DataDir,
                                               user, password, additionalParams);

            process = new PostgresProcess(newConfig, runtimeConfig);
            process.Start();

            return(newConfig.ToConnectionString());
        }
示例#4
0
        public static IServiceProvider Build()
        {
            var webRequestHeaders = new Dictionary <string, string>
            {
                { "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" }
            };
            var webRequestConfig = new WebRequestConfig(1000, null, webRequestHeaders);

            var loggingConfig = new LoggingConfig(
                @"D:\Repos\ffdb_data_3\dev_test_logs\",
                maxBytes: null,
                RollingInterval.Day,
                rollOnFileSizeLimit: false,
                useDebugLogLevel: true,
                messageTemplate: @"{Timestamp:MM-dd HH:mm:ss} [{PipelineStage}] {Message:lj}{NewLine}{Exception}");

            var postgresConfig = new PostgresConfig
            {
                DatabaseName = "ffdb_test_2",
                Host         = "localhost",
                Username     = "******",
                Password     = "******"
            };

            var programOptions = new ProgramOptions
            {
                SaveToDisk              = true,
                SkipRosterFetch         = true,
                SaveOriginalSourceFiles = true
            };

            var baseServiceCollection = new EngineBaseServiceCollection();

            ServiceCollection services = baseServiceCollection
                                         .SetRootDataPath(@"D:\Repos\ffdb_data_4\")
                                         .SetWebRequestConfig(webRequestConfig)
                                         .SetLoggingConfig(loggingConfig)
                                         .SetDatabaseProviderFactory(loggerFactory => new PostgresDbProvider(postgresConfig, loggerFactory))
                                         .SetProgramOptions(programOptions)
                                         .Create();

            return(services.BuildServiceProvider());
        }
示例#5
0
 public Postgres(PostgresConfig postgresConfig)
 {
     this.postgresConfig = postgresConfig;
     ConnectionString    = postgresConfig.ConnectionString();
     connection          = new NpgsqlConnection(ConnectionString);
 }
示例#6
0
 private static string BuildConnectionString(PostgresConfig pgConfig)
 {
     return($"User ID={pgConfig.User};Password={pgConfig.Password};Host={pgConfig.Hostname};Port={pgConfig.Port};Database={pgConfig.Database};SSL Mode=Require;Trust Server Certificate=true;");
 }