Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions uSync.BackOffice/Services/ISyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.IO;
using System.Threading.Tasks;

using Umbraco.Cms.Core;

using uSync.BackOffice.Configuration;
using uSync.BackOffice.Models;
using uSync.BackOffice.SyncHandlers.Interfaces;
Expand Down Expand Up @@ -168,4 +170,12 @@ public interface ISyncService
/// merge the given folders in single 'production' files for each handler.
/// </summary>
Task<int> MergeExportFolder(string[] paths, IEnumerable<HandlerConfigPair> handlers);
Comment thread
KevinJump marked this conversation as resolved.

/// <summary>
/// export a single item to the specified folders using the supplied handler options.
/// </summary>
/// <param name="udi">The unique document identifier of the item to export.</param>
/// <param name="folders">The target folders to export the item into.</param>
/// <param name="options">The handler options to use during export.</param>
Task<IEnumerable<uSyncAction>> ExportSingleItem(Udi udi, string[] folders, SyncHandlerOptions options);
}
15 changes: 15 additions & 0 deletions uSync.BackOffice/Services/SyncService_Single.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using System.Xml.Linq;

using Umbraco.Cms.Core;
using Umbraco.Extensions;

using uSync.BackOffice.Extensions;
Expand Down Expand Up @@ -360,4 +361,18 @@ public async Task<IList<OrderedNodeInfo>> LoadOrderedNodesAsync(ISyncHandler han
/// </remarks>
private static int CalculateProgress(int value, int total, int min, int max)
=> (int)(min + (((float)value / total) * (max - min)));


/// <summary>
/// export a single item via the correct handler.
/// </summary>
/// <remarks>
/// this method isn't used directly in the code, but is here as a helper .
/// </remarks>
Comment thread
KevinJump marked this conversation as resolved.
public async Task<IEnumerable<uSyncAction>> ExportSingleItem(Udi udi, string[] folders, SyncHandlerOptions options)
{
var handler = _handlerFactory.GetValidHandlerByEntityType(udi.EntityType, options);
if (handler == null) return [uSyncAction.Fail("Single", "Unknown", udi.EntityType, ChangeType.Fail, $"Could not find handler for entity type '{udi.EntityType}'", new KeyNotFoundException(udi.EntityType))];
return await handler.Handler.ExportAsync(udi, folders, handler.Settings);
}
}
Loading