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()));
        }
        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()));
        }
        public IEnumerable <SyncHandlerView> GetActionHandlers([FromQuery] HandlerActions action, uSyncOptions options)
        {
            var handlerGroup = string.IsNullOrWhiteSpace(options.Group)
                ? uSyncConfig.Settings.UIEnabledGroups
                : options.Group;

            var handlerSet = string.IsNullOrWhiteSpace(options.Set)
                ? uSyncConfig.Settings.DefaultSet
                : options.Set;

            return(handlerFactory.GetValidHandlers(new SyncHandlerOptions
            {
                Group = handlerGroup,
                Action = action,
                Set = handlerSet
            }).Select(x => new SyncHandlerView
            {
                Enabled = x.Handler.Enabled,
                Alias = x.Handler.Alias,
                Name = x.Handler.Name,
                Icon = x.Handler.Icon,
                Group = x.Handler.Group,
                Set = handlerSet
            }));
        }
Пример #4
0
        public uSyncWarningMessage GetSyncWarnings([FromQuery] HandlerActions action, uSyncOptions options)
        {
            var handlers = handlerFactory.GetValidHandlers(new SyncHandlerOptions
            {
                Group  = options.Group,
                Action = action
            });

            var message = new uSyncWarningMessage();

            if (this.uSyncConfig.Settings.ShowVersionCheckWarning && !uSyncService.CheckVersionFile(this.uSyncConfig.GetRootFolder()))
            {
                message.Type    = "info";
                message.Message = textService.Localize("usync", "oldformat");
                return(message);
            }

            var createOnly = handlers
                             .Where(h => h.Settings.GetSetting(Core.uSyncConstants.DefaultSettings.CreateOnly, false))
                             .Select(x => x.Handler.Alias)
                             .ToList();

            if (createOnly.Count > 0)
            {
                message.Type    = "warning";
                message.Message = textService.Localize("usync", "createWarning", new [] { string.Join(",", createOnly) });
                return(message);
            }


            return(message);
        }