private void getParameters_Click(object sender, EventArgs e) { reportURL.Text = "http://localhost/reportserver?/Pro_SSRS/Chapter_6/EmployeeServiceCost"; GetParameters reportParameters = new GetParameters(reportURL.Text); if (reportParameters.ShowDialog() == DialogResult.OK) { reportViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote; reportViewer.ServerReport.ReportServerUrl = new Uri(@"http://localhost/reportserver/"); reportViewer.ServerReport.ReportPath = "/Pro_SSRS/Chapter_6/EmployeeServiceCost"; reportViewer.ServerReport.SetParameters(reportParameters.Parameters); reportViewer.ShowParameterPrompts = false; reportViewer.RefreshReport(); } }
private void ScheduleReport() { // See if the user wants to schedule this vs. run it now if (sharedSchedules.SelectedValue.ToString() != "NS") { string desc = "Send report via email"; string eventType = String.Empty; string matchData = String.Empty; // If the user selected SnapShot then set up the parameters for a snapshot if (sharedSchedules.SelectedValue.ToString() == "SS") { eventType = "SnapshotUpdated"; matchData = null; } // otherwise the user is using a subscription else { eventType = "TimedSubscription"; matchData = sharedSchedules.SelectedValue.ToString(); } ParameterValue[] extensionParams = new ParameterValue[8]; extensionParams[0] = new ParameterValue(); extensionParams[0].Name = "TO"; extensionParams[0].Value = GetEmailFromAD(); extensionParams[1] = new ParameterValue(); extensionParams[1].Name = "ReplyTo"; extensionParams[1].Value = "*****@*****.**"; extensionParams[2] = new ParameterValue(); extensionParams[2].Name = "IncludeReport"; extensionParams[2].Value = "True"; extensionParams[3] = new ParameterValue(); extensionParams[3].Name = "RenderFormat"; extensionParams[3].Value = "PDF"; extensionParams[4] = new ParameterValue(); extensionParams[4].Name = "Subject"; extensionParams[4].Value = "@ReportName was executed at @ExecutionTime"; extensionParams[5] = new ParameterValue(); extensionParams[5].Name = "Comment"; extensionParams[5].Value = "Here is your @ReportName report."; extensionParams[6] = new ParameterValue(); extensionParams[6].Name = "IncludeLink"; extensionParams[6].Value = "True"; extensionParams[7] = new ParameterValue(); extensionParams[7].Name = "Priority"; extensionParams[7].Value = "NORMAL"; // Configure the extension settings required for the CreateSubscription method ExtensionSettings extSettings = new ExtensionSettings(); extSettings.ParameterValues = extensionParams; extSettings.Extension = "Report Server Email"; // Get the reports parameters using the GetParameters form GetParameters reportParameters = new GetParameters(url); reportParameters.ShowDialog(); Microsoft.Reporting.WinForms.ReportParameter[] rps = reportParameters.Parameters; // Convert the Winforms.ReportParameter returned from the GetParameters // to ParameterValues required for the CreateSubscription method int i = 0; foreach (Microsoft.Reporting.WinForms.ReportParameter rp in rps) { if (rp.Values.Count != 0) { i++; } } ParameterValue[] pvs = new ParameterValue[i]; int j = 0; foreach (Microsoft.Reporting.WinForms.ReportParameter rp in rps) { if (rp.Values.Count != 0) { pvs[j] = new ParameterValue(); pvs[j].Name = rp.Name; pvs[j].Value = rp.Values[0]; j++; } } // Now setup the subscription try { rs.CreateSubscription(report, extSettings, desc, eventType, matchData, pvs); } catch (SoapException ex) { MessageBox.Show(ex.Detail.InnerXml.ToString()); } } }