예제 #1
0
        public async Task<BatchJobExecutionResult> Run(BatchRunResult runResult, Stopwatch stopWatch = null)
        {
            stopWatch = stopWatch ?? Stopwatch.StartNew();

            _setBatchJobExecutionStatus.Starting(runResult);

            var batchJobExecutionResult = await _batchJobExecutionService.Execute(runResult.BatchJob);

            runResult.MillisecondsTaken = Convert.ToDecimal(stopWatch.Elapsed.TotalMilliseconds);
            _setBatchJobExecutionStatus.Complete(runResult, batchJobExecutionResult);
            return batchJobExecutionResult;
        }
예제 #2
0
        public BatchRun Create(Batch batch)
        {
            if (batch == null)
                return null;
            BatchJob jobAlias = null;

            var subQuery = QueryOver.Of<BatchRunResult>()
                .Where(result => result.Status != JobExecutionStatus.Failed && result.BatchJob.Id == jobAlias.Id)
                .Select(result => result.Id);

            var jobs = _statelessSession.QueryOver(() => jobAlias)
                .Where(job => job.Batch.Id == batch.Id)
                .WithSubquery.WhereNotExists(subQuery)
                .List();

            // we need to make sure that the site is loaded from the correct session
            var site = _statelessSession.Get<Site>(batch.Site.Id);
            return _statelessSession.Transact(session =>
            {
                var now = CurrentRequestData.Now;
                var batchRun = new BatchRun
                {
                    Batch = batch,
                    BatchRunResults = new List<BatchRunResult>(),
                    Site = site,
                    CreatedOn = now,
                    UpdatedOn = now
                };
                session.Insert(batchRun);
                for (int index = 0; index < jobs.Count; index++)
                {
                    BatchJob batchJob = jobs[index];
                    var batchRunResult = new BatchRunResult
                    {
                        BatchJob = batchJob,
                        Status = JobExecutionStatus.Pending,
                        ExecutionOrder = index,
                        BatchRun = batchRun,
                        Site = site,
                        CreatedOn = now,
                        UpdatedOn = now
                    };
                    batchRun.BatchRunResults.Add(batchRunResult);
                    session.Insert(batchRunResult);
                }
                return batchRun;
            });
        }
예제 #3
0
 public PartialViewResult Show(BatchRunResult result)
 {
     return PartialView(result);
 }