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 #2
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");
             }
        }