ReportViewerExtensions.cs
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using Microsoft.Reporting.WebForms;
using System;
using System.Linq;
namespace Vrh.Web.OneReport.ReportViewerForMvc
{
/// <summary>
/// ReportViewerExtensions helpers for ReportViewerForMvc
/// </summary>
public static class ReportViewerExtensions
{
/// <summary>
/// Copy the properties of the specified ReportViewer to the ReportViewer.
/// </summary>
/// <param name="reportViewer">The ReportViewer that this method extends.</param>
/// <param name="properties">The ReportViewer whose properties should be copied to the ReportViewer.</param>
public static void SetProperties(this ReportViewer reportViewer, ReportViewer properties)
{
if (reportViewer == null)
{
throw new ArgumentNullException("reportViewer", "Value cannot be null.");
}
CopyPropertiesHelper.Copy<ReportViewer>(ref reportViewer, properties);
reportViewer.LocalReport.SetProperties(properties.LocalReport);
reportViewer.ServerReport.SetProperties(properties.ServerReport);
}
/// <summary>
/// Copy the properties of the specified LocalReport to the LocalReport.
/// </summary>
/// <param name="localReport">The LocalReport that this method extends.</param>
/// <param name="properties">The LocalReport whose properties should be copied to the LocalReport.</param>
public static void SetProperties(this LocalReport localReport, LocalReport properties)
{
if (localReport == null)
{
throw new ArgumentNullException("localReport", "Value cannot be null.");
}
CopyPropertiesHelper.Copy<LocalReport>(ref localReport, properties);
localReport.DataSources.Add(properties.DataSources.ToList());
try
{
localReport.SetParameters(properties.GetParameters());
}
catch (MissingReportSourceException) { } //Do nothing
}
/// <summary>
/// Copy the properties of the specified ServerReport to the ServerReport.
/// </summary>
/// <param name="serverReport">The ServerReport that this method extends.</param>
/// <param name="properties">The ServerReport whose properties should be copied to the ServerReport.</param>
public static void SetProperties(this ServerReport serverReport, ServerReport properties)
{
if (serverReport == null)
{
throw new ArgumentNullException("serverReport", "Value cannot be null.");
}
CopyPropertiesHelper.Copy<ServerReport>(ref serverReport, properties);
try
{
serverReport.SetParameters(properties.GetParameters());
}
catch (MissingReportSourceException) { } //Do nothing
}
}
}