private void finishButton_Click(object sender, EventArgs e) { JobExecutionController.UpdateDatabase("OrderJob", "status", 2, "id_OrderJob", currentJob.id_OrderJob); JobExecutionController.UpdateDatabase("Userr", "isBusy", 1, "ID", workerID); activeJobTimer.Stop(); jobTotalTimer.Stop(); clockTimer.Stop(); MessageBox.Show("Jūs užbaigėte paskirtą užduotį per " + FormatToTime(diffTicks), "Užduoties pabaiga"); BaseForm form = new BaseForm(workerID); form.Show(); Close(); }
public void Execute_a_job_with_job_data_map() { // Arrange // - Add a job into the test scheduler IScheduler sched = GetTestScheduler(); IJobDetail job = JobBuilder.Create <NoOpJob>() .WithIdentity("TestJob2", "TestGroup") .UsingJobData("MyParam1", "Initial Data") .Build(); sched.AddJob(job, true); // - Setup the mock HTTP Request var request = new Mock <HttpRequestBase>(); var context = new Mock <HttpContextBase>(); context.SetupGet(x => x.Request).Returns(request.Object); NameValueCollection formParameters = new NameValueCollection(); formParameters.Add("jdm_MyParam1", "Working on the railroad"); request.SetupGet(x => x.Form).Returns(formParameters); // - Create the fake instance repo and the job execution controller IInstanceRepository instanceRepo = new FakeInstanceRepository(); instanceRepo.Save(GetTestInstance()); JobExecutionController jec = new JobExecutionController(instanceRepo); // - Set the mocked context for the controller jec.ControllerContext = new ControllerContext(context.Object, new RouteData(), jec); // Act ActionResult result = jec.RunNow("MyTestInstance", "TestGroup", "TestJob2"); // - Get the triggers of the job IList <ITrigger> trigOfJob = sched.GetTriggersOfJob(JobKey.Create("TestJob2", "TestGroup")); //Assert Assert.IsTrue(result is ContentResult && ((ContentResult)result).Content == "Job execution started"); Assert.IsTrue(trigOfJob.Count() > 0); Assert.AreEqual(trigOfJob[0].JobDataMap["MyParam1"], "Working on the railroad"); }
private void LoadCurrentJob() { currentJob = JobExecutionController.GetOrderJob(workerID); Job jobDescription = JobExecutionController.GetJobDescription(currentJob); if (currentJob == null) { noTasksLabel.Text = "Šiuo metu neturite priskirtų darbų, galite pailsėti :)"; if (timerHasBeenStarted) { return; } activeJobTimer.Tick += new EventHandler(CheckForActiveJobs); activeJobTimer.Interval = 1000; activeJobTimer.Start(); ToogleJobInfo(false); timerHasBeenStarted = !timerHasBeenStarted; } else { playSimpleSound(); ToogleJobInfo(true); taskPlaceLabel.Text = "Sandėlis " + currentJob.place; jobTitleLabel.Text = jobDescription.name; jobTotalTimer.Tick += new EventHandler(UpdateTotalJobTime); jobTotalTimer.Interval = 1000; jobTotalTimer.Start(); activeJobTimer.Stop(); } }
public void Execute_a_job() { // Arrange // - Add a job into the test scheduler IScheduler sched = GetTestScheduler(); IJobDetail job = JobBuilder.Create <NoOpJob>() .WithIdentity("TestJob", "TestGroup") .Build(); sched.AddJob(job, true); // - Setup the mock HTTP Request var request = new Mock <HttpRequestBase>(); var context = new Mock <HttpContextBase>(); context.SetupGet(x => x.Request).Returns(request.Object); NameValueCollection formParameters = new NameValueCollection(); // NOTE: adding items to the formParameter collection is possible here request.SetupGet(x => x.Form).Returns(formParameters); // - Create the fake instance repo and the job execution controller IInstanceRepository instanceRepo = new FakeInstanceRepository(); instanceRepo.Save(GetTestInstance()); JobExecutionController jec = new JobExecutionController(instanceRepo); // - Set the fake request for the controller jec.ControllerContext = new ControllerContext(context.Object, new RouteData(), jec); // Act ActionResult result = jec.RunNow("MyTestInstance", "TestGroup", "TestJob"); //Assert Assert.IsTrue(result is ContentResult && ((ContentResult)result).Content == "Job execution started"); }
public JobExecutionControllerTests() { _mediator = Mock.Of <IMediator>(); _controller = new JobExecutionController(_mediator); }