コード例 #1
0
        public ScheduleJobResult StartExport([FromBody] ScheduleJobRequest request)
        {
            log.LogInformation($"StartExport: Url {request?.Url}");

            JobRequest jobRequest = new JobRequest()
            {
                JobUid = Guid.Parse("c3cbb048-05c1-4961-a799-70434cb2f162"), SetupParameters = request, RunParameters = Request.Headers.GetCustomHeaders()
            };

            log.LogInformation($"{nameof(StartExport)}: {JsonConvert.SerializeObject(request)}");
            jobRequest.Validate();
            jobRequest.AttributeFilters = SpecialFilters.ExportFilter;
            string hangfireJobId;

            try
            {
                hangfireJobId = jobRunner.QueueHangfireJob(jobRequest);
            }
            catch (Exception e)
            {
                log.LogError($"Queue VSS job failed with exception {e.Message}", e);
                throw;
            }

            //Hangfire will substitute a PerformContext automatically
            return(new ScheduleJobResult {
                JobId = hangfireJobId
            });
        }
コード例 #2
0
        public void ValidateJobRequestSuccess()
        {
            var request = new JobRequest {
                JobUid = Guid.NewGuid()
            };

            request.Validate();
        }
コード例 #3
0
        // POST api/job
        public JobStatus Post([FromBody] JobRequest req)
        {
            string id;

            try
            {
                req.Validate();

                id = client.SpawnNewJob(UserName, req.JobName, req.DllPath, req.InPath, req.OutFile);
            }
            catch (Exception ex)
            {
                return(new JobStatus()
                {
                    JobId = null, Status = ex.Message
                });
            }
            return(Get(id));
        }
コード例 #4
0
        public ScheduleJobResult RunJob([FromBody] JobRequest request)
        {
            Log.LogInformation($"{nameof(RunJob)}: {JsonConvert.SerializeObject(request)}");
            request.Validate();
            string hangfireJobId;

            try
            {
                hangfireJobId = JobRunner.QueueHangfireJob(request);
            }
            catch (Exception e)
            {
                Log.LogError(e, $"Queue VSS job failed with exception {e.Message}");
                throw;
            }

            //Hangfire will substitute a PerformContext automatically
            return(new ScheduleJobResult {
                JobId = hangfireJobId
            });
        }
コード例 #5
0
        public void ValidateJobRequestFailure()
        {
            var request = new JobRequest();

            Assert.ThrowsException <ServiceException>(() => request.Validate());
        }
コード例 #6
0
        public Task <ContractExecutionResult> RunHangfireJob(JobRequest request, PerformContext context)
        {
            request.Validate();

            return(RunJob(request, context));
        }