So I have created a data type, Sequence, that has a text field (start time, for example, 9:30am), a number (delay time, in minutes), and a list of steps (another data type that can execute actions such as send an email, write a note, etc). Another data type, userSequence, uses a sequence for instructions, as well as the user data type to know who to do the actions on.
So I have a BEWF that can be triggered with the parameters of a user and a sequence, which will create a new userSequence, that will in turn begin to schedule steps listed in the attached sequence. This is where I run into a problem, as I want to schedule the BEWF to wait at least the delay time specified in the sequence, and then run at the specified start time.
For example, suppose my sequence had a delay time of 30 minutes, and a start time of 9:30am. Let’s say a user is added to a userSequence at 8:00am. The program would wait 30 minutes, (now 8:30am) and then wait until 09:30am to run. Another instance, if it was run at (9:01am), it would wait 30 minutes (09:31am), then wait until the following day at 9:30am.
So the first problem would be to convert the text time into a date. I would feed the parameters of the text time and the current date (date1) and compare that to the current date plus the delay time (date2). If date1>=date2, then schedule for date1. If date1<date2, add 1440 minutes (24 hours) and check again, repeating as necessary.
Question 1 - what would be the most efficient way of converting text time (h:MM tt format) into a date?
Question 2 - Is this logic I’m using for scheduling sound? Or is there a cleaner way of scheduling I’m overlooking?