Example #1
0
        public async Task Execute(JobLocator jobLocator, bool jobIsCompleted)
        {
            try
            {
                var job = await jobRepo.Get(jobLocator.SubscriptionName, jobLocator.JobIdentifier);

                if (job == null)
                {
                    logger.LogError($"Job meta data could not be found for SubscriptionName {jobLocator.SubscriptionName} and JobIdentifier {jobLocator.JobIdentifier}. " +
                                    "This should never happen, probably means there's a bug in the scheduler or somebody has manually messed with the scheduling DB");
                    return;
                }

                await serviceBus.EnsureSubscriptionIsSetup(jobLocator.SubscriptionName);

                await serviceBus.PublishEventToTopic(jobLocator.SubscriptionName, JsonConvert.SerializeObject(job));

                if (jobIsCompleted)
                {
                    await jobRepo.Delete(jobLocator.SubscriptionName, jobLocator.JobIdentifier);
                }
            }
            catch (Exception e)
            {
                logger.LogError(e, "Error in JobExecute logic");
            }
        }
Example #2
0
 private static string JobLocatorToPath(JobLocator jobLocator) => $"/api/Job/{jobLocator.SubscriptionName}/{jobLocator.JobIdentifier}";
Example #3
0
 public async Task <Job> GetJob(JobLocator jobLocator)
 {
     return(await GetAsync <Job>(JobLocatorToPath(jobLocator), functionKeys.GetJob));
 }
Example #4
0
 public async Task DeleteJob(JobLocator jobLocator)
 {
     await DeleteAsync(JobLocatorToPath(jobLocator), functionKeys.DeleteJob);
 }
Example #5
0
 public async Task DeleteJob(JobLocator jobLocator, CancellationToken ct)
 {
     await RemoveJobIfAlreadyExists(jobLocator.JobIdentifier, jobLocator.SubscriptionName, ct);
 }