コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        public IEnumerable <uSyncAction> Export(uSyncOptions options)
        {
            var hubClient = new HubClientService(options.ClientId);

            if (options.Clean)
            {
                uSyncService.CleanExportFolder(settings.RootFolder);
            }

            return(uSyncService.Export(settings.RootFolder, new SyncHandlerOptions()
            {
                Group = options.Group
            },
                                       hubClient.Callbacks()));
        }
コード例 #3
0
        public IEnumerable <uSyncAction> Export(uSyncOptions options)
        {
            var hubClient = new HubClientService(hubContext, options.ClientId);

            if (options.Clean)
            {
                uSyncService.CleanExportFolder(uSyncConfig.GetRootFolder());
            }

            return(uSyncService.Export(uSyncConfig.GetRootFolder(), new SyncHandlerOptions()
            {
                Group = options.Group
            },
                                       hubClient.Callbacks()));
        }