/// <summary> /// Deletes the specified job instance /// </summary> /// <param name="job"></param> /// <returns>Indicates whether the operation was successful</returns> public async Task <bool> DeleteAsync(JobInstance jobInstance) { var deleteOperation = TableOperation.Delete(jobInstance); var result = await JobInstancesTable.ExecuteAsync(deleteOperation); var history = await GetJobInstanceAsync(jobInstance.JobId, jobInstance.StartedOn, jobInstance.InstanceId); if (history != null) { deleteOperation = TableOperation.Delete(history); _ = await JobInstancesTable.ExecuteAsync(deleteOperation); } var succeeded = result.HttpStatusCode >= 200 && result.HttpStatusCode < 300; if (succeeded) { //TODO if we got here, but this fails then we have orphan records in the details table. //TODO return more than a simple boolean and/or create a cleanup method that can run on a schedule for such events JobServiceHelper.DeleteAllEntitiesInBatches(JobInstanceDetailsTable, jobInstance.PartitionKey); } return(succeeded); }
/// <summary> /// Deletes all the associated entities for the specified job instance. This does not delete the job instance. /// </summary> /// <param name="jobInstanceProviderKey"></param> /// <returns>TODO// what should we return???</returns> public async Task DeleteAll(Guid instanceId) { await JobServiceHelper.DeleteAllEntitiesInBatchesAsync(JobInstanceDetailsTable, instanceId.ToString()); }