public SitecoreAndUnicornLog(ILog sitecoreLog, Unicorn.Logging.ILogger unicornLogger) { if (sitecoreLog == null) { throw new ArgumentNullException(nameof(sitecoreLog)); } if (unicornLogger == null) { throw new ArgumentNullException(nameof(unicornLogger)); } _sitecoreLog = sitecoreLog; _unicornLogger = unicornLogger; }
protected virtual BulkLoadContext CreateBulkLoadContext(BulkLoader bulkLoader, string databaseName, IConfiguration[] configurations, DataBlasterParameters parameters, ILogger logger) { var context = bulkLoader.NewBulkLoadContext(databaseName); context.Log = new SitecoreAndUnicornLog(LoggerFactory.GetLogger(GetType()), logger); context.AllowTemplateChanges = true; context.StageDataWithoutProcessing = parameters.StageDataWithoutProcessing; // Use the shotgun, removing items one by one is too slow for full deserialize. context.RemoveItemsFromCaches = false; context.UpdateHistory = !SkipHistoryEngine; context.UpdatePublishQueue = !SkipPublishQueue; context.UpdateLinkDatabase = !SkipLinkDatabase && configurations.Any(x => x.Resolve <ISyncConfiguration>().UpdateLinkDatabase); context.UpdateIndexes = !SkipIndexes && configurations.Any(x => x.Resolve <ISyncConfiguration>().UpdateSearchIndex); return(context); }
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); } } } }