public void ShouldBeAbleToRunJobWithSpecifiedStepNumber() { string name = MethodBase.GetCurrentMethod().Name; TestWorker.ValueToCheck = false; StepTestWorker.ValueToCheck = false; JobManagerService jc = GetTestJobConductor(name); string jobName = "Job_" + name; jc.AddWorker(jobName, typeof(TestWorker).AssemblyQualifiedName, "TestWorker"); jc.AddWorker(jobName, typeof(StepTestWorker).AssemblyQualifiedName, "StepTestWorker"); Expect.IsFalse(TestWorker.ValueToCheck); Expect.IsFalse(StepTestWorker.ValueToCheck); bool? finished = false; AutoResetEvent signal = new AutoResetEvent(false); jc.JobFinished += (o, a) => { Expect.IsFalse(TestWorker.ValueToCheck, "testworker value should have been false after job finished"); Expect.IsTrue(StepTestWorker.ValueToCheck, "Step test worker value should have been true after job finished"); finished = true; signal.Set(); }; JobConf conf = jc.GetJob(jobName); jc.RunJob(conf.CreateJob(), 1); signal.WaitOne(10000); Expect.IsTrue(finished.Value, "finished value should have been set"); }
/// <summary> /// 启动 /// </summary> /// <param name="jobkey"></param> /// <returns></returns> public ActionResult RunJob(string jobkey) { _jobManagerService.RunJob(jobkey); var result = new { status = true, message = "" }; return(Json(result, JsonRequestBehavior.AllowGet)); }