/// <summary> /// Processes the job instance. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <returns><see cref="Task"/>.</returns> private async Task Process(CancellationToken cancellationToken) { while (_isActive) { JobInstanceModel jobInstance = await _apiClient.JobInstanceProcessor.GetFirstAvailable(_agent.Id); if (jobInstance != null) { PackageModel package = await _apiClient.PackageProcessor.Get(jobInstance.Job.PackageName); if (package == null) { throw new Exception(""); // TODO: to modify } if (!IsPackageValid(package)) { DownloadTestPackage(package); } if (!IsPackageValid(package)) { throw new Exception(""); // TODO: to modify } // TODO: Execute test } await Task.Delay(1000, cancellationToken); // TODO: the delay value need to be dynamic } }
/// <summary> /// Updates the job instance. /// </summary> /// <param name="model">The model.</param> /// <returns><see cref="AgentModel"/>.</returns> public async Task <JobInstanceModel> Update(JobInstanceModel model) { try { HttpResponseMessage httpResponseMessage = await _httpClient.SendRequestAsync(HttpMethod.Put, $"/api/v1/jobinstance/{model.Id}", model); return (JsonConvert.DeserializeObject <JobInstanceModel>(await httpResponseMessage.Content.ReadAsStringAsync())); } catch (Exception ex) { HandleError(ex); } return(null); }
public async Task <IActionResult> Get(string agentId) { try { JobInstanceModel model = await _jobInstanceService.GetFirstAvailable(agentId); if (model == null) { return(StatusCode(404)); } return(Ok(model)); } catch (Exception ex) { HandleError(ex); return(StatusCode(500, agentId)); } }
/// <inheritdoc /> /// <summary> /// Adds the specified job instance to the repository. /// </summary> /// <param name="model">The model.</param> /// <returns> /// <see cref="T:YellowJacket.Models.JobInstanceModel" />. /// </returns> public async Task <JobInstanceModel> Add(JobInstanceModel model) { return(_mapper.Map <JobInstanceModel>( await _jobInstanceRepository.Add( _mapper.Map <JobInstanceEntity>(model)))); }
/// <inheritdoc /> /// <summary> /// Validates the specified model. /// </summary> /// <param name="model">The model.</param> /// <returns> /// <see cref="T:FluentValidation.Results.ValidationResult" />. /// </returns> public ValidationResult Validate(JobInstanceModel model) { return(new JobInstanceValidator().Validate(model)); }
/// <inheritdoc /> /// <summary> /// Updates the specified job instance. /// </summary> /// <param name="model">The model.</param> /// <returns> /// <see cref="T:YellowJacket.Models.JobInstanceModel" />. /// </returns> public async Task <JobInstanceModel> Update(JobInstanceModel model) { return(_mapper.Map <JobInstanceEntity, JobInstanceModel>( await _jobInstanceRepository.Update( _mapper.Map <JobInstanceModel, JobInstanceEntity>(model)))); }