private static void AssertJobParameter(Job newJob) { GeresAssertionHelper.AssertNull(newJob, "newJob"); GeresAssertionHelper.AssertNullOrEmpty(newJob.JobName, "newJob.JobName"); GeresAssertionHelper.AssertNull(newJob.Parameters, "newJob.Parameters"); GeresAssertionHelper.AssertNullOrEmptyOrWhitespace(newJob.JobType, "newJob.JobType"); GeresAssertionHelper.AssertNullOrEmptyOrWhitespace(newJob.JobProcessorPackageName, "newJob.JobProcessorPackageName"); GeresAssertionHelper.AssertNullOrEmptyOrWhitespace(newJob.TenantName, "newJob.TenantName"); GeresAssertionHelper.AssertLength(newJob.TenantName, "newJob.TenantName", 1, 15); }
public List <string> SubmitJobs([FromBody] List <Job> newJobs, string batchId = "") { try { // Parameter validations GeresAssertionHelper.AssertNull(newJobs, "newJobs"); foreach (var j in newJobs) { AssertJobParameter(j); } var logJobs = string.Join(", ", newJobs.Select(j => j.JobName).ToArray()); GeresEventSource.Log.WebApiSubmitJobsReceived(newJobs.Count, logJobs, logJobs, batchId); var jobIds = _jobController.SubmitJobs(newJobs, batchId); GeresEventSource.Log.WebApiSubmitJobsSuccessful(newJobs.Count, string.Join(", ", jobIds.ToArray()), batchId); return(jobIds); } catch (ArgumentException ex) { Trace.TraceWarning("WebAPI - JobController -- Invalid job passed into system: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); GeresEventSource.Log.WebApiSubmitJobsInvalidParameterSubmitted(batchId, ex.Message, ex.StackTrace); throw new HttpResponseException(HttpStatusCode.BadRequest); } catch (InvalidOperationException ex) { Trace.TraceWarning("WebAPI - JobController -- Job could not be submitted to system: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); var logJobs = string.Join(", ", newJobs.Select(j => j.JobName).ToArray()); GeresEventSource.Log.WebApiSubmitJobsFailed(newJobs.Count, logJobs, logJobs, batchId, ex.Message, ex.StackTrace); throw new HttpResponseException(HttpStatusCode.BadRequest); } catch (Exception ex) { Trace.TraceError("WebAPI - JobController -- Unknown exception occured: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); GeresEventSource.Log.WebApiUnknownExceptionOccured(ex.Message, ex.StackTrace); throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
private static void AssertBatchParameter(Batch batch) { GeresAssertionHelper.AssertNull(batch, "batch"); GeresAssertionHelper.AssertNullOrEmpty(batch.BatchName, "batch.BatchName"); }