/// <summary> /// Pause a job /// </summary> /// <param name="job">An instance of the BulkJob created by the method CreateJob</param> public async Task PauseAsync(BulkJob job) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("pause", "1"); await BulkOperations(job, parameters); }
private async Task BulkOperations(BulkJob job, Dictionary <string, string> parameters) { try { parameters.Add("token", job.Settings.Token); parameters.Add("name", job.Name); var response = await diffbotCall.GetAsync("bulk", this.version, parameters); if (response["Error"] != null) { job.Error = response["StatusCode"].ToString() + ": " + response["Error"].ToString(); } else { job.Error = null; Jobs jobs = JsonConvert.DeserializeObject <Jobs>(response.ToString()); if (jobs.AllJobs != null) { job.JobStatus = jobs.AllJobs.FirstOrDefault(j => j.Name == job.Name); } else { job.JobStatus = null; } } } catch (Exception ex) { job.Error = ex.InnerException != null ? " " + ex.InnerException.Message : ex.Message; } }
/// <summary> /// Starts the job. /// </summary> /// <param name="job">An instance of the BulkJob created by the method CreateJob</param> public async Task StartAsync(BulkJob job) { try { var response = await diffbotCall.PostAsync("bulk", this.version, job.Settings); if (response["Error"] != null) { job.Error = response["StatusCode"].ToString() + ": " + response["Error"].ToString(); } else { job.Error = null; Jobs jobs = JsonConvert.DeserializeObject <Jobs>(response.ToString()); job.JobStatus = jobs.AllJobs.FirstOrDefault(j => j.Name == job.Name); } } catch (Exception ex) { job.Error = ex.InnerException != null ? " " + ex.InnerException.Message : ex.Message; } }
/// <summary> /// Update the status of a job /// </summary> /// <param name="job">An instance of the BulkJob created by the method CreateJob</param> public async Task UpdateStatusAsync(BulkJob job) { Dictionary <string, string> parameters = new Dictionary <string, string>(); await BulkOperations(job, parameters); }