public Job AddJob(string jobName, string dictionaryName, List <CustomFieldTypeId> customFieldTypeIdList, Guid transferId) { try { using (var scope = new TransactionScope()) { JobId jobId = jobRep.GetNextId(); var job = new Job(jobId, jobName, dictionaryName); job.TransferId = transferId; assignJobCustomField(job, customFieldTypeIdList); jobRep.AddJob(job); scope.Complete(); return(job); } } catch (Exception exp) { var res = jobRep.TryConvertException(exp); if (res == null) { throw; } throw res; } }
public Task StartAsync(CancellationToken cancellationToken) { try { // set IsExecuting to false in case this job was forcefully terminated previously using (var scope = _serviceScopeFactory.CreateScope()) { string jobTypeName = Utilities.GetFullTypeName(GetType().AssemblyQualifiedName); IJobRepository jobs = scope.ServiceProvider.GetRequiredService <IJobRepository>(); Job job = jobs.GetJobs().Where(item => item.JobType == jobTypeName).FirstOrDefault(); if (job != null) { job.IsStarted = true; job.IsExecuting = false; jobs.UpdateJob(job); } else { // auto registration - does not run on initial installation but will run after restart job = new Job { JobType = jobTypeName }; // optional properties var jobType = Type.GetType(jobTypeName); var jobObject = ActivatorUtilities.CreateInstance(scope.ServiceProvider, jobType) as HostedServiceBase; if (jobObject.Name != "") { job.Name = jobObject.Name; } else { job.Name = Utilities.GetTypeName(job.JobType); } job.Frequency = jobObject.Frequency; job.Interval = jobObject.Interval; job.StartDate = jobObject.StartDate; job.EndDate = jobObject.EndDate; job.RetentionHistory = jobObject.RetentionHistory; job.IsEnabled = jobObject.IsEnabled; job.IsStarted = true; job.IsExecuting = false; jobs.AddJob(job); } } _executingTask = ExecuteAsync(_cancellationTokenSource.Token); if (_executingTask.IsCompleted) { return(_executingTask); } } catch { // can occur during the initial installation because this method is called during startup and the database has not yet been created } return(Task.CompletedTask); }
public static void CreateJob(IJobRepository jobRepository, string name, string dictionaryName) { var job = new Job(jobRepository.GetNextId(), name, dictionaryName); job.AssignCustomFields(DefinedCustomFields.Where(dc => dc.EntityId.Equals(EntityTypeEnum.Job)).ToList()); jobRepository.AddJob(job); Jobs.Add(job); }
public Job Post([FromBody] Job Job) { if (ModelState.IsValid) { Job = Jobs.AddJob(Job); logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Added {Job}", Job); } return(Job); }
public async Task <IActionResult> AddJob([FromBody] Job job) { var _job = await _jobRepository.AddJob(job); if (_job == null) { return(NotFound("Vaga não encontrada")); } else { return(Ok(_job)); } }
public ActionResult <JobDto> CreateJob(JobForCreationDto job) { if (String.IsNullOrEmpty(job.Name)) { return(BadRequest()); } var jobEntity = _mapper.Map <Job>(job); _jobRepository.AddJob(jobEntity); var jobToReturn = _mapper.Map <JobDto>(jobEntity); return(CreatedAtRoute("GetJob", new { jobPriority = jobToReturn.Priority }, jobToReturn)); }
public ActionResult Create(Job job) { string body = ""; if (Request.Form.HasKeys()) { foreach (string x in Request.Form) { body = body + x + "=" + Request.Form[x] + "\n"; } } string jobName = "CMAES" + DateTime.Now.Second.ToString(); Messaging messaging = new Messaging(); IMapMessage response = messaging.RequestMap(jobName, "AddJob", body); job.IsTemplate = false; job.Name = jobName; job.Problem_Id = 1; job.Status = "Submitted"; job.StartTime = DateTime.Now; _jobRepository.AddJob(job); Thread.Sleep(1000); Response.Redirect("/default.aspx"); return(View(job)); // var jobs = _jobRepository.FindAllJobs(); //return View(jobs); //if (ModelState.IsValid) //{ // try // { // _jobRepository.AddJob(job); // return RedirectToAction("Index"); // } // catch // { // return View(job); // } //} //else //{ // return View(job); //} }
public Job Post([FromBody] Job job) { if (ModelState.IsValid) { job = _jobs.AddJob(job); _logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Added {Job}", job); } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Job Post Attempt {Job}", job); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; job = null; } return(job); }
public IActionResult CreateJob([FromBody] Job job) { if (job == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var createdJob = _jobRepository.AddJob(job); return(Created("Job", createdJob)); }
public IActionResult AddJob([FromBody] JobPosition job) { if (job == null) { return(BadRequest()); } try { _jobRepository.AddJob(job); } catch (Exception) { return(BadRequest()); } return(Ok("Sve je u redu")); }
public IActionResult Create(JobCreateViewModel model) { if (ModelState.IsValid) { string uniqueFileName = ProcessUploadedFile(model); Job newJob = new Job { UserID = userManager.GetUserId(User), Company = model.Company, JobPosition = model.JobPosition, JobLink = model.JobLink, ContactEmail = model.ContactEmail, ContactName = model.ContactName, ContactPhone = model.ContactPhone, AppliedDate = model.AppliedDate, CloseDate = model.CloseDate, Expectation = model.Expectation, AnnualRate = model.AnnualRate, CommuteCost = model.CommuteCost, Bonus = model.Bonus, JobStatus = 0, NextStep = JobStatus.Apply, Location = model.Location, InterviewDate = model.InterviewDate, InterviewDate2 = null, JobDescription = model.JobDescription, Notes = null, CoverLetter = null, Feedback = null, IsAgency = model.IsAgency, IsHomeOffice = model.IsHomeOffice, IsApprentice = model.IsApprentice, IsPartTime = model.IsPartTime, FilePath = uniqueFileName }; _jobRepository.AddJob(newJob); newJob.EncryptedId = protector.Protect(newJob.Id.ToString()); return(RedirectToAction("Details", new { id = newJob.EncryptedId })); } return(View()); }
private async Task ExecuteJob(JobMetadata jobMetadata) { dynamic jobImplementation = null; try { using (var scope = _settings.JobScopeFactory.Create()) { try { jobImplementation = scope.CreateJob(jobMetadata.JobType); } catch (Exception ex) { //Дополнительное логирование ошибки, когда джоб не может быть создан _settings.Logger.Error($"Ошибка создания джоба {jobMetadata.JobType}", ex); throw; } _settings.Logger.Debug("got jobImplementation -" + jobImplementation.GetType()); _settings.Logger.Debug("got JobParam -" + jobMetadata.JobParam.GetType()); await jobImplementation.Execute((dynamic)jobMetadata.JobParam); _settings.Logger.Debug("jobMetadata excecuted"); if (jobMetadata.NextJob != null) { jobMetadata.NextJob.StartAt = DateTime.UtcNow + jobMetadata.NextJob.Delay.GetValueOrDefault(); await _jobRepository.AddJob(JobDb.CreatedJobDb(jobMetadata.NextJob, _settings.JsonSerializerSettings)); _settings.Logger.Debug("next jobMetadata added"); } await _jobRepository.RemoveJob(jobMetadata.JobId); _settings.Logger.Debug("jobMetadata saved success"); } } catch (Exception ex) { await HandleFailed(jobMetadata, ex, jobImplementation); } }
public void AddJob(Job user) { _jobRepository.AddJob(user); }
public Task AddEnqueueJob(JobMetadata jobMetadata) { var job = JobDb.CreatedJobDb(jobMetadata, _jsonSerializerSettings); return(_jobRepository.AddJob(job)); }
public ResModel AddJob(JobDto jobDto, UserDto operationUser) { return(_jobRepository.AddJob(jobDto, operationUser)); }