-
|
Hello! I’ve been experimenting with the uSyncService, which exposes an Import method, but I’m unsure how to handle or provide certain properties, such as ClientId. Here's what I'm currently trying: public IActionResult Import()
{
uSyncOptions options = new uSyncOptions
{
Force = false,
Set = "Default",
ClientId = ""
};
var hubClient = new HubClientService(_hubContext, options.ClientId);
var dashbracoPath = Path.Combine(Directory.GetCurrentDirectory(), "uSync.Dashbraco");
var imports = _uSyncService.Import(dashbracoPath, options.Force, new SyncHandlerOptions()
{
Group = options.Group,
Action = HandlerActions.Import,
Set = "Default"
},
callbacks: hubClient.Callbacks());
return Ok();
}I've found a few older forum threads that discuss this topic, but they date back a few years: Thanks in advance ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi, yes this has been encapsulated a bit in v15, but you can see from the public async Task<IEnumerable<uSyncAction>> StartupImportAsync(string[] folders, bool force, SyncHandlerOptions handlerOptions, uSyncCallbacks? callbacks = null)
{
handlerOptions ??= new SyncHandlerOptions();
handlerOptions.Action = HandlerActions.Import;
var handlers = _handlerFactory.GetValidHandlers(handlerOptions);
var changes = await ImportAsync(folders, force, handlers, handlerOptions, callbacks);
// on first boot, we refresh the snapshot cache if we have imported any content
// just because it seems not to refresh as part of the boot.
if (changes.Any(x => x.Change > ChangeType.NoChange && x.ItemType == "IContent"))
_distributedCache.RefreshAllPublishedSnapshot();
return changes;
}you don't need to start the hub or worry about callbacks, if they are null, then uSync will continue to do it's thing, it just doesn't send anything to signalr to show progress (and if you are doing it in code, you probibly don't need that. so if you change the folders then this will work. (for v13 the code is similar just not async. |
Beta Was this translation helpful? Give feedback.
Hi,
yes this has been encapsulated a bit in v15, but you can see from the
StartupImportAsyncmethod.