public async Task <ActionResult> Add(TaskJobInfo info) { AjaxResult ajaxResult = new AjaxResult(); if (info.JobID == 0) { info.LastExecuteTime = DateTime.Now; var jobId = _yunYingRepository.Insert(info); if (jobId > 0) { info.JobID = (int)jobId; await _quartzManager.CreateJob(info); ajaxResult.IsOk = true; ajaxResult.Msg = "添加成功"; } else { ajaxResult.IsOk = false; ajaxResult.Msg = "添加失败"; } } else { var updateInfo = _yunYingRepository.GetModel <TaskJobInfo>(new { JobId = info.JobID }); string oldJobName = updateInfo.JobName; updateInfo.JobName = info.JobName; updateInfo.JobDesc = info.JobDesc; updateInfo.JobClassName = info.JobClassName; updateInfo.CronExpression = info.CronExpression; updateInfo.ApiUrl = Convert.ToString(info.ApiUrl); if (_yunYingRepository.Update(updateInfo) > 0) { await _quartzManager.DeleteJob(oldJobName); await _quartzManager.CreateJob(updateInfo); ajaxResult.IsOk = true; ajaxResult.Msg = "更新成功"; } else { ajaxResult.IsOk = false; ajaxResult.Msg = "更新失败"; } } return(Json(ajaxResult)); }