public async Task <IActionResult> UpdateJobTaskOrder(int projectId, int jobId, UpdateTaskOrderDto dto)
        {
            _logger.LogInformation("Updating tasks order for job {jobId} in project {projectId}. Request body: {@dto}", jobId, projectId, dto);

            var jobs = await _jobDefinitionService.GetJobTaskDefinitions(jobId);

            foreach (var jobOrder in dto.TaskOrders)
            {
                var job = jobs.FirstOrDefault(j => j.Id == jobOrder.Key);
                job.Sequence = jobOrder.Value;
                await _jobDefinitionService.UpdateJobTaskDefinition(job);
            }

            return(Ok());
        }
Пример #2
0
        public async Task <IActionResult> UpdateJobTaskDefinition(int projectId, int jobId, int taskId, UpdateJobTaskDefinitionDto jobTaskDefinition)
        {
            // exclude additional configs since it may contain secret values
            var requestBodyToLog = new UpdateJobTaskDefinitionDto
            {
                Id       = jobTaskDefinition.Id,
                Name     = jobTaskDefinition.Name,
                Configs  = jobTaskDefinition.Configs,
                Provider = jobTaskDefinition.Provider,
                Sequence = jobTaskDefinition.Sequence,
                Type     = jobTaskDefinition.Type
            };

            _logger.LogInformation("Updating job task definition {taskId} in job definition {jobId}, project {projectId}. Request body: {@requestBodyToLog}",
                                   taskId, jobId, projectId, requestBodyToLog);

            try
            {
                if (taskId != jobTaskDefinition.Id)
                {
                    _logger.LogWarning("Task Id doesn't match.");
                    return(BadRequest("Task Id doesn't match."));
                }

                var entity = _mapper.Map <JobTaskDefinition>(jobTaskDefinition);
                await _jobDefinitionService.UpdateJobTaskDefinition(entity);

                return(Ok());
            }
            catch (DuplicateJobTaskDefinitionException dupTaskEx)
            {
                _logger.LogWarning(dupTaskEx, "Duplicate task name");
                return(BadRequest(dupTaskEx.Message));
            }
            catch (InvalidPluginTypeException pluginTypeEx)
            {
                _logger.LogWarning(pluginTypeEx, "Invalid provider's plugin type");
                return(BadRequest(pluginTypeEx.Message));
            }
            catch (ProviderNotInstalledException provEx)
            {
                _logger.LogWarning(provEx, "Provider not installed");
                return(BadRequest(provEx.Message));
            }
            catch (ExternalServiceRequiredException esrEx)
            {
                _logger.LogWarning(esrEx, "External service required");
                return(BadRequest(esrEx.Message));
            }
            catch (ExternalServiceNotFoundException esnfEx)
            {
                _logger.LogWarning(esnfEx, "External service not found");
                return(BadRequest(esnfEx.Message));
            }
            catch (IncorrectExternalServiceTypeException iestEx)
            {
                _logger.LogWarning(iestEx, "Incorrect external service type");
                return(BadRequest(iestEx.Message));
            }
        }
        public async Task <IActionResult> UpdateJobTaskOrder(int projectId, int jobId, UpdateTaskOrderDto dto)
        {
            _logger.LogRequest("Updating tasks order for job {jobId} in project {projectId}. Request body: {@dto}", jobId, projectId, dto);

            var tasks = await _jobDefinitionService.GetJobTaskDefinitions(jobId, decrypt : true);

            foreach (var taskOrder in dto.TaskOrders)
            {
                var task = tasks.FirstOrDefault(j => j.Id == taskOrder.Key);
                task.Sequence = taskOrder.Value;
                await _jobDefinitionService.UpdateJobTaskDefinition(task, validate : false);
            }

            _logger.LogResponse("Task order for job definition {jobId} in project {projectId} updated", jobId, projectId);

            return(Ok());
        }