public void Given_work_item() { var definition = JobFactory.Interval("Foo1", () => { return Task.Factory.StartNew(() => Console.WriteLine("Foo1")); }, TimeSpan.FromMinutes(10)); _item = new JobItem(new DefaultSchedulerContext(), definition, null); }
public void Add(JobItem item) { if (IsJobRegisterd(item.JobKey)) { throw new InvalidOperationException("Job with key " + item.JobKey + " already registered.\r\n" + "You can use IsJobRegisterd to check if job is already registered"); } _items.TryAdd(item.JobKey, item); }
public void Add(JobItem item) { if (IsJobRegisterd(item.JobKey)) { throw new InvalidOperationException("Job with key " + item.JobKey + " already registered.\r\n" + "You can use IsJobRegisterd to check if job is already registered"); } _items.TryAdd(item.JobKey, item); }
public void Given_work_item() { var ctx = new TestSchedulerContext(); // Make workitem think that it was created yesterday ctx.MoveToYesterday(); _item = WorkItemFactory.Create(ctx); // Now update date to today, this // will make workitem applicable for scheduling ctx.MoveToNow(); // Force workitem to reschedule _item.UpdateState(); //Console.WriteLine("bo ya:" + _item.Status); }
public void Given_work_item() { var state = TempFolderStateProvider.CreateInTempFolder("When_work_item_has_not_run_since_before_interval" + Guid.NewGuid().ToString()); state.Store("Foo1", new WorkState { LastCompleteTime = new DateTime(11, 10, 09) }); var ctx = new TestSchedulerContext(); ctx.State = state; // Make workitem with LastComplete from 9-10-2011 _item = WorkItemFactory.Create(ctx); // Force workitem to reschedule _item.UpdateState(); }
public void Given_work_item() { var ctx = new TestSchedulerContext(); _item = WorkItemFactory.Create(ctx); // Make item think that now tomorrow, so // it became applicable for scheduling ctx.MoveToTommorrow(); _item.UpdateState(); _item.Run(); // and .. wait until it will complete while (true) { if (_item.Status == JobStatus.Pending) { break; } Thread.Sleep(200); } }
private static string GatherJobReport(JobItem jobItem) { if (jobItem.PreviousRuns.Count == 0) { return("N/A"); } var message = new StringBuilder(); var average = Math.Round(jobItem.PreviousRuns.Average(x => (x.Completed - x.Started).TotalSeconds), 2); message.AppendLine("Average execution time: " + average + "s."); var failedRuns = jobItem.PreviousRuns.Where(x => x.Result == JobRunResult.Failure).ToList(); if (failedRuns.Count != 0) { message.AppendLine("Job failed at least " + failedRuns.Count + " times."); } return(message.ToString()); }
private static JobHealth GatherJobHealth(JobItem x) { return(x.PreviousRuns.Any(xx => xx.Result == JobRunResult.Failure) ? JobHealth.Bad : JobHealth.Good); }
private static string GatherJobReport(JobItem jobItem) { if (jobItem.PreviousRuns.Count == 0) { return "N/A"; } var message = new StringBuilder(); var average = Math.Round(jobItem.PreviousRuns.Average(x => (x.Completed - x.Started).TotalSeconds), 2); message.AppendLine("Average execution time: " + average + "s."); var failedRuns = jobItem.PreviousRuns.Where(x => x.Result == JobRunResult.Failure).ToList(); if (failedRuns.Count != 0) { message.AppendLine("Job failed at least " + failedRuns.Count + " times."); } return message.ToString(); }
private static JobHealth GatherJobHealth(JobItem x) { return x.PreviousRuns.Any(xx => xx.Result == JobRunResult.Failure) ? JobHealth.Bad : JobHealth.Good; }