public IQueryable <Job> GetBatchStatus(string batchId, int numOfRecords = 1000, string continuationToken = "") { try { // Parameter Validations GeresAssertionHelper.AssertNullOrEmpty(batchId, "batchId"); // Log the query request GeresEventSource.Log.WebApiMonitoringQueryBatchReceived(batchId); using (var repo = RepositoryFactory.CreateJobsRepository(CloudConfigurationManager.GetSetting(GlobalConstants.STORAGE_CONNECTIONSTRING_CONFIGNAME))) { var jobEntities = repo.GetJobs(batchId, numOfRecords, ref continuationToken); if (jobEntities == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } List <Job> jobs = new List <Job>(); foreach (JobEntity je in jobEntities) { Job job = JobEntity.ConvertToJob(je); jobs.Add(job); } // If the continuation token is not null, add it to the HTTP Header if (!string.IsNullOrEmpty(continuationToken)) { System.Web.HttpContext.Current.Response.AddHeader("gerespagingtoken", continuationToken); } // Log the query completion GeresEventSource.Log.WebApiMonitoringQueryBatchSuccessful(batchId, jobs.Count); return(jobs.AsQueryable()); } } catch (HttpResponseException ex) { throw ex; } catch (ArgumentException ex) { Trace.TraceWarning("WebAPI - JobMonitorController -- Invalid parameter passed into system: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); GeresEventSource.Log.WebApiBatchMonitoringInvalidParameterReceived(batchId, ex.Message, ex.StackTrace); throw new HttpResponseException(HttpStatusCode.BadRequest); } catch (Exception ex) { Trace.TraceError("WebAPI - JobMonitorController -- Unknown exception occured: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); GeresEventSource.Log.WebApiUnknownExceptionOccured(ex.Message, ex.StackTrace); throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public Job GetJobStatus(string jobId, string batchId = "") { try { // Parameter Assertions GeresAssertionHelper.AssertNullOrEmpty(jobId, "jobId"); // Logging the message GeresEventSource.Log.WebApiMonitoringQueryJobReceived(jobId); // Core execution logic using (var repo = RepositoryFactory.CreateJobsRepository(CloudConfigurationManager.GetSetting(GlobalConstants.STORAGE_CONNECTIONSTRING_CONFIGNAME))) { JobEntity jobEntity = null; if (!string.IsNullOrEmpty(batchId)) { jobEntity = repo.GetJob(jobId, batchId); } else { jobEntity = repo.GetJob(jobId); } if (jobEntity == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } Job job = JobEntity.ConvertToJob(jobEntity); GeresEventSource.Log.WebApiMonitoringQueryJobSuccessful(job.JobId, job.JobType); return(job); } } catch (HttpResponseException ex) { throw ex; } catch (ArgumentException ex) { Trace.TraceWarning("WebAPI - JobMonitorController -- Invalid parameter passed into system: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); GeresEventSource.Log.WebApiJobMonitoringInvalidParameterReceived(jobId, ex.Message, ex.StackTrace); throw new HttpResponseException(HttpStatusCode.BadRequest); } catch (Exception ex) { Trace.TraceError("WebAPI - JobMonitorController -- 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 Job GetJob(string jobId, string batchId) { GeresEventSource.Log.EngineJobHostLookingUpJobInRepository(jobId, batchId); var job = new Job(); using (var repo = RepositoryFactory.CreateJobsRepository(CloudConfigurationManager.GetSetting(GlobalConstants.STORAGE_CONNECTIONSTRING_CONFIGNAME))) { var jobEntity = repo.GetJob(jobId, batchId); if (jobEntity != null) { job = JobEntity.ConvertToJob(jobEntity); } else { throw new ApplicationException("Unable to find job with ID in repository: " + jobId + " and batch ID " + batchId); } } return(job); }