Blame view

Vrh.Web.OneReport.Lib/ReportViewerForMVC/ReportExtensions.cs 2.16 KB
ab9f2fbe   Schwirg László   Add project files.
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
  using Microsoft.Reporting.WebForms;
  using System;
  using System.Linq;
  
  namespace Vrh.Web.OneReport.ReportViewerForMvc
  {
      /// <summary>
      /// ReportExtensions helpers for ReportViewerForMvc
      /// </summary>
      public static class ReportExtensions
      {
          /// <summary>
          /// Set the ReportParameters of the specified ReportParameterInfoCollection.
          /// </summary>
          /// <param name="report">The Report that this method extends.</param>
          /// <param name="collection">The collection whose ReportParameters should be added to the Report.</param>
          public static void SetParameters(this Report report, ReportParameterInfoCollection collection)
          {
              if (report == null)
              {
                  throw new ArgumentNullException("report", "Value cannot be null.");
              }
              if (collection == null)
              {
                  throw new ArgumentNullException("collection", "Value cannot be null.");
              }
  
              foreach (ReportParameterInfo reportParameterInfo in collection)
              {
                  report.SetParameters(reportParameterInfo);
              }
          }
  
          /// <summary>
          /// Set the ReportParameter of the specified ReportParameterInfo.
          /// </summary>
          /// <param name="report">The Report that this method extends.</param>
          /// <param name="reportParameterInfo">The ReportParameterInfor whose parameter should be added to the Report.</param>
          public static void SetParameters(this Report report, ReportParameterInfo reportParameterInfo)
          {
              if (report == null)
              {
                  throw new ArgumentNullException("report", "Value cannot be null.");
              }
  
              if (reportParameterInfo == null)
              {
                  throw new ArgumentNullException("reportParameterInfo", "Value cannot be null.");
              }
  
              ReportParameter reportParameter = new ReportParameter(
                      reportParameterInfo.Name,
                      reportParameterInfo.Values.ToArray(),
                      reportParameterInfo.Visible);
  
              report.SetParameters(reportParameter);
          }
      }
  }