Schedule task to run everyday at specific time with Quartz.NET











up vote
3
down vote

favorite
1












I am using Quartz.NET for doing a task everyday at specific hour and this is my code:



public class TestSchedule : ISchedule
{
public void Run()
{

DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);

IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1")
.Build();

ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
.Build();

ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sc = sf.GetScheduler();
sc.ScheduleJob(job, trigger);

sc.Start();
}
}


my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0) )
now, how can say that run everyday at 7 o'clock?
PS : I don't want use CronTrigger to do that.










share|improve this question




























    up vote
    3
    down vote

    favorite
    1












    I am using Quartz.NET for doing a task everyday at specific hour and this is my code:



    public class TestSchedule : ISchedule
    {
    public void Run()
    {

    DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);

    IJobDetail job = JobBuilder.Create<HelloJob>()
    .WithIdentity("job1")
    .Build();

    ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger1")
    .StartAt(startTime)
    .WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
    .Build();

    ISchedulerFactory sf = new StdSchedulerFactory();
    IScheduler sc = sf.GetScheduler();
    sc.ScheduleJob(job, trigger);

    sc.Start();
    }
    }


    my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0) )
    now, how can say that run everyday at 7 o'clock?
    PS : I don't want use CronTrigger to do that.










    share|improve this question


























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      I am using Quartz.NET for doing a task everyday at specific hour and this is my code:



      public class TestSchedule : ISchedule
      {
      public void Run()
      {

      DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);

      IJobDetail job = JobBuilder.Create<HelloJob>()
      .WithIdentity("job1")
      .Build();

      ITrigger trigger = TriggerBuilder.Create()
      .WithIdentity("trigger1")
      .StartAt(startTime)
      .WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
      .Build();

      ISchedulerFactory sf = new StdSchedulerFactory();
      IScheduler sc = sf.GetScheduler();
      sc.ScheduleJob(job, trigger);

      sc.Start();
      }
      }


      my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0) )
      now, how can say that run everyday at 7 o'clock?
      PS : I don't want use CronTrigger to do that.










      share|improve this question















      I am using Quartz.NET for doing a task everyday at specific hour and this is my code:



      public class TestSchedule : ISchedule
      {
      public void Run()
      {

      DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);

      IJobDetail job = JobBuilder.Create<HelloJob>()
      .WithIdentity("job1")
      .Build();

      ITrigger trigger = TriggerBuilder.Create()
      .WithIdentity("trigger1")
      .StartAt(startTime)
      .WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
      .Build();

      ISchedulerFactory sf = new StdSchedulerFactory();
      IScheduler sc = sf.GetScheduler();
      sc.ScheduleJob(job, trigger);

      sc.Start();
      }
      }


      my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0) )
      now, how can say that run everyday at 7 o'clock?
      PS : I don't want use CronTrigger to do that.







      quartz-scheduler quartz.net






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 6:47









      Cœur

      17k9102140




      17k9102140










      asked Jun 25 '13 at 5:11









      Sirwan Afifi

      7,60874082




      7,60874082
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          DailyTimeIntervalTriggerImpl only support repeatCount.




          This trigger also supports "repeatCount" feature to end the trigger
          fire time after a certain number of count is reached. Just as the
          SimpleTrigger, setting repeatCount=0 means trigger will fire once
          only! Setting any positive count then the trigger will repeat count +
          1 times. Unlike SimpleTrigger, the default value of repeatCount of
          this trigger is set to REPEAT_INDEFINITELY instead of 0 though.




          Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.



          Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:



          ITrigger trigger = TriggerBuilder.Create()
          .WithIdentity("trigger1")
          .StartAt(startTime)
          .WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
          .Build();





          share|improve this answer

















          • 1




            Another solution would be .EndingDailyAfterCount(1) instead of .WithIntervalInHours(24). So you won't get into troubles with DST (daylight saving time) related issues.
            – Christian
            Mar 27 '17 at 7:40













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17289568%2fschedule-task-to-run-everyday-at-specific-time-with-quartz-net%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          DailyTimeIntervalTriggerImpl only support repeatCount.




          This trigger also supports "repeatCount" feature to end the trigger
          fire time after a certain number of count is reached. Just as the
          SimpleTrigger, setting repeatCount=0 means trigger will fire once
          only! Setting any positive count then the trigger will repeat count +
          1 times. Unlike SimpleTrigger, the default value of repeatCount of
          this trigger is set to REPEAT_INDEFINITELY instead of 0 though.




          Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.



          Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:



          ITrigger trigger = TriggerBuilder.Create()
          .WithIdentity("trigger1")
          .StartAt(startTime)
          .WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
          .Build();





          share|improve this answer

















          • 1




            Another solution would be .EndingDailyAfterCount(1) instead of .WithIntervalInHours(24). So you won't get into troubles with DST (daylight saving time) related issues.
            – Christian
            Mar 27 '17 at 7:40

















          up vote
          4
          down vote



          accepted










          DailyTimeIntervalTriggerImpl only support repeatCount.




          This trigger also supports "repeatCount" feature to end the trigger
          fire time after a certain number of count is reached. Just as the
          SimpleTrigger, setting repeatCount=0 means trigger will fire once
          only! Setting any positive count then the trigger will repeat count +
          1 times. Unlike SimpleTrigger, the default value of repeatCount of
          this trigger is set to REPEAT_INDEFINITELY instead of 0 though.




          Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.



          Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:



          ITrigger trigger = TriggerBuilder.Create()
          .WithIdentity("trigger1")
          .StartAt(startTime)
          .WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
          .Build();





          share|improve this answer

















          • 1




            Another solution would be .EndingDailyAfterCount(1) instead of .WithIntervalInHours(24). So you won't get into troubles with DST (daylight saving time) related issues.
            – Christian
            Mar 27 '17 at 7:40















          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          DailyTimeIntervalTriggerImpl only support repeatCount.




          This trigger also supports "repeatCount" feature to end the trigger
          fire time after a certain number of count is reached. Just as the
          SimpleTrigger, setting repeatCount=0 means trigger will fire once
          only! Setting any positive count then the trigger will repeat count +
          1 times. Unlike SimpleTrigger, the default value of repeatCount of
          this trigger is set to REPEAT_INDEFINITELY instead of 0 though.




          Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.



          Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:



          ITrigger trigger = TriggerBuilder.Create()
          .WithIdentity("trigger1")
          .StartAt(startTime)
          .WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
          .Build();





          share|improve this answer












          DailyTimeIntervalTriggerImpl only support repeatCount.




          This trigger also supports "repeatCount" feature to end the trigger
          fire time after a certain number of count is reached. Just as the
          SimpleTrigger, setting repeatCount=0 means trigger will fire once
          only! Setting any positive count then the trigger will repeat count +
          1 times. Unlike SimpleTrigger, the default value of repeatCount of
          this trigger is set to REPEAT_INDEFINITELY instead of 0 though.




          Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.



          Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:



          ITrigger trigger = TriggerBuilder.Create()
          .WithIdentity("trigger1")
          .StartAt(startTime)
          .WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
          .Build();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 25 '13 at 11:09









          LeftyX

          27.7k17110173




          27.7k17110173








          • 1




            Another solution would be .EndingDailyAfterCount(1) instead of .WithIntervalInHours(24). So you won't get into troubles with DST (daylight saving time) related issues.
            – Christian
            Mar 27 '17 at 7:40
















          • 1




            Another solution would be .EndingDailyAfterCount(1) instead of .WithIntervalInHours(24). So you won't get into troubles with DST (daylight saving time) related issues.
            – Christian
            Mar 27 '17 at 7:40










          1




          1




          Another solution would be .EndingDailyAfterCount(1) instead of .WithIntervalInHours(24). So you won't get into troubles with DST (daylight saving time) related issues.
          – Christian
          Mar 27 '17 at 7:40






          Another solution would be .EndingDailyAfterCount(1) instead of .WithIntervalInHours(24). So you won't get into troubles with DST (daylight saving time) related issues.
          – Christian
          Mar 27 '17 at 7:40




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17289568%2fschedule-task-to-run-everyday-at-specific-time-with-quartz-net%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python