public override string Execute() { Console.WriteLine($"Trying to get queue \"{Number}\" in project {Project}..."); var message = ""; var code = ""; if (!int.TryParse(Number, out var id)) { code = Number; } JobDto queue = null; var project = _projectService.GetProjectByName(Project).Result; if (project != null) { queue = !string.IsNullOrEmpty(code) ? _jobQueueService.GetJobQueue(project.Id, code).Result : _jobQueueService.GetJobQueue(project.Id, id).Result; if (queue != null) { message = queue.ToCliString($"Job Queue {Number}", excludedFields: new string[] { "ProjectId", "JobDefinitionId", "JobTasksStatus" }); if (queue.JobTasksStatus?.Count > 0) { var sb = new System.Text.StringBuilder(); sb.AppendLine(); sb.AppendLine(" ------------------------------------------------------------------"); sb.AppendLine(" Job Task Status:"); foreach (var taskStatus in queue.JobTasksStatus.OrderBy(t => t.Sequence)) { sb.AppendLine(); sb.AppendLine($" {taskStatus.Sequence}. Task Name: {taskStatus.TaskName}"); sb.AppendLine($" Status: {taskStatus.Status}"); sb.AppendLine($" Remarks: {taskStatus.Remarks}"); } sb.AppendLine(); sb.AppendLine(" ------------------------------------------------------------------"); message += sb.ToString(); } } } if (queue == null) { message = $"Failed getting queue {Number}. Make sure the project name and queue number are correct."; } return(message); }
public override string Execute() { Console.WriteLine($"Trying to cancel queue \"{Number}\" in project {Project}..."); string message; var code = ""; if (!int.TryParse(Number, out var id)) { code = Number; } var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var queue = !string.IsNullOrEmpty(code) ? _jobQueueService.GetJobQueue(project.Id, code).Result : _jobQueueService.GetJobQueue(project.Id, id).Result; if (queue != null) { if (!CancellablleJobStatus.Contains(queue.Status)) { message = $"Cannot cancel queue {Number} with status {queue.Status}"; return(message); } if (queue.Status == JobStatus.Processing && !string.IsNullOrEmpty(queue.CatapultEngineId)) { if (!Console.GetYesNo($"The job queue {Number} was being processed by engine {queue.CatapultEngineId}. Make sure the engine process has stopped. Continue the job cancellation?", false)) { return(string.Empty); } } _jobQueueService.UpdateJobQueue(project.Id, queue.Id, new UpdateJobDto { Id = queue.Id, Status = JobStatus.Cancelled, CatapultEngineId = queue.CatapultEngineId, CatapultEngineIPAddress = queue.CatapultEngineIPAddress, CatapultEngineMachineName = queue.CatapultEngineMachineName, CatapultEngineVersion = queue.CatapultEngineVersion, JobTasksStatus = queue.JobTasksStatus, JobType = queue.JobType, OutputValues = queue.OutputValues, Remarks = Reason ?? queue.Remarks }).Wait(); message = $"Queue {Number} has been cancelled successfully"; Logger.LogInformation(message); return(message); } } message = $"Failed to cancel queue {Number}. Make sure the project name and queue number are correct."; return(message); }
public override string Execute() { Console.WriteLine($"Trying to get queue \"{Number}\" in project {Project}..."); string message; var code = ""; if (!int.TryParse(Number, out var id)) { code = Number; } var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var queue = !string.IsNullOrEmpty(code) ? _jobQueueService.GetJobQueue(project.Id, code).Result : _jobQueueService.GetJobQueue(project.Id, id).Result; if (queue != null) { switch (queue.Status) { case JobStatus.Processing: _jobQueueLogListener.Listen(queue.Id, OnLogReceived, OnLogError).Wait(); message = ""; return(message); case JobStatus.Completed: case JobStatus.Error: case JobStatus.Pending: case JobStatus.Cancelled: message = _jobQueueService.GetJobLogs(project.Id, queue.Id).Result; return(message); case JobStatus.Queued: if (Wait) { Console.WriteLine("Waiting for log stream..."); _jobQueueLogListener.Listen(queue.Id, OnLogReceived, OnLogError).Wait(); message = ""; } else { message = $"Queue {Number} is queued"; } return(message); default: message = $"Queue {Number} has unknown status"; return(message); } } } message = $"Failed getting queue {Number}. Make sure the project name and queue number are correct."; return(message); }
public override string Execute() { Console.WriteLine($"Trying to restart queue \"{Number}\" in project {Project}..."); string message; var code = ""; if (!int.TryParse(Number, out var id)) { code = Number; } var project = _projectService.GetProjectByName(Project).Result; if (project != null) { var queue = !string.IsNullOrEmpty(code) ? _jobQueueService.GetJobQueue(project.Id, code).Result : _jobQueueService.GetJobQueue(project.Id, id).Result; if (queue != null) { _jobQueueService.UpdateJobQueue(queue.Id, new UpdateJobDto { Id = queue.Id, Status = JobStatus.Queued, CatapultEngineId = queue.CatapultEngineId, CatapultEngineIPAddress = queue.CatapultEngineIPAddress, CatapultEngineMachineName = queue.CatapultEngineMachineName, CatapultEngineVersion = queue.CatapultEngineVersion, JobTasksStatus = queue.JobTasksStatus, JobType = queue.JobType, OutputValues = queue.OutputValues, Remarks = null }).Wait(); message = $"Queue {Number} has been restarted successfully"; Logger.LogInformation(message); return(message); } } message = $"Failed to restart queue {Number}. Make sure the project name and queue number are correct."; return(message); }