CHAPTER 10 MANAGING REPORTS
The code in Listing 10-6 uses the ComboItem class that you created in Chapter 9 to add the items to
combo boxes. With PickSchedule.cs in design mode, double-click the form. This creates an empty
method to handle the form’s Load event. Add the code shown in Listing 10-6 to the PickSchedule_Load
method.
Listing 10-6. Getting Shared Schedules
private void PickSchedule_Load(object sender, EventArgs e)
{ rs = new SSRSWebService.ReportingService2010();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
Schedule[] schedules = null;
try
{
schedules = rs.ListSchedules(null);
if (schedules != null)
{
//Build list items
ArrayList aList = new ArrayList();
// Now add the Do Not Schedule item
aList.Add(new ComboItem("Do not schedule", "NS"));
// And the Snapshot schedule
aList.Add(new ComboItem("Schedule with Snapshot", "SS"));
foreach (Schedule s in schedules)
{
aList.Add(new ComboItem(s.Description, s.ScheduleID));
Debug.WriteLine(String.Format
("Desc: {0} - ID: {1}", s.Description, s.ScheduleID));
}
//Bind list items to combo box
sharedSchedules.DataSource = aList;
sharedSchedules.DisplayMember = "Display";
sharedSchedules.ValueMember = "Value";
}
}
catch (SoapException ex) { MessageBox.Show(ex.Detail.InnerXml.ToString()); }
}
Scheduling the Report
Now that you have the list of available scheduling options, you need to add some code to handle the case
in which the user has selected to schedule the report to be delivered based on one of the shared
schedules or on the creation of a snapshot. To do this, you’ll use another method of the Report Service
Web service, CreateSubscription. The CreateSubscription method of the API takes six parameters:
- Report: The full path name of the report for which to create a subscription.
- ExtensionSettings: A delivery extension that contains a list of settings specific to
the extension. SSRS 2012 comes with two built-in extensions: the Email Delivery
extension and the File Share Delivery extension. - Description: A meaningful description displayed to users.