Beispiel #1
0
        private void SaveEntityLookup(bool saveToDb)
        {
            if (saveToDb)
            {
                using (var c = SqlConnectionHelper.OpenConnection(Settings.Current.Building.DestinationConnectionString))
                    using (var bulkCopy = new SqlBulkCopy(c, SqlBulkCopyOptions.TableLock, null))
                    {
                        if (locationConcepts != null)
                        {
                            bulkCopy.Write(new LocationDataReader(locationConcepts.Lookup.Values.ToList()), "LOCATION");
                        }

                        if (organizationConcepts != null)
                        {
                            bulkCopy.Write(new OrganizationDataReader(organizationConcepts.Lookup.Values.ToList()), "ORGANIZATION");
                        }

                        if (careSiteConcepts != null)
                        {
                            bulkCopy.Write(new CareSiteDataReader(careSiteConcepts.Lookup.Values.ToList()), "CARE_SITE");
                        }

                        if (providerConcepts != null)
                        {
                            bulkCopy.Write(new ProviderDataReader(providerConcepts.Lookup.Values.ToList()), "PROVIDER");
                        }

                        bulkCopy.Close();
                    }
            }
            else
            {
                var folder = Settings.Current.ResultFolder;
                if (locationConcepts != null)
                {
                    SaveToFile(folder, new LocationDataReader(locationConcepts.Lookup.Values.ToList()), "LOCATION");
                }

                if (organizationConcepts != null)
                {
                    SaveToFile(folder, new OrganizationDataReader(organizationConcepts.Lookup.Values.ToList()),
                               "ORGANIZATION");
                }

                if (careSiteConcepts != null)
                {
                    SaveToFile(folder, new CareSiteDataReader(careSiteConcepts.Lookup.Values.ToList()), "CARE_SITE");
                }

                if (providerConcepts != null)
                {
                    SaveToFile(folder, new ProviderDataReader(providerConcepts.Lookup.Values.ToList()), "PROVIDER");
                }
            }
        }
Beispiel #2
0
        public override void Write(int?chunkId, int?subChunkId, System.Data.IDataReader reader, string tableName)
        {
            if (tableName.ToLower().StartsWith("_chunks"))
            {
                tableName = Settings.Current.Building.SourceSchemaName + "." + tableName;
            }
            else
            {
                tableName = Settings.Current.Building.DestinationSchemaName + "." + tableName;
            }

            bulkCopy.Write(reader, tableName);
        }
Beispiel #3
0
        public void CreateChunks()
        {
            dbKeyOffset.Create(Settings.Current.Building.Id.Value);
            dbChunk.ClearChunks(Settings.Current.Building.Id.Value);
            dbSource.CreateChunkTable();
            foreach (var chunk in GetPersonKeys(Settings.Current.Builder.BatchSize))
            {
                var chunkId = dbChunk.AddChunk(Settings.Current.Building.Id.Value);

                using (var bulkCopy = new SqlBulkCopy(Settings.Current.Building.SourceConnectionString))
                {
                    bulkCopy.Write(
                        new ChunkDataReader(
                            chunk.Select(
                                c => new ChunkRecord {
                        Id = chunkId, PersonId = Convert.ToInt64(c.Key), PersonSource = c.Value
                    })
                            .ToList()),
                        "_chunks");
                    bulkCopy.Close();
                }
            }
            dbSource.CreateIndexesChunkTable();
        }
Beispiel #4
0
 public override void Write(int?chunkId, int?subChunkId, System.Data.IDataReader reader, string tableName)
 {
     bulkCopy.Write(reader, tableName);
 }