/// <summary> /// Creates a row mapper for job executions. /// </summary> /// <param name="jobInstance">the job instance of the executions to create (optional)</param> /// <returns>a row mapper for job executions</returns> private RowMapper <JobExecution> GetJobExecutionRowMapper(JobInstance jobInstance = null) { JobParameters jobParameters = null; return((dataRecord, i) => { var wrapper = new DataRecordWrapper(dataRecord); var id = wrapper.Get <long>(0); var jobConfigurationLocation = wrapper.Get <string>(9); if (jobParameters == null) { jobParameters = GetJobParameters(id); } var jobExecution = jobInstance == null ? new JobExecution(id, jobParameters, jobConfigurationLocation) : new JobExecution(jobInstance, id, jobParameters, jobConfigurationLocation); jobExecution.StartTime = wrapper.Get <DateTime?>(1); jobExecution.EndTime = wrapper.Get <DateTime?>(2); jobExecution.Status = dataRecord.IsDBNull(3) ? null : BatchStatus.ValueOf(dataRecord.GetString(3)); jobExecution.ExitStatus = new ExitStatus(wrapper.Get <string>(4), wrapper.Get <string>(5)); jobExecution.CreateTime = wrapper.Get <DateTime>(6); jobExecution.LastUpdated = wrapper.Get <DateTime?>(7); jobExecution.Version = wrapper.Get <int?>(8); return jobExecution; }); }
/// <summary> /// Creates a row mapper that for step executions. /// </summary> /// <param name="jobExecution">the job execution to use when creating the step executions</param> /// <returns>a row mapper</returns> private static RowMapper <StepExecution> GetStepExecutionRowMapper(JobExecution jobExecution) { return((dataRecord, i) => { var wrapper = new DataRecordWrapper(dataRecord); var stepExecution = new StepExecution(wrapper.Get <string>((1)), jobExecution, wrapper.Get <long>((0))) { StartTime = wrapper.Get <DateTime>((2)), EndTime = wrapper.Get <DateTime>((3)), BatchStatus = BatchStatus.ValueOf(wrapper.Get <string>((4))), CommitCount = wrapper.Get <int>((5)), ReadCount = wrapper.Get <int>((6)), FilterCount = wrapper.Get <int>((7)), WriteCount = wrapper.Get <int>((8)), ExitStatus = new ExitStatus(wrapper.Get <string>((9)), wrapper.Get <string>(10)), ReadSkipCount = wrapper.Get <int>((11)), WriteSkipCount = wrapper.Get <int>((12)), ProcessSkipCount = wrapper.Get <int>((13)), RollbackCount = wrapper.Get <int>((14)), LastUpdated = wrapper.Get <DateTime?>(15), Version = wrapper.Get <int?>((16)) }; return stepExecution; }); }
public void ValueOfTest() { BatchStatus st1 = BatchStatus.ValueOf("COMPLETED"); Assert.AreEqual(BatchStatus.Completed, st1); BatchStatus st2 = BatchStatus.ValueOf("STARTING"); Assert.AreEqual(BatchStatus.Starting, st2); BatchStatus st3 = BatchStatus.ValueOf("STARTED"); Assert.AreEqual(BatchStatus.Started, st3); BatchStatus st4 = BatchStatus.ValueOf("STOPPING"); Assert.AreEqual(BatchStatus.Stopping, st4); BatchStatus st5 = BatchStatus.ValueOf("STOPPED"); Assert.AreEqual(BatchStatus.Stopped, st5); BatchStatus st6 = BatchStatus.ValueOf("FAILED"); Assert.AreEqual(BatchStatus.Failed, st6); BatchStatus st7 = BatchStatus.ValueOf("ABANDONED"); Assert.AreEqual(BatchStatus.Abandoned, st7); BatchStatus st8 = BatchStatus.ValueOf("UNKNOWN"); Assert.AreEqual(BatchStatus.Unknown, st8); }
/// <summary> /// Persists the status and version fields of a job execution. /// The job execution must have already been persisted. /// </summary> /// <param name="jobExecution"></param> public void SynchronizeStatus(JobExecution jobExecution) { using (var scope = new TransactionScope(TransactionScopeOption.Required, TransactionOptions)) { var currentVersion = DbOperator.Query <long>(InsertTablePrefix(CurrentVersionJobExecutionQuery), new Dictionary <string, object> { { "id", jobExecution.Id } }); if (currentVersion != jobExecution.Version) { var status = DbOperator.Query <string>(InsertTablePrefix(GetStatusQuery), new Dictionary <string, object> { { "id", jobExecution.Id } }); jobExecution.UpgradeStatus(BatchStatus.ValueOf(status)); jobExecution.Version = (int?)currentVersion; } scope.Complete(); } }
public void ValueOf2Test() { BatchStatus st1 = BatchStatus.ValueOf("COMPLETED1"); }