public JsonResult Create([Bind(Include = "cronSchedule,params")] QuartzJob job) { ResultMessage msg = new ResultMessage(); try { job.jobType = (int)CronJobType.CalAtt; msg = DoValidation(job); if (!msg.Success) { return(Json(msg, JsonRequestBehavior.AllowGet)); } else { IQuartzJobService cs = new QuartzJobService(Settings.Default.db); bool isSucceed = cs.Create(job); msg.Success = isSucceed; msg.Content = isSucceed ? "" : "添加失败"; // 重启任务服务 TaskDispatcher dtt = new TaskDispatcher(Settings.Default.queue); dtt.SendRestartSvcMessage(); return(Json(msg, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new ResultMessage() { Success = false, Content = ex.Message }, JsonRequestBehavior.AllowGet)); } }
//如果存在员工排班,则不可删除 public ActionResult Delete(int id, FormCollection collection) { ResultMessage msg = new ResultMessage(); try { IQuartzJobService js = new QuartzJobService(Settings.Default.db); bool isSucceed = js.Delete(id); msg.Success = isSucceed; msg.Content = isSucceed ? "" : "删除失败"; // 重启任务服务 TaskDispatcher dtt = new TaskDispatcher(Settings.Default.queue); dtt.SendRestartSvcMessage(); return(Json(msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new ResultMessage() { Success = false, Content = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private void restartSvcBtn_Click(object sender, RoutedEventArgs e) { TaskDispatcher dtt = new TaskDispatcher(Settings.Default.queue); dtt.SendRestartSvcMessage(); }