public IActionResult Create([FromBody] JobSubmissionRequest model)
        {
            var user       = _userService.GetByUserName(User.FindFirstValue(ClaimTypes.Name));
            var submission = _mapper.Map <JobSubmission>(model);

            if (!_jobService.Exists(submission.JobId))
            {
                return(Ok(new BaseResponse("Job Not Found!")));
            }

            if (_jobSubmissionService.AlreadySubmitted(user.Client.Id, submission.JobId))
            {
                return(Ok(new BaseResponse("Already Submitted!")));
            }

            if (_jobSubmissionService.AlreadyAcceptedOtherSubmit(submission.JobId))
            {
                return(Ok(new BaseResponse("Already Accepted Other Submission!")));
            }

            submission.ClientId = user.Client.Id;
            var m = _crudService.Create(submission);

            return(Ok(new DataResponse <JobSubmissionResponse>(_mapper.Map <JobSubmissionResponse>(m))));
        }
        public IActionResult Create([FromBody] JobSubmissionRequest model)
        {
            var clientId   = long.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));
            var submission = _mapper.Map <JobSubmission>(model);

            if (!_jobService.Exists(submission.JobId))
            {
                return(NotFound(new BaseResponse("Job Not Found!")));
            }

            if (_jobSubmissionService.AlreadySubmitted(clientId, submission.JobId))
            {
                return(Ok(new BaseResponse("Already Submitted!")));
            }

            if (_jobSubmissionService.AlreadyAcceptedOtherSubmit(submission.JobId))
            {
                return(Ok(new BaseResponse("Already Accepted Other Submission!")));
            }

            submission.ClientId = clientId;
            var m = _jobSubmissionService.Create(submission);

            return(CreatedAtAction(nameof(GetList), new { id = m.JobId },
                                   new DataResponse <JobSubmissionResponse>(_mapper.Map <JobSubmissionResponse>(m))));
        }
Ejemplo n.º 3
0
        public async Task <string> StartDataPackage(JobSubmission job, RequestedTime dateMode, int?year, int?month, int?day, List <string> variables)
        {
            var time = new TimeMode();

            if (dateMode == RequestedTime.Before)
            {
                time.Kind = "before";
                time.Date = new Date()
                {
                    Year = year.Value, Month = month, Day = day
                };
            }
            else if (dateMode == RequestedTime.Exact)
            {
                time.Kind = "exact";
                time.Date = new Date()
                {
                    Year = year.Value, Month = month, Day = day
                };
            }
            else
            {
                time.Kind = "latest";
            }

            var command = new JobSubmissionRequest()
            {
                East      = job.East,
                West      = job.West,
                North     = job.North,
                South     = job.South,
                Variables = GetCustomRequest(variables),
                TimeMode  = time
            };

            try {
                var result = await _connection.SubmitJobAsync(command);

                return(result.Id.ToString());
            } catch (Exception e)
            {
                _logger.LogCritical("Job could not be submitted to the geotemporal engine. The error was: " + e.Message);
                return(null);
            }
        }
Ejemplo n.º 4
0
        public async Task <string> StartProJob(JobSubmission job)
        {
            var command = new JobSubmissionRequest()
            {
                East      = job.East,
                West      = job.West,
                North     = job.North,
                South     = job.South,
                Variables = GetReportRequest(true),
                TimeMode  = new TimeMode {
                    Kind = "latest", Date = null
                }
            };

            try {
                var result = await _connection.SubmitJobAsync(command);

                return(result.Id.ToString());
            } catch (Exception)
            {
                _logger.LogCritical("Job could not be submitted to EcoSet.");
                return("");
            }
        }
Ejemplo n.º 5
0
        public async Task <string> StartJob(JobSubmission job)
        {
            var command = new JobSubmissionRequest()
            {
                East      = job.East,
                West      = job.West,
                North     = job.North,
                South     = job.South,
                Variables = GetReportRequest(false),
                TimeMode  = new TimeMode {
                    Kind = "latest", Date = null
                }
            };

            try {
                var result = await _connection.SubmitJobAsync(command);

                return(result.Id.ToString());
            } catch (Exception e)
            {
                _logger.LogCritical("Job could not be submitted to the geotemporal engine. The error was: " + e.Message);
                return(null);
            }
        }