Quartz .NET - remove trigger if all future fire times in past - quartz.net

I've set up the quartz scheduler to ignore misfires and move on to the next fire time (using .WithMisfireHandlingInstructionNextWithRemainingCount() and .WithMisfireHandlingInstructionDoNothing()). This works fine but if there is no next fire time the trigger will just keep the old next fire time that has already misfired and wait for it to fire (it will never fire because it is in the past).
The way I'm testing this is pausing a trigger and waiting for the fire times to pass/misfire. The trigger's state is updated to COMPLETE only after resuming and remains in the database. I want the trigger to remove itself from the database (like it normally does when complete). I also want the trigger to complete without me having to resume the trigger but that's a bonus.

So the problem was I was setting the start time (using .StartAt() method) to the start time of the intervals I was using. For example, let's say it is currently 9am on June 23rd. If I had a trigger that runs daily starting at 3am then the start time of the daily interval is 3am. However, I was also setting the start time of the trigger to 3am, which is in the past. This ended up causing me many issues.

Related

automatically tracking time through start / stop progress

I like to track time spent on JIRA issues when I click on Start Progress and then Stop Progress, or Resolve.
Is it possible to get JIRA to automatically allocate time to the task, like say:
14:20: Clicked on Start Progress
14:45: Clicked on Stop Progress > Logs 25 minutes to the task
15:30: Clicked on Start Progress
15:45: Clicked on Resolve > Logs 15 minutes to the task.
Is this possible?
Yes, it is possible.
You might want to have a look at Listeners:
"A Listener is a class that implements one of the Listener interfaces. It is then called whenever events occur in JIRA. Using those events, you can then perform any action you want."
In your case you could implement the issueStarted, issueStopped and issueResolved method.
On issueStarted you could somehow save the current timestamp (e.g. in an invisible customfield) and on issueStopped/issueResolved you could trigger the creation of a worklog-entry.
There is an app on the Atlassian Marketplace, Clockwork Automated Timesheets, that does exactly that.
It fully integrates with Jira's workflow so that the time logged corresponds to how much time an issue was In Progress or had any other active status.
If necessary, the timers can always be started or stopped manually by using Start/Stop buttons.
There are also reports available.
At the moment the app is free.
Cheers,
Jacek

What happens if a job is scheduled in the past?

I'm new to Quartz.Net and I'm wondering what happens if a job is scheduled in the past? Is an exception thrown? Is it run immediately? I'm wondering if I need to guard for this condition when I schedule jobs.
You will get an exception if the trigger you are adding would never fire. There is a distinction here to note: you can schedule start time to be in the past but there needs to be some future time for the trigger to fire. So having start time of NOW()-1d is fine if you have firing happening after the time you add the trigger (EndTimeUtc in the future AND schedule that permits futher fires from now).
So you should check that GetNextFireTimeUtc returns non-null value for trigger you are adding.

Auto-detect time of day

I'm writing a daily to do list app, and want the app to update certain elements with each new day. This isn't a problem if the user closes the app one day and then reopens it the next -- I just compare days in the startup methods.
However, this is a problem if the user happens to be using the app exactly at midnight. At midnight, daily task elements need to reset themselves automatically for the new day.
Here's my issue -- I could have a constant thread running in the background, always accessing [NSDate date] and checking for a new day. But I feel like there must be a better way, especially because this only has to happen once per day (and then, only if the user is using the app at midnight).
Thank you in advance!
In applicationDidFinishLaunching: and applicationWillEnterForeground:, setup an NSTimer scheduled to trigger at midnight. Also, register for UIApplicationSignificantTimeChangeNotification to reschedule the timer for time zone changes etc.

Quartz.NET and daylight savings issue

We have a Quartz.NET cron trigger setup that needs to execute a job using the following schedule:
At 02:00hrs in the merchants time zone daily
However, when Daylight Savings Time (DST) occurs abnormalities occur i.e:
When the merchants timezone moves from +2 GMT to +3 GMT, the job does not get executed.
When the merchants timezone moves from +3 GMT to +2 GMT, the job does gets executed twice.
We already know that this behaviour is by design (http://www.quartz-scheduler.net/faq.html#daylight) but what are people using as a solution to this DST issue?
Cheers
Billy Stack
The link you point to may have been updated in the three years or so (!) since you asked this question. It would appear that the job should not be executed twice.
I'm unsure whether 02:00 officially 'occurs' in the US when daylight savings starts, so the concern about the job skipping execution at 02:00 could be resolved by setting it to 01:59:59 (cron trigger "59 59 1 ? *"), as long as you were in North America. Other countries may change at a different time of night. In Europe, for instance, the change is at 01:00, so there it would be better to set the trigger to 02:00:01
Just experienced the same issue as well, although in my case the trigger was not scheduled to fire between 0:00 and the DST change time (2:00 in the US). Instead, I had a job that runs MON-FRI at 8 in the morning, so it ran twice on the Monday November the 5th, the day following the DST change day.
If you read the FAQ item linked to in the question, it kinda makes sense. The Cron trigger wakes up, fires the job, then calculates next time to wake up. When it woke up on Friday at 8am, it calculated next time to run as Monday at 8am. However, by Monday morning what used to be 8am became 7am, so the trigger fired at that time. And then when it ran, the next time was "correctly" calculated as 8am, so it ran again at that time also.
Hope this helps somebody struggling to understand the issue.
Jobs run twice in the fall and don't run at all in the spring. It doesn't matter what time they are scheduled. The question was and still is, "How do you stop this from happening?" If you manually delete all jobs after the time change and before they run then add them back then it works fine. I haven't looked at it yet but thinking this could be automated. Write something that reads all scheduled jobs and adds them and deletes the old records. Whatever you write would need to run from the Windows job scheduler because it wouldn't run at all in the spring if it ran from Quartz.

Scheduled task with windows services and system.timer.timer

i want implement a windows services scheduled task.
I already created windows service. In a service i have implemented a timer.The timer is initialized at class interval. The timers interval is set in the start method of service and also it is enabled in the start method of the service. After timers elapsed event is fire i have done some actions.
My problem is that, i am in a dilemma. Lets say the action i have done in Elapsed event, lets say take one hour and the timers interval is set to half an hour. so there are chances that even if the previous call to elapsed event has not ended new call to elapsed event will occur.
my question will there be any conflict or is it ok or shall i use threads.
please give some advice
You can stop the timer at the begining of your long running method, then start it again at the end:
Timer.Change(Timeout.Infinite, Timeout.Infinite)
// do long task ...
Timer.Change(dueTime,period)

Resources