#How do I use the Izenda Reports report email scheduler?
##Izenda Reports Scheduler Setup Instructions
###Task-based scheduler
https://github.com/izenda/custom-scheduler
First, a little background about how the scheduler works. The scheduler requires the use of the Izenda Scheduler executable that is packaged with our reference implementation starter kit. You then need to add a scheduled task to your system that runs on an interval you specify. The task will execute the Izenda Scheduler to send a command to the response server (rs.aspx) that determines if any reports need to go out. You can specify the URL of your rs.aspx page as a command line parameter when setting up the task as will be discussed below.
Here are the steps to install the Izenda Scheduler. It is recommended that you perform these installation steps on the Web Server on which Izenda Reports is installed. The Windows' Scheduled Task Functionality described is only available on Windows Server operating systems.
- Right Click the Start button in Windows Server
- Click on the Control Panel menu option
- Navigate to Scheduled Tasks
- Under Actions menu option select Create Task….
- In the General tab, give the Task a Name. Select Run whether user is logged on or not.
- Go to the Triggers Tab and select New, Set the triggers for a the new task (daily, weekly, monthly) and the start date for the task. In the Advanced Settings on this tab set the repeat frequency (5 minutes, 30 minutes, etc.). If you must have the Izenda items scheduled run on the exact minute it is scheduled, your task should be set to run every minute. The delivery will only happen when this task is run, so if a report is set to run at 11:30, and the scheduled task is set for 11:35 the 11:30 report will be delivered at 11:35.
- Go to the Actions Tab and under Action select "Start a program". In the Program/script window browse to or paste in the full file path of the folder that you installed Izenda Reports and select the Izenda scheduler program ( IzendaScheduler.exe ). Example: c:\IzendaReports\reference-implementations\bin\IzendaScheduler.exe. Now in the Add Arguments section you will need to paste the full path to the rs.aspx page for the site, example: (http://localhost/rs.aspx)
- If you are not an administrator on the machine you may need to enter the user name and password of an account with sufficient rights to schedule the task (usually administrator)
- Please review the Conditions and Settings tabs for any items that you may want to set based on your needs.
- Click Ok
Now that you have setup the scheduler, we will need to setup Izenda Reports. There are two ways to do this. We recommend using the InitializeReporting() method in your CustomAdHocConfig class to do this.
###Service-based scheduler
Izenda now also offers the option of using a service-based scheduler. The MSI installer and service based scheduler is also available at our GitHub scheduler repo https://github.com/izenda/custom-scheduler. After running the installer, there will be an executable in the directory you specified in the installer wizard along with a config file called IzendaService.exe.config. Here is how to configure the service-based scheduler:
- Open task manager.
- Locate IzendaService.
- The service should be running. Right click the service and select "Stop".
- Open the Windows Explorer.
- Navigate to where the IzendaService scheduler is installed (by default C:/Program Files (x86)/IzendaService).
- Open IzendaService.exe.config in the text editor of your choice with administrator privileges.
- Edit the url setting to the location of your rs.aspx page with the run_scheduled_reports=1 query string parameter. (ex: http://yourhost/yourapp/rs.aspx?run_scheduled_reports=1 )
- Optional: The rs.aspx page also accepts the parameter ssl=1 for running scheduled reports. This will require the process to use SSL security when contacting the email server. (rs.aspx?run_scheduled_reports=1&ssl=1)
- Edit the interval setting to the time in milliseconds that will elapse between calls to the URL specified.
- Save the config file with the modified settings.
- Go back to the task manager and restart the IzendaService.
The service-based scheduler is now ready to run and will call the requested URL each time the interval elapses from the time the service was started.
##Setting up the scheduler using the Settings.aspx page (Trial/POC)
To use the Settings.aspx page:
- Navigate to the Settings.aspx page in Izenda Reports (for example http://yourhost/yourapp/settings.aspx).
- Click the "Email and Scheduling" Tab
- Set the "Email From Address" field (e.g. admin@yourdomain.com).
- Check the "Show Schedule Controls" check box
- Enter in your SMTP relay server in the "Smtp Server" field (e.g. smtp.yourcompany.com).
- Click "Save to Izenda.Config" in the upper left-hand corner
- Open a report you want to schedule in the report designer, click the “Misc” tab of the report. The scheduler controls will be towards the bottom of the page. Enter the email addresses separated by commas. Set the report type and the repeat frequency. You must set the repeat frequency in order to schedule the report.
- Save the report again.
- The e-mail scheduler setup is now finished.
##Setting up the scheduler using the Global.asax (Production)
To set the settings in the Global.asax:
- Set up your SMTP Server in the Global.asax file inside of the InitializeReporting() method by modifying the following settings. The Global.asax file can be found in the root of the directory to which you installed Izenda Reports.
Izenda.AdHoc.AdHocSettings.SmtpServer = "INSERT IP ADDRESS HERE";
- Set up your e-mail report format string. This is the string that the user will see when the e-mail is received. The {0} will be replaced with the report that the user has been scheduled to receive. Remember to replace "Host" with your domain, such as "SomeCompany.com" and "App" with your application name, such as "Reporting".
Izenda.AdHoc.AdHocSettings.ScheduledReportsUrlFormatString = "http://Host/App/reportviewer.aspx?{0}";
- Set the e-mail address all users will see when a report is scheduled and sent via e-mail.
Izenda.AdHoc.AdHocSettings.EmailFromAddress = "reports@somecompany.com";
- Lastly, enable the the report scheduling controls so they are show in the “Misc” tab.
Izenda.AdHoc.AdHocSettings.ShowScheduleControls = true;
##Testing the scheduler
To test this, go back to a report you wish to schedule and click on it. Click the Misc tab of the report. The scheduler controls will be towards the bottom of the page. Enter the e-mail addresses separated by commas, then set the report type and the schedule frequency. Save the report again. Now go back to the Report List. Next to the report, you should see the schedule time for the report. Now we can also look at the scheduled tasks on the server.
- In either case, you should receive the link to your scheduled report in your e-mail.
- Using the DOS command line, navigate into the Izenda Reports root directory (for example, C:\web\IzendaReports) and run IzendaScheduler.exe "http://yourhost/yourapp/rs.aspx". This should return a list of scheduled reports in the DOS window.
-
Navigate to the rs.aspx page in the application (for example, http://yourhost/yourapp/rs.aspx). Now add this to the end of the URL, ?run_scheduled_reports=30 (30 equals the frequency in minutes it will run). The url in the browser should read: http://yourhost/yourapp/rs.aspx?run_scheduled_reports=30
- This will return a list of scheduled reports into the browser window.
- In order for this method to work, you must have a report scheduled in the past
##Security On Scheduled Reports
Scheduled reports only supports per-user security using the Link format. Scheduled attachments will not apply hidden filters normally, but you can apply security through PreExecuteReportSet() based on the security of the report owner. If per-user security is required, the Link format will require the user to login before seeing the report.
##Saving Reports to Disk
The Scheduler can be used to save reports to disk.
Here are some basic instructions for setting up this functionality with the Scheduler.
- Add the file FileScheduler.cs to the folder \App_Code\
- In SchedulerPage.aspx, we will create the SchedulerPage.aspx.cs
From your root, create a page called SchedulerPage.aspx with the following SchedulerPage.aspx.cs code behind:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SchedulerPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FileScheduler.RunScheduledReports(Response.Output, DateTime.Now);
}
}
How to use:
- Create a report and schedule it. In this case, we need to save to a folder – so instead of an email recipient, specify the folder in which to save your report.
- Open the SchedulerPage.aspx page in the browser.
##Clearing scheduler settings on new report save
You can use the following custom code to make sure that when a copy of a report is saved, the scheduler settings are not saved along with the report copy:
public override void SaveReportSet(ReportInfo reportInfo, ReportSet reportSet)
{
ReportSet existingReport = LoadFilteredReportSet(reportInfo.FullName);
// If this is a new report or SaveAs report
if (existingReport == null)
{
reportSet.Recipients = "";
reportSet.RepeatType = RepeatType.None;
}
// Save report normally
base.SaveReportSet(reportInfo, reportSet);
}
##Overnight batch report processing
One extremely useful function of scheduling reports is batch processing of reports during nighttime hours. Implementation of overnight processing is just a matter of setting which reports will run during office off-hours.
First, you need to open the report you will want to schedule in the ReportDesigner. Navigate to the Misc tab and choose the time your report will run and the frequency. For overnight processing, just select a time period that does not conflict with your normal business hours. Save the report with the desired frequency. You must do this for each report you want to process.
Next, you will just need to ensure the scheduler process is running. Normally servers are left on overnight anyway, so just as long as the server computer that the scheduler is installed on and the server where the reporting application is installed on are running, the reports will get processed. Generally, these will be on the same machine anyway. The interval of the scheduler you defined when you installed it will ping the reporting application to see if any reports need to be scheduled. If one or more are scheduled, the reporting application will begin processing and sending those reports via email. So essentially, overnight processing is the same process as any other time of day with respect to setup.
