# WebReports.Api.Scheduler

## ReportScheduler Class

The ReportScheduler class can be used to schedule reports to run on a regular basis. Output can be emailed or stored in a repository. The output destination (email or storage) is normally set on a global basis. This API allows you to override the global setting for individual report schedules if desired.

A ReportScheduler object uses the following enumerations:

- WeekOfMonthType – weeks of the month.
  - Uses the enumeration WeekOfMonthType (First, Second, Third, Fourth, Last)
- DayOfWeekType – days of the week.

Uses the enumeration DayOfWeekType (Day, Weekday, Weekendday, Sunday, Monday, Tuesday, The API is designed to mirror the capabilities of the SchedulerWizard in the Exago main interface. There are a few concepts that will be helpful to understand in using the API. In general each API call requires the following information:

- Schedule name: A “handle” to refer to this schedule.
- Recurrence Information: usually a Start Date and Time, recurrence pattern and end condition. The end condition may be “No end condition” which indicates that the schedule should execute indefinitely according to the specified recurrence pattern. In certain instances, the recurrence information uses static Enumerations from the ReportScheduleInfo class.
- Email information: Includes To List, CC List, BCC List, Subject and Body. A new class ScheduleEmailInfo has been created to easily pass this information.

> NOTE. a small number of Scheduler API calls don’t follow the above pattern. For example, there are CreateOnceSchedule and CreateImmediateSchedule calls that don’t use any recurrence information.

For each schedule type that uses a recurrence pattern the following rules apply:

- The start time can be passed in one of two ways:
  - As the Time Component of the startDate DateTime
  - As a separate TimeSpan schedTime

The TimeSpan will always take precedence if not null. If the TimeSpan is null, the scheduler will use the Time element of startDate

- The end condition can be set in one of three ways
  - No End Condition: Report executions will continue indefinitely
  - End by number of occurrences: Executions will cease after N occurrences, where N is a passed parameter
  - End by Date: Executions will cease after a certain date where the date is a passed parameter.

Each type of call is overloaded to reflect the desired end condition. For example, there are three possible ways to create an “Every Weekday” schedule:

string CreateEveryWeekdaySchedule(string name, DateTime rangeStartDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo) //No end condition

string CreateEveryWeekdaySchedule(string name, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo) //End by number of occurrences

string CreateEveryWeekdaySchedule(string name, DateTime rangeStartDate, DateTime rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo) //End by date

As noted above, report output can be sent through email or stored to a repository, and the choice can be made with the schedule. Passing a ScheduleEmailInfo object to the appropriate argument will tell the Exago Scheduler to send output through email based on the passed information. Passing null for the argument will tell the scheduler to archive the output for that schedule.

> NOTE. Archiving requires a Report Path to be set in the Scheduler Configuration XML. The Report Path tells the scheduler where to store the output.

A ReportScheduler object has the following methods:

> (v2016.3+) All "Create" methods return the JobId string of the schedule object. This can be passed into GetReportScheduleInfoByJobId() to return the schedule for further manipulation.

#### string CreateImmediateSchedule(string name, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run immediately.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() See SchedulerEmailInfo class for information on emailInfo.

#### string CreateOnceScheduleByDateTime(DateTime schedDateTime, string name, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedule a report to be run every weekday. Report will be executed indefinitely.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateEveryWeekdaySchedule(string name, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run every weekday. Report will be executed the number of times specified in rangeEndAfterNOccurrences.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateEveryWeekdaySchedule(string name, DateTime rangeStartDate, DateTime rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run every weekday. Report will be executed until the specified rangeEndDate.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateEveryNDaySchedule(string name, int everyNDays, DateTime rangeStartDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a daily interval. Report will be executed indefinitely.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNDays indicates the interval at which the schedule is run (e.g. every 10 days). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateEveryNDaySchedule (string name, int everyNDays, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a daily interval. Report will be executed the number of times specified in rangeEndAfterNOccurrences.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNDays indicates the interval at which the schedule is run (e.g. every 10 days). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateEveryNDaySchedule(string name, int everyNDays, DateTime rangeStartDate, DateTime rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a daily interval. Report will be executed until the specified rangeEndDate.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNDays indicates the interval at which the schedule is run (e.g. every 10 days). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateWeeklySchedule(string name, int everyNWeeks, List<DayOfWeek> days, DateTime rangeStartDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a weekly interval. Report will be executed indefinitely.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNWeeks indicates the interval at which the schedule is run (e.g. every 2 weeks). days indicates a list of the days each week to run the schedule. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### stringvoid · v2016.3 CreateWeeklySchedule(string name, int everyNWeeks, List<DayOfWeek> days, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a weekly interval. Report will be executed until the specified rangeEndDate.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNWeeks indicates the interval at which the schedule is run (e.g. every 2 weeks). days indicates a list of the days each week to run the schedule. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateWeeklySchedule(string name, int everyNWeeks, List<DayOfWeek> days, DateTime rangeStartDate, int rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a weekly interval. Report will be executed the number of times specified in rangeEndAfterNOccurrences.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNWeeks indicates the interval at which the schedule is run (e.g. every 2 weeks). days indicates a list of the days each week to run the schedule. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateMonthlyScheduleByNumericDay(string name, int everyNMonths, int numericDay, DateTime rangeStartDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a specific day each month. Report will be executed indefinitely.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNMonths indicates the interval at which the schedule is run (e.g. every 2 months). numericDay indicates the day of each month to run the schedule (e.g. 17). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateMonthlyScheduleByNumericDay(string name, int everyNMonths, int numericDay, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a specific day each month. Report will be executed the number of times specified in rangeEndAfterNOccurrences.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNMonths indicates the interval at which the schedule is run (e.g. every 2 months). numericDay indicates the day of each month to run the schedule (e.g. 17). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateMonthlyScheduleByNumericDay(string name, int everyNMonths, int numericDay, DateTime rangeStartDate, DateTime rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a specific day each month. Report will be executed the specified rangeEndDate.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNMonths indicates the interval at which the schedule is run (e.g. every 2 months). numericDay indicates the day of each month to run the schedule (e.g. 17). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateMonthlyScheduleByDescriptionDay(string name, int everyNMonths, WeekOfMonthType ordinal, DayOfWeekType dayOfWeek, DateTime rangeStartDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a described day each month. Report will be executed indefinitely.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNMonths indicates the interval at which the schedule is run (e.g. every 2 months). ordinal used in context with dayOfWeek describe when during each month to run the scheduled report. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. ordinal and dayOfWeek are enumerations detailed at the beginning of this section See SchedulerEmailInfo class for information on emailInfo.

#### string CreateMonthlyScheduleByDescriptionDay(string name, int everyNMonths, WeekOfMonthType ordinal, DayOfWeekType dayOfWeek, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a described day each month. Report will be executed the number of times specified in rangeEndAfterNOccurrences.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNMonths indicates the interval at which the schedule is run (e.g. every 2 months). ordinal used in context with dayOfWeek describe when during each month to run the scheduled report. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. ordinal and dayOfWeek are enumerations detailed at the beginning of this section See SchedulerEmailInfo class for information on emailInfo.

#### string CreateMonthlyScheduleByDescriptionDay(string name, int everyNMonths, WeekOfMonthType ordinal, DayOfWeekType dayOfWeek, DateTime rangeStartDate, DateTime rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a described day each month. Report will be executed the specified rangeEndDate.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() everyNMonths indicates the interval at which the schedule is run (e.g. every 2 months). ordinal used in context with dayOfWeek describe when during each month to run the scheduled report. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. ordinal and dayOfWeek are enumerations detailed at the beginning of this section See SchedulerEmailInfo class for information on emailInfo.

#### string CreateYearlyScheduleByNumericDay(string name, int numericMonth, int numericDay, DateTime rangeStartDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a specific month and day each year. Report will be executed indefinitely.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() numericMonth indicates the month of each year to run the schedule (e.g. 3). numericDay indicates the day of each month to run the schedule (e.g. 17). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateYearlyScheduleByNumericDay(string name, int numericMonth, int numericDas, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a specific day each month. Report will be executed the number of times specified in rangeEndAfterNOccurrences.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() numericMonth indicates the month of each year to run the schedule (e.g. 3). numericDay indicates the day of each month to run the schedule (e.g. 17). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateYearlyScheduleByNumericDay(string name, int numericMonth, int numericDay, DateTime rangeStartDate, DateTime rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a specific day each month. Report will be executed the specified rangeEndDate.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() numericMonth indicates the month of each year to run the schedule (e.g. 3). numericDay indicates the day of each month to run the schedule (e.g. 17). If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateYearlyScheduleByDescriptionDay(string name, int numericMonth, WeekOfMonthType ordinal, DayOfWeekType dayOfWeek, DateTime rangeStartDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a described day each month. Report will be executed indefinitely.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() numericMonth indicates the month of each year to run the schedule (e.g. 3). ordinal used in context with dayOfWeek describe when during each month to run the scheduled report. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. ordinal and dayOfWeek are enumerations detailed at the beginning of this section. See SchedulerEmailInfo class for information on emailInfo.

#### string CreateYearlyScheduleByDescriptionDay(string name, int numericMonth, WeekOfMonthType ordinal, DayOfWeekType dayOfWeek, DateTime rangeStartDate, int rangeEndAfterNOccurrences, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a described day each month. Report will be executed the number of times specified in rangeEndAfterNOccurrences.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() numericMonth indicates the month of each year to run the schedule (e.g. 3). ordinal used in context with dayOfWeek describe when during each month to run the scheduled report. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. ordinal and dayOfWeek are enumerations detailed at the beginning of this section See SchedulerEmailInfo class for information on emailInfo.

#### string CreateYearlyScheduleByDescriptionDay(string name, int numericMonth, WeekOfMonthType ordinal, DayOfWeekType dayOfWeek, DateTime rangeStartDate, DateTime rangeEndDate, TimeSpan schedTime, SchedulerEmailInfo emailInfo)

Description | Schedules a report to be run on a described day each month. Report will be executed the specified rangeEndDate.
Remarks | Before calling this method be sure to activate the report you want to schedule using api.ReportObjectFactory.LoadFromRepository() numericMonth indicates the month of each year to run the schedule (e.g. 3). ordinal used in context with dayOfWeek describe when during each month to run the scheduled report. If schedTime is null the time component of schedDateTime will be used to determine the time the report is run. ordinal and dayOfWeek are enumerations detailed at the beginning of this section See SchedulerEmailInfo class for information on emailInfo.

## SchedulerEmailInfo Class

The SchedulerEmailInfo class is utilized used by methods of ReportScheduler objects.

A SchedulerEmailInfo object has the following property:

- toAddrs – list of email addresses and/or distribution lists for the 'To' field of the email.
- ccAddrs – list of email addresses and/or distribution lists for the ‘cc’ field of the email.
- bcAddrs – list of email addresses and/or distribution lists for the 'bc' field of the email.

> NOTE. If toAddrs, ccAddrs and bcAddrs are all null, Exago will attempt to archive the report to the Scheduler Repository.

- Subject – The subject of the email.
- body – The body text of the email.