public async Task <ApiResult> Delete(string jobId) { if (string.IsNullOrWhiteSpace(jobId)) { return(new ApiResult(ApiResult.Error, "Id is empty/null")); } var job = await _store.GetJob(jobId); if (job == null) { return(new ApiResult(ApiResult.Error, $"Job {jobId} not exists")); } var node = await _sharding.GetNode(job.SchedName, job.SchedInstanceId); if (node == null || !node.IsAvailable()) { return(new ApiResult(ApiResult.Error, $"Sharding node [{job.SchedName}, {job.SchedInstanceId}] is offline")); } var sched = _schedCache.GetOrCreate(node.SchedName, node.SchedInstanceId, node.Provider, node.ConnectionString); // Remove from quartz firstly, then remove from swarm await sched.DeleteJob(new JobKey(jobId)); await sched.UnscheduleJob(new TriggerKey(jobId)); await _store.DeleteJob(jobId); _logger.LogInformation($"Delete job {jobId} success"); return(new ApiResult(ApiResult.SuccessCode, "success")); }
public async Task <IActionResult> Delete(string jobId) { if (string.IsNullOrWhiteSpace(jobId)) { return(new JsonResult(new ApiResult(ApiResult.Error, "Id is empty/null"))); } if (!await _store.CheckJobExists(jobId)) { return(new JsonResult(new ApiResult(ApiResult.Error, $"Job {jobId} not exists"))); } // Remove from quartz firstly, then remove from swarm await _scheduler.DeleteJob(new JobKey(jobId)); await _scheduler.UnscheduleJob(new TriggerKey(jobId)); await _store.DeleteJob(jobId); return(new JsonResult(new ApiResult(ApiResult.SuccessCode, "success"))); }