public static void Main(string[] args) { var jobbrClient = new JobbrClient("http://localhost:1337"); var allJobs = jobbrClient.GetAllJobs(); if (allJobs.Count == 0) { Console.WriteLine("At least one job is required to run this demo. Press enter to quit..."); Console.ReadLine(); return; } var jobId = allJobs.First().Id; var trigger = jobbrClient.AddTrigger(jobId, new InstantTriggerDto { IsActive = true, UserDisplayName = "userName" }); Console.WriteLine("Got Trigger with Id:" + trigger.Id); var jobRuns = jobbrClient.GetJobRunsByTriggerId(jobId, trigger.Id); Console.WriteLine("There are {0} jobruns assigned to this trigger id.", jobRuns.Count); var jobRun = jobbrClient.GetJobRunById(jobRuns[0].JobRunId); Console.WriteLine("Current State: " + jobRun.State); Console.WriteLine("------------------------------------------------------------------------------"); Console.ReadLine(); var createdTrigger = jobbrClient.AddTrigger(jobId, new ScheduledTriggerDto { IsActive = true, UserDisplayName = "userName", StartDateTimeUtc = DateTime.UtcNow.AddMinutes(30) }); Console.WriteLine("Created FutureTrigger with Id:" + trigger.Id + ", IsActive: " + createdTrigger.IsActive); var futureTrigger = jobbrClient.GetTriggerById <ScheduledTriggerDto>(jobId, createdTrigger.Id); Console.WriteLine("Got FutureTrigger by Id:" + trigger.Id + ", IsActive: " + createdTrigger.IsActive); var disableTriggerInfo = new ScheduledTriggerDto() { Id = futureTrigger.Id, IsActive = false }; var dectivatedTrigger = jobbrClient.UpdateTrigger(jobId, disableTriggerInfo); Console.WriteLine("Disabled FutureTrigger width Id:" + trigger.Id + ", IsActive: " + dectivatedTrigger.IsActive); Console.WriteLine("Press enter to quit..."); Console.ReadLine(); }
public void AddRecurringTrigger() { using (this.GivenRunningServerWithWebApi()) { var client = new JobbrClient(this.BackendAddress); var job = new Job(); this.JobStorage.AddJob(job); var triggerDto = client.AddTrigger(job.Id, new RecurringTriggerDto { Comment = "test" }); Assert.IsNotNull(triggerDto); Assert.IsTrue(triggerDto.Id > 0); } }