protected virtual void LoadItems(IConfiguration[] configurations, DataBlasterParameters parameters, ILogger logger)
        {
            var databaseNames = configurations
                                .SelectMany(c => c.Resolve <PredicateRootPathResolver>().GetRootPaths().Select(rp => rp.DatabaseName))
                                .Distinct();

            foreach (var databaseName in databaseNames)
            {
                logger.Info($"Syncing database '{databaseName}'...");

                var context   = CreateBulkLoadContext(BulkLoader, databaseName, configurations, parameters, logger);
                var bulkItems = ItemExtractor.ExtractBulkItems(context, configurations, databaseName);
                BulkLoader.LoadItems(context, bulkItems);

                if (context.AnyStageFailed)
                {
                    throw new Exception($"Stage failed during bulkload of database '{databaseName}': {context.FailureMessage}");
                }

                // Support publishing after sync.
                if (!IsUnicornPublishEnabled && !databaseName.Equals("core", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var itemChange in context.ItemChanges)
                    {
                        ManualPublishQueueHandler.AddItemToPublish(itemChange.ItemId);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public UnicornDataBlaster(BulkLoader bulkLoader = null, ItemExtractor itemExtractor = null)
 {
     BulkLoader    = bulkLoader ?? new BulkLoader();
     ItemExtractor = itemExtractor ?? new ItemExtractor();
 }
Exemplo n.º 3
0
 public UnicornDataBlaster(ItemExtractor itemExtractor)
     : this(new BulkLoader(), itemExtractor)
 {
 }
Exemplo n.º 4
0
 public UnicornDataBlaster(BulkLoader bulkLoader, ItemExtractor itemExtractor)
 {
     BulkLoader    = bulkLoader;
     ItemExtractor = itemExtractor;
 }