time compare in windows servuce - windows-services

I had written one windows service in C#.NET which fires on every miniutes... I want to execute certain code(some logic) on every month on say xyz date.... this task shld repeted on every month on same date... So can any one tell me how to do this..? I mean to say the block of code which i will write shld get executed on same date of every month...

Deploy this as a scheduled task rather than a service.

Related

Custom Quartz.Net trigger

I would like to implement my own custom trigger. the main purpose of the trigger twice: on start date and end date (think of it as on/off switch, "on" state and start date and "off" state on end date).
What is best way to achieve that?
AbstractTrigger or implement ITrigger?
Implementing IScheduleBuilder is required?
When you start to wonder whether to implement your own trigger there's possibly something going to the wrong direction. Quartz has a rich set of triggers that should cater for various scheduling needs which are based on interval/reoccurrence rules.
Not fully understanding your use case, I'd just schedule two triggers for start and stop actions. You could parametrize the triggers to supply the operation mode via job data map (TurnOn, TurnOff). You easily have start action to run on times like 8:35 am, every Monday, Wednesday and Saturday and corresponding stop trigger say the given dates on 10 pm.
I created the custom trigger by extending AbstactTrigger and implementing ISchedulerBuilder specified to this trigger type.

how to create Event which repeats every specific day

I do have a function like , On every thursday there is a show coming in my application and I want to provide add event functionality which will set event for every thursday for example next 5 years.
I know how to add Event but do not have idea how to add event for every thursday or a specific day.
Thanks your for your help.
Plenty of examples at https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.3
If unsure, you can always create such an event in your calendar client of choice and then export this event. Or you can go to http://jkbr.github.io/rrule/ and build it. For example http://jkbr.github.io/rrule/#/text/every%20week%20on%20Thursday%20until%20April%2017,%202019

Realtime timer that counts down time for ruby on rails app

Im in the need on some advise for a realtime serverside timer that would countdown from say 100 seconds. Reason for serverside timer is no tampering.
currently use delayed job but problem its not realtime i could mimic a timer by creatind job every second, but dirty solution
need to display time in view by getting timer value with ajax call to method that returns servertime on page. Know how to do this just to give idea. reload timer would still countdown correctly even on reload page.
Anyone could advise to get a realtime counter in rails app serverside? I would want to create one or more independant timers i can get a value from in railsapp.
Why don't you just create the record you need, but add a "don't open before" DateTime field you can check to see if it's okay to show it?
This sort of thing is trivial to do, and you can set a timer on the client to count-down in JavaScript, then reload the page with the final data at the appropriate time. If someone is impatient and reloads early, you can compute the number of seconds remaining before it can be shown using simple math:
time_left_in_seconds = record.show_at.to_i - Time.now.to_i
Then all you have to do is show a JavaScript timer for that number of seconds, then trigger a page refresh.

WF DelayActivity fires immediately?

I have a Workflow I have created and deployed to a Sharepoint 2007 farm. When it runs against an item two delay activities I have created fire immediately.
I have setup a callback on the InitializeTimeoutDuration event. Through logs and debug output I can see that it is setting the delay to one hour. However, at the next SP timer job cycle (less than 5 minutes) the events proceeding the Delay activity fire off.
I'm lost here. Any help is greatly appreciated.
Update
Through some digging I was able to determine why this was firing off. Once the workflow started a record gets added to the ScheduledWorkItems table in the SP Content database. However, the "DeliveryDate" on the record is set to the current time while the "Created" date is set to one hour previous. However, the delay I'm using is 2 hours, so neither of these times make sense to me at all. Going to try hardcoding it....
Update 2
Even with a hardcoded duration the times are off. I hardcoded a 2 hour delay in and the "DeliveryDate" is now one hour in the future while the "Created" date is one hour in the past. So at least the difference between them is good.
Update
Well, that's embarrassing... found the problem. I'm posting it in here for others that may make mistakes like I do. First off, I was not correct in my UTC->local conversion. The times on the database were correct. What was not correct was how I was setting the TimeoutDuration:
// WRONG!
delayActivity.TimeoutDuration = new TimeSpan("1:00:00"); // one hour
what I should have been doing:
// RIGHT!
((DelayActivity)sender).TimeoutDuration = new TimeSpan("1:00:00"); // one hour
once I made that change everything else seems to be fine.
Well, that's embarassing... found the problem. I'm posting it in here for others that may make mistakes like I do. First off, I was not correct in my UTC->local conversion. The times on the database were correct. What was not correct was how I was setting the TimeoutDuration:
// WRONG!
delayActivity.TimeoutDuration = new TimeSpan("1:00:00"); // one hour
what I should have been doing:
// RIGHT!
((DelayActivity)sender).TimeoutDuration = new TimeSpan("1:00:00"); // one hour
once I made that change everything else seems to be fine.

iPad Dev: Turn a given Date or String from SQL into NSDate

I have an app that creates and stores a session with a given start date. The user would create a new work session and when they start it, the current time would get saved to the database. The app needs to count time between the start and end of a work session. However, I need to be able to pause, restart, and continue sessions, so I need to get the date from the database.
Say a user starts at 10:30am on a particular day and continues their work session until 12:30pm. Say they need to close the app for whatever reason and come back to the work session. The session needs to count and show the current elapsed time since the beginning. So, I wanted to make an NSDate object with the start time taken from the database...but I can't. At least, I can't find a way of initializing a Date object with a string or even a set of parameters. I'm sure there's a way to do it, but I can't find one.
Take a look at the dateFromString: method on NSDateFormatter
you can start with the Apple Doc here
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW1
could type up examples, but I think the documentation contains some

Resources