Пример #1
0
        public void Save(CdmVersions cdm, string destinationConnectionString, IDatabaseEngine destinationEngine, string sourceSchema, string destinationSchema)
        {
            Console.WriteLine($"Saving chunkId={ChunkId} ...");
            Console.WriteLine("DestinationConnectionString=" + destinationConnectionString);

            if (ChunkData.Persons.Count == 0)
            {
                ChunkData.Clean();
                return;
            }

            var saver = destinationEngine.GetSaver();

            var timer = new Stopwatch();

            timer.Start();
            using (saver)
            {
                saver.Create(destinationConnectionString, cdm, sourceSchema, destinationSchema).Save(ChunkData, OffsetManager);
            }
            timer.Stop();

            Console.WriteLine($"Saving chunkId={ChunkId} - complete");

            ChunkData.Clean();
            GC.Collect();
        }
Пример #2
0
        public virtual ISaver Create(string connectionString, CdmVersions cdmVersion, string sourceSchema, string destinationSchema)
        {
            CdmVersion        = cdmVersion;
            SourceSchema      = sourceSchema;
            DestinationSchema = destinationSchema;

            return(this);
        }
Пример #3
0
        public virtual void SaveEntityLookup(CdmVersions cdmVersions, List <Location> location, List <CareSite> careSite, List <Provider> provider, List <CohortDefinition> cohortDefinition)
        {
            try
            {
                if (cdmVersions == CdmVersions.V6)
                {
                    if (location != null && location.Count > 0)
                    {
                        Write(null, null, new cdm6.LocationDataReader(location), "LOCATION");
                    }

                    if (careSite != null && careSite.Count > 0)
                    {
                        Write(null, null, new cdm6.CareSiteDataReader(careSite), "CARE_SITE");
                    }

                    if (provider != null && provider.Count > 0)
                    {
                        Write(null, null, new cdm6.ProviderDataReader(provider), "PROVIDER");
                    }
                }
                else
                {
                    if (location != null && location.Count > 0)
                    {
                        Write(null, null, new LocationDataReader(location), "LOCATION");
                    }

                    if (careSite != null && careSite.Count > 0)
                    {
                        Write(null, null, new CareSiteDataReader(careSite), "CARE_SITE");
                    }

                    if (provider != null && provider.Count > 0)
                    {
                        foreach (var chunk in SplitList(provider))
                        {
                            Write(null, null, new ProviderDataReader(chunk), "PROVIDER");
                        }
                    }
                }

                if (cohortDefinition != null && cohortDefinition.Count > 0)
                {
                    Write(null, null, new cdm6.CohortDefinitionDataReader(cohortDefinition), "COHORT_DEFINITION");
                }

                Commit();
            }
            catch (Exception e)
            {
                //Logger.WriteError(e);
                Rollback();
                throw;
            }
        }
Пример #4
0
        public override ISaver Create(string connectionString, CdmVersions cdmVersion, string sourceSchema, string destinationSchema)
        {
            CdmVersion        = cdmVersion;
            SourceSchema      = sourceSchema;
            DestinationSchema = destinationSchema;

            var odbc = new OdbcConnectionStringBuilder(connectionString);

            var connectionStringTemplate = "Server={server};Port=5432;Database={database};User Id={username};Password={password};SslMode=Require;Trust Server Certificate=true";

            var npgsqlConnectionString = connectionStringTemplate.Replace("{server}", odbc["server"].ToString())
                                         .Replace("{database}", odbc["database"].ToString()).Replace("{username}", odbc["uid"].ToString())
                                         .Replace("{password}", odbc["pwd"].ToString());

            Console.WriteLine("npgsqlConnectionString=" + npgsqlConnectionString);
            _connection = SqlConnectionHelper.OpenNpgsqlConnection(npgsqlConnectionString);

            return(this);
        }
