/// <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; }); }
public void TestGetDecimal2() { var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(3m)); var result = dataRecordWrapper.Get <long?>(1); Assert.AreEqual(3L, result); }
public void TestGetDecimal2() { var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(3m)); var result = dataRecordWrapper.Get<long?>(1); Assert.AreEqual(3L, result); }
public void TestGetNullable5() { var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(null)); var result = dataRecordWrapper.Get <DateTime?>(1); Assert.IsNull(result); }
public void TestGetNullable3() { var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(2L)); var result = dataRecordWrapper.Get <int?>(1); Assert.AreEqual(2, result); }
public void TestGetNullable5() { var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(null)); var result = dataRecordWrapper.Get<DateTime?>(1); Assert.IsNull(result); }
public void TestGetNullable3() { var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(2L)); var result = dataRecordWrapper.Get<int?>(1); Assert.AreEqual(2, result); }
/// <summary> /// Retrieves job parameters for an execution. /// </summary> /// <param name="executionId">the job execution id</param> /// <returns>the job parameters of that execution</returns> private JobParameters GetJobParameters(long executionId) { var parameters = new OrderedDictionary <string, JobParameter>(16); RowHandler handler = dataRecord => { var wrapper = new DataRecordWrapper(dataRecord); var type = (ParameterType)Enum.Parse(typeof(ParameterType), wrapper.Get <string>(2)); JobParameter parameter; switch (type) { case ParameterType.String: parameter = new JobParameter(wrapper.Get <string>(3), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Long: parameter = new JobParameter(wrapper.Get <long>(5), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Double: parameter = new JobParameter(wrapper.Get <double>(6), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Date: parameter = new JobParameter(wrapper.Get <DateTime>(4), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; default: throw new InvalidOperationException("Unsupported type :[" + type + "]"); //should never happen } parameters.Add(wrapper.Get <string>(1), parameter); }; DbOperator.Select(InsertTablePrefix(FindParamsFromIdQuery), handler, new Dictionary <string, object> { { "id", executionId } }); return(new JobParameters(parameters)); }
public void TestGetNullable4() { var now = DateTime.Now; var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(now)); var result = dataRecordWrapper.Get <DateTime?>(1); Assert.AreEqual(now, result); }
public void TestGetNullable4() { var now = DateTime.Now; var dataRecordWrapper = new DataRecordWrapper(new MockDataRecord(now)); var result = dataRecordWrapper.Get<DateTime?>(1); Assert.AreEqual(now, result); }
/// <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; }; }
/// <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> /// Retrieves job parameters for an execution. /// </summary> /// <param name="executionId">the job execution id</param> /// <returns>the job parameters of that execution</returns> private JobParameters GetJobParameters(long executionId) { var parameters = new OrderedDictionary<string, JobParameter>(16); RowHandler handler = dataRecord => { var wrapper = new DataRecordWrapper(dataRecord); var type = (ParameterType)Enum.Parse(typeof(ParameterType), wrapper.Get<string>(2)); JobParameter parameter; switch (type) { case ParameterType.String: parameter = new JobParameter(wrapper.Get<string>(3), string.Equals(wrapper.Get<string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Long: parameter = new JobParameter(wrapper.Get<long>(5), string.Equals(wrapper.Get<string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Double: parameter = new JobParameter(wrapper.Get<double>(6), string.Equals(wrapper.Get<string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Date: parameter = new JobParameter(wrapper.Get<DateTime>(4), string.Equals(wrapper.Get<string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; default: throw new InvalidOperationException("Unsupported type :[" + type + "]");//should never happen } parameters.Add(wrapper.Get<string>(1), parameter); }; DbOperator.Select(InsertTablePrefix(FindParamsFromIdQuery), handler, new Dictionary<string, object> { { "id", executionId } }); return new JobParameters(parameters); }
/// <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; }); }