Пример #1
0
        public async Task <IActionResult> CheckJob()
        {
            if (!await CheckEngineStatus())
            {
                return(Unauthorized());
            }

            // log as debug so it won't be put to log when min level is Info
            _logger.LogDebug("Checking for job queue");

            var isEngine = User.IsInRole(UserRole.Engine);

            var engineName = "";

            if (isEngine)
            {
                engineName = User.Identity.Name;
            }

            var job = await _jobQueueService.GetFirstUnassignedQueuedJob(engineName);

            var result = _mapper.Map <JobDto>(job);

            // update engine's last seen
            await _engineService.UpdateLastSeen(engineName, GetEngineVersion(Request.Headers["User-Agent"].ToString()));

            _logger.LogResponse("Queued job queue checked. Response body: {@result}", result);

            return(Ok(result));
        }