Exemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync(string jobId)
        {
            try
            {
                if (string.IsNullOrEmpty(jobId))
                {
                    return(View("Empty"));
                }

                // get log id from job
                var job = await _jobStore.GetJobInfoAsync(jobId);

                if (job == null || string.IsNullOrEmpty(job.LogId))
                {
                    return(View("Empty"));
                }

                var log = await _logStore.GetLogContentAsync(job.LogId);

                if (log == null)
                {
                    return(View("Empty"));
                }
                var jhvm = new JobHistoryViewModel(job);
                ViewData["LogContents"] = log.Trim();
                return(View("Default", jhvm));
            }
            catch (Exception e)
            {
                return(View("Error", e));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get(string logId)
        {
            try
            {
                var logContent = await _logStore.GetLogContentAsync(logId);

                return(new ObjectResult(logContent));
            }
            catch (LogNotFoundException)
            {
                return(NotFound());
            }
            catch (Exception ex)
            {
                Log.ForContext <LogsController>().Error(ex, "Error retrieving log {LogId}", logId);
                return(StatusCode(500));
            }
        }