Example #1
0
 private static string ActionInfo(ActionView action)
 {
     var sb = new StringBuilder();
     sb.AppendLine(action.Title);
     sb.AppendLine();
     sb.Append("ID: ");
     sb.AppendLine(action.CommandId);
     sb.Append("Reassure Before Execution: ");
     sb.AppendLine(action.Reassure ? "yes" : "no");
     sb.Append("Create Log: ");
     sb.AppendLine(action.Logs != null ? "yes" : "no");
     sb.Append("Keep Window Open: ");
     sb.AppendLine(action.KeepOpen ? "yes" : "no");
     sb.Append("Always Close Window: ");
     sb.AppendLine(!action.KeepOpen && action.AlwaysClose ? "yes" : "no");
     sb.Append("Run in Background: ");
     sb.AppendLine(action.Visible ? "no" : "yes");
     sb.Append("Command: ");
     sb.AppendLine(action.Command);
     if (!string.IsNullOrWhiteSpace(action.Arguments))
     {
         sb.Append("Arguments: ");
         sb.AppendLine(action.Arguments);
     }
     sb.Append("Working Directory: ");
     sb.AppendLine(action.WorkingDirectory);
     return sb.ToString();
 }
Example #2
0
 private static bool Reassure(ActionView action)
 {
     var result = MessageBox.Show(
         "Are you sure you want to execute the following logged?\n\n" + ActionInfo(action),
         "Execute Action", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
     return result == MessageBoxResult.OK;
 }
Example #3
0
 public static async Task ExecuteAction(ActionView action)
 {
     if (!action.Reassure || Reassure(action))
     {
         await action.ExecuteAsync();
         DashOpsCommands.ShowLastLog.RaiseCanExecuteChanged();
         CommandManager.InvalidateRequerySuggested();
     }
 }
Example #4
0
        private ActionView ActionViewFromCommandAction(CommandAction action)
        {
            var actionView = new ActionView
            {
                Command          = ExpandEnv(action.Command),
                Arguments        = FormatArguments(action.Arguments),
                WorkingDirectory = BuildAbsolutePath(action.WorkingDirectory),
                ExitCodes        = action.ExitCodes != null && action.ExitCodes.Length > 0
                    ? action.ExitCodes
                    : new[] { 0 },
                Title       = action.Description,
                Reassure    = action.Reassure,
                Visible     = !action.Background,
                Logs        = ExpandEnv(action.Logs),
                NoLogs      = action.NoLogs,
                KeepOpen    = action.KeepOpen,
                AlwaysClose = action.AlwaysClose,
                Tags        = action.Tags ?? Array.Empty <string>(),
                Facettes    = action.Facettes != null
                    ? new Dictionary <string, string>(action.Facettes)
                    : new Dictionary <string, string>(),
            };

            if (!string.IsNullOrWhiteSpace(action.Verb))
            {
                actionView.Facettes[nameof(CommandAction.Verb)] = action.Verb;
            }
            if (!string.IsNullOrWhiteSpace(action.Service))
            {
                actionView.Facettes[nameof(CommandAction.Service)] = action.Service;
            }
            if (!string.IsNullOrWhiteSpace(action.Host))
            {
                actionView.Facettes[nameof(CommandAction.Host)] = action.Host;
            }
            return(actionView);
        }
Example #5
0
 public static void ShowActionInfo(ActionView action)
 {
     MessageBox.Show(ActionInfo(action), "Action Info",
         MessageBoxButton.OK, MessageBoxImage.Information);
 }