public void Job_Execute_ReturnsEmpty() { var command = new JobCommand(_console, LoggerMock.GetLogger <JobCommand>().Object); var resultMessage = command.Execute(); Assert.Equal("", resultMessage); }
public bool CanRunCommand(JobCommand command) { return(command switch { JobCommand.Remove => Finished, JobCommand.Cancel => canCancel && !Finished && jobsClient != null, _ => throw new ArgumentOutOfRangeException(nameof(command), command, "Invalid command!"), });
/// <summary> /// Get the specified job command's execute method. /// </summary> /// <exception cref="UnexpectedException">When job command's execute method not found.</exception> protected virtual ExecuteJobCommand GetExecuteMethod(JobCommand jobCommand) { if (!methods.TryGetValue(jobCommand, out ExecuteJobCommand method)) { throw new UnexpectedException($"The operation is not found exectuer with type {jobCommand}."); } return(method); }
private void AddJob(JobCommand command, string packageName, IConstraint constraint = null, bool @fixed = false) { jobs.AddLast(new Job { Command = command, PackageName = packageName.ToLower(), Constraint = constraint, Fixed = @fixed, }); }
public override async Task <JobResult> EjecutarJob(JobCommand command) { await NofificarProgreso(1, "Se hizo tarea 1"); await NofificarProgreso(2, "Se hizo tarea 2"); await NofificarProgreso(3, "Se hizo tarea 3"); await NofificarProgreso(4, "Se hizo tarea 4"); await NofificarProgreso(5, "Se hizo tarea 5"); return(new JobResult() { OutputJob = "Se termino pé" }); }
public bool CanRunCommand(JobCommand command) { switch (command) { case JobCommand.Remove: return(Finished); case JobCommand.Cancel: return(canCancel && !Finished && jobsClient != null); default: throw new ArgumentOutOfRangeException(nameof(command), command, "Invalid command!"); } }
private void btnEditCommand_Click(object sender, EventArgs e) { if (lsvCommands.FocusedItem == null) { return; } var cmd = (JobCommand)lsvCommands.FocusedItem.Tag; var rec = (JobWithFile)lsvJobs.FocusedItem.Tag; Job job = Job.LoadFromFile(rec.FullFile); JobConnection jobconn = new JobConnection(rec.FullFile); JobCommand cmd2 = job.Root.FindCommand(cmd.GroupId); cmd2.Edit(jobconn); }
private bool CheckGenerator(JobCommand cmd) { var gen = cmd as DbCreatorGeneratorCommand; try { gen.Check(); } catch (Exception err) { Errors.Report(err); return(false); } return(true); }
public virtual async Task Execute(JobCommand command) { JobId = command.JobId; await NofificarInicio(); try { var result = await EjecutarJob(command);//.ConfigureAwait(false); await NofificarFin(result); //return result; } catch (Exception ex) { await NofificarError(ex.Message, ex.StackTrace); throw; } }
public override IEnumerable<IPlugin> GetRunablePlugins( JobCommand command ) { if (command != JobCommand.Execute && command != JobCommand.Commit && command != JobCommand.Rollback) yield break; IEnumerable<IPluginTrackable> steps = command == JobCommand.Rollback ? PluginTrackables.GetReverseEnumerator : PluginTrackables; //Reverse order for Rollback. foreach (IStep step in steps) { bool didEnter = false; foreach (IPlugin plugin in step.GetRunablePlugins(command)) { didEnter = true; yield return plugin; } if (didEnter || step.HasRunningPlugins) yield break; } }
public override IEnumerable<IPlugin> GetRunablePlugins(JobCommand command) { if (command != JobCommand.Execute && command != JobCommand.Commit && command != JobCommand.Rollback) yield break; foreach (IStepContent pluginTrackable in PluginTrackables) { if (pluginTrackable is IPlugin) { if (IsPluginRunnable(command, (IPlugin) pluginTrackable)) yield return (IPlugin) pluginTrackable; } else if (pluginTrackable is IFlow) { foreach (IPlugin plugin in ((IFlow) pluginTrackable).GetRunablePlugins(command)) { yield return plugin; } } else throw new NotImplementedException("Not implemented for " + pluginTrackable.GetType().FullName); } }
public async Task RunCommand(JobCommand command, CancellationToken cancellationToken) { switch (command) { case JobCommand.Remove: onRemove(); break; case JobCommand.Cancel: try { await jobsClient.Cancel(job, cancellationToken).ConfigureAwait(false); //still has to finish cancelling and propagate back to us } catch (InsufficientPermissionsException) { canCancel = false; } break; default: throw new ArgumentOutOfRangeException(nameof(command), command, "Invalid command!"); } }
public QueueCommandHandler(JobCommand jobCommand) { Command = jobCommand; }
public abstract IEnumerable<IPlugin> GetRunablePlugins(JobCommand command);
private static bool IsPluginRunnable(JobCommand command, IPlugin plugin) { switch (command) { case JobCommand.Execute: return plugin.Status == PluginStatus.Initialized; case JobCommand.Commit: return plugin.Status == PluginStatus.Executed; case JobCommand.Rollback: return plugin.Status == PluginStatus.Executed || plugin.Status == PluginStatus.ExecuteFailed; default: return false; } }
public abstract Task<JobResult> EjecutarJob(JobCommand command);
public DataSynInfoReportProcessor(DataSynInfoReportConfiguration config, JobCommand cmd) : base(config, cmd) { }
public SolverResult(JobCommand command, IPackage from, IPackage to) { Command = command; From = from; To = to; }
public SolverResult(JobCommand command, IPackage package) { Command = command; To = package; }
public override IJobReportProcessor CreateProcessor(JobCommand cmd) { return(new DataSynSqlReportProcessor(this, cmd)); }
public DataSynReportEnv(JobCommand cmd) : base(cmd) { }
/// <summary> /// New job. /// </summary> /// <remarks> /// Keep seconds for UI-less jobs: 0 ~ hidden mode, in this case a job creates UI on errors, as it is not attended. /// Other UI-less jobs are completely owned creators. /// </remarks> internal Job(JobCommand command, object parameters, string name, bool ui, int keepSeconds) { JobCommand = command; Parameters = parameters; Name = name; KeepSeconds = keepSeconds; // create/open runspace //! *) Do not catch, if we fail, we fail and there is nothing to repair yet (not open) //! *) Use existing configuration, it is faster! Most of *-Far* cmdlets should not be used, //! but some of them can be used, e.g. Update-FarDescription; also we want to use ETS types, //! e.g. FarDescription property. if (ui) { JobUI = new JobUI(); Runspace = RunspaceFactory.CreateRunspace(new FarHost(JobUI), Runspace.DefaultRunspace.InitialSessionState); } else { //! DefaultHost is created internally. Perhaps it is reasonable to live with it, not with a custom host. Runspace = RunspaceFactory.CreateRunspace(Runspace.DefaultRunspace.InitialSessionState); } Runspace.Open(); // new shell with the command PowerShell = PowerShell.Create(); PowerShell.Runspace = Runspace; JobCommand.Add(PowerShell); // add command parameters if (parameters != null) { IDictionary namedParameters = parameters as IDictionary; IList argumentList; if (namedParameters != null) PowerShell.AddParameters(namedParameters); else if ((argumentList = parameters as IList) != null) PowerShell.AddParameters(argumentList); else PowerShell.AddParameters(new object[] { parameters }); } // UI: Write all output, including errors. if (JobUI != null) { PowerShell.Commands.AddCommand(A.OutHostCommand); } // Hidden: Write output to "Out-Null" to avoid memory use. else if (keepSeconds <= 0) { //! User can use his Out-Null PowerShell.AddCommand("Out-Null"); } // Output: create it once: it is cumulative else { Output = new PSDataCollection<PSObject>(); } }
public override IEnumerable<IPlugin> GetRunablePlugins(JobCommand command) { throw new MethodAccessException("This function is not available on Job class."); }
public DataSynSqlReportProcessor(DataSynSqlReportConfiguration config, JobCommand command) : base(config, command) { }