Beispiel #1
0
        public void GetJobRunById()
        {
            using (this.GivenRunningServerWithWebApi())
            {
                var client = new JobbrClient(this.BackendAddress);

                var job = new Job();
                this.JobStorage.AddJob(job);

                var trigger = new RecurringTrigger();
                this.JobStorage.AddTrigger(job.Id, trigger);

                var jobRun = new JobRun {
                    Job = new Job {
                        Id = job.Id
                    }, Trigger = new RecurringTrigger {
                        Id = trigger.Id
                    }
                };
                this.JobStorage.AddJobRun(jobRun);

                var jobRunDto = client.GetJobRunById(jobRun.Id);

                Assert.IsNotNull(jobRunDto);
                Assert.AreEqual(jobRun.Id, jobRunDto.JobRunId);
                Assert.AreEqual(jobRun.Job.Id, jobRunDto.JobId);
                Assert.AreEqual(jobRun.Trigger.Id, jobRunDto.TriggerId);
            }
        }
Beispiel #2
0
        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();
        }