Hi There,
I have to schedule a trigger based on below requirement .can some one suggest.
I have a input file with list of items in column A(List Details) to be processed at specific timings mentioned in the corresponding column B (Trigger Timings).
List Details Trigger Timings
List1 11:00 AM
List2 12:00 AM
List3 11:00 AM
List4 11:00 AM
List5 12:00 PM
List6 3:00 PM
List7 6:00 PM
List9 11:00 PM
Use 0 11-23 * * * cron expression to schedule the bot to run.
At init stage check the current timing and get List base on current time.
you can use below logic to get list from DataTable
Dim now As DateTime = DateTime.Now
Dim startTime As TimeSpan = New TimeSpan(now.Hour, 0, 0)
Dim endTime As TimeSpan = startTime.Add(TimeSpan.FromHours(1))
' Get the first matching List Details value, or Nothing if no match
Dim firstMatch As String = dt.AsEnumerable().
Where(Function(row)
Dim triggerTimeString As String = row("Trigger Timings").ToString().Trim()
Dim parsedTime As DateTime
Return DateTime.TryParseExact(triggerTimeString, "h:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.None, parsedTime) AndAlso
parsedTime.TimeOfDay >= startTime AndAlso parsedTime.TimeOfDay < endTime
End Function).
Select(Function(row) row("List Details").ToString()).
FirstOrDefault()
1/ Is the “input file” variable? So e.g. can it contain different list of items every day?
2/ What “items in column A(List Details)” actually represent?
@J0ska - Yes input file is a variable and the file contains every day different list of items .
Column A Contains some input data which needs to be processed . And Column B Contains the Trigger timings ie., what time in that day to get processed.
So it means you have a process (Executor) that should be started at time according ColB (e.g. 11:00 AM) and process data according ColA (e.g. List1).
So you will need another process (Dispatcher) that will read data from your file and it will schedule process Executor at respective time and with respective input data.
Best would be to run a dispatcher and add the items to queue with defferred time using. The time from column B..and use a queue trigger for actual process..so when the item gets active the process runs and as queue already hs data of what item it would be able to process that item..and deferred datetime takes care of running based on trigger
@Anil_G Thanks for your response . However i have the following questions.
You mean while adding the queue item itself you want me to define the timing of each queue item to run what time its is as per the column B ?
Also lets say i have three queue items needs to run at 10 AM, 1 PM & 6 PM . Now my question is when the queue trigger activates at 10 AM and it complete its transaction by 11 AM Now the bot will still be in running state and waiting for the 1 PM and again for 6 PM items ? Overall i want to know the state of the bot whether it is keep running or will it be in idle state and then again pick the item as soon the time arrives.
Yes while adding queue item you can give deferred time which would make item active only after the defined time and date
No as no queue items are available at 11 it would stop and once it is 1 again one queue gets active and the process gets triggered by the queue trigger again
Add the data table to a queue, and create a new process that runs every 5 minutes. In this process, check the queue transactions and compare each transaction’s scheduled time with the current system time. If the scheduled time matches the current time — or falls within a ±5-minute window — process the item. This approach allows you to handle the entire scenario in a fully dynamic and scalable way.