本文整理汇总了C#中Quartz.Impl.JobDetailImpl类的典型用法代码示例。如果您正苦于以下问题:C# JobDetailImpl类的具体用法?C# JobDetailImpl怎么用?C# JobDetailImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JobDetailImpl类属于Quartz.Impl命名空间,在下文中一共展示了JobDetailImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScheduleJob
public void ScheduleJob(string jobName, ISchedule schedule, Action action)
{
var jobDetail = new JobDetailImpl(jobName, typeof (ActionJob));
jobDetail.JobDataMap[ActionJob.ActionParamName] = action;
_quartzScheduler.ScheduleJob(jobDetail, ((TriggerWrapper) schedule).QuartzTrigger);
_quartzScheduler.Start();
}
示例2: ExceptionPolicyNoRestartImmediately
public void ExceptionPolicyNoRestartImmediately()
{
sched.Start();
JobKey jobKey = new JobKey("ExceptionPolicyNoRestartJob", "ExceptionPolicyNoRestartGroup");
JobDetailImpl exceptionJob = new JobDetailImpl(jobKey.Name, jobKey.Group, typeof (ExceptionJob));
exceptionJob.Durable = true;
sched.AddJob(exceptionJob, false);
ExceptionJob.ThrowsException = true;
ExceptionJob.Refire = false;
ExceptionJob.UnscheduleAllTriggers = false;
ExceptionJob.UnscheduleFiringTrigger = false;
ExceptionJob.LaunchCount = 0;
sched.TriggerJob(jobKey);
int i = 10;
while ((i > 0) && (ExceptionJob.LaunchCount <= 1))
{
i--;
Thread.Sleep(200);
if (ExceptionJob.LaunchCount > 1)
{
break;
}
}
sched.DeleteJob(jobKey);
Assert.AreEqual(1, ExceptionJob.LaunchCount, "The job should NOT have been refired after exception");
}
示例3: TestClone
public void TestClone()
{
JobDetailImpl jobDetail = new JobDetailImpl();
JobDetailImpl clonedJobDetail = (JobDetailImpl) jobDetail.Clone();
Assert.AreEqual(jobDetail, clonedJobDetail);
}
示例4: Start
static void Start(IAppBuilder app) {
// First, initialize Quartz.NET as usual. In this sample app I'll configure Quartz.NET by code.
var schedulerFactory = new StdSchedulerFactory();
var scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
// I'll add some global listeners
//scheduler.ListenerManager.AddJobListener(new GlobalJobListener());
//scheduler.ListenerManager.AddTriggerListener(new GlobalTriggerListener());
// A sample trigger and job
var trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger")
.WithSchedule(DailyTimeIntervalScheduleBuilder.Create()
.WithIntervalInSeconds(6))
.StartNow()
.Build();
var job = new JobDetailImpl("myJob", null, typeof(HelloJob));
scheduler.ScheduleJob(job, trigger);
// A cron trigger and job
var cron = TriggerBuilder.Create()
.WithIdentity("myCronTrigger")
.ForJob(job.Key)
.WithCronSchedule("0/10 * * * * ?") // every 10 seconds
.Build();
scheduler.ScheduleJob(cron);
// A dummy calendar
//scheduler.AddCalendar("myCalendar", new DummyCalendar { Description = "dummy calendar" }, false, false);
app.Use(QuartzNetWebConsole.Setup.Owin("/quartz/", () => scheduler));
}
示例5: AddSelfUpdaterCheckJob
public virtual void AddSelfUpdaterCheckJob()
{
try {
if (ConfigurationManager.AppSettings["SelfUpdaterCronTrigger"] != null)
{
try
{
var jobDetail = new JobDetailImpl("SelfUpdaterChecker", null, typeof(SelfUpdaterCheckJob));
HttpContext.Current.Application.Lock();
var executeJob = !bool.Parse(HttpContext.Current.Application["NugetSelfUpdatesToInstall"].ToString());
HttpContext.Current.Application.UnLock();
jobDetail.JobDataMap.Add("ExcecuteJob", executeJob);
var cronExpression = ConfigurationManager.AppSettings["SelfUpdaterCronTrigger"];
var trigger = new CronTriggerImpl("TriggerSelfUpdaterChecker", "SelfUpdaterChecker", cronExpression);
_sched.ScheduleJob(jobDetail, trigger);
}
catch (Exception e)
{
ErrorHandler.Publish(LogLevel.Error, "Failed to add selfUpdater job", e);
}
}
}
catch (Exception e) {
ErrorHandler.Publish(LogLevel.Error, "Failed to add selfUpdater job", e);
}
}
示例6: TestSameDefaultPriority
public void TestSameDefaultPriority()
{
NameValueCollection config = new NameValueCollection();
config["quartz.threadPool.threadCount"] = "1";
config["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool";
IScheduler sched = new StdSchedulerFactory(config).GetScheduler();
DateTime n = DateTime.UtcNow;
DateTime cal = new DateTime(n.Year, n.Month, n.Day, n.Hour, n.Minute, 1, n.Millisecond);
IMutableTrigger trig1 = new SimpleTriggerImpl("T1", null, cal);
IMutableTrigger trig2 = new SimpleTriggerImpl("T2", null, cal);
JobDetailImpl jobDetail = new JobDetailImpl("JD", null, typeof (TestJob));
sched.ScheduleJob(jobDetail, trig1);
trig2.JobKey = new JobKey(jobDetail.Key.Name);
sched.ScheduleJob(trig2);
sched.Start();
Thread.Sleep(2000);
Assert.AreEqual("T1T2", result.ToString());
sched.Shutdown();
}
示例7: TestSqlStatementInsertsNewRowIntoExistingTable
public void TestSqlStatementInsertsNewRowIntoExistingTable()
{
using (var dbConnection = new SQLiteConnection(ConnectionString))
{
// Arrange
var pluginRunner = new SqlJob();
dbConnection.Open();
const string sql = "create table names (name varchar(20))";
var command = new SQLiteCommand(sql, dbConnection);
command.ExecuteNonQuery();
IJobDetail jobDetail = new JobDetailImpl("TestJob1", typeof(IJob));
jobDetail.JobDataMap.Add("connectionString", ConnectionString);
jobDetail.JobDataMap.Add("providerAssemblyName", @"System.Data.SQLite");
jobDetail.JobDataMap.Add("connectionClass", @"System.Data.SQLite.SQLiteConnection");
jobDetail.JobDataMap.Add("commandClass", @"System.Data.SQLite.SQLiteCommand");
jobDetail.JobDataMap.Add("dataAdapterClass", @"System.Data.SQLite.SQLiteDataAdapter");
jobDetail.JobDataMap.Add("nonQueryCommand", @"insert into names (name) values ('Me')");
_mockJobExecutionContext.SetupGet(p => p.MergedJobDataMap).Returns(jobDetail.JobDataMap);
_mockJobExecutionContext.SetupGet(p => p.JobDetail).Returns(jobDetail);
// Act
pluginRunner.Execute(_mockJobExecutionContext.Object);
// Assert
const string resultSql = "select * from names";
var resultDa = new SQLiteDataAdapter(resultSql, dbConnection);
var ds = new DataSet();
resultDa.Fill(ds, "Results");
Assert.Equal(1, ds.Tables.Count);
Assert.Equal("Me", ds.Tables[0].Rows[0][0]);
}
}
示例8: StartJob
private void StartJob(JobDefinition job)
{
this.EventReporter.Trace("Creating job: " + job.JobName);
if(job.Schedule is JobCronSchedule)
{
}
else if(job.Schedule is JobSimpleSchedule)
{
var type = this.TypeLoader.LoadType(job.AssemblyName, job.ClassName);
var genericJobWrapperType = typeof(JobWrapper<,>);
var combinedJobType = genericJobWrapperType.MakeGenericType(type);
var jobDetail = new JobDetailImpl(job.JobName, combinedJobType);
var simpleSchedule = (JobSimpleSchedule)job.Schedule;
ITrigger trigger;
if (simpleSchedule.DelayStartMinutes != 0)
{
trigger = new SimpleTriggerImpl(job.JobName + "Trigger", DateBuilder.FutureDate(simpleSchedule.DelayStartMinutes,IntervalUnit.Minute), null, SimpleTriggerImpl.RepeatIndefinitely, TimeSpan.FromMinutes(simpleSchedule.IntervalMinutes));
}
else
{
trigger = new SimpleTriggerImpl(job.JobName + "Trigger", null, SimpleTriggerImpl.RepeatIndefinitely, TimeSpan.FromMinutes(simpleSchedule.IntervalMinutes));
}
this.Scheduler.ScheduleJob(jobDetail, trigger);
}
this.EventReporter.Trace("Done Creating " + job.JobName);
}
示例9: TestTriggerFireExclusion
public void TestTriggerFireExclusion()
{
sched.Start();
TestJob.JobHasFired = false;
JobDetailImpl myDesc = new JobDetailImpl("name", "group", typeof(TestJob));
IOperableTrigger trigger = new CronTriggerImpl("trigName", "trigGroup", "0/15 * * * * ?");
AnnualCalendar calendar = new AnnualCalendar();
calendar.SetDayExcluded(DateTime.Now, true);
sched.AddCalendar("calendar", calendar, true, true);
trigger.CalendarName = "calendar";
sched.ScheduleJob(myDesc, trigger);
IOperableTrigger triggerreplace = new CronTriggerImpl("foo", "trigGroup", "name", "group", "0/15 * * * * ?");
triggerreplace.CalendarName = "calendar";
sched.RescheduleJob(new TriggerKey("trigName", "trigGroup"), triggerreplace);
Thread.Sleep(1000 * 20);
Assert.IsFalse(TestJob.JobHasFired, "task must not be neglected - it is forbidden by the calendar");
calendar.SetDayExcluded(DateTime.Now, false);
sched.AddCalendar("calendar", calendar, true, true);
Thread.Sleep(1000 * 20);
Assert.IsTrue(TestJob.JobHasFired, "task must be neglected - it is permitted by the calendar");
sched.DeleteJob(new JobKey("name", "group"));
sched.DeleteCalendar("calendar");
sched.Shutdown();
}
示例10: Service1
public Service1()
{
InitializeComponent();
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
ISchedulerFactory schedFact = new StdSchedulerFactory();
_scheduler = schedFact.GetScheduler();
var parseJob = new JobDetailImpl("ParseJob", "ParserStuff", typeof(ParseJob));
var parseTrigger = new CronTriggerImpl("ParseTime", "ParserStuff", "0 0/10 * * * ?") // Exactly every ten minutes
{
StartTimeUtc = DateTime.UtcNow
};
_scheduler.ScheduleJob(parseJob, parseTrigger);
var summaryJob = new JobDetailImpl("SummaryJob", "SummaryStuff", typeof(SummaryJob));
var summaryTrigger = new CronTriggerImpl("SummaryTime", "SummaryStuff", "0 0 4 1/1 * ? *") // At 04:00 AM every night
{
StartTimeUtc = DateTime.UtcNow
};
_scheduler.ScheduleJob(summaryJob, summaryTrigger);
}
示例11: TestWebRequestJobPassesFireInstanceIdInTheQueryString
public void TestWebRequestJobPassesFireInstanceIdInTheQueryString()
{
const string testFireInstanceId = "123";
using (WebApp.Start<Startup>(BaseHostingAddress)) // base hosting address
{
// Arrange
var pluginRunner = new WebRequest.WebRequestJob();
_mockJobExecutionContext.SetupGet(p => p.FireInstanceId).Returns(testFireInstanceId);
IJobDetail jobDetail = new JobDetailImpl("jobsettings", typeof (IJob));
jobDetail.JobDataMap.Add("actionType", "http");
jobDetail.JobDataMap.Add("method", "GET");
jobDetail.JobDataMap.Add("contentType", "text/plain");
jobDetail.JobDataMap.Add("uri", BaseHostingAddress + "/testapi/test?JobName=TestJob&FireInstanceId={$FireInstanceId}");
_mockJobExecutionContext.SetupGet(p => p.MergedJobDataMap).Returns(jobDetail.JobDataMap);
_mockJobExecutionContext.SetupGet(p => p.JobDetail).Returns(jobDetail);
// Act
pluginRunner.Execute(_mockJobExecutionContext.Object);
// Assert
_mockJobExecutionContext.VerifySet(p => p.Result = "\"" + testFireInstanceId + "\"", Times.Once);
}
}
示例12: ScheduleDailyJob
/// <param name="scheduleConfig">Setting Key from your CloudConfigurations, value format "hh:mm;hh:mm;"</param>
/// <param name="jobType">must inherit from IJob</param>
/// <param name="timeZoneId">See http://alexandrebrisebois.wordpress.com/2013/01/20/using-quartz-net-to-schedule-jobs-in-windows-azure-worker-roles/ for Ids</param>
public void ScheduleDailyJob(string scheduleConfig, Type jobType, string timeZoneId)
{
var schedule = CloudConfigurationManager.GetSetting(scheduleConfig);
if (schedule == "-")
return;
schedule.Split(';').Where(s => !string.IsNullOrWhiteSpace(s)).ToList().ForEach(h =>
{
var index = h.IndexOf(':');
var hour = h.Substring(0, index);
var minutes = h.Substring(index + 1, h.Length - (index + 1));
var job = new JobDetailImpl(jobType.Name + hour + minutes, null,
jobType);
var trigger = TriggerBuilder.Create()
.StartNow()
.WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(Convert.ToInt32(hour,CultureInfo.InvariantCulture),
Convert.ToInt32(minutes, CultureInfo.InvariantCulture))
.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)))
.Build();
sched.ScheduleJob(job, trigger);
});
}
示例13: SettingKeyShouldAlsoSetNameAndGroup
public void SettingKeyShouldAlsoSetNameAndGroup()
{
JobDetailImpl detail = new JobDetailImpl();
detail.Key = new JobKey("name", "group");
Assert.That(detail.Name, Is.EqualTo("name"));
Assert.That(detail.Group, Is.EqualTo("group"));
}
示例14: Start
public void Start()
{
IJobDetail berthInUasgeJob = new JobDetailImpl("NpcMmsJob", "NpcMessageJob", typeof(NpcMmsJob));
var trigger = new CronTriggerImpl("NpcMmsJobTrigger", "NpcMessageJob", "00 0/10 * * * ? *");
_scheduler.ScheduleJob(berthInUasgeJob, trigger);
_scheduler.Start();
}
示例15: Init
public static void Init()
{
var scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
var job = new JobDetailImpl("SearchJob", "jobs", typeof(SearchJob));
var trigger = new CronTriggerImpl("SearchTrigger", "jobs", ConfigurationManager.AppSettings["CronTrigger"]);
scheduler.ScheduleJob(job, trigger);
}