public void AddWaitingTest() { JobRepository.Add(NewJob()); Assert.That(JobRepository.WaitingJobs().Count(), Is.EqualTo(1)); Assert.That(JobRepository.DoneJobs(), Is.Empty); Assert.That(JobRepository.ActiveJobs(), Is.Empty); }
public void SaveJob(JobItem job) { var result = new JobItem(); try { _logger.LogTrace("Saving the Job", job); if (!string.IsNullOrEmpty(job.Id)) { Expression <Func <JobItem, bool> > expr = (x => x.Id == job.Id); if (_jobRepository.Exists(expr)) { result = _jobRepository.Update(job); } else { result = _jobRepository.Add(job); } } else { result = _jobRepository.Add(job); } JobCreatedIntegrationEvent test = new JobCreatedIntegrationEvent("test"); _eventBus.Publish(test); _logger.LogTrace("Item Saved & event publised. event:", test); } catch (Exception ex) { _logger.LogError("Unable to save the ", ex); } }
public IActionResult Add(IncomingJob incomingJob) { Job job = new Job() { Image = incomingJob.Image, FileName = incomingJob.FileName, StatusDateTime = DbUtils.UnixTimeStampToDateTime(incomingJob.StatusTime), FilamentLength = (int)incomingJob.FilamentLength, PrintLength = (int)incomingJob.PrintLength, DeviceIdentifier = incomingJob.DeviceIdentifier, StatusMessage = incomingJob.StatusMessage, PercentDone = (int?)incomingJob.PercentDone, TimeLeft = incomingJob.TimeLeft, }; Printer currentPrinter = _printerRepository.GetPrinterByDeviceIdentifier(job.DeviceIdentifier);// add catch if not found job.PrinterId = currentPrinter.Id; Job lastJob = _jobRepository.GetLastPrinterJob(currentPrinter.Id); if (job.PercentDone == 100) { job.CompleteDateTime = DateTime.Now; } if (job.PercentDone > lastJob.PercentDone) { job.Id = lastJob.Id; _jobRepository.Update(job); return(Ok()); } _jobRepository.Add(job); return(base.Created("", job)); }
public void New(ICommand command) { if (command == null) { throw new ArgumentNullException("command"); } Job j = Job.Create(command.Id); _Repository.Add(j); }
public IActionResult Create([FromBody] Job job) { if (job == null || job.Id != 0) { return(BadRequest()); } else if (job.DriverVersion < 1) { return(BadRequest("The driver is not compatible with this server, please update it.")); } else if (job.State != JobState.New) { return(BadRequest("The job state should be ServerState.New. You are probably using a wrong version of the driver.")); } job.Hardware = Startup.Hardware; job.HardwareVersion = Startup.HardwareVersion; job.OperatingSystem = Startup.OperatingSystem; // Use server-side date and time to prevent issues from time drifting job.LastDriverCommunicationUtc = DateTime.UtcNow; job = _jobs.Add(job); Response.Headers["Location"] = $"/jobs/{job.Id}"; return(new StatusCodeResult((int)HttpStatusCode.Accepted)); }
// Если джоба уже зашедулена, то exception (вначале нужно расшедулить ее) // Если джобы нет в базе, она создается и шедулится // Если джоба есть в базе, ее поля обновляются. Затем она шедулится public Guid ScheduleJob(Job job) { if (ScheduledJob(job.Id)) { throw new InvalidOperationException("This job has been already scheduled"); } Job scheduleJob; var jobExistDb = GetJobDbAtId(job.Id); var jobDb = JobMapper.Mapper.DomainToDb(job); if (jobExistDb == null) { _jobRepository.Add(jobDb); _unitOfWork.Commit(); scheduleJob = job; } else { // Change job info jobExistDb.ClassName = jobDb.ClassName; jobExistDb.Data = jobDb.Data; jobExistDb.Triggers = jobDb.Triggers; _jobRepository.Update(jobExistDb); _unitOfWork.Commit(); scheduleJob = JobMapper.Mapper.DbToDomain(jobExistDb); } QuartzScheduleJob(scheduleJob); return(scheduleJob.Id); }
public IActionResult CreateJob(int id, [FromBody] JobViewModel job) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Customer _customerDb = _customerRepository.GetSingle(id); Job _newJob; if (_customerDb == null) { return(NotFound()); } else { _newJob = new Job { JobType = (JobType)Enum.Parse(typeof(JobType), job.JobType), Date = DateTime.Now.Date, Status = JobStatusType.Active, CustomerId = id }; } _jobRepository.Add(_newJob); _jobRepository.Commit(); job = Mapper.Map <Job, JobViewModel>(_newJob); //check logic - return jobs created from customer To-Do CreatedAtRouteResult result = CreatedAtRoute("GetCustomerJobs", new { controller = "Customers", id }, job); return(result); }
public async Task <IActionResult> CreateJob(JobDTO jobDto) { var job = _mapper.Map <JobDTO, Job>(jobDto); await _repository.Add(job); return(CreatedAtAction(nameof(GetJob), new { id = job.JobId }, job)); }
protected async Task SubmitPipelineJob(string jobName, string pipelineId, JobPriority jobPriority, string basePath, IList <InstanceStorageInfo> instances) { Guard.Against.NullOrWhiteSpace(pipelineId, nameof(pipelineId)); if (instances.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(instances)); } jobName = jobName.FixJobName(); Guard.Against.NullOrWhiteSpace(jobName, nameof(jobName)); using var _ = _logger.BeginScope(new LogginDataDictionary <string, object> { { "JobName", jobName }, { "PipelineId", pipelineId }, { "Priority", jobPriority }, { "Instances", instances.Count } }); _logger.Log(LogLevel.Debug, "Queueing a new job."); var job = new InferenceJob() { JobName = jobName, PipelineId = pipelineId, Priority = jobPriority, Source = $"{AeTitle} ({Name})", Instances = instances }; await _jobStore.Add(job, false); _logger.Log(LogLevel.Information, "Job added to queue."); }
public Job AssignJob(JobId jobId, List <SharedJobCustomFieldId> customFieldIdList, IList <JobIndexForJob> jobIndexList) { using (var tr = new TransactionScope()) { var period = periodRep.GetById(jobId.PeriodId); var sharedJob = pmsAdminService.GetSharedJob(jobId.SharedJobId); var sharedJobCustomFields = pmsAdminService.GetSharedCutomFieldListForJob(jobId.SharedJobId, customFieldIdList); var jobCustomFields = new List <JobCustomField>(); foreach (var sharedJobCustomField in sharedJobCustomFields) { jobCustomFields.Add(new JobCustomField(new JobCustomFieldId(period.Id, sharedJobCustomField.Id, jobId.SharedJobId), sharedJobCustomField )); } var jobIndexIds = jobIndexList.Select(jj => jj.JobIndexId).ToList(); var jobIndices = jobIndexRep.FindJobIndices(jobIndexIds); //job.UpdateJobIndices(jobIndices.ToList()); var jobJobInddices = new List <JobJobIndex>(); foreach (var jobIndex in jobIndices) { var jobindexForJob = jobIndexList.Single(j => j.JobIndexId == jobIndex.Id); jobJobInddices.Add(new JobJobIndex(jobIndex.Id, jobindexForJob.ShowforTopLevel, jobindexForJob.ShowforSameLevel, jobindexForJob.ShowforLowLevel)); } var job = new Job(period, sharedJob, jobCustomFields, jobJobInddices); jobRep.Add(job); tr.Complete(); return(job); } }
public IActionResult Post(Job job) { job.CreateDate = DateTime.Now; _jobRepository.Add(job); return(CreatedAtAction(nameof(Get), new { id = job.Id }, job)); }
public IActionResult Create(Job job) { if (ModelState.IsValid) { //add the employee Job newJob = _jobRepository.Add(job); return(RedirectToAction("jobdetails", "job", new { id = newJob.Id })); } return(View()); }
public async Task Add() { var entity = new JobDTO(); var UserId = Convert.ToInt32(_context.HttpContext.User.Claims.Where(x => x.Type == "UserId").First().Value); var job = new Job(); try { foreach (var key in _context.HttpContext.Request.Form.Keys) { entity = JsonConvert.DeserializeObject <JobDTO>(_context.HttpContext.Request.Form[key]); job = _mapper.Map <Job>(entity); var file = _context.HttpContext.Request.Form.Files.Count > 0 ? _context.HttpContext.Request.Form.Files[0] : null; if (file != null) { string folderName = "Upload"; string webRootPath = _hostingEnvironment.WebRootPath; if (string.IsNullOrWhiteSpace(webRootPath)) { webRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"); } string newPath = Path.Combine(webRootPath, folderName); if (!Directory.Exists(newPath)) { Directory.CreateDirectory(newPath); } if (file.Length > 0) { string fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); string fullPath = Path.Combine(newPath, fileName); job.ImagePath = fullPath; using (var stream = new FileStream(fullPath, FileMode.Create)) { file.CopyTo(stream); } } } } } catch (Exception e) { } job.UserId = UserId; job.PostDate = DateTime.Now; await _jobRepository.Add(job); _jobRepository.SaveAll(); }
public ActionResult Create([Bind(Include = "JobId,Company,JobName,From,Until,StillWorking,JobExplanation,PurposeOfLeaving,PersonId")] Job job) { if (ModelState.IsValid) { _jobRepository.Add(job); _jobRepository.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonId = new SelectList(_personRepository.All, "PersonId", "Firstname", job.PersonId); return(View(job)); }
public Job Add(Job item) { var foundJob = _repo.GetByCustomerAndJobName(item.CustomerId, item.JobName); if (foundJob != null) { return(foundJob); } else { return(_repo.Add(item)); } }
public JobOutput Execute(Job job) { var j = _jobRepository.CheckDuplicated(job); if (j == null) { return(_mapper.Map <Job, JobOutput>(_jobRepository.Add(job))); } else { throw new JobWithThisNameAndOrCodeAlreadyExists(job.Name, job.Code, "Ya existe un puesto con este nombre y/o con este código"); } }
public CreateResponse Create(JobRequest request) { try { var job = TypeAdapter.Adapt <Job>(request); _jobValidator.ValidateAndThrowException(job, "Base"); _jobRepository.Add(job); return(new CreateResponse(job.Id)); } catch (DataAccessException) { throw new ApplicationException(); } }
public ActionResult Create(FormCollection collection) { try { Job job = new Job(); TryUpdateModel(job); _jobRepository.Add(job); _unitOfWork.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Create([FromBody] JobDto jobVM) { Console.Write(jobVM); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var job = Mapper.Map <JobDto, Job>(jobVM); _jobRepository.Add(job); _jobRepository.Commit(); _workerService.RegisterTask("job", job.Id); return(new OkResult()); }
public async Task Add(JobForTableDTO jobDTO) { var UserId = Convert.ToInt32(_context.HttpContext.User.Claims.Where(x => x.Type == "UserId").First().Value); Job job = new Job(); IFormFile file = jobDTO.Image; string fullPath = null; var imageId = 0; if (file != null) { string folderName = "Upload"; string webRootPath = _hostingEnvironment.WebRootPath; if (string.IsNullOrWhiteSpace(webRootPath)) { webRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"); } string newPath = Path.Combine(webRootPath, folderName); if (!Directory.Exists(newPath)) { Directory.CreateDirectory(newPath); } if (file.Length > 0) { string fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); fullPath = Path.Combine(newPath, fileName); using (var stream = new FileStream(fullPath, FileMode.Create)) { file.CopyTo(stream); } } imageId = _serviceImage.GetIdInsertedImage(fullPath); job.ImageId = imageId; } job.UserId = UserId; job.PostDate = DateTime.Now; job.CategoryId = jobDTO.CategoryId; job.CityId = jobDTO.CityId; job.Title = jobDTO.Title; job.Salary = jobDTO.Salary; job.TypeJobId = jobDTO.TypeJobId; job.EndDate = jobDTO.FinishedOn; job.Contact = jobDTO.Contact; await _jobRepository.Add(job); }
public async Task <int> Handle(CreateJobCommand request, CancellationToken cancellationToken) { var job = new Job { JobNumber = request.JobNumber, Description = request.Description, Location = request.Location, CoordinatorId = request.CoordinatorId, DateReceived = request.DateReceived, DateScheduled = request.DateScheduled, }; await _repo.Add(job); return(job.Id); }
public async Task <BaseResponse> Add(AddJobRequest model) { var job = new Job(); job.Name = model.Name; job.Description = model.Description; job.StartDate = model.StartDate; job.JobType = (JobType)model.Type; job.UserId = _parameter.UserId; var result = await _jobRepository.Add(job); if (result.State != State.Success) { _logManager.Error(result.ToString()); } return(result); }
public static void CreateJob(IJobRepository jobRepository, PMSAdmin.Domain.Model.Jobs.Job adminJob) { var jobCustomFields = AdminMigrationUtility.DefinedCustomFields.Where(d => adminJob.CustomFieldTypeIdList.Contains(d.Id)) .Select( c => new JobCustomField( new JobCustomFieldId(Period.Id, new SharedJobCustomFieldId(c.Id.Id), new SharedJobId(adminJob.Id.Id)), new SharedJobCustomField(new SharedJobCustomFieldId(c.Id.Id), c.Name, c.DictionaryName, c.MinValue, c.MaxValue, c.TypeId))).ToList(); var jobJobIndices = jobIndices.Select(j => new JobJobIndex(j.Id, true, true, true)).ToList(); var job = new Job(Period, new SharedJob(new SharedJobId(adminJob.Id.Id), adminJob.Name, adminJob.DictionaryName), jobCustomFields, jobJobIndices); jobRepository.Add(job); Jobs.Add(job); }
public async Task <IActionResult> Create(JobViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // TODO: add converters var job = new Job { CompanyName = model.CompanyName, Description = model.Description, KMWebLink = model.KMWebLink, OfficialSiteWebLink = model.OfficialSiteWebLink, IsActive = model.IsActive }; await jobRepository.Add(job); return(Ok(job)); }
public string CreateJob(string scheduleSerializeObject, string jobId = "") { var schedule = JsonSerializer.Deserialize <Schedule>(scheduleSerializeObject); Job job = new Job(); job.AgentId = schedule.AgentId == null ? Guid.Empty : schedule.AgentId.Value; job.CreatedBy = schedule.CreatedBy; job.CreatedOn = DateTime.Now; job.EnqueueTime = DateTime.Now; job.JobStatus = JobStatusType.New; job.ProcessId = schedule.ProcessId == null ? Guid.Empty : schedule.ProcessId.Value; job.Message = "Job is created through internal system logic."; jobRepository.Add(job); _hub.Clients.All.SendAsync("botnewjobnotification", job.AgentId.ToString()); return("Success"); }
public OperationResult CreateUpdateMachinePriceTableJob(Machine machine) { if (machine == null) { throw new ArgumentNullException(nameof(machine)); } var job = new Job { JobType = JobType.UpdateMachineProductTable, ScheduledDateTime = DateTime.MinValue, Data = machine.Id.ToString() }; _jobRepository.Add(job); _jobRepository.Save(); return(OperationResult.Success); }
public JobStatus Order(Order order) { try { order.Validate(_mediaInfoFacade, _timeProvider); } catch { _logging.LogWarning("Failed to validate order", order); throw; } var job = Mapper.Map <Job>(order); if (order.Format == StateFormat.custom) { _logging.LogWarning($"Custom format received : {order.CustomFormat}", job.Urn); } _jobRepository.Add(job); _logging.LogInfo($"Received valid order.", job); return(Mapper.Map <JobStatus>(job)); }
public void ModifyJob() { if (String.IsNullOrWhiteSpace(ModifiedJob)) { MessageBox.Show("Please do not leave any fields blank.", "Input Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (_jobs.Add(ModifiedJob.Trim())) { MessageBox.Show($"The job, {ModifiedJob}, was modified.", "Operation Successful", MessageBoxButton.OK, MessageBoxImage.Information); TryClose(true); } else { MessageBox.Show($"Unable to modify the job, {ModifiedJob}.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CreateJob(JobLocationRequest jobLocationRequest) { try { var locationStart = _locationRepository.Get(jobLocationRequest.Start); var locationDestination = _locationRepository.Get(jobLocationRequest.Destination); if (locationStart == null || locationDestination == null) { throw new Exception("No location found"); } var job = new Job() { Status = JobStatus.StatusPending, CreatedDate = DateTime.Now }; _jobRepository.Add(job); var startGoal = new Goal() { JobId = job.JobId, LocationId = jobLocationRequest.Start, Status = "pending" }; var destinationGoal = new Goal() { JobId = job.JobId, LocationId = jobLocationRequest.Destination, Status = "pending" }; _goalRepository.Add(startGoal); _goalRepository.Add(destinationGoal); } catch (Exception e) { throw new Exception(e.ToString()); } }
public void AddJob() { if (string.IsNullOrWhiteSpace(NewJob)) { MessageBox.Show("Please do not leave any fields blank.", "Input Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (_jobs.Add(NewJob.Trim())) { MessageBox.Show($"The job, {NewJob}, was added to the database.", "Operation Successful", MessageBoxButton.OK, MessageBoxImage.Information); NewJob = ""; TryClose(true); } else { MessageBox.Show($"Unable to add the job, {NewJob}, to the database.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }