本文整理汇总了C#中Quartz.Impl.StdSchedulerFactory类的典型用法代码示例。如果您正苦于以下问题:C# StdSchedulerFactory类的具体用法?C# StdSchedulerFactory怎么用?C# StdSchedulerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StdSchedulerFactory类属于Quartz.Impl命名空间,在下文中一共展示了StdSchedulerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuartzService
public QuartzService()
{
InitializeComponent();
logger = LogManager.GetLogger(GetType());
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
scheduler = schedulerFactory.GetScheduler();
}
示例2: TestMethod1
public void TestMethod1()
{
XmlConfigurator.Configure();
log.Info("------- Initializing ----------------------");
// First we must get a reference to a scheduler
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<MyJob>()
.WithIdentity("MyJob")
.Build();
// Trigger the job to run on the next round minute
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("MyTrigger")
.WithCronSchedule("0 0/5 * * * ?")
.Build();
// Tell quartz to schedule the job using our trigger
sched.ScheduleJob(job, trigger);
// Start up the scheduler (nothing can actually run until the
// scheduler has been started)
sched.Start();
sched.Shutdown();
Thread.Sleep(300 * 1000);
}
示例3: OnStart
protected override void OnStart(string[] args)
{
using (System.IO.StreamWriter sw = new System.IO.StreamWriter("E:\\log.txt", true))
{
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "start.");
}
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<HelloWorld>()
.WithIdentity("myJob", "group1")
.Build();
//ITrigger trigger = TriggerBuilder.Create()
// .WithIdentity("myTrigger", "group1")
// .StartNow()
// .WithSimpleSchedule(x => x
// .WithIntervalInHours(1)
// .RepeatForever())
// .Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger", "group1")
.WithCronSchedule("0/5 * * * * ?")
.ForJob("myJob", "group1")
.Build();
sched.ScheduleJob(job, trigger);
}
示例4: JobSchedule
public JobSchedule()
{
var schedFact = new StdSchedulerFactory();
sched = schedFact.GetScheduler();
sched.Start();
}
示例5: OnStart
protected override void OnStart(string[] args)
{
logger.Log(LogLevel.Info, String.Format("Starting Open Payments Processor"));
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
IScheduler sched = schedFact.GetScheduler();
Context ctx = new Context();
JobDetail jobDetail = new JobDetail("myJob", null, typeof(ProcessOpenPaymentJob));
Trigger trigger = TriggerUtils.MakeDailyTrigger(5, 00);
trigger.StartTimeUtc = DateTime.UtcNow;
trigger.Name = "myTrigger1";
sched.ScheduleJob(jobDetail, trigger);
try
{
logger.Log(LogLevel.Info, String.Format("Starting Scheduler"));
sched.Start();
}
catch (Exception ex)
{
logger.Log(LogLevel.Info, String.Format("Exception Starting Scheduler {0}", ex.Message));
throw;
}
}
示例6: TestFactoryCanBeUsedWithEmptyProperties
public Task TestFactoryCanBeUsedWithEmptyProperties()
{
var props = new NameValueCollection();
props["quartz.serializer.type"] = TestConstants.DefaultSerializerType;
StdSchedulerFactory factory = new StdSchedulerFactory(props);
return factory.GetScheduler();
}
示例7: Main
static void Main(string[] args)
{
var factory = new StdSchedulerFactory();
var scheduler = factory.GetScheduler();
scheduler.Start();
while (!scheduler.IsStarted)
{
Console.WriteLine("Waiting for scheduler to start.");
Thread.Sleep(1000);
}
Console.WriteLine("IsStarted={0}", scheduler.IsStarted);
Console.WriteLine("SchedulerInstanceId={0}", scheduler.SchedulerInstanceId);
Console.WriteLine("SchedulerName={0}", scheduler.SchedulerName);
Console.WriteLine("The scheduler is running. Press any key to stop");
Console.ReadKey();
Console.WriteLine("Shutting down scheduler");
scheduler.Shutdown(false);
while (!scheduler.IsShutdown)
{
Console.WriteLine("Waiting for scheduler to shutdown.");
Thread.Sleep(1000);
}
Console.WriteLine("IsShutdown={0}", scheduler.IsShutdown);
Console.WriteLine("The scheduler has been shutdown.");
}
示例8: Main
static void Main(string[] args)
{
try
{
Console.Title = "QMail";
Console.ForegroundColor = ConsoleColor.White;
ISchedulerFactory sf = new StdSchedulerFactory();
Scheduler = sf.GetScheduler();
new TskInspectDetailJobTrigger();
Scheduler.Start();
for (var i = 0; i < 10; i++) {
Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(" ---------------------------------------------------");
Console.WriteLine(" ...................QMail已启动......................");
Console.WriteLine(" ...................请不要关闭此窗口.................");
Console.WriteLine(" ---------------------------------------------------");
for (var i = 0; i < 10; i++)
{
Console.WriteLine();
}
Console.ReadLine();
}
catch (Exception e) {
LogUtil.Logger.Error(e.Message);
}
}
示例9: TaskPoolManager
/// <summary>
/// 静态初始化
/// </summary>
static TaskPoolManager()
{
_taskpoolmanager = new TaskPoolManager();
ISchedulerFactory sf = new StdSchedulerFactory();
_sched = sf.GetScheduler();
_sched.Start();
}
示例10: Scheduler
static Scheduler()
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
QuartzSheduler = schedFact.GetScheduler();
QuartzSheduler.Start();
items = new List<Item>();
}
示例11: Main
static void Main(string[] args)
{
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
IScheduler sched1 = sf.GetScheduler();
JobDetail job = new JobDetail("job1","group1",typeof(SimpleJob));
//DateTime runtime = TriggerUtils.GetEvenMinuteDate(DateTime.UtcNow);//下一分钟
//DateTime runtime = TriggerUtils.GetNextGivenSecondDate(null, 15);//15秒后
//每一秒运行一次 重复十次 开始时间为now 结束时间为null
//SimpleTrigger trigger = new SimpleTrigger("trigger1", "gropp1", "job1", "group1", DateTime.UtcNow, null, 10, TimeSpan.FromSeconds(10));
SimpleTrigger trigger = new SimpleTrigger("trigger1",
"gropp1",
DateTime.UtcNow,
null,
SimpleTrigger.RepeatIndefinitely,
TimeSpan.FromSeconds(1));
sched.ScheduleJob(job,trigger);
LogManager.GetLogger(typeof(Program)).Info("开始循环,每10秒运行一次,重复10次");
sched.Start();
//Thread.Sleep(90 * 1000);
}
示例12: Should_be_possible_to_reschedule_the_collectRequest_that_was_not_collect
public void Should_be_possible_to_reschedule_the_collectRequest_that_was_not_collect()
{
var fakeSession = DataProvider.GetSession();
var package1 = new CollectRequestFactory().CreateCollectRequest(fakeSession);
var collectRequest = package1.Item2;
this.SaveCollectRequest(collectRequest);
var package2 = new CollectRequestFactory().CreateCollectRequest(fakeSession);
var otherCollectRequest = package2.Item2;
this.SaveCollectRequest(otherCollectRequest);
package1.Item1.ScheduleInformation.ExecutionDate.AddSeconds(100);
package2.Item1.ScheduleInformation.ExecutionDate.AddSeconds(100);
var fakeRepository = new CollectRequestRepository(DataProvider);
var scheduler = new StdSchedulerFactory().GetScheduler();
var scheduleController = new ScheduleController(scheduler);
scheduleController.TypeOfExecutionJob = typeof(TestJob);
scheduleController.ReScheduleCollectRequests(
fakeSession,
new[] { collectRequest, otherCollectRequest },
fakeRepository);
Assert.AreEqual(2, scheduleController.GetNumberOfCollectRequestScheduled(), "the number of collectRequest schedule is not expected");
scheduler.Shutdown();
}
示例13: StartSample
public void StartSample()
{
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// define the job and tie it to our HelloJob class
JobDataMap newJobDataMap = new JobDataMap {{"myStateData", new List<DateTimeOffset>()}};
IJobDetail job = JobBuilder.Create<StateJob>()
.WithIdentity("myJob", "group1")
.SetJobData(newJobDataMap)
.Build();
// Trigger the job to run now, and then every 5 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(5)
.RepeatForever())
.Build();
sched.ScheduleJob(job, trigger);
}
示例14: InitScheduler
public static void InitScheduler(String link)
{
if (rootPath != null)
return;
rootPath = link;
ISchedulerFactory schedFact = new StdSchedulerFactory();
Scheduler = schedFact.GetScheduler();
Scheduler.Start();
IJobDetail jobDetail = JobBuilder.Create<PhotoNotifyJob>().WithIdentity("PhotoNotificationJob").Build();
jobDetail.JobDataMap.Add("path", rootPath);
//Wystartuj jak najwczesniej, o godzinie 2:00 rano
DateTime startAt = DateTime.Today;
startAt = startAt.AddHours(2);
if (startAt < DateTime.Now) //jesli juz minela godzina 2, wystartuj nastepnego dnia
startAt = startAt.AddDays(1);
ITrigger trigger2 = (ISimpleTrigger)TriggerBuilder.Create()
.WithIdentity("trigger")
.StartAt(startAt) // wystartuj scheduler o zadanej godzinie
.WithSimpleSchedule(x => x.WithIntervalInHours(24).RepeatForever()) //odpalaj notyfikacje co 24h, bez limitu powtorzen
.Build();
DateTimeOffset ft = Scheduler.ScheduleJob(jobDetail, trigger2);
System.Diagnostics.Debug.WriteLine(jobDetail.Key + " has been scheduled to run at: " + ft);
}
示例15: Scheduler
private Scheduler()
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
this._sched = schedFact.GetScheduler();
// Start up the scheduler (nothing can actually run until the scheduler has been started)
this._sched.Start();
}