Schedule Setting on Business File Service
Hi,
Is there a way to set the SettingSchedule on a EnsLib.File.PassthroughService at 9:00 am to 9:30 am but only end of the month?
Comments
Hello Warren,
You can use "Schedule Specifications" in production to schedule running your business host. First select your business host(service) and go to additional setting and check "Schedule" option click the magnifier. It opens the "Schedule Spec Editor" and create your schedule ex: "monthend_9to930" and click add action. Then select START and STOP action this action is basically "action:YYYY-MM-DDThh:mm:ss" . Refer the below sample and documentation
| START | *-*-31T09:00:00 |
| STOP | *-*-31T09:30:00 |
Note: this is suitable only for 31 days of month
February 31st?
You're right. I just add as a sample. There is no direct end of month option to execute. Just select monthly and 1 to 31 dates or 1st to 5th week option. If really go with schedule option then follow your below code
The easiest way would be to run on the first day of a month and send results for a previous month.
Another way you can do it is to create a schedule which runs 9:00 am to 9:30 am every day (or 28-31) and checks if this is a last day of a month before doing anything.
Schedule is limited to Max String length, so you can also generate a very long schedule once. For example this code would produce a schedule for the next 10 years:
/// date - start date. Must be the last day of the month./// months - how many months to generateClassMethod Test(date = "2024-09-30", months = 120)
{
while$i(months,-1)>=0 {
set year = $system.SQL.DATEPART("year", date)
set month = $tr($j($system.SQL.DATEPART("month", date), 2), " ", 0)
set day = $system.SQL.DATEPART("day", date)
write$$$FormatText("START:%1-%2-%3T09:00:00,STOP:%1-%2-%3T09:30:00,", year, month, day)
set date = $system.SQL.DATEADD("day", -1, $system.SQL.DATEADD("month", 1, $system.SQL.DATEADD("day", 1, date)))
}
}Schedule
If you're okay with February 28th for leap years a schedule can be simplified to 12 entries with * in the year.
If all of the above is not an option create a separate Business Service which runs on a first day of a month, calculates last day of a month and sets a correct schedule for BO.