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 async Task <IActionResult> GetJobLogs(int projectId, int queueId) { _logger.LogInformation("Getting logs for job queue {queueId}", queueId); var logs = await _jobQueueService.GetJobLogs(projectId, queueId); return(Ok(logs)); }
public async Task <IActionResult> GetJobLogs(int projectId, int queueId) { _logger.LogRequest("Getting logs for job queue {queueId}", queueId); var logs = await _jobQueueService.GetJobLogs(projectId, queueId); _logger.LogResponse("Log for job queue {queueId} in project {projectId} retrieved", queueId, projectId); return(Ok(logs)); }