Пример #5
0
        public override ISaver Create(string connectionString, CdmVersions cdmVersion, string sourceSchema, string destinationSchema)
        {
            CdmVersion        = cdmVersion;
            SourceSchema      = sourceSchema;
            DestinationSchema = destinationSchema;

            var odbc = new OdbcConnectionStringBuilder(connectionString);

            //var connectionStringTemplate = "Server={server};Port=5432;Database={database};User Id={username};Password={password};SslMode=Require;Trust Server Certificate=true";
            var connectionStringTemplate = "Server={server};Port={port};Database={database};User Id={username};Password={password}";

            ////TMP
            //if (odbc["server"].ToString() == "10.110.1.7" ||
            //    odbc["server"].ToString() == "185.134.75.47" ||
            //    odbc["server"].ToString() == "192.168.20.47" ||
            //    odbc["server"].ToString() == "10.5.10.33")
            //    connectionStringTemplate = "Server={server};Port=5431;Database={database};User Id={username};Password={password}";
            var npgsqlConnectionString = "";

            if (odbc["port"] == null)
            {
                npgsqlConnectionString = connectionStringTemplate.Replace("{server}", odbc["server"].ToString())
                                         .Replace("{database}", odbc["database"].ToString()).Replace("{username}", odbc["uid"].ToString())
                                         .Replace("{password}", odbc["pwd"].ToString())
                                         .Replace("{port}", "5432");
            }
            else
            {
                npgsqlConnectionString = connectionStringTemplate.Replace("{server}", odbc["server"].ToString())
                                         .Replace("{database}", odbc["database"].ToString()).Replace("{username}", odbc["uid"].ToString())
                                         .Replace("{password}", odbc["pwd"].ToString())
                                         .Replace("{port}", odbc["port"].ToString());
            }

            //var npgsqlConnectionString = connectionStringTemplate.Replace("{server}", odbc["server"].ToString())
            //    .Replace("{database}", odbc["database"].ToString()).Replace("{username}", odbc["uid"].ToString())
            //    .Replace("{password}", odbc["pwd"].ToString());

            Console.WriteLine("npgsqlConnectionString=" + npgsqlConnectionString);
            _connection = SqlConnectionHelper.OpenNpgsqlConnection(npgsqlConnectionString);

            return(this);
        }
Пример #6
0
        public override ISaver Create(string connectionString, CdmVersions cdmVersion, string sourceSchema, string destinationSchema)
        {
            CdmVersion        = cdmVersion;
            SourceSchema      = sourceSchema;
            DestinationSchema = destinationSchema;

            var odbcConnection = new OdbcConnectionStringBuilder(connectionString);
            var sqlConnection  = new MySqlConnectionStringBuilder
            {
                Server   = odbcConnection["server"].ToString(),
                UserID   = odbcConnection["user"].ToString(),
                Password = odbcConnection["password"].ToString(),
                Database = odbcConnection["database"].ToString(),
                DefaultCommandTimeout = 9999,
                ConnectionTimeout     = 9999,
                AllowLoadLocalInfile  = true
            };

            _connection  = SqlConnectionHelper.OpenMySqlConnection(sqlConnection.ConnectionString);
            _transaction = _connection.BeginTransaction();

            return(this);
        }
Пример #7
0
        public override ISaver Create(string connectionString, CdmVersions cdmVersion, string sourceSchema, string destinationSchema)
        {
            CdmVersion        = cdmVersion;
            SourceSchema      = sourceSchema;
            DestinationSchema = destinationSchema;

            var odbcConnection = new OdbcConnectionStringBuilder(connectionString);
            var sqlConnection  = new SqlConnectionStringBuilder
            {
                ["Data Source"]     = odbcConnection["server"],
                ["Initial Catalog"] = odbcConnection["database"],
                ["User Id"]         = odbcConnection["uid"],
                ["Password"]        = odbcConnection["pwd"]
            };

            _connection  = SqlConnectionHelper.OpenMssqlConnection(sqlConnection.ConnectionString);
            _transaction = _connection.BeginTransaction();
            _bulkCopy    = new SqlBulkCopy(_connection, SqlBulkCopyOptions.TableLock, _transaction)
            {
                BulkCopyTimeout = 600
            };

            return(this);
        }
Пример #8
0
 public CdmVersionAttribute(CdmVersions value)
 {
     this.Value = value;
 }