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
            }));
        }
Exemple #2
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);
        }
Exemple #3
0
 /// <summary>
 /// Is the handler valid for the given action
 /// </summary>
 public static bool IsValidAction(this HandlerConfigPair handlerAndConfig, HandlerActions action)
 {
     if (action.IsValidAction(handlerAndConfig.Settings.Actions))
     {
         return(true);
     }
     return(false);
 }
 public IEnumerable <SyncHandlerView> GetActionHandlers(HandlerActions action, uSyncOptions options)
 => handlerFactory.GetValidHandlers(new SyncHandlerOptions
 {
     Group  = options.Group,
     Action = action
 }).Select(x => new SyncHandlerView
 {
     Enabled = x.Handler.Enabled,
     Alias   = x.Handler.Alias,
     Name    = x.Handler.Name,
     Icon    = x.Handler.Icon,
     Group   = x.Handler.Group
 });
        /// <summary>
        ///  Complete a bulk run, fire the event so other things know we have done it.
        /// </summary>
        public void FinishBulkProcess(HandlerActions action, IEnumerable <uSyncAction> actions)
        {
            switch (action)
            {
            case HandlerActions.Export:
                fireBulkComplete(ExportComplete, actions);
                break;

            case HandlerActions.Import:
                fireBulkComplete(ImportComplete, actions);
                break;

            case HandlerActions.Report:
                fireBulkComplete(ReportComplete, actions);
                break;
            }
        }
        /// <summary>
        ///  Complete a bulk run, fire the event so other things know we have done it.
        /// </summary>
        public void FinishBulkProcess(HandlerActions action, IEnumerable <uSyncAction> actions)
        {
            switch (action)
            {
            case HandlerActions.Export:
                WriteVersionFile(_uSyncConfig.GetRootFolder());
                _mutexService.FireBulkComplete(new uSyncExportCompletedNotification(actions));
                break;

            case HandlerActions.Import:
                _mutexService.FireBulkComplete(new uSyncImportCompletedNotification(actions));
                break;

            case HandlerActions.Report:
                _mutexService.FireBulkComplete(new uSyncReportCompletedNotification(actions));
                break;
            }
        }
        /// <summary>
        ///  Start a bulk run, fires events, and for exports writes the version file.
        /// </summary>
        public void StartBulkProcess(HandlerActions action)
        {
            switch (action)
            {
            case HandlerActions.Export:
                WriteVersionFile(settings.RootFolder);
                fireBulkStarting(ExportStarting);
                break;

            case HandlerActions.Import:
                fireBulkStarting(ImportStarting);
                break;

            case HandlerActions.Report:
                fireBulkStarting(ReportStarting);
                break;
            }
        }
        /// <summary>
        ///  Start a bulk run, fires events, and for exports writes the version file.
        /// </summary>
        public void StartBulkProcess(HandlerActions action)
        {
            switch (action)
            {
            case HandlerActions.Export:
                _mutexService.FireBulkStarting(new uSyncExportStartingNotification());
                break;

            case HandlerActions.Import:
                // cleans any caches we might have set.
                _appCache.ClearByKey("usync_");

                _mutexService.FireBulkStarting(new uSyncImportStartingNotification());
                break;

            case HandlerActions.Report:
                _mutexService.FireBulkStarting(new uSyncReportStartingNotification());
                break;
            }
        }
 private bool IsValidAction(HandlerActions requestedAction, string[] actions)
 => requestedAction == HandlerActions.None ||
 actions.InvariantContains("all") ||
 actions.InvariantContains(requestedAction.ToString());
Exemple #10
0
 /// <summary>
 /// Construct options with set and handler action set.
 /// </summary>
 public SyncHandlerOptions(string setName, HandlerActions action)
     : this()
 {
     this.Set    = setName;
     this.Action = action;
 }
Exemple #11
0
 /// <summary>
 ///  is this config pair valid for the settings we have for it.
 /// </summary>
 private bool IsValidHandler(HandlerConfigPair handlerConfigPair, HandlerActions actions, string group)
 => handlerConfigPair.IsEnabled() && handlerConfigPair.IsValidAction(actions) && handlerConfigPair.IsValidGroup(group);
 public void FinishProcess([FromQuery] HandlerActions action, IEnumerable <uSyncAction> actions)
 => uSyncService.FinishBulkProcess(action, actions);
 public void StartProcess([FromQuery] HandlerActions action)
 => uSyncService.StartBulkProcess(action);
 /// <summary>
 ///  checks to see if the reuqested action is valid for the configured list of actions.
 /// </summary>
 public static bool IsValidAction(this HandlerActions requestedAction, IEnumerable <string> actions)
 => requestedAction == HandlerActions.None ||
 actions.Count() == 0 ||
 actions.InvariantContains("all") ||
 actions.InvariantContains(requestedAction.ToString());