/// <summary> /// Report the changes for a folder /// </summary> /// <param name="folder">Folder to run the report for</param> /// <param name="handlers">List of SyncHandlers to use for the report</param> /// <param name="callbacks">Callback functions to keep UI uptodate</param> /// <returns>List of actions detailing what would and wouldn't change</returns> public IEnumerable <uSyncAction> Report(string folder, IEnumerable <ExtendedHandlerConfigPair> handlers, uSyncCallbacks callbacks) { var sw = Stopwatch.StartNew(); fireBulkStarting(ReportStarting); logger.Debug <uSyncService>("Reporting For [{0}]", string.Join(",", handlers.Select(x => x.Handler.Name))); var actions = new List <uSyncAction>(); var summary = new SyncProgressSummary(handlers.Select(x => x.Handler), "Reporting", handlers.Count()); if (GlobalSettings.DebugMode && settings.ReportDebug) { // debug - full export into a dated folder. summary.UpdateMessage("Debug: Creating Extract in Tracker folder"); logger.Warn <uSyncService>("Running Report Debug - this can be a slow process, don't enable unless you need it"); callbacks?.Callback?.Invoke(summary); this.Export($"~/uSync/Tracker/{DateTime.Now.ToString("yyyyMMdd_HHmmss")}/", handlers, callbacks); } foreach (var configuredHandler in handlers) { var handler = configuredHandler.Handler; var handlerSettings = configuredHandler.Settings; summary.Increment(); summary.UpdateHandler(handler.Name, HandlerStatus.Processing, $"Reporting {handler.Name}", 0); callbacks?.Callback?.Invoke(summary); var handlerActions = handler.Report($"{folder}/{handler.DefaultFolder}", handlerSettings, callbacks?.Update); actions.AddRange(handlerActions); summary.UpdateHandler(handler.Name, HandlerStatus.Complete, handlerActions.CountChanges(), handlerActions.ContainsErrors()); } summary.UpdateMessage("Report Complete"); callbacks?.Callback?.Invoke(summary); fireBulkComplete(ReportComplete, actions); sw.Stop(); logger.Info <uSyncService>("uSync Report: {handlerCount} handlers, processed {itemCount} items, {changeCount} changes in {ElapsedMilliseconds}ms", handlers.Count(), actions.Count, actions.CountChanges(), sw.ElapsedMilliseconds); callbacks?.Update?.Invoke($"Processed {actions.Count} items in {sw.ElapsedMilliseconds}ms", 1, 1); return(actions); }
/// <summary> /// Export items from umbraco into a given folder /// </summary> /// <param name="folder">folder to place items</param> /// <param name="handlerAliases">List of handlers to use for export</param> /// <param name="callbacks">callback functions to update the UI</param> /// <returns>List of actions detailing what was exported</returns> public IEnumerable <uSyncAction> Export(string folder, IEnumerable <ExtendedHandlerConfigPair> handlers, uSyncCallbacks callbacks) { var sw = Stopwatch.StartNew(); fireBulkStarting(ExportStarting); var actions = new List <uSyncAction>(); var summary = new SyncProgressSummary(handlers.Select(x => x.Handler), "Exporting", handlers.Count()); foreach (var configuredHandler in handlers) { var handler = configuredHandler.Handler; summary.Increment(); summary.UpdateHandler( handler.Name, HandlerStatus.Processing, $"Exporting {handler.Name}", 0); callbacks?.Callback?.Invoke(summary); var handlerActions = handler.ExportAll($"{folder}/{handler.DefaultFolder}", configuredHandler.Settings, callbacks?.Update); actions.AddRange(handlerActions); summary.UpdateHandler(handler.Name, HandlerStatus.Complete, handlerActions.CountChanges(), handlerActions.ContainsErrors()); } summary.UpdateMessage("Export Completed"); callbacks?.Callback?.Invoke(summary); fireBulkComplete(ExportComplete, actions); sw.Stop(); logger.Info <uSyncService>("uSync Export: {handlerCount} handlers, processed {itemCount} items, {changeCount} changes in {ElapsedMilliseconds}ms", handlers.Count(), actions.Count, actions.CountChanges(), sw.ElapsedMilliseconds); callbacks?.Update?.Invoke($"Processed {actions.Count} items in {sw.ElapsedMilliseconds}ms", 1, 1); return(actions); }