public async Task <JobEntity> AddNewJobAsync(AddJobDto dto) { var jobId = dto.JobId ?? await _client.GetGrain <IJobIdGrain>(Constants.JobIdGrainDefaultName).GetNewIdAsync(); return(_mapper.Map <JobEntity>(await _client.GetGrain <IJobGrain>(jobId) .AddJobAsync(dto))); }
public AddJobDtoInternal(AddJobDto dto) { JobName = dto.JobName; ParentJobId = dto.ParentJobId; Tags = dto.Tags; CreatedBy = dto.CreatedBy; Options = dto.Options; }
public async Task <JobEntity> AddNewJobAsync(AddJobDto dto, Guid bufferId) { RequestContext.Set(Constants.BufferIdKey, bufferId); var jobId = dto.JobId ?? await _client.GetGrain <IJobIdGrain>(Constants.JobIdGrainDefaultName).GetNewIdAsync(); return(_mapper.Map <JobEntity>(await _client.GetGrain <IJobGrainInMem>(jobId) .AddJobAsync(dto))); }
public async Task <JobEntity> CreateNewJobAsync(AddJobDto dto) { var resp = await SendRequestAsync <JobEntity, AddJobDto>(HttpMethod.Post, $"api/jobTracker/new", dto); if (resp.Result) { return(resp.Data); } throw new Exception($"{nameof(CreateNewJobAsync)} failed {resp.Msg}"); }
internal override async Task <JobEntity> CreateNewJobWithBufferAsync(AddJobDto dto, Guid bufferId) { var resp = await SendRequestAsync <JobEntity, AddJobDto>(HttpMethod.Post, $"api/bufferManager/{bufferId}/job/new", dto); if (resp.Result) { return(resp.Data); } throw new Exception($"{nameof(CreateNewJobWithBufferAsync)} failed {resp.Msg}"); }
public async Task <JobEntityState> AddJobAsync(AddJobDto dto) { var addJobDto = new AddJobDtoInternal(dto); if (State.CurrentJobState != JobState.WaitingForActivation) { throw new InvalidOperationException($"job id duplicate: {this.GetPrimaryKeyLong()}"); } const JobState state = JobState.WaitingToRun; var jobId = this.GetPrimaryKeyLong(); State.JobId = jobId; State.ParentJobId = addJobDto.ParentJobId; State.CreateBy = addJobDto.CreatedBy; State.Tags = addJobDto.Tags; State.Options = addJobDto.Options; if (addJobDto.ParentJobId.HasValue) { var parentGrain = GrainFactory.GetGrain <IJobGrain>(addJobDto.ParentJobId.Value); var parent = await parentGrain.GetJobEntityAsync(); if (parent.CurrentJobState == JobState.WaitingForActivation) { throw new InvalidOperationException($"parent job {addJobDto.ParentJobId} not exist"); } State.AncestorJobId = parent.AncestorJobId; await UpdateJobStateAsync(new UpdateJobStateDto(JobState.WaitingToRun), false); } else { State.AncestorJobId = jobId; } var ancestorRefGrain = GrainFactory.GetGrain <IDescendantsRefGrain>(State.AncestorJobId); await ancestorRefGrain.AttachToChildrenAsync(jobId); State.StateChanges.Add(new StateChangeDto(state)); State.JobName = addJobDto.JobName; await WriteStateAsync(); if (!State.ParentJobId.HasValue) { var indexGrain = GrainFactory.GetGrain <IShardJobIndexGrain>(Helper.GetTimeIndex()); await indexGrain.AddToIndexAsync(new JobIndexInternal(State.JobId, State.JobName, State.CreateBy, State.Tags)); } return(State); }
public override async Task <JobEntity> CreateNewJobAsync(AddJobDto dto) { if (dto.JobId == null) { dto.JobId = await GetNextIdAsync(); } var resp = await SendRequestAsync <JobEntity, AddJobDto>(HttpMethod.Post, "api/jobTracker/new", dto); if (resp.Result) { return(resp.Data); } throw new Exception($"{nameof(CreateNewJobAsync)} failed {resp.Msg}"); }
public async Task <JobEntityState> AddJobAsync(AddJobDto addJobDto) { if (_state.CurrentJobState != JobState.WaitingForActivation) { throw new InvalidOperationException($"job id duplicate: {this.GetPrimaryKeyLong()}"); } const JobState state = JobState.WaitingToRun; var jobId = this.GetPrimaryKeyLong(); _state.JobId = jobId; _state.ParentJobId = addJobDto.ParentJobId; _state.CreatedBy = addJobDto.CreatedBy; _state.Tags = addJobDto.Tags; _state.Options = addJobDto.Options; if (addJobDto.ParentJobId.HasValue) { var parentGrain = GrainFactory.GetGrain <IJobGrainInMem>(addJobDto.ParentJobId.Value); var parent = await parentGrain.GetJobAsync(); if (parent.CurrentJobState == JobState.WaitingForActivation) { throw new JobNotFoundException($"parent job {addJobDto.ParentJobId} not exist"); } _state.AncestorJobId = parent.AncestorJobId; await UpdateJobStateAsync(new UpdateJobStateDto(JobState.WaitingToRun), false); } else { _state.AncestorJobId = jobId; _state.StateChanges.Add(new StateChangeDto(state)); } var ancestorRefGrain = GrainFactory.GetGrain <IDescendantsRefGrainInMem>(_state.AncestorJobId); await ancestorRefGrain.AttachToChildrenAsync(jobId); _state.JobName = addJobDto.JobName; _state.SourceLink = addJobDto.SourceLink; _state.ActionConfigs = addJobDto.ActionConfigs; _state.StateCheckConfigs = addJobDto.StateCheckConfigs; await ScheduleStateCheckMessageAsync(_state.StateCheckConfigs, _state.JobId); return(_state); }
public async Task <ServiceResponse <List <GetJobDto> > > AddJob(AddJobDto newJob) { ServiceResponse <List <GetJobDto> > response = new ServiceResponse <List <GetJobDto> >(); try { Job job = _mapper.Map <Job>(newJob); await _context.Jobs.AddAsync(job); await _context.SaveChangesAsync(); response.Data = _context.Jobs.Select(j => _mapper.Map <GetJobDto>(j)).ToList(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); }
public async Task <AddJobErrorResult> AddJobFromParentAsync(AddJobDto addJobDto, long ancestorJobId, long?trackCountRef) { if (State.CurrentJobState != JobState.WaitingForActivation) { throw new InvalidOperationException($"job id duplicate: {this.GetPrimaryKeyLong()}"); } try { const JobState state = JobState.WaitingToRun; State.JobId = this.GetPrimaryKeyLong(); State.ParentJobId = addJobDto.ParentJobId; State.CreatedBy = addJobDto.CreatedBy; State.Tags = addJobDto.Tags; State.TrackCountRef = trackCountRef; State.Options = addJobDto.Options; State.AncestorJobId = ancestorJobId; State.StateChanges.Add(new StateChangeDto(state)); State.JobName = addJobDto.JobName; State.SourceLink = addJobDto.SourceLink; State.ActionConfigs = addJobDto.ActionConfigs; State.StateCheckConfigs = addJobDto.StateCheckConfigs; await ScheduleStateCheckMessageAsync(State.StateCheckConfigs, State.JobId); await WriteStateAsync(); } catch (Exception ex) { var res = new AddJobErrorResult { JobId = this.GetPrimaryKeyLong(), Error = ex.ToString() }; DeactivateOnIdle(); return(res); } return(null); }
public async Task <IActionResult> PostJob(AddJobDto newJob) { return(Ok(await _resumeService.AddJob(newJob))); }
public async Task <JobEntityState> AddJobAsync(AddJobDto addJobDto) { if (State.CurrentJobState != JobState.WaitingForActivation) { throw new InvalidOperationException($"job id duplicate: {this.GetPrimaryKeyLong()}"); } try { const JobState state = JobState.WaitingToRun; var jobId = this.GetPrimaryKeyLong(); State.JobId = jobId; State.ParentJobId = addJobDto.ParentJobId; State.CreatedBy = addJobDto.CreatedBy; State.Tags = addJobDto.Tags; State.Options = addJobDto.Options; if (addJobDto.TrackJobCount) { State.TrackCountRef = jobId; } if (addJobDto.ParentJobId.HasValue) { var parentGrain = GrainFactory.GetGrain <IJobGrain>(addJobDto.ParentJobId.Value); var parent = await parentGrain.GetJobAsync(); if (parent.CurrentJobState == JobState.WaitingForActivation) { throw new JobNotFoundException($"parent job {addJobDto.ParentJobId} not exist"); } State.AncestorJobId = parent.AncestorJobId; State.TrackCountRef ??= parent.TrackCountRef; await UpdateJobStateAsync(new UpdateJobStateDto(JobState.WaitingToRun), false); } else { State.AncestorJobId = jobId; State.StateChanges.Add(new StateChangeDto(state)); } var ancestorRefGrain = GrainFactory.GetGrain <IDescendantsRefGrain>(State.AncestorJobId); await ancestorRefGrain.AttachToChildrenAsync(jobId); State.JobName = addJobDto.JobName; State.SourceLink = addJobDto.SourceLink; State.ActionConfigs = addJobDto.ActionConfigs; State.StateCheckConfigs = addJobDto.StateCheckConfigs; await ScheduleStateCheckMessageAsync(State.StateCheckConfigs, State.JobId); if (!State.ParentJobId.HasValue) { var indexGrain = GrainFactory.GetGrain <IShardJobIndexGrain>(Helper.GetTimeIndex()); await indexGrain.AddToIndexAsync(new JobIndexInternal(State.JobId, State.JobName, State.CreatedBy, State.Tags)); } if (State.TrackCountRef.HasValue) { var counter = GrainFactory.GetGrain <IAggregateCounterGrain>(State.TrackCountRef.Value); await counter.AddAsync(); } } catch (Exception) { DeactivateOnIdle(); throw; } await WriteStateAsync(); return(State); }
public async Task <ReturnDto <JobEntity> > AddNewJob( [FromBody] AddJobDto dto) { return(new ReturnDto <JobEntity>(await _service.AddNewJobAsync(dto))); }
internal abstract Task <JobEntity> CreateNewJobWithBufferAsync(AddJobDto dto, Guid bufferId);
public async Task <JobEntity> CreateNewJobAsync(AddJobDto dto) { return(await _client.CreateNewJobWithBufferAsync(dto, _scopeBufferId)); }
public abstract Task <JobEntity> CreateNewJobAsync(AddJobDto dto);
public async Task <ReturnDto <JobEntity> > AddJobToBufferAsync([FromBody] AddJobDto dto, [FromRoute] Guid bufferId) { return(new ReturnDto <JobEntity>(await _svc.AddNewJobAsync(dto, bufferId))); }