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);
                    }
                }
            }
        }
Пример #2
0
        private void ItemCreator(PullItemModel args, CancellationToken cancellationToken)
        {
            var bulkLoader = new BulkLoader();

            try
            {
                var context = bulkLoader.NewBulkLoadContext("master");
                bulkLoader.LoadItems(context, GetAllItemsToCreate(context, cancellationToken));
                _checksumManager.RegenerateChecksum();
            }
            catch (OperationCanceledException e)
            {
                Log.Warn("Content migration operation was cancelled", e, this);
                Status.Cancelled = true;
            }
            catch (Exception e)
            {
                Log.Error("Catastrophic error when creating items", e, this);
            }
        }