/// <inheritdoc/> protected override void Migrate() { // first boot migration. if (!_uSyncConfig.Settings.ImportOnFirstBoot) { return; } var sw = Stopwatch.StartNew(); var changes = 0; _logger.LogInformation("Import on Firstboot Set - will import {group} handler groups", _uSyncConfig.Settings.FirstBootGroup); // if config service is set to import on first boot then this // will let uSync do a first boot import // not sure about context on migrations so will need to test // or maybe we fire something into a notification (or use a static) using (var reference = _umbracoContextFactory.EnsureUmbracoContext()) { var results = _uSyncService.Import(_uSyncConfig.GetRootFolder(), false, new SyncHandlerOptions { Group = _uSyncConfig.Settings.FirstBootGroup }); changes = results.CountChanges(); }; sw.Stop(); _logger.LogInformation("uSync First boot complete {changes} changes in ({time}ms}", changes, sw.ElapsedMilliseconds); }
public IEnumerable <uSyncAction> Import(uSyncOptions options) { var hubClient = new HubClientService(options.ClientId); return(uSyncService.Import(settings.RootFolder, options.Force, new SyncHandlerOptions() { Group = options.Group }, callbacks: hubClient.Callbacks())); }
public IEnumerable <uSyncAction> Import(uSyncOptions options) { var hubClient = new HubClientService(hubContext, options.ClientId); return(uSyncService.Import(uSyncConfig.GetRootFolder(), options.Force, new SyncHandlerOptions() { Group = options.Group }, callbacks: hubClient.Callbacks())); }
/// <summary> /// Initialize uSync elements (run start up import etc). /// </summary> private void InituSync() { var sw = Stopwatch.StartNew(); try { using (var reference = _umbracoContextFactory.EnsureUmbracoContext()) { if (IsExportAtStatupEnabled() || (IsExportOnSaveOn() && !_syncFileService.RootExists(_uSyncConfig.GetRootFolder()))) { var options = new SyncHandlerOptions { Group = _uSyncConfig.Settings.ExportOnSave }; _logger.LogInformation("uSync: Running export at startup"); _uSyncService.Export(_uSyncConfig.GetRootFolder(), options); } if (IsImportAtStatupEnabled()) { _logger.LogInformation("uSync: Running Import at startup {group}", _uSyncConfig.Settings.ImportAtStartup); if (!HasStopFile(_uSyncConfig.GetRootFolder())) { _uSyncService.Import(_uSyncConfig.GetRootFolder(), false, new SyncHandlerOptions { Group = _uSyncConfig.Settings.ImportAtStartup }); ProcessOnceFile(_uSyncConfig.GetRootFolder()); } else { _logger.LogInformation("Startup Import blocked by usync.stop file"); } } } } catch (Exception ex) { _logger.LogWarning(ex, "uSync: Error during startup {message}", ex.Message); } finally { sw.Stop(); _logger.LogInformation("uSync: Startup Complete {elapsed}ms", sw.ElapsedMilliseconds); } }