├── ReportViewerForMvc.Example ├── Views │ ├── _ViewStart.cshtml │ ├── Examples │ │ ├── LocalReportExample.cshtml │ │ ├── ServerReportExample.cshtml │ │ └── AnonymousExample.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── Home │ │ └── Index.cshtml │ └── Web.config ├── favicon.ico ├── Global.asax ├── Scripts │ ├── _references.js │ ├── respond.min.js │ └── respond.js ├── Reports │ ├── dsLocalReport.cs │ ├── dsLocalReport.xsc │ ├── dsLocalReport.xss │ ├── dsLocalReport.xsd │ └── LocalReportExample.rdlc ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff ├── App_Start │ ├── FilterConfig.cs │ ├── RouteConfig.cs │ └── BundleConfig.cs ├── Controllers │ ├── HomeController.cs │ └── ExamplesController.cs ├── Global.asax.cs ├── Content │ └── Site.css ├── ReportViewerWebForm.aspx ├── packages.config ├── Web.Debug.config ├── Web.Release.config ├── Properties │ └── AssemblyInfo.cs ├── SqlServerTypes │ ├── Loader.cs │ └── readme.htm ├── Web.config ├── Project_Readme.html └── ReportViewerForMvc.Example.csproj ├── NuGet ├── lib │ └── net461 │ │ └── ReportViewerForMvc.dll ├── nuget_pack.bat ├── content │ ├── web.config.transform │ └── ReportViewerWebForm.aspx └── ReportViewerForMvc.nuspec ├── ReportViewerForMvc ├── Scripts │ ├── PostMessage.js │ └── ReceiveMessage.js ├── packages.config ├── ReportViewerWebForm.aspx.cs ├── WebResourceHelper.cs ├── ReportViewerWebForm.aspx ├── ReportDataSourceCollectionExtensions.cs ├── ReportViewerWebForm.aspx.designer.cs ├── CopyPropertiesHelper.cs ├── Properties │ └── AssemblyInfo.cs ├── ReportExtensions.cs ├── IframeBuilder.cs ├── ReportViewerExtensions.cs ├── ReportViewerHelpers.cs ├── ReportViewerForMvc.cs ├── HtmlHelperExtensions.cs └── ReportViewerForMvc.csproj ├── ReportViewerForMvc.Tests ├── Reports │ └── ReportData.cs ├── TestViewDataContainer.cs ├── Properties │ ├── DataSources │ │ └── ReportViewerForMvc.Tests.Reports.ReportTable.datasource │ └── AssemblyInfo.cs ├── packages.config ├── app.config ├── ReportDataSourceCollectionExtensionsTests.cs ├── SqlServerTypes │ ├── Loader.cs │ └── readme.htm ├── ReportExtensionsTests.cs ├── ReportViewerExtensionsTests.cs ├── TestData.cs ├── HtmlHelperExtensionsTests.cs ├── ReportViewerForMvcTests.cs └── ReportViewerForMvc.Tests.csproj ├── LICENSE ├── README.md ├── ReportViewerForMvc.sln └── .gitignore /ReportViewerForMvc.Example/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chasoliveira/ReportViewerForMvc/HEAD/ReportViewerForMvc.Example/favicon.ico -------------------------------------------------------------------------------- /NuGet/lib/net461/ReportViewerForMvc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chasoliveira/ReportViewerForMvc/HEAD/NuGet/lib/net461/ReportViewerForMvc.dll -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="ReportViewerForMvc.Example.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Scripts/_references.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chasoliveira/ReportViewerForMvc/HEAD/ReportViewerForMvc.Example/Scripts/_references.js -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Reports/dsLocalReport.cs: -------------------------------------------------------------------------------- 1 | namespace ReportViewerForMvc.Example.Reports 2 | { 3 | 4 | 5 | public partial class dsLocalReport 6 | { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chasoliveira/ReportViewerForMvc/HEAD/ReportViewerForMvc.Example/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chasoliveira/ReportViewerForMvc/HEAD/ReportViewerForMvc.Example/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chasoliveira/ReportViewerForMvc/HEAD/ReportViewerForMvc.Example/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /NuGet/nuget_pack.bat: -------------------------------------------------------------------------------- 1 | ::nuget pack ..\ReportViewerForMvc\ReportViewerForMvc.csproj -Properties Configuration=Release 2 | robocopy ..\ReportViewerForMvc\bin\Release lib\net461 ReportViewerForMvc.dll /is 3 | 4 | nuget pack ReportViewerForMvc.nuspec -Exclude *.bat 5 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Views/Examples/LocalReportExample.cshtml: -------------------------------------------------------------------------------- 1 | @using ReportViewerForMvc; 2 | 3 | @{ 4 | ViewBag.Title = "LocalReportExample"; 5 | } 6 | 7 | 8 |

Local report example

9 | 10 | @Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer) 11 | 12 | 13 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Views/Examples/ServerReportExample.cshtml: -------------------------------------------------------------------------------- 1 | @using ReportViewerForMvc; 2 | 3 | @{ 4 | ViewBag.Title = "Control Example"; 5 | } 6 | 7 |

Server report example

8 | 9 | @Html.ReportViewer( 10 | ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, 11 | new { scrolling = "no" }) 12 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace ReportViewerForMvc.Example 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ReportViewerForMvc/Scripts/PostMessage.js: -------------------------------------------------------------------------------- 1 | Sys.Application.add_load(function () { 2 | $find("ReportViewer1").add_propertyChanged(viewerPropertyChanged); 3 | }); 4 | 5 | function viewerPropertyChanged(sender, e) { 6 | if (e.get_propertyName() === "isLoading") { 7 | top.postMessage("", '*'); //Trigger resize. 8 | } 9 | } 10 | 11 | //TODO: Get control ID dynamically. -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | 9 | Error 10 | 11 | 12 |
13 |

Error.

14 |

An error occurred while processing your request.

15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace ReportViewerForMvc.Example.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public ActionResult Index() 12 | { 13 | return View(); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Reports/dsLocalReport.xsc: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/Reports/ReportData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ReportViewerForMvc.Tests.Reports 9 | { 10 | public class ReportData 11 | { 12 | } 13 | 14 | public class ReportTable : DataTable 15 | { 16 | public ReportTable() 17 | { 18 | Columns.Add("Column1"); 19 | Columns.Add("Column2"); 20 | Columns.Add("Column3"); 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /ReportViewerForMvc/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Optimization; 7 | using System.Web.Routing; 8 | 9 | namespace ReportViewerForMvc.Example 10 | { 11 | public class MvcApplication : System.Web.HttpApplication 12 | { 13 | protected void Application_Start() 14 | { 15 | AreaRegistration.RegisterAllAreas(); 16 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | BundleConfig.RegisterBundles(BundleTable.Bundles); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/TestViewDataContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web; 7 | using System.Web.Mvc; 8 | 9 | namespace ReportViewerForMvc.Tests 10 | { 11 | public class TestViewDataContainer : IViewDataContainer 12 | { 13 | private ViewDataDictionary viewData = new ViewDataDictionary(); 14 | public ViewDataDictionary ViewData 15 | { 16 | get 17 | { 18 | return this.viewData; 19 | } 20 | set 21 | { 22 | this.viewData = value; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace ReportViewerForMvc.Example 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/Properties/DataSources/ReportViewerForMvc.Tests.Reports.ReportTable.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | ReportViewerForMvc.Tests.Reports.ReportTable, ReportViewerForMvc.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /NuGet/content/web.config.transform: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportViewerWebForm.aspx.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Reporting.WebForms; 2 | using System; 3 | using System.Web.UI.WebControls; 4 | 5 | namespace ReportViewerForMvc 6 | { 7 | /// 8 | /// The Web Form used for rendering a ReportViewer control. 9 | /// 10 | public partial class ReportViewerWebForm : System.Web.UI.Page 11 | { 12 | protected void Page_Load(object sender, EventArgs e) 13 | { 14 | BuildReportViewer(); 15 | } 16 | 17 | private void BuildReportViewer() 18 | { 19 | if (!IsPostBack) 20 | { 21 | ReportViewerForMvc.ReportViewer.ID = ReportViewer1.ID; 22 | 23 | ReportViewer1.SetProperties(ReportViewerForMvc.ReportViewer); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /ReportViewerForMvc/WebResourceHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace ReportViewerForMvc 5 | { 6 | internal static class WebResourceHelper 7 | { 8 | internal static string GetWebResourceUrl(Type type, string resourceName) 9 | { 10 | string resourceUrl = null; 11 | 12 | Page page = new Page(); 13 | try 14 | { 15 | resourceUrl = page.ClientScript.GetWebResourceUrl(type, resourceName); 16 | } 17 | catch (ArgumentNullException) 18 | { 19 | //TODO: Validate if IIS is not running. Unit testing fails due basepath is null. 20 | //in the meanwhile do nothing ...like my boss. 21 | } 22 | 23 | return resourceUrl; 24 | } 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Set width on the form input elements since they're 100% wide by default */ 13 | input, 14 | select, 15 | textarea { 16 | max-width: 280px; 17 | } 18 | 19 | /* styles for validation helpers */ 20 | .field-validation-error { 21 | color: #b94a48; 22 | } 23 | 24 | .field-validation-valid { 25 | display: none; 26 | } 27 | 28 | input.input-validation-error { 29 | border: 1px solid #b94a48; 30 | } 31 | 32 | input[type="checkbox"].input-validation-error { 33 | border: 0 none; 34 | } 35 | 36 | .validation-summary-errors { 37 | color: #b94a48; 38 | } 39 | 40 | .validation-summary-valid { 41 | display: none; 42 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Reports/dsLocalReport.xss: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Views/Examples/AnonymousExample.cshtml: -------------------------------------------------------------------------------- 1 | @using ReportViewerForMvc; 2 | @using System.Web.UI.WebControls; 3 | 4 | @{ 5 | ViewBag.Title = "Anonymous Example"; 6 | } 7 | 8 |

AnonymousExample

9 | 10 | @{ 11 | List dataList = new List(); 12 | var data = new 13 | { 14 | Dept = "Document Control", 15 | Shift = "Day", 16 | EmployeeID = "1" 17 | }; 18 | dataList.Add(data); 19 | } 20 | 21 | @Html.ReportViewer( 22 | new 23 | { 24 | ProcessingMode = 0, //ProcessingMode.Local 25 | SizeToReportContent = true, 26 | Width = Unit.Percentage(100), 27 | Height = Unit.Percentage(100) 28 | }, 29 | new 30 | { 31 | ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\LocalReportExample.rdlc" 32 | }, 33 | new 34 | { 35 | ReportTitle = "Local Report Example" 36 | }, 37 | new 38 | { 39 | Name = "dsLocalReport", 40 | Value = dataList 41 | }, 42 | null) -------------------------------------------------------------------------------- /NuGet/content/ReportViewerWebForm.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="True" CodeBehind="ReportViewerWebForm.aspx.cs" Inherits="ReportViewerForMvc.ReportViewerWebForm" %> 2 | 3 | <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportViewerWebForm.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="True" CodeBehind="ReportViewerWebForm.aspx.cs" Inherits="ReportViewerForMvc.ReportViewerWebForm" %> 2 | 3 | <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/ReportViewerWebForm.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="True" CodeBehind="ReportViewerWebForm.aspx.cs" Inherits="ReportViewerForMvc.ReportViewerWebForm" %> 2 | 3 | <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /ReportViewerForMvc/Scripts/ReceiveMessage.js: -------------------------------------------------------------------------------- 1 | var ReportViewerForMvc = ReportViewerForMvc || (new function () { 2 | 3 | var _iframeId = {}; 4 | 5 | var resizeIframe = function (msg) { 6 | var height = msg.source.document.body.scrollHeight; 7 | var width = msg.source.document.body.scrollWidth; 8 | 9 | $(ReportViewerForMvc.getIframeId()).height(height); 10 | $(ReportViewerForMvc.getIframeId()).width(width); 11 | } 12 | 13 | var addEvent = function (element, eventName, eventHandler) { 14 | if (element.addEventListener) { 15 | element.addEventListener(eventName, eventHandler); 16 | } else if (element.attachEvent) { 17 | element.attachEvent('on' + eventName, eventHandler); 18 | } 19 | } 20 | 21 | this.setIframeId = function (value) { 22 | _iframeId = '#' + value; 23 | }; 24 | 25 | this.getIframeId = function () { 26 | return _iframeId; 27 | }; 28 | 29 | this.setAutoSize = function () { 30 | addEvent(window, 'message', resizeIframe); 31 | } 32 | 33 | }()); 34 | 35 | ReportViewerForMvc.setAutoSize(); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014 Armando Aguirre Sepulveda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace ReportViewerForMvc.Example 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 15 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 16 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 17 | "~/Scripts/modernizr-*")); 18 | 19 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 20 | "~/Scripts/bootstrap.js", 21 | "~/Scripts/respond.js")); 22 | 23 | bundles.Add(new StyleBundle("~/Content/css").Include( 24 | "~/Content/bootstrap.css", 25 | "~/Content/site.css")); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /NuGet/ReportViewerForMvc.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Chaso.ReportViewerForMvc 5 | 1.1.1.1 6 | ReportViewer for MVC 7 | Armando Aguirre, Charles Oliveira 8 | Armando Aguirre 9 | https://github.com/chasoliveira/ReportViewerForMvc/blob/master/LICENSE 10 | https://github.com/chasoliveira/ReportViewerForMvc 11 | true 12 | 13 | ReportViewer for MVC is a .NET project that make possible to use an ASP.NET ReportViewer control into an MVC web application. 14 | It provides a set of HTML Helpers and a simple ASP.NET Web Form for displaying the ReportViewer within an auto-resized iframe tag. 15 | Update to depends of Microsoft.ReportingServices.ReportViewerControl.WebForms Version 140.1000.523. 16 | 17 | Copyright (c) 2014 Armando Aguirre Sepulveda 18 | ReportViewer MVC Report Viewer Reports SSRS HtmlHelper HtmlHelpers Reporting Chaso Chasoliveira 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportDataSourceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Reporting.WebForms; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace ReportViewerForMvc 6 | { 7 | /// 8 | /// ReportDataSourceCollectionExtensions helpers for ReportViewerForMvc 9 | /// 10 | public static class ReportDataSourceCollectionExtensions 11 | { 12 | /// 13 | /// Adds the elements of the specified collection to the end of the ReportDataSourceCollection. 14 | /// 15 | /// The ReportDataSourceCollection that this method extends. 16 | /// The collection whose elements should be added to the end of the ReportDataSourceCollection. 17 | public static void Add(this ReportDataSourceCollection reportDataSourceCollection, IEnumerable collection) 18 | { 19 | if (reportDataSourceCollection == null) 20 | { 21 | throw new ArgumentNullException("reportDataSourceCollection", "Value cannot be null."); 22 | } 23 | if (collection == null) 24 | { 25 | throw new ArgumentNullException("collection", "Value cannot be null."); 26 | } 27 | 28 | foreach (ReportDataSource reportDataSource in collection) 29 | { 30 | reportDataSourceCollection.Add(reportDataSource); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ReportViewerForMvc.Example")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Armando Aguirre")] 12 | [assembly: AssemblyProduct("ReportViewerForMvc.Example")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8091dd20-a1e2-483f-a8ed-e478ec14e373")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "ReportViewerForMvc Helper"; 3 | } 4 | 5 |
6 |

ASP.NET

7 |

ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.

8 |

Learn more »

9 |
10 | 11 |
12 |
13 |

Getting started

14 |

15 | ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that 16 | enables a clean separation of concerns and gives you full control over markup 17 | for enjoyable, agile development. 18 |

19 |

Learn more »

20 |
21 |
22 |

Get more libraries

23 |

NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

24 |

Learn more »

25 |
26 |
27 |

Web Hosting

28 |

You can easily find a web hosting company that offers the right mix of features and price for your applications.

29 |

Learn more »

30 |
31 |
-------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ReportViewerForMvc.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Armando Aguirre")] 12 | [assembly: AssemblyProduct("ReportViewerForMvc.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("55475572-6b43-41c5-aada-95bc3788e2f2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportViewerWebForm.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace ReportViewerForMvc { 11 | 12 | 13 | public partial class ReportViewerWebForm { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// ScriptManager1 control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.ScriptManager ScriptManager1; 32 | 33 | /// 34 | /// ReportViewer1 control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::Microsoft.Reporting.WebForms.ReportViewer ReportViewer1; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/ReportDataSourceCollectionExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Microsoft.Reporting.WebForms; 4 | using System.Linq; 5 | 6 | namespace ReportViewerForMvc.Tests 7 | { 8 | [TestClass] 9 | public class ReportDataSourceCollectionExtensionsTests 10 | { 11 | private TestData testData = new TestData(); 12 | 13 | [TestMethod] 14 | public void Add_WithReportDataSourceList() 15 | { 16 | LocalReport localReport = new LocalReport(); 17 | 18 | localReport.DataSources.Add(testData.ReportViewerTests.LocalReport.DataSources.ToList()); 19 | 20 | Assert.AreEqual(localReport.DataSources.Count, testData.ReportViewerTests.LocalReport.DataSources.Count); 21 | foreach(var reportDataSource in localReport.DataSources) 22 | { 23 | Assert.AreEqual(testData.ReportViewerTests.LocalReport.DataSources[reportDataSource.Name], reportDataSource); 24 | } 25 | } 26 | 27 | [TestMethod] 28 | [ExpectedException(typeof(ArgumentNullException))] 29 | public void Add_WithNullInstance() 30 | { 31 | ReportDataSourceCollectionExtensions.Add(null, testData.ReportViewerTests.LocalReport.DataSources.ToList()); 32 | } 33 | 34 | [TestMethod] 35 | [ExpectedException(typeof(ArgumentNullException))] 36 | public void Add_WithNullCollection() 37 | { 38 | LocalReport localReport = new LocalReport(); 39 | localReport.DataSources.Add(null); 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ReportViewerForMvc/CopyPropertiesHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace ReportViewerForMvc 5 | { 6 | internal static class CopyPropertiesHelper 7 | { 8 | internal static void Copy(ref T obj, T properties) 9 | { 10 | if (properties == null) 11 | { 12 | throw new ArgumentNullException("properties", "Value cannot be null."); 13 | } 14 | 15 | Copy(ref obj, properties); 16 | } 17 | 18 | internal static void Copy(ref T1 obj, T2 properties) 19 | { 20 | Type objType = obj.GetType(); 21 | Type propertiesType = properties.GetType(); 22 | BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance; 23 | 24 | foreach (PropertyInfo propertyInfo in propertiesType.GetProperties(bindingFlags)) 25 | { 26 | try 27 | { 28 | if (propertyInfo.CanRead) 29 | { 30 | var valueToCopy = propertyInfo.GetValue(properties); 31 | var objProperty = objType.GetProperty(propertyInfo.Name); 32 | 33 | if (objProperty.CanWrite) 34 | { 35 | objProperty.SetValue(obj, valueToCopy); 36 | } 37 | } 38 | } 39 | catch (NullReferenceException ex) 40 | { 41 | throw ex; 42 | } 43 | catch (TargetInvocationException) { } //Do nothing, just like my boss. 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Views/Web.config: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /ReportViewerForMvc/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ReportViewerForMvc")] 9 | [assembly: AssemblyDescription("MVC HTML helpers for ReportViewer control.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Armando Aguirre")] 12 | [assembly: AssemblyProduct("ReportViewerForMvc")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2014 Armando Aguirre Sepulveda")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0e626bc2-cc54-4d59-822c-7fc1f290ac0d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.1.0")] 36 | [assembly: AssemblyFileVersion("1.1.1.0")] 37 | 38 | [assembly: System.Web.UI.WebResource("ReportViewerForMvc.Scripts.ReceiveMessage.js", "application/x-javascript")] 39 | [assembly: System.Web.UI.WebResource("ReportViewerForMvc.Scripts.PostMessage.js", "application/x-javascript")] -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/SqlServerTypes/Loader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace SqlServerTypes 6 | { 7 | /// 8 | /// Utility methods related to CLR Types for SQL Server 9 | /// 10 | public class Utilities 11 | { 12 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 13 | private static extern IntPtr LoadLibrary(string libname); 14 | 15 | /// 16 | /// Loads the required native assemblies for the current architecture (x86 or x64) 17 | /// 18 | /// 19 | /// Root path of the current application. Use Server.MapPath(".") for ASP.NET applications 20 | /// and AppDomain.CurrentDomain.BaseDirectory for desktop applications. 21 | /// 22 | public static void LoadNativeAssemblies(string rootApplicationPath) 23 | { 24 | var nativeBinaryPath = IntPtr.Size > 4 25 | ? Path.Combine(rootApplicationPath, @"SqlServerTypes\x64\") 26 | : Path.Combine(rootApplicationPath, @"SqlServerTypes\x86\"); 27 | 28 | LoadNativeAssembly(nativeBinaryPath, "msvcr120.dll"); 29 | LoadNativeAssembly(nativeBinaryPath, "SqlServerSpatial140.dll"); 30 | } 31 | 32 | private static void LoadNativeAssembly(string nativeBinaryPath, string assemblyName) 33 | { 34 | var path = Path.Combine(nativeBinaryPath, assemblyName); 35 | var ptr = LoadLibrary(path); 36 | if (ptr == IntPtr.Zero) 37 | { 38 | throw new Exception(string.Format( 39 | "Error loading {0} (ErrorCode: {1})", 40 | assemblyName, 41 | Marshal.GetLastWin32Error())); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/SqlServerTypes/Loader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace SqlServerTypes 6 | { 7 | /// 8 | /// Utility methods related to CLR Types for SQL Server 9 | /// 10 | public class Utilities 11 | { 12 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 13 | private static extern IntPtr LoadLibrary(string libname); 14 | 15 | /// 16 | /// Loads the required native assemblies for the current architecture (x86 or x64) 17 | /// 18 | /// 19 | /// Root path of the current application. Use Server.MapPath(".") for ASP.NET applications 20 | /// and AppDomain.CurrentDomain.BaseDirectory for desktop applications. 21 | /// 22 | public static void LoadNativeAssemblies(string rootApplicationPath) 23 | { 24 | var nativeBinaryPath = IntPtr.Size > 4 25 | ? Path.Combine(rootApplicationPath, @"SqlServerTypes\x64\") 26 | : Path.Combine(rootApplicationPath, @"SqlServerTypes\x86\"); 27 | 28 | LoadNativeAssembly(nativeBinaryPath, "msvcr120.dll"); 29 | LoadNativeAssembly(nativeBinaryPath, "SqlServerSpatial140.dll"); 30 | } 31 | 32 | private static void LoadNativeAssembly(string nativeBinaryPath, string assemblyName) 33 | { 34 | var path = Path.Combine(nativeBinaryPath, assemblyName); 35 | var ptr = LoadLibrary(path); 36 | if (ptr == IntPtr.Zero) 37 | { 38 | throw new Exception(string.Format( 39 | "Error loading {0} (ErrorCode: {1})", 40 | assemblyName, 41 | Marshal.GetLastWin32Error())); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ReportViewerForMvc - @ViewBag.Title 7 | @Styles.Render("~/Content/css") 8 | @Scripts.Render("~/bundles/modernizr") 9 | 10 | 11 | 31 |
32 | @RenderBody() 33 |
34 |
35 |

© @DateTime.Now.Year - My ASP.NET Application

36 |
37 |
38 | 39 | @Scripts.Render("~/bundles/jquery") 40 | @Scripts.Render("~/bundles/bootstrap") 41 | @RenderSection("scripts", required: false) 42 | 43 | 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReportViewer for MVC 2 | 3 | ReportViewer for MVC is a simple library that makes it possible to use an ASP.NET ReportViewer control in an ASP.NET MVC application. 4 | 5 | It provides a set of HTML Helpers and all of it's dependencies for displaying a report. Local or server, it handles all. 6 | 7 | ## Why do I need this? 8 | 9 | Server controls (like ReportViewer) cannot be used within Razor views. In order to use a control, you would need to add an ASPX view page and all of it's configurations, as well as, work through the code. 10 | 11 | This library will setup all of that work for you, and will provide easy access to display your report. Also, it will auto-resize the report on your webpage to get the desired display. 12 | 13 | ## Where can I get it? 14 | This is a version modified to .Netframework 4.6.1 15 | Download & install from [NuGet](https://www.nuget.org/packages/Chaso.ReportViewerForMvc/). 16 | 17 | ```PowerShell 18 | Install-Package Chaso.ReportViewerForMvc -Version 1.1.1.1 19 | ``` 20 | ## The Original Source Is! 21 | Download & install from [NuGet](https://www.nuget.org/packages/ReportViewerForMvc/). 22 | 23 | ```PowerShell 24 | PM> Install-Package ReportViewerForMvc 25 | ``` 26 | 27 | ## How do I use it? 28 | 29 | After installing, the simplest solution is to setup the report on the controller and render it on the view. 30 | 31 | The example below, will configure a report on localhost and auto-resize it. Check more details on the [Getting Started](https://github.com/armanio123/ReportViewerForMvc/wiki/Getting-Started) page. 32 | 33 | Controller: 34 | 35 | ```C# 36 | var reportViewer = new ReportViewer() 37 | { 38 | ProcessingMode = ProcessingMode.Remote, 39 | SizeToReportContent = true, 40 | Width = Unit.Percentage(100), 41 | Height = Unit.Percentage(100), 42 | }; 43 | 44 | reportViewer.ServerReport.ReportPath = "/ReportFolder/SampleReport"; 45 | reportViewer.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer/"); 46 | 47 | ViewBag.ReportViewer = reportViewer; 48 | ``` 49 | 50 | View: 51 | 52 | ```C# 53 | @Html.ReportViewer( 54 | ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, 55 | new { scrolling = "no" }) 56 | ``` 57 | 58 | ## More info 59 | 60 | Check the [Wiki](https://github.com/armanio123/ReportViewerForMvc/wiki) for the project. -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Reporting.WebForms; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace ReportViewerForMvc 6 | { 7 | /// 8 | /// ReportExtensions helpers for ReportViewerForMvc 9 | /// 10 | public static class ReportExtensions 11 | { 12 | /// 13 | /// Set the ReportParameters of the specified ReportParameterInfoCollection. 14 | /// 15 | /// The Report that this method extends. 16 | /// The collection whose ReportParameters should be added to the Report. 17 | public static void SetParameters(this Report report, ReportParameterInfoCollection collection) 18 | { 19 | if (report == null) 20 | { 21 | throw new ArgumentNullException("report", "Value cannot be null."); 22 | } 23 | if (collection == null) 24 | { 25 | throw new ArgumentNullException("collection", "Value cannot be null."); 26 | } 27 | 28 | foreach (ReportParameterInfo reportParameterInfo in collection) 29 | { 30 | report.SetParameters(reportParameterInfo); 31 | } 32 | } 33 | 34 | /// 35 | /// Set the ReportParameter of the specified ReportParameterInfo. 36 | /// 37 | /// The Report that this method extends. 38 | /// The ReportParameterInfor whose parameter should be added to the Report. 39 | public static void SetParameters(this Report report, ReportParameterInfo reportParameterInfo) 40 | { 41 | if (report == null) 42 | { 43 | throw new ArgumentNullException("report", "Value cannot be null."); 44 | } 45 | 46 | if (reportParameterInfo == null) 47 | { 48 | throw new ArgumentNullException("reportParameterInfo", "Value cannot be null."); 49 | } 50 | 51 | ReportParameter reportParameter = new ReportParameter( 52 | reportParameterInfo.Name, 53 | reportParameterInfo.Values.ToArray(), 54 | reportParameterInfo.Visible); 55 | 56 | report.SetParameters(reportParameter); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/SqlServerTypes/readme.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Microsoft.SqlServer.Types 5 | 17 | 18 | 19 |
20 |

Action required to load native assemblies

21 |

22 | To deploy an application that uses spatial data types to a machine that does not have 'System CLR Types for SQL Server' installed you also need to deploy the native assembly SqlServerSpatial140.dll. Both x86 (32 bit) and x64 (64 bit) versions of this assembly have been added to your project under the SqlServerTypes\x86 and SqlServerTypes\x64 subdirectories. The native assembly msvcr120.dll is also included in case the C++ runtime is not installed. 23 |

24 |

25 | You need to add code to load the correct one of these assemblies at runtime (depending on the current architecture). 26 |

27 |

ASP.NET Web Sites

28 |

29 | For ASP.NET Web Sites, add the following block of code to the code behind file of the Web Form where you have added Report Viewer Control: 30 |

31 |     Default.aspx.cs:
32 |         
33 |     public partial class _Default : System.Web.UI.Page
34 |     {
35 |         static bool _isSqlTypesLoaded = false;
36 | 
37 |         public _Default()
38 |         {
39 |             if (!_isSqlTypesLoaded)
40 |             {
41 |                 SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~"));
42 |                 _isSqlTypesLoaded = true;
43 |             }
44 |             
45 |         }
46 |     }
47 | 
48 |

49 |

ASP.NET Web Applications

50 |

51 | For ASP.NET Web Applications, add the following line of code to the Application_Start method in Global.asax.cs: 52 |

    SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
53 |

54 |

Desktop Applications

55 |

56 | For desktop applications, add the following line of code to run before any spatial operations are performed: 57 |

    SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
58 |

59 |
60 | 61 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/SqlServerTypes/readme.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Microsoft.SqlServer.Types 5 | 17 | 18 | 19 |
20 |

Action required to load native assemblies

21 |

22 | To deploy an application that uses spatial data types to a machine that does not have 'System CLR Types for SQL Server' installed you also need to deploy the native assembly SqlServerSpatial140.dll. Both x86 (32 bit) and x64 (64 bit) versions of this assembly have been added to your project under the SqlServerTypes\x86 and SqlServerTypes\x64 subdirectories. The native assembly msvcr120.dll is also included in case the C++ runtime is not installed. 23 |

24 |

25 | You need to add code to load the correct one of these assemblies at runtime (depending on the current architecture). 26 |

27 |

ASP.NET Web Sites

28 |

29 | For ASP.NET Web Sites, add the following block of code to the code behind file of the Web Form where you have added Report Viewer Control: 30 |

31 |     Default.aspx.cs:
32 |         
33 |     public partial class _Default : System.Web.UI.Page
34 |     {
35 |         static bool _isSqlTypesLoaded = false;
36 | 
37 |         public _Default()
38 |         {
39 |             if (!_isSqlTypesLoaded)
40 |             {
41 |                 SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~"));
42 |                 _isSqlTypesLoaded = true;
43 |             }
44 |             
45 |         }
46 |     }
47 | 
48 |

49 |

ASP.NET Web Applications

50 |

51 | For ASP.NET Web Applications, add the following line of code to the Application_Start method in Global.asax.cs: 52 |

    SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
53 |

54 |

Desktop Applications

55 |

56 | For desktop applications, add the following line of code to run before any spatial operations are performed: 57 |

    SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
58 |

59 |
60 | 61 | -------------------------------------------------------------------------------- /ReportViewerForMvc/IframeBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using System.Web.Mvc; 5 | 6 | namespace ReportViewerForMvc 7 | { 8 | internal class IframeBuilder 9 | { 10 | internal static HtmlString Iframe(object htmlAttributes) 11 | { 12 | IDictionary parsedHtmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); 13 | 14 | ReportViewerForMvc.IframeId = GetId(parsedHtmlAttributes); 15 | 16 | string parsedIframe = CreateIframeTag(parsedHtmlAttributes); 17 | parsedIframe += ReceiveMessageScript(); 18 | parsedIframe += SetIframeIdScript(); 19 | 20 | return new HtmlString(parsedIframe); 21 | } 22 | 23 | private static string GetId(IDictionary htmlAttributes) 24 | { 25 | string id; 26 | 27 | if (htmlAttributes["id"] == null) 28 | { 29 | id = "r" + Guid.NewGuid().ToString(); 30 | } 31 | else 32 | { 33 | id = TagBuilder.CreateSanitizedId(htmlAttributes["id"].ToString()); 34 | 35 | if (id == null) 36 | { 37 | throw new ArgumentNullException("htmlAttributes.id", "Value cannot be null."); 38 | } 39 | } 40 | 41 | return id; 42 | } 43 | 44 | private static string CreateIframeTag(IDictionary htmlAttributes) 45 | { 46 | string applicationPath = (HttpContext.Current.Request.ApplicationPath == "/") ? "" : HttpContext.Current.Request.ApplicationPath; 47 | 48 | TagBuilder tagBuilder = new TagBuilder("iframe"); 49 | tagBuilder.GenerateId(ReportViewerForMvc.IframeId); 50 | tagBuilder.MergeAttribute("src", applicationPath +"/ReportViewerWebForm.aspx"); 51 | tagBuilder.MergeAttributes(htmlAttributes, false); 52 | tagBuilder.SetInnerText("iframes not supported."); 53 | 54 | return tagBuilder.ToString(); 55 | } 56 | 57 | private static string ReceiveMessageScript() 58 | { 59 | string script = ""; 60 | 61 | return script; 62 | } 63 | 64 | private static string SetIframeIdScript() 65 | { 66 | string script = ""; 67 | 68 | return script; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportViewerForMvc.Example", "ReportViewerForMvc.Example\ReportViewerForMvc.Example.csproj", "{F239E560-E292-48B9-B937-9D0CFF12C884}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportViewerForMvc", "ReportViewerForMvc\ReportViewerForMvc.csproj", "{B7F6A951-ECE3-4BDD-BE20-0F7FFD944695}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportViewerForMvc.Tests", "ReportViewerForMvc.Tests\ReportViewerForMvc.Tests.csproj", "{8133D27D-C746-434E-A733-9BC8965A6073}" 11 | EndProject 12 | Global 13 | GlobalSection(TeamFoundationVersionControl) = preSolution 14 | SccNumberOfProjects = 4 15 | SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} 16 | SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs26 17 | SccProjectUniqueName0 = ReportViewerForMvc\\ReportViewerForMvc.csproj 18 | SccProjectName0 = ReportViewerForMvc 19 | SccLocalPath0 = ReportViewerForMvc 20 | SccProjectUniqueName1 = ReportViewerForMvc.Example\\ReportViewerForMvc.Example.csproj 21 | SccProjectName1 = ReportViewerForMvc.Example 22 | SccLocalPath1 = ReportViewerForMvc.Example 23 | SccProjectUniqueName2 = ReportViewerForMvc.Tests\\ReportViewerForMvc.Tests.csproj 24 | SccProjectName2 = ReportViewerForMvc.Tests 25 | SccLocalPath2 = ReportViewerForMvc.Tests 26 | SccLocalPath3 = . 27 | EndGlobalSection 28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 29 | Debug|Any CPU = Debug|Any CPU 30 | Release|Any CPU = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 33 | {F239E560-E292-48B9-B937-9D0CFF12C884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {F239E560-E292-48B9-B937-9D0CFF12C884}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {F239E560-E292-48B9-B937-9D0CFF12C884}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {F239E560-E292-48B9-B937-9D0CFF12C884}.Release|Any CPU.Build.0 = Release|Any CPU 37 | {B7F6A951-ECE3-4BDD-BE20-0F7FFD944695}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 38 | {B7F6A951-ECE3-4BDD-BE20-0F7FFD944695}.Debug|Any CPU.Build.0 = Debug|Any CPU 39 | {B7F6A951-ECE3-4BDD-BE20-0F7FFD944695}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {B7F6A951-ECE3-4BDD-BE20-0F7FFD944695}.Release|Any CPU.Build.0 = Release|Any CPU 41 | {8133D27D-C746-434E-A733-9BC8965A6073}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 42 | {8133D27D-C746-434E-A733-9BC8965A6073}.Debug|Any CPU.Build.0 = Debug|Any CPU 43 | {8133D27D-C746-434E-A733-9BC8965A6073}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {8133D27D-C746-434E-A733-9BC8965A6073}.Release|Any CPU.Build.0 = Release|Any CPU 45 | EndGlobalSection 46 | GlobalSection(SolutionProperties) = preSolution 47 | HideSolutionNode = FALSE 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportViewerExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Reporting.WebForms; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace ReportViewerForMvc 6 | { 7 | /// 8 | /// ReportViewerExtensions helpers for ReportViewerForMvc 9 | /// 10 | public static class ReportViewerExtensions 11 | { 12 | /// 13 | /// Copy the properties of the specified ReportViewer to the ReportViewer. 14 | /// 15 | /// The ReportViewer that this method extends. 16 | /// The ReportViewer whose properties should be copied to the ReportViewer. 17 | public static void SetProperties(this ReportViewer reportViewer, ReportViewer properties) 18 | { 19 | if (reportViewer == null) 20 | { 21 | throw new ArgumentNullException("reportViewer", "Value cannot be null."); 22 | } 23 | 24 | CopyPropertiesHelper.Copy(ref reportViewer, properties); 25 | 26 | reportViewer.LocalReport.SetProperties(properties.LocalReport); 27 | reportViewer.ServerReport.SetProperties(properties.ServerReport); 28 | } 29 | 30 | /// 31 | /// Copy the properties of the specified LocalReport to the LocalReport. 32 | /// 33 | /// The LocalReport that this method extends. 34 | /// The LocalReport whose properties should be copied to the LocalReport. 35 | public static void SetProperties(this LocalReport localReport, LocalReport properties) 36 | { 37 | if (localReport == null) 38 | { 39 | throw new ArgumentNullException("localReport", "Value cannot be null."); 40 | } 41 | 42 | CopyPropertiesHelper.Copy(ref localReport, properties); 43 | 44 | localReport.DataSources.Add(properties.DataSources.ToList()); 45 | 46 | try 47 | { 48 | localReport.SetParameters(properties.GetParameters()); 49 | } 50 | catch (MissingReportSourceException) { } //Do nothing 51 | } 52 | 53 | /// 54 | /// Copy the properties of the specified ServerReport to the ServerReport. 55 | /// 56 | /// The ServerReport that this method extends. 57 | /// The ServerReport whose properties should be copied to the ServerReport. 58 | public static void SetProperties(this ServerReport serverReport, ServerReport properties) 59 | { 60 | if (serverReport == null) 61 | { 62 | throw new ArgumentNullException("serverReport", "Value cannot be null."); 63 | } 64 | 65 | CopyPropertiesHelper.Copy(ref serverReport, properties); 66 | 67 | try 68 | { 69 | serverReport.SetParameters(properties.GetParameters()); 70 | } 71 | catch (MissingReportSourceException) { } //Do nothing 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/ReportExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Microsoft.Reporting.WebForms; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace ReportViewerForMvc.Tests 8 | { 9 | [TestClass] 10 | public class ReportExtensionsTests 11 | { 12 | TestData testData = new TestData(); 13 | 14 | [TestMethod] 15 | public void SetParameters_WithReportParameterInfo() 16 | { 17 | LocalReport report = new LocalReport(); 18 | report.ReportPath = TestData.LocalReportPath; 19 | 20 | foreach (ReportParameterInfo rpi in testData.ReportViewerTests.LocalReport.GetParameters()) 21 | { 22 | report.SetParameters(rpi); 23 | } 24 | 25 | TestLocalReportParameters(testData.ReportViewerTests.LocalReport, report); 26 | } 27 | 28 | [TestMethod] 29 | public void SetParameters_WithReportParameterInfoCollection() 30 | { 31 | LocalReport report = new LocalReport(); 32 | report.ReportPath = TestData.LocalReportPath; 33 | 34 | report.SetParameters(testData.ReportViewerTests.LocalReport.GetParameters()); 35 | 36 | TestLocalReportParameters(testData.ReportViewerTests.LocalReport, report); 37 | } 38 | 39 | [TestMethod] 40 | [ExpectedException(typeof(ArgumentNullException))] 41 | public void SetParameters_WithNullInstance_ReportParameterInfo() 42 | { 43 | ReportExtensions.SetParameters(null, testData.ReportViewerTests.LocalReport.GetParameters()[0]); 44 | } 45 | 46 | [TestMethod] 47 | [ExpectedException(typeof(ArgumentNullException))] 48 | public void SetParameters_WithNullInstance_ReportParameterInfoCollection() 49 | { 50 | ReportExtensions.SetParameters(null, testData.ReportViewerTests.LocalReport.GetParameters()); 51 | } 52 | 53 | [TestMethod] 54 | [ExpectedException(typeof(ArgumentNullException))] 55 | public void SetParameters_WithNullReportParameterInfo() 56 | { 57 | testData.ReportViewerTests.LocalReport.SetParameters(null as ReportParameterInfo); 58 | } 59 | 60 | [TestMethod] 61 | [ExpectedException(typeof(ArgumentNullException))] 62 | public void SetParameters_WithNullReportParameterInfoCollection() 63 | { 64 | testData.ReportViewerTests.LocalReport.SetParameters(null as ReportParameterInfoCollection); 65 | } 66 | 67 | private void TestLocalReportParameters(LocalReport expected, LocalReport actual) 68 | { 69 | ReportParameterInfoCollection collection = actual.GetParameters(); 70 | 71 | IEnumerator expectedEnum = expected.GetParameters().GetEnumerator(); 72 | IEnumerator actualEnum = actual.GetParameters().GetEnumerator(); 73 | 74 | while (expectedEnum.MoveNext() && actualEnum.MoveNext()) 75 | { 76 | Assert.AreEqual(expectedEnum.Current.Name, actualEnum.Current.Name); 77 | Assert.AreEqual(expectedEnum.Current.Visible, actualEnum.Current.Visible); 78 | Assert.IsTrue(expectedEnum.Current.Values.SequenceEqual(actualEnum.Current.Values)); 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportViewerHelpers.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Reporting.WebForms; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Reflection; 6 | 7 | namespace ReportViewerForMvc 8 | { 9 | internal static class ReportViewerHelper 10 | { 11 | internal static ReportViewer AnonymousToReportViewer(object obj) 12 | { 13 | try 14 | { 15 | return obj.ToType(); 16 | } 17 | catch (ArgumentException ex) 18 | { 19 | throw new ArgumentException("Could not convert anonymous object to type ReportViewer", ex); 20 | } 21 | } 22 | 23 | internal static LocalReport AnonymousToLocalReport(object obj) 24 | { 25 | try 26 | { 27 | return obj.ToType(); 28 | } 29 | catch (ArgumentException ex) 30 | { 31 | throw new ArgumentException("Could not convert anonymous object to type LocalReport", ex); 32 | } 33 | } 34 | 35 | internal static ServerReport AnonymousToServerReport(object obj) 36 | { 37 | try 38 | { 39 | return obj.ToType(); 40 | } 41 | catch (ArgumentException ex) 42 | { 43 | throw new ArgumentException("Could not convert anonymous object to type ServerReport", ex); 44 | } 45 | 46 | } 47 | 48 | internal static List AnonymousToReportParameter(object obj) 49 | { 50 | List reportParameters = new List(); 51 | 52 | foreach (KeyValuePair keyValuePair in obj.ToDictionary()) 53 | { 54 | reportParameters.Add(new ReportParameter(keyValuePair.Key, keyValuePair.Value)); 55 | } 56 | 57 | return reportParameters; 58 | } 59 | 60 | internal static List AnonymousToReportDataSourceList(object obj) 61 | { 62 | List reportDataSourceList = new List(); 63 | 64 | try 65 | { 66 | if (obj.GetType().IsArray) 67 | { 68 | foreach (var reportDataSource in (IEnumerable)obj) 69 | { 70 | reportDataSourceList.Add(reportDataSource.ToType()); 71 | } 72 | } 73 | else 74 | { 75 | reportDataSourceList.Add(obj.ToType()); 76 | } 77 | } 78 | catch (ArgumentException ex) 79 | { 80 | throw new ArgumentException("Could not convert anonymous object to type ReportDataSource", ex); 81 | } 82 | 83 | return reportDataSourceList; 84 | } 85 | 86 | private static T ToType(this object obj) 87 | { 88 | if (obj == null) 89 | { 90 | throw new ArgumentNullException("obj", "Value cannot be null."); 91 | } 92 | 93 | T instance = Activator.CreateInstance(); 94 | 95 | foreach (PropertyInfo propertyInfo in obj.GetType().GetProperties()) 96 | { 97 | var property = typeof(T).GetProperty(propertyInfo.Name); 98 | if (property == null) 99 | { 100 | throw new ArgumentException("An attempt was made to set the property '" + propertyInfo.Name + "' that is not found on object type '" + typeof(T).Name + "'"); 101 | } 102 | 103 | property.SetValue(instance, propertyInfo.GetValue(obj)); 104 | } 105 | 106 | return instance; 107 | } 108 | 109 | private static IDictionary ToDictionary(this object obj) 110 | { 111 | IDictionary dic = new Dictionary(); 112 | 113 | foreach (PropertyInfo propertyInfo in obj.GetType().GetProperties()) 114 | { 115 | dic.Add(propertyInfo.Name, propertyInfo.GetValue(obj).ToString()); 116 | } 117 | 118 | return dic; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Controllers/ExamplesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using Microsoft.Reporting.WebForms; 7 | using System.Web.UI.WebControls; 8 | using System.Data; 9 | using System.Data.SqlClient; 10 | using ReportViewerForMvc.Example.Reports; 11 | 12 | namespace ReportViewerForMvc.Example.Controllers 13 | { 14 | public class ExamplesController : Controller 15 | { 16 | private dsLocalReport tds = new dsLocalReport(); 17 | 18 | // 19 | // GET: /Example/ 20 | public ActionResult AnonymousExample() 21 | { 22 | return View(); 23 | } 24 | 25 | /// 26 | /// Creates a ReportViewer control and stores it on the ViewBag 27 | /// 28 | /// 29 | public ActionResult ServerReportExample() 30 | { 31 | ReportViewer reportViewer = new ReportViewer(); 32 | reportViewer.ProcessingMode = ProcessingMode.Remote; 33 | reportViewer.SizeToReportContent = true; 34 | reportViewer.Width = Unit.Percentage(100); 35 | reportViewer.Height = Unit.Percentage(100); 36 | 37 | reportViewer.ServerReport.ReportPath = "/AdventureWorks 2012/Sales_by_Region"; 38 | reportViewer.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer/"); 39 | reportViewer.ServerReport.SetParameters(GetParametersServer()); 40 | 41 | ViewBag.ReportViewer = reportViewer; 42 | 43 | return View(); 44 | } 45 | 46 | /// 47 | /// Creates a ReportViewer control and stores it on the ViewBag 48 | /// 49 | /// 50 | public ActionResult LocalReportExample() 51 | { 52 | SetLocalReport(); 53 | 54 | return View(); 55 | } 56 | 57 | private void SetLocalReport() 58 | { 59 | ReportViewer reportViewer = new ReportViewer(); 60 | reportViewer.ProcessingMode = ProcessingMode.Local; 61 | reportViewer.SizeToReportContent = true; 62 | reportViewer.Width = Unit.Percentage(100); 63 | reportViewer.Height = Unit.Percentage(100); 64 | 65 | FillDataSet(); 66 | reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\LocalReportExample.rdlc"; 67 | reportViewer.LocalReport.DataSources.Add(new ReportDataSource("dsLocalReport", tds.Tables[0])); 68 | reportViewer.LocalReport.SetParameters(GetParametersLocal()); 69 | 70 | ViewBag.ReportViewer = reportViewer; 71 | } 72 | 73 | private void FillDataSet() 74 | { 75 | string connectionString = GetConnectionString(); 76 | 77 | using (SqlConnection sqlConnection = new SqlConnection(connectionString)) 78 | { 79 | string queryString = GetQueryString(); 80 | 81 | SqlDataAdapter sqlDataAapter = new SqlDataAdapter(queryString, sqlConnection); 82 | 83 | sqlDataAapter.Fill(tds, tds.DataTable1.TableName); 84 | } 85 | } 86 | 87 | private string GetConnectionString() 88 | { 89 | return "Data Source=localhost;Initial Catalog=AdventureWorks2012;Integrated Security=True"; 90 | } 91 | 92 | private string GetQueryString() 93 | { 94 | return "SELECT d.name as Dept, s.Name as Shift, e.BusinessEntityID as EmployeeID" 95 | + " FROM (HumanResources.Department d INNER JOIN HumanResources.EmployeeDepartmentHistory e ON d.DepartmentID = e.DepartmentID)" 96 | + " INNER JOIN HumanResources.Shift s ON e.ShiftID = s.ShiftID"; 97 | } 98 | 99 | private ReportParameter[] GetParametersLocal() 100 | { 101 | ReportParameter p1 = new ReportParameter("ReportTitle", "Local Report Example"); 102 | return new ReportParameter[] { p1 }; 103 | } 104 | 105 | private ReportParameter[] GetParametersServer() 106 | { 107 | ReportParameter p1 = new ReportParameter("ShowBingMaps", "Visible"); 108 | ReportParameter p2 = new ReportParameter("ShowAll", "True"); 109 | return new ReportParameter[] { p1, p2 }; 110 | } 111 | 112 | } 113 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Scripts/respond.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.style.background="none";d.appendChild(g);return function(h){g.innerHTML='­';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document); 18 | 19 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 20 | (function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body");x.style.background="none"}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this); -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 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 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportViewerForMvc.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Reporting.WebForms; 2 | using System; 3 | using System.Web; 4 | 5 | namespace ReportViewerForMvc 6 | { 7 | /// 8 | /// Encapsulates the methods and properties used for the ReportViewerForMvc extension. 9 | /// 10 | public static class ReportViewerForMvc 11 | { 12 | internal static string IframeId { get; set; } 13 | 14 | private static ReportViewer reportViewer; 15 | internal static ReportViewer ReportViewer 16 | { 17 | get { return reportViewer; } 18 | set 19 | { 20 | //TODO: Implement dynamic ID 21 | reportViewer = value; 22 | reportViewer.ID = "ReportViewer1"; 23 | } 24 | } 25 | 26 | internal static HtmlString GetIframe(ReportViewer reportViewer, object htmlAttributes) 27 | { 28 | if (reportViewer == null) 29 | { 30 | throw new ArgumentNullException("reportViewer", "Value cannot be null."); 31 | } 32 | 33 | ReportViewerForMvc.ReportViewer = reportViewer; 34 | return IframeBuilder.Iframe(htmlAttributes); 35 | } 36 | 37 | /// 38 | /// Constructs a ReporViewer 39 | /// 40 | /// The object containing the ReportViewer properties. 41 | /// An object containing the LocalReport/ServerReport properties. 42 | /// An instance of ReportViewer with the specified properties 43 | public static ReportViewer AnonymousReportViewer(object reportViewer, object report) 44 | { 45 | return AnonymousReportViewer(reportViewer, report, null, null); 46 | } 47 | 48 | /// 49 | /// Constructs a ReporViewer with parameters 50 | /// 51 | /// The object containing the ReportViewer properties. 52 | /// An object containing the LocalReport/ServerReport properties. 53 | /// Object that contains the parameters for a report. 54 | /// An instance of ReportViewer with the specified properties 55 | public static ReportViewer AnonymousReportViewer(object reportViewer, object report, object parameters) 56 | { 57 | return AnonymousReportViewer(reportViewer, report, parameters, null); 58 | } 59 | 60 | /// 61 | /// Constructs a ReporViewer with parameters and data sources. 62 | /// 63 | /// The object containing the ReportViewer properties. 64 | /// An object containing the LocalReport/ServerReport properties. 65 | /// Object that contains the parameters for a report. 66 | /// The data sources to be added to the report. 67 | /// An instance of ReportViewer with the specified properties 68 | public static ReportViewer AnonymousReportViewer(object reportViewer, object report, object parameters, object dataSources) 69 | { 70 | if (reportViewer == null) 71 | { 72 | throw new ArgumentNullException("reportViewer", "Value cannot be null."); 73 | } 74 | if (report == null) 75 | { 76 | throw new ArgumentNullException("report", "Value cannot be null."); 77 | } 78 | 79 | ReportViewer reportViewerControl = ReportViewerHelper.AnonymousToReportViewer(reportViewer); 80 | 81 | if (reportViewerControl.ProcessingMode == ProcessingMode.Local) 82 | { 83 | reportViewerControl.LocalReport.SetProperties(ReportViewerHelper.AnonymousToLocalReport(report)); 84 | 85 | if (parameters != null) 86 | { 87 | reportViewerControl.LocalReport.SetParameters(ReportViewerHelper.AnonymousToReportParameter(parameters)); 88 | } 89 | if (dataSources != null) 90 | { 91 | reportViewerControl.LocalReport.DataSources.Add(ReportViewerHelper.AnonymousToReportDataSourceList(dataSources)); 92 | } 93 | } 94 | else if (reportViewerControl.ProcessingMode == ProcessingMode.Remote) 95 | { 96 | reportViewerControl.ServerReport.SetProperties(ReportViewerHelper.AnonymousToServerReport(report)); 97 | 98 | if (parameters != null) 99 | { 100 | reportViewerControl.ServerReport.SetParameters(ReportViewerHelper.AnonymousToReportParameter(parameters)); 101 | } 102 | } 103 | 104 | return reportViewerControl; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Reports/dsLocalReport.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | SELECT d.Name AS Dept, s.Name AS Shift, e.BusinessEntityID AS EmployeeID 16 | FROM HumanResources.Department AS d INNER JOIN 17 | HumanResources.EmployeeDepartmentHistory AS e ON d.DepartmentID = e.DepartmentID INNER JOIN 18 | HumanResources.Shift AS s ON e.ShiftID = s.ShiftID 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 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/ReportViewerExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Microsoft.Reporting.WebForms; 4 | using System.Linq; 5 | using System.Collections.Generic; 6 | 7 | namespace ReportViewerForMvc.Tests 8 | { 9 | [TestClass] 10 | public class ReportViewerExtensionsTests 11 | { 12 | TestData testData = new TestData(); 13 | 14 | [TestMethod] 15 | public void SetProperties_WithReportViewer() 16 | { 17 | ReportViewer reportViewer = new ReportViewer(); 18 | reportViewer.SetProperties(testData.ReportViewerTests); 19 | 20 | CompareReportViewer(testData.ReportViewerTests, reportViewer); 21 | } 22 | 23 | [TestMethod] 24 | public void SetProperties_WithLocalReport() 25 | { 26 | LocalReport localReport = new LocalReport(); 27 | localReport.SetProperties(testData.ReportViewerTests.LocalReport); 28 | 29 | CompareLocalReport(testData.ReportViewerTests.LocalReport, localReport); 30 | } 31 | 32 | [TestMethod] 33 | public void SetProperties_WithServerReport() 34 | { 35 | ServerReport serverReport = new ServerReport(); 36 | serverReport.SetProperties(testData.ReportViewerTests.ServerReport); 37 | 38 | CompareServerReport(testData.ReportViewerTests.ServerReport, serverReport); 39 | } 40 | 41 | [TestMethod] 42 | [ExpectedException(typeof(ArgumentNullException))] 43 | public void SetProperties_WithNullReportViewerIntance() 44 | { 45 | ReportViewerExtensions.SetProperties(null, testData.ReportViewerTests); 46 | } 47 | 48 | [TestMethod] 49 | [ExpectedException(typeof(ArgumentNullException))] 50 | public void SetProperties_WithNullLocalReportIntance() 51 | { 52 | ReportViewerExtensions.SetProperties(null, testData.ReportViewerTests.LocalReport); 53 | } 54 | 55 | [TestMethod] 56 | [ExpectedException(typeof(ArgumentNullException))] 57 | public void SetProperties_WithNullServerReportIntance() 58 | { 59 | ReportViewerExtensions.SetProperties(null, testData.ReportViewerTests.ServerReport); 60 | } 61 | 62 | [TestMethod] 63 | [ExpectedException(typeof(ArgumentNullException))] 64 | public void SetProperties_WithNullReportViewer() 65 | { 66 | testData.ReportViewerTests.SetProperties(null); 67 | } 68 | 69 | [TestMethod] 70 | [ExpectedException(typeof(ArgumentNullException))] 71 | public void SetProperties_WithNullLocalReport() 72 | { 73 | testData.ReportViewerTests.LocalReport.SetProperties(null); 74 | } 75 | 76 | [TestMethod] 77 | [ExpectedException(typeof(ArgumentNullException))] 78 | public void SetProperties_WithNullServerReport() 79 | { 80 | testData.ReportViewerTests.ServerReport.SetProperties(null); 81 | } 82 | 83 | 84 | private void CompareReportViewer(ReportViewer expected, ReportViewer current) 85 | { 86 | Assert.AreEqual(expected.ProcessingMode, current.ProcessingMode); 87 | Assert.AreEqual(expected.SizeToReportContent, current.SizeToReportContent); 88 | Assert.AreEqual(expected.Width, current.Width); 89 | Assert.AreEqual(expected.Height, current.Height); 90 | 91 | CompareLocalReport(expected.LocalReport, current.LocalReport); 92 | CompareServerReport(expected.ServerReport, current.ServerReport); 93 | } 94 | 95 | private void CompareLocalReport(LocalReport expected, LocalReport current) 96 | { 97 | Assert.AreEqual(expected.ReportPath, current.ReportPath); 98 | 99 | TestParameters(expected.GetParameters().ToList(), current.GetParameters().ToList()); 100 | TestDataSource(expected.DataSources.ToList(), current.DataSources.ToList()); 101 | } 102 | 103 | private void CompareServerReport(ServerReport expected, ServerReport current) 104 | { 105 | Assert.AreEqual(expected.ReportPath, current.ReportPath); 106 | Assert.AreEqual(expected.ReportServerUrl, current.ReportServerUrl); 107 | 108 | TestParameters(expected.GetParameters().ToList(), current.GetParameters().ToList()); 109 | } 110 | 111 | private void TestParameters(List expected, List current) 112 | { 113 | Assert.AreEqual(expected.Count, current.Count); 114 | 115 | for (int a = 0; a < expected.Count; a++) 116 | { 117 | Assert.AreEqual(expected[a].Name, current[a].Name); 118 | Assert.AreEqual(expected[a].Values.Count, current[a].Values.Count); 119 | for (int b = 0; b < expected[a].Values.Count; b++) 120 | { 121 | Assert.AreEqual(expected[a].Values[b], current[a].Values[b]); 122 | } 123 | Assert.AreEqual(expected[a].Visible, current[a].Visible); 124 | } 125 | } 126 | 127 | private void TestDataSource(List expected, List current) 128 | { 129 | Assert.AreEqual(expected.Count, current.Count); 130 | for (int a = 0; a < expected.Count; a++) 131 | { 132 | Assert.AreEqual(expected[a].Name, current[a].Name); 133 | Assert.AreEqual(expected[a].Value, current[a].Value); 134 | } 135 | } 136 | 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Project_Readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Your ASP.NET application 6 | 95 | 96 | 97 | 98 | 102 | 103 |
104 |
105 |

This application consists of:

106 |
    107 |
  • Sample pages showing basic nav between Home, About, and Contact
  • 108 |
  • Theming using Bootstrap
  • 109 |
  • Authentication, if selected, shows how to register and sign in
  • 110 |
  • ASP.NET features managed using NuGet
  • 111 |
112 |
113 | 114 | 131 | 132 |
133 |

Deploy

134 | 139 |
140 | 141 |
142 |

Get help

143 | 147 |
148 |
149 | 150 | 151 | -------------------------------------------------------------------------------- /ReportViewerForMvc/HtmlHelperExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Reporting.WebForms; 2 | using System.Web; 3 | using System.Web.Mvc; 4 | 5 | namespace ReportViewerForMvc 6 | { 7 | /// 8 | /// HTML helpers for ReportViewerForMvc 9 | /// 10 | public static class HtmlHelperExtensions 11 | { 12 | /// 13 | /// Returns an HTML iframe that renders an ASP.NET ReportViewer control. 14 | /// 15 | /// The HTML helper instance that this method extends. 16 | /// The object containing the ReportViewer control properties. 17 | /// An HTML iframe that sets its heigh and width based on the content of the report. 18 | public static HtmlString ReportViewer(this HtmlHelper helper, ReportViewer reportViewer) 19 | { 20 | return ReportViewerForMvc.GetIframe(reportViewer, null); 21 | } 22 | 23 | /// 24 | /// Returns an HTML iframe that renders an ASP.NET ReportViewer control. 25 | /// 26 | /// The HTML helper instance that this method extends. 27 | /// The object containing the ReportViewer control properties. 28 | /// The object containing the HTML attributes of the iframe. 29 | /// An HTML iframe with the specified attributes that sets its heigh and width based on the content of the report. 30 | public static HtmlString ReportViewer(this HtmlHelper helper, ReportViewer reportViewer, object htmlAttributes) 31 | { 32 | return ReportViewerForMvc.GetIframe(reportViewer, htmlAttributes); 33 | } 34 | 35 | /// 36 | /// Returns an HTML iframe that renders an ASP.NET ReportViewer control. 37 | /// 38 | /// The HTML helper instance that this method extends. 39 | /// The object containing the ReportViewer control properties. 40 | /// An object containing the LocalReport/ServerReport properties. 41 | /// An HTML iframe that sets its heigh and width based on the content of the report. 42 | public static HtmlString ReportViewer(this HtmlHelper helper, object reportViewer, object report) 43 | { 44 | ReportViewer reportViewerControl = ReportViewerForMvc.AnonymousReportViewer(reportViewer, report); 45 | 46 | return ReportViewerForMvc.GetIframe(reportViewerControl, null); 47 | } 48 | 49 | /// 50 | /// Returns an HTML iframe that renders an ASP.NET ReportViewer control. 51 | /// 52 | /// The HTML helper instance that this method extends. 53 | /// The object containing the ReportViewer control properties. 54 | /// An object containing the LocalReport/ServerReport properties. 55 | /// The object containing the HTML attributes of the iframe. 56 | /// An HTML iframe with the specified attributes that sets its heigh and width based on the content of the report. 57 | public static HtmlString ReportViewer(this HtmlHelper helper, object reportViewer, object report, object htmlAttributes) 58 | { 59 | ReportViewer reportViewerControl = ReportViewerForMvc.AnonymousReportViewer(reportViewer, report); 60 | 61 | return ReportViewerForMvc.GetIframe(reportViewerControl, htmlAttributes); 62 | } 63 | 64 | /// 65 | /// Returns an HTML iframe that renders an ASP.NET ReportViewer control. 66 | /// 67 | /// The HTML helper instance that this method extends. 68 | /// The object containing the ReportViewer control properties. 69 | /// An object containing the LocalReport/ServerReport properties. 70 | /// Object that contains the parameters for a report. 71 | /// The object containing the HTML attributes of the iframe. 72 | /// An HTML iframe with the specified attributes that sets its heigh and width based on the content of the report. 73 | public static HtmlString ReportViewer(this HtmlHelper helper, object reportViewer, object report, object parameters, object htmlAttributes) 74 | { 75 | ReportViewer reportViewerControl = ReportViewerForMvc.AnonymousReportViewer(reportViewer, report, parameters); 76 | 77 | return ReportViewerForMvc.GetIframe(reportViewerControl, htmlAttributes); 78 | } 79 | 80 | /// 81 | /// Returns an HTML iframe that renders an ASP.NET ReportViewer control. 82 | /// 83 | /// The HTML helper instance that this method extends. 84 | /// The object containing the ReportViewer control properties. 85 | /// An object containing the LocalReport/ServerReport properties. 86 | /// Object that contains the parameters for a report. 87 | /// The data sources to be added to the report. 88 | /// The object containing the HTML attributes of the iframe. 89 | /// An HTML iframe with the specified attributes that sets its heigh and width based on the content of the report. 90 | public static HtmlString ReportViewer(this HtmlHelper helper, object reportViewer, object report, object parameters, object dataSources, object htmlAttributes) 91 | { 92 | ReportViewer reportViewerControl = ReportViewerForMvc.AnonymousReportViewer(reportViewer, report, parameters, dataSources); 93 | 94 | return ReportViewerForMvc.GetIframe(reportViewerControl, htmlAttributes); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # Benchmark Results 46 | BenchmarkDotNet.Artifacts/ 47 | 48 | # .NET Core 49 | project.lock.json 50 | project.fragment.lock.json 51 | artifacts/ 52 | **/Properties/launchSettings.json 53 | 54 | *_i.c 55 | *_p.c 56 | *_i.h 57 | *.ilk 58 | *.meta 59 | *.obj 60 | *.pch 61 | *.pdb 62 | *.pgc 63 | *.pgd 64 | *.rsp 65 | *.sbr 66 | *.tlb 67 | *.tli 68 | *.tlh 69 | *.tmp 70 | *.tmp_proj 71 | *.log 72 | *.vspscc 73 | *.vssscc 74 | .builds 75 | *.pidb 76 | *.svclog 77 | *.scc 78 | 79 | # Chutzpah Test files 80 | _Chutzpah* 81 | 82 | # Visual C++ cache files 83 | ipch/ 84 | *.aps 85 | *.ncb 86 | *.opendb 87 | *.opensdf 88 | *.sdf 89 | *.cachefile 90 | *.VC.db 91 | *.VC.VC.opendb 92 | 93 | # Visual Studio profiler 94 | *.psess 95 | *.vsp 96 | *.vspx 97 | *.sap 98 | 99 | # TFS 2012 Local Workspace 100 | $tf/ 101 | 102 | # Guidance Automation Toolkit 103 | *.gpState 104 | 105 | # ReSharper is a .NET coding add-in 106 | _ReSharper*/ 107 | *.[Rr]e[Ss]harper 108 | *.DotSettings.user 109 | 110 | # JustCode is a .NET coding add-in 111 | .JustCode 112 | 113 | # TeamCity is a build add-in 114 | _TeamCity* 115 | 116 | # DotCover is a Code Coverage Tool 117 | *.dotCover 118 | 119 | # AxoCover is a Code Coverage Tool 120 | .axoCover/* 121 | !.axoCover/settings.json 122 | 123 | # Visual Studio code coverage results 124 | *.coverage 125 | *.coveragexml 126 | 127 | # NCrunch 128 | _NCrunch_* 129 | .*crunch*.local.xml 130 | nCrunchTemp_* 131 | 132 | # MightyMoose 133 | *.mm.* 134 | AutoTest.Net/ 135 | 136 | # Web workbench (sass) 137 | .sass-cache/ 138 | 139 | # Installshield output folder 140 | [Ee]xpress/ 141 | 142 | # DocProject is a documentation generator add-in 143 | DocProject/buildhelp/ 144 | DocProject/Help/*.HxT 145 | DocProject/Help/*.HxC 146 | DocProject/Help/*.hhc 147 | DocProject/Help/*.hhk 148 | DocProject/Help/*.hhp 149 | DocProject/Help/Html2 150 | DocProject/Help/html 151 | 152 | # Click-Once directory 153 | publish/ 154 | 155 | # Publish Web Output 156 | *.[Pp]ublish.xml 157 | *.azurePubxml 158 | # Note: Comment the next line if you want to checkin your web deploy settings, 159 | # but database connection strings (with potential passwords) will be unencrypted 160 | *.pubxml 161 | *.publishproj 162 | 163 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 164 | # checkin your Azure Web App publish settings, but sensitive information contained 165 | # in these scripts will be unencrypted 166 | PublishScripts/ 167 | 168 | # NuGet Packages 169 | *.nupkg 170 | # The packages folder can be ignored because of Package Restore 171 | **/packages/* 172 | # except build/, which is used as an MSBuild target. 173 | !**/packages/build/ 174 | # Uncomment if necessary however generally it will be regenerated when needed 175 | #!**/packages/repositories.config 176 | # NuGet v3's project.json files produces more ignorable files 177 | *.nuget.props 178 | *.nuget.targets 179 | 180 | # Microsoft Azure Build Output 181 | csx/ 182 | *.build.csdef 183 | 184 | # Microsoft Azure Emulator 185 | ecf/ 186 | rcf/ 187 | 188 | # Windows Store app package directories and files 189 | AppPackages/ 190 | BundleArtifacts/ 191 | Package.StoreAssociation.xml 192 | _pkginfo.txt 193 | *.appx 194 | 195 | # Visual Studio cache files 196 | # files ending in .cache can be ignored 197 | *.[Cc]ache 198 | # but keep track of directories ending in .cache 199 | !*.[Cc]ache/ 200 | 201 | # Others 202 | ClientBin/ 203 | ~$* 204 | *~ 205 | *.dbmdl 206 | *.dbproj.schemaview 207 | *.jfm 208 | *.pfx 209 | *.publishsettings 210 | orleans.codegen.cs 211 | 212 | # Since there are multiple workflows, uncomment next line to ignore bower_components 213 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 214 | #bower_components/ 215 | 216 | # RIA/Silverlight projects 217 | Generated_Code/ 218 | 219 | # Backup & report files from converting an old project file 220 | # to a newer Visual Studio version. Backup files are not needed, 221 | # because we have git ;-) 222 | _UpgradeReport_Files/ 223 | Backup*/ 224 | UpgradeLog*.XML 225 | UpgradeLog*.htm 226 | 227 | # SQL Server files 228 | *.mdf 229 | *.ldf 230 | *.ndf 231 | 232 | # Business Intelligence projects 233 | *.rdl.data 234 | *.bim.layout 235 | *.bim_*.settings 236 | 237 | # Microsoft Fakes 238 | FakesAssemblies/ 239 | 240 | # GhostDoc plugin setting file 241 | *.GhostDoc.xml 242 | 243 | # Node.js Tools for Visual Studio 244 | .ntvs_analysis.dat 245 | node_modules/ 246 | 247 | # Typescript v1 declaration files 248 | typings/ 249 | 250 | # Visual Studio 6 build log 251 | *.plg 252 | 253 | # Visual Studio 6 workspace options file 254 | *.opt 255 | 256 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 257 | *.vbw 258 | 259 | # Visual Studio LightSwitch build output 260 | **/*.HTMLClient/GeneratedArtifacts 261 | **/*.DesktopClient/GeneratedArtifacts 262 | **/*.DesktopClient/ModelManifest.xml 263 | **/*.Server/GeneratedArtifacts 264 | **/*.Server/ModelManifest.xml 265 | _Pvt_Extensions 266 | 267 | # Paket dependency manager 268 | .paket/paket.exe 269 | paket-files/ 270 | 271 | # FAKE - F# Make 272 | .fake/ 273 | 274 | # JetBrains Rider 275 | .idea/ 276 | *.sln.iml 277 | 278 | # CodeRush 279 | .cr/ 280 | 281 | # Python Tools for Visual Studio (PTVS) 282 | __pycache__/ 283 | *.pyc 284 | 285 | # Cake - Uncomment if you are using it 286 | # tools/** 287 | # !tools/packages.config 288 | 289 | # Tabs Studio 290 | *.tss 291 | 292 | # Telerik's JustMock configuration file 293 | *.jmconfig 294 | 295 | # BizTalk build output 296 | *.btp.cs 297 | *.btm.cs 298 | *.odx.cs 299 | *.xsd.cs 300 | 301 | # OpenCover UI analysis results 302 | OpenCover/ -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/TestData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | using Microsoft.Reporting.WebForms; 8 | using System.Web.UI.WebControls; 9 | using System.Data; 10 | using ReportViewerForMvc.Tests.Reports; 11 | using System.IO; 12 | using System.Reflection; 13 | 14 | namespace ReportViewerForMvc.Tests 15 | { 16 | public class TestData 17 | { 18 | public const string DefaultSrc = "/ReportViewerWebForm.aspx"; 19 | public const string DefaultStyle = "border:none; width:100%; height:100%;"; 20 | public const string DefaultInnerText = "iframes not supported."; 21 | public static readonly string LocalReportPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Reports\Report1.rdlc"; 22 | public const string ServerReportPath = "/AdventureWorks 2012/Sales_by_Region"; 23 | public const string ReportServerUrl = "http://localhost/ReportServer/"; 24 | 25 | public readonly ReportViewer ReportViewerTests; 26 | public readonly List ReportParameterList; 27 | 28 | #region AnonymousProperties 29 | 30 | #region Local 31 | 32 | public static readonly object AnonymousLocalReportViewer = new 33 | { 34 | ProcessingMode = ProcessingMode.Local, 35 | SizeToReportContent = true, 36 | Width = Unit.Percentage(100), 37 | Height = Unit.Percentage(100), 38 | }; 39 | 40 | public static readonly object AnonymousLocalReport = new 41 | { 42 | ReportPath = LocalReportPath 43 | }; 44 | 45 | public static readonly object AnonymousLocalParameters = new 46 | { 47 | ReportParameter1 = "", 48 | ReportParameter2 = "Value2" 49 | }; 50 | 51 | public readonly object AnonymousDataSourceList; 52 | public readonly object AnonymousDataSource; 53 | 54 | #endregion 55 | 56 | #region Server 57 | 58 | public static readonly object AnonymousServerReportViewer = new 59 | { 60 | ProcessingMode = ProcessingMode.Remote, 61 | SizeToReportContent = true, 62 | Width = Unit.Percentage(100), 63 | Height = Unit.Percentage(100), 64 | }; 65 | 66 | public static readonly object AnonymousServerReport = new 67 | { 68 | ReportPath = ServerReportPath, 69 | ReportServerUrl = new Uri(ReportServerUrl) 70 | }; 71 | 72 | public static readonly object AnonymousServerParameters = new 73 | { 74 | ShowBingMaps = "Visible", 75 | ShowAll = "True" 76 | }; 77 | 78 | #endregion 79 | 80 | public static readonly object HtmlAttributes = new 81 | { 82 | height = "10", 83 | innertText = "Changed inner text attribute.", 84 | name = "testName", 85 | seamless = "seamless", 86 | style = "border:1px solid red;", 87 | width = "20" 88 | }; 89 | 90 | public static readonly object IncorrectData = new 91 | { 92 | You = "Got", 93 | Nothing = "Son" 94 | }; 95 | 96 | #endregion 97 | 98 | public TestData() 99 | { 100 | //Prepare LocalReport parameters 101 | ReportParameterList = new List(); 102 | ReportParameterList.Add(new ReportParameter("ReportParameter1")); 103 | ReportParameterList.Add(new ReportParameter("ReportParameter2", "Value2")); 104 | ReportParameterList.Add(new ReportParameter("ReportParameter3", new string[] { "Array1", "Array2", "Array3" })); 105 | ReportParameterList.Add(new ReportParameter("ReportParameter4", "Value4", true)); 106 | ReportParameterList.Add(new ReportParameter("ReportParameter5", new string[] { "Array1", "Array2", "Array3" }, true)); 107 | 108 | //Prepare LocalReport datasource 109 | List dataList = new List(); 110 | for (int i = 0; i <= 10; i++) 111 | { 112 | var data = new 113 | { 114 | Column1 = "ValueA" + i.ToString(), 115 | Column2 = "ValueB" + i.ToString(), 116 | Column3 = "ValueC" + i.ToString() 117 | }; 118 | 119 | dataList.Add(data); 120 | } 121 | 122 | //ReportViewer properties 123 | ReportViewerTests = new ReportViewer(); 124 | ReportViewerTests.ProcessingMode = ProcessingMode.Local; 125 | ReportViewerTests.SizeToReportContent = true; 126 | ReportViewerTests.Width = Unit.Percentage(100); 127 | ReportViewerTests.Height = Unit.Percentage(100); 128 | 129 | //LocalReport properties 130 | ReportViewerTests.LocalReport.ReportPath = LocalReportPath; 131 | ReportViewerTests.LocalReport.DataSources.Add(new ReportDataSource("ReportViewerForMvcTestsReport", dataList)); 132 | ReportViewerTests.LocalReport.DataSources.Add(new ReportDataSource("ReportViewerForMvcTestsReport1", dataList)); 133 | ReportViewerTests.LocalReport.DataSources.Add(new ReportDataSource("ReportViewerForMvcTestsReport2", dataList)); 134 | ReportViewerTests.LocalReport.SetParameters(ReportParameterList); 135 | 136 | //ServerReport properties 137 | ReportViewerTests.ServerReport.ReportPath = ServerReportPath; 138 | ReportViewerTests.ServerReport.ReportServerUrl = new Uri(ReportServerUrl); 139 | ReportViewerTests.ServerReport.SetParameters(GetParametersServer()); 140 | 141 | //Set anonymous DataSource 142 | AnonymousDataSourceList = new[] 143 | { 144 | new { Name = "ReportViewerForMvcTestsReport", Value = dataList }, 145 | new { Name = "ReportViewerForMvcTestsReport1", Value = dataList }, 146 | new { Name = "ReportViewerForMvcTestsReport2", Value = dataList }, 147 | }; 148 | AnonymousDataSource = new 149 | { 150 | Name = "ReportViewerForMvcTestsReport2", 151 | Value = dataList 152 | }; 153 | } 154 | 155 | private ReportParameter[] GetParametersServer() 156 | { 157 | ReportParameter p1 = new ReportParameter("ShowBingMaps", "Visible"); 158 | ReportParameter p2 = new ReportParameter("ShowAll", "True"); 159 | return new ReportParameter[] { p1, p2 }; 160 | } 161 | } 162 | } -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/HtmlHelperExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Web; 4 | using System.Web.Mvc; 5 | using HtmlAgilityPack; 6 | using Microsoft.Reporting.WebForms; 7 | using System.IO; 8 | 9 | namespace ReportViewerForMvc.Tests 10 | { 11 | [TestClass] 12 | public class HtmlHelperExtensionsTests 13 | { 14 | private HtmlHelper htmlHelper = new HtmlHelper(new ViewContext(), new TestViewDataContainer()); 15 | private TestData testData = new TestData(); 16 | 17 | #region ControlTests 18 | 19 | [TestMethod] 20 | public void ReportViewer_WellFormedIframe() 21 | { 22 | MockHttpContext(); 23 | 24 | HtmlString htmlString; 25 | 26 | htmlString = htmlHelper.ReportViewer(testData.ReportViewerTests); 27 | TestWellformedHtmlDefaultAttributes(htmlString); 28 | 29 | htmlString = htmlHelper.ReportViewer(testData.ReportViewerTests, TestData.HtmlAttributes); 30 | TestWellformedHtmlCustomAttributes(htmlString); 31 | } 32 | 33 | [TestMethod] 34 | [ExpectedException(typeof(ArgumentNullException))] 35 | public void ReportViewer_WithNullReportViewer_NoHtmlAttributes() 36 | { 37 | htmlHelper.ReportViewer(null); 38 | } 39 | 40 | [TestMethod] 41 | [ExpectedException(typeof(ArgumentNullException))] 42 | public void ReportViewer_WithNullReportViewer() 43 | { 44 | htmlHelper.ReportViewer(null, TestData.HtmlAttributes); 45 | } 46 | 47 | [TestMethod] 48 | [ExpectedException(typeof(ArgumentNullException))] 49 | public void ReportViewer_WithNullHtmlId() 50 | { 51 | htmlHelper.ReportViewer(testData.ReportViewerTests, new { id = "" }); 52 | } 53 | 54 | #endregion 55 | 56 | #region AnonymousTests 57 | 58 | [TestMethod] 59 | public void ReportViewer_WithAnonymousLocalReport() 60 | { 61 | MockHttpContext(); 62 | 63 | HtmlString htmlString; 64 | 65 | htmlString = htmlHelper.ReportViewer( 66 | TestData.AnonymousLocalReportViewer, 67 | TestData.AnonymousLocalReport, 68 | TestData.AnonymousLocalParameters, 69 | testData.AnonymousDataSource, 70 | null); 71 | 72 | TestWellformedHtmlDefaultAttributes(htmlString); 73 | 74 | htmlString = htmlHelper.ReportViewer( 75 | TestData.AnonymousLocalReportViewer, 76 | TestData.AnonymousLocalReport, 77 | TestData.AnonymousLocalParameters, 78 | testData.AnonymousDataSourceList, 79 | TestData.HtmlAttributes); 80 | 81 | TestWellformedHtmlCustomAttributes(htmlString); 82 | } 83 | 84 | [TestMethod] 85 | public void ReportViewer_WithAnonymousServerReport() 86 | { 87 | MockHttpContext(); 88 | 89 | HtmlString htmlString; 90 | 91 | htmlString = htmlHelper.ReportViewer( 92 | TestData.AnonymousServerReportViewer, 93 | TestData.AnonymousServerReport, 94 | TestData.AnonymousServerParameters, 95 | null); 96 | 97 | TestWellformedHtmlDefaultAttributes(htmlString); 98 | 99 | htmlString = htmlHelper.ReportViewer( 100 | TestData.AnonymousServerReportViewer, 101 | TestData.AnonymousServerReport, 102 | TestData.AnonymousServerParameters, 103 | TestData.HtmlAttributes); 104 | 105 | TestWellformedHtmlCustomAttributes(htmlString); 106 | } 107 | 108 | [TestMethod] 109 | [ExpectedException(typeof(ArgumentNullException))] 110 | public void ReportViewer_WithNullAnonymousReportViewer() 111 | { 112 | htmlHelper.ReportViewer((object)null, TestData.AnonymousLocalReport); 113 | } 114 | 115 | [TestMethod] 116 | [ExpectedException(typeof(ArgumentNullException))] 117 | public void ReportViewer_WithNullAnonymousReport() 118 | { 119 | htmlHelper.ReportViewer(TestData.AnonymousLocalReportViewer, (object)null); 120 | } 121 | 122 | [TestMethod] 123 | [ExpectedException(typeof(ArgumentException))] 124 | public void ReportViewer_WithMalformedAnonymousReportViewer() 125 | { 126 | htmlHelper.ReportViewer(TestData.IncorrectData, TestData.AnonymousLocalReport); 127 | } 128 | 129 | [TestMethod] 130 | [ExpectedException(typeof(ArgumentException))] 131 | public void ReportViewer_WithMalformedAnonymousLocalReport() 132 | { 133 | htmlHelper.ReportViewer(TestData.AnonymousLocalReportViewer, TestData.IncorrectData); 134 | } 135 | 136 | [TestMethod] 137 | [ExpectedException(typeof(LocalProcessingException))] 138 | public void ReportViewer_WithMalformedAnonymousParameters() 139 | { 140 | htmlHelper.ReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport, TestData.IncorrectData, null); 141 | } 142 | 143 | [TestMethod] 144 | [ExpectedException(typeof(ArgumentException))] 145 | public void ReportViewer_WithMalformedAnonymousParameters_ServerReport() 146 | { 147 | htmlHelper.ReportViewer(TestData.AnonymousServerReportViewer, TestData.AnonymousServerReport, TestData.IncorrectData, null); 148 | } 149 | 150 | [TestMethod] 151 | [ExpectedException(typeof(ArgumentException))] 152 | public void ReportViewer_WithMalformedAnonymousDataSources() 153 | { 154 | htmlHelper.ReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport, null, TestData.IncorrectData, null); 155 | } 156 | 157 | #endregion 158 | 159 | #region PrivateMethods 160 | 161 | private void TestWellformedHtmlDefaultAttributes(HtmlString htmlString) 162 | { 163 | HtmlDocument htmlDocument = new HtmlDocument(); 164 | htmlDocument.LoadHtml(htmlString.ToString()); 165 | HtmlNode iframeResult = htmlDocument.DocumentNode.ChildNodes[0]; 166 | 167 | Assert.AreEqual("iframe", htmlDocument.DocumentNode.ChildNodes[0].Name); 168 | Assert.AreEqual("script", htmlDocument.DocumentNode.ChildNodes[1].Name); 169 | Assert.AreEqual("script", htmlDocument.DocumentNode.ChildNodes[2].Name); 170 | 171 | TestDefaultIframeAttributes(iframeResult); 172 | } 173 | 174 | private void TestWellformedHtmlCustomAttributes(HtmlString htmlString) 175 | { 176 | HtmlDocument htmlDocument = new HtmlDocument(); 177 | htmlDocument.LoadHtml(htmlString.ToString()); 178 | HtmlNode iframeResult = htmlDocument.DocumentNode.ChildNodes[0]; 179 | 180 | Assert.AreEqual("iframe", htmlDocument.DocumentNode.ChildNodes[0].Name); 181 | Assert.AreEqual("script", htmlDocument.DocumentNode.ChildNodes[1].Name); 182 | Assert.AreEqual("script", htmlDocument.DocumentNode.ChildNodes[2].Name); 183 | 184 | TestCustomIframeAttributes(iframeResult); 185 | } 186 | 187 | private void TestDefaultIframeAttributes(HtmlNode iframeResult) 188 | { 189 | Assert.AreEqual("iframe", iframeResult.Name); 190 | Assert.IsNotNull(iframeResult.Id); 191 | Assert.IsTrue(iframeResult.Id != ""); 192 | Assert.AreEqual(TestData.DefaultSrc, iframeResult.GetAttributeValue("src", "src not found")); 193 | } 194 | 195 | private void TestCustomIframeAttributes(HtmlNode iframeResult) 196 | { 197 | foreach (var property in TestData.HtmlAttributes.GetType().GetProperties()) 198 | { 199 | var propertyValue = property.GetValue(TestData.HtmlAttributes); 200 | Assert.AreEqual(propertyValue, iframeResult.GetAttributeValue(property.Name, null)); 201 | } 202 | } 203 | 204 | private void MockHttpContext() 205 | { 206 | HttpContext.Current = new HttpContext( 207 | new HttpRequest("", "http://tempuri.org", ""), 208 | new HttpResponse(new StringWriter()) 209 | ); 210 | } 211 | 212 | #endregion 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /ReportViewerForMvc/ReportViewerForMvc.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B7F6A951-ECE3-4BDD-BE20-0F7FFD944695} 8 | Library 9 | Properties 10 | ReportViewerForMvc 11 | ReportViewerForMvc 12 | v4.6.1 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.DataVisualization.dll 40 | 41 | 42 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.Design.dll 43 | 44 | 45 | False 46 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.ProcessingObjectModel.dll 47 | 48 | 49 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WebDesign.dll 50 | 51 | 52 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WebForms.dll 53 | 54 | 55 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WinForms.dll 56 | 57 | 58 | ..\packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll 59 | 60 | 61 | True 62 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | False 71 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 72 | 73 | 74 | False 75 | ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 76 | 77 | 78 | False 79 | ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 80 | 81 | 82 | False 83 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 84 | 85 | 86 | False 87 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 88 | 89 | 90 | False 91 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | ReportViewerWebForm.aspx 111 | ASPXCodeBehind 112 | Always 113 | 114 | 115 | ReportViewerWebForm.aspx.cs 116 | Always 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | ASPXCodeBehind 129 | Always 130 | 131 | 132 | 133 | 134 | Designer 135 | 136 | 137 | 138 | 145 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/ReportViewerForMvcTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Microsoft.Reporting.WebForms; 4 | using System.Web.UI.WebControls; 5 | using System.Reflection; 6 | using System.Collections.Specialized; 7 | using System.Linq; 8 | using System.Collections; 9 | 10 | namespace ReportViewerForMvc.Tests 11 | { 12 | [TestClass] 13 | public class ReportViewerForMvcTests 14 | { 15 | TestData testData = new TestData(); 16 | 17 | [TestMethod] 18 | public void AnonymousReportViewer_WithLocalReport() 19 | { 20 | ReportViewer reportViewer; 21 | 22 | reportViewer = ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport); 23 | 24 | TestObjects(TestData.AnonymousLocalReportViewer, reportViewer); 25 | TestObjects(TestData.AnonymousLocalReport, reportViewer.LocalReport); 26 | 27 | reportViewer = ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport, TestData.AnonymousLocalParameters); 28 | 29 | TestObjects(TestData.AnonymousLocalReportViewer, reportViewer); 30 | TestObjects(TestData.AnonymousLocalReport, reportViewer.LocalReport); 31 | TestParameters(TestData.AnonymousLocalParameters, reportViewer.LocalReport.GetParameters()); 32 | 33 | reportViewer = ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport, TestData.AnonymousLocalParameters, testData.AnonymousDataSource); 34 | 35 | TestObjects(TestData.AnonymousLocalReportViewer, reportViewer); 36 | TestObjects(TestData.AnonymousLocalReport, reportViewer.LocalReport); 37 | TestParameters(TestData.AnonymousLocalParameters, reportViewer.LocalReport.GetParameters()); 38 | TestDataSources(testData.AnonymousDataSource, reportViewer.LocalReport.DataSources); 39 | 40 | reportViewer = ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport, TestData.AnonymousLocalParameters, testData.AnonymousDataSourceList); 41 | 42 | TestObjects(TestData.AnonymousLocalReportViewer, reportViewer); 43 | TestObjects(TestData.AnonymousLocalReport, reportViewer.LocalReport); 44 | TestParameters(TestData.AnonymousLocalParameters, reportViewer.LocalReport.GetParameters()); 45 | TestDataSources(testData.AnonymousDataSourceList, reportViewer.LocalReport.DataSources); 46 | } 47 | 48 | [TestMethod] 49 | public void AnonymousReportViewer_WithServerReport() 50 | { 51 | ReportViewer reportViewer; 52 | 53 | reportViewer = ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousServerReportViewer, TestData.AnonymousServerReport); 54 | 55 | TestObjects(TestData.AnonymousServerReportViewer, reportViewer); 56 | TestObjects(TestData.AnonymousServerReport, reportViewer.ServerReport); 57 | 58 | reportViewer = ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousServerReportViewer, TestData.AnonymousServerReport, TestData.AnonymousServerParameters); 59 | 60 | TestObjects(TestData.AnonymousServerReportViewer, reportViewer); 61 | TestObjects(TestData.AnonymousServerReport, reportViewer.ServerReport); 62 | TestParameters(TestData.AnonymousServerParameters, reportViewer.ServerReport.GetParameters()); 63 | } 64 | 65 | [TestMethod] 66 | [ExpectedException(typeof(ArgumentNullException))] 67 | public void AnonymousReportViewer_WithNullReportViewer() 68 | { 69 | ReportViewerForMvc.AnonymousReportViewer(null, TestData.AnonymousLocalReport); 70 | } 71 | 72 | [TestMethod] 73 | [ExpectedException(typeof(ArgumentNullException))] 74 | public void AnonymousReportViewer_WithNullLocalReport() 75 | { 76 | ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, null); 77 | } 78 | 79 | [TestMethod] 80 | [ExpectedException(typeof(ArgumentNullException))] 81 | public void AnonymousReportViewer_WithNullServerReport() 82 | { 83 | ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousServerReportViewer, null); 84 | } 85 | 86 | [TestMethod] 87 | [ExpectedException(typeof(ArgumentException))] 88 | public void AnonymousReportViewer_WithMalformedReportViewer() 89 | { 90 | ReportViewerForMvc.AnonymousReportViewer(TestData.IncorrectData, TestData.AnonymousLocalReport); 91 | } 92 | 93 | [TestMethod] 94 | [ExpectedException(typeof(ArgumentException))] 95 | public void AnonymousReportViewerr_WithMalformedLocalReport() 96 | { 97 | ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, TestData.IncorrectData); 98 | } 99 | 100 | [TestMethod] 101 | [ExpectedException(typeof(LocalProcessingException))] 102 | public void AnonymousReportViewer_WithMalformedParameters() 103 | { 104 | ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport, TestData.IncorrectData); 105 | } 106 | 107 | [TestMethod] 108 | [ExpectedException(typeof(ArgumentException))] 109 | public void AnonymousReportViewer_WithMalformedParameters_ServerReport() 110 | { 111 | ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousServerReportViewer, TestData.AnonymousServerReport, TestData.IncorrectData); 112 | } 113 | 114 | [TestMethod] 115 | [ExpectedException(typeof(ArgumentException))] 116 | public void AnonymousReportViewer_WithMalformedDataSources() 117 | { 118 | ReportViewerForMvc.AnonymousReportViewer(TestData.AnonymousLocalReportViewer, TestData.AnonymousLocalReport, null, TestData.IncorrectData); 119 | } 120 | 121 | #region privateMethods 122 | 123 | private void TestObjects(object expected, object actual) 124 | { 125 | foreach (PropertyInfo propertyInfo in expected.GetType().GetProperties()) 126 | { 127 | var expectedValue = expected.GetType().GetProperty(propertyInfo.Name).GetValue(expected); 128 | var actualValue = actual.GetType().GetProperty(propertyInfo.Name).GetValue(actual); 129 | 130 | Assert.AreEqual(expectedValue, actualValue); 131 | } 132 | } 133 | 134 | private void TestParameters(object expected, ReportParameterInfoCollection actual) 135 | { 136 | int count = 0; 137 | 138 | foreach (ReportParameterInfo actualReportParameterInfo in actual) 139 | { 140 | PropertyInfo expectedPropertyInfo = expected.GetType().GetProperty(actualReportParameterInfo.Name); 141 | 142 | if (expectedPropertyInfo != null) 143 | { 144 | count++; 145 | 146 | Assert.AreEqual(expectedPropertyInfo.Name, actualReportParameterInfo.Name); 147 | 148 | string expectedValue = expectedPropertyInfo.GetValue(expected).ToString(); 149 | if (String.IsNullOrEmpty(expectedValue)) 150 | { 151 | Assert.IsTrue(actualReportParameterInfo.Values.Count == 0); 152 | } 153 | else 154 | { 155 | Assert.AreEqual(expectedValue, actualReportParameterInfo.Values[0]); 156 | } 157 | } 158 | } 159 | 160 | Assert.IsTrue(expected.GetType().GetProperties().LongLength == count); 161 | } 162 | 163 | private void TestDataSources(object expected, ReportDataSourceCollection actual) 164 | { 165 | foreach (ReportDataSource actualReportDataSource in actual) 166 | { 167 | if (expected.GetType().IsArray) 168 | { 169 | bool isDataSourceFound = false; 170 | foreach (var expectedReportDataSource in (IEnumerable)expected) 171 | { 172 | if (expectedReportDataSource.GetType().GetProperty("Name").GetValue(expectedReportDataSource).ToString() == actualReportDataSource.Name) 173 | { 174 | isDataSourceFound = true; 175 | TestObjects(expectedReportDataSource, actualReportDataSource); 176 | break; 177 | } 178 | } 179 | 180 | if(!isDataSourceFound) 181 | { 182 | Assert.Fail(); 183 | } 184 | } 185 | else 186 | { 187 | TestObjects(expected, actualReportDataSource); 188 | } 189 | } 190 | } 191 | 192 | #endregion 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Scripts/respond.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia = window.matchMedia || (function(doc, undefined){ 18 | 19 | var bool, 20 | docElem = doc.documentElement, 21 | refNode = docElem.firstElementChild || docElem.firstChild, 22 | // fakeBody required for 23 | fakeBody = doc.createElement('body'), 24 | div = doc.createElement('div'); 25 | 26 | div.id = 'mq-test-1'; 27 | div.style.cssText = "position:absolute;top:-100em"; 28 | fakeBody.style.background = "none"; 29 | fakeBody.appendChild(div); 30 | 31 | return function(q){ 32 | 33 | div.innerHTML = '­'; 34 | 35 | docElem.insertBefore(fakeBody, refNode); 36 | bool = div.offsetWidth == 42; 37 | docElem.removeChild(fakeBody); 38 | 39 | return { matches: bool, media: q }; 40 | }; 41 | 42 | })(document); 43 | 44 | 45 | 46 | 47 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 48 | (function( win ){ 49 | //exposed namespace 50 | win.respond = {}; 51 | 52 | //define update even in native-mq-supporting browsers, to avoid errors 53 | respond.update = function(){}; 54 | 55 | //expose media query support flag for external use 56 | respond.mediaQueriesSupported = win.matchMedia && win.matchMedia( "only all" ).matches; 57 | 58 | //if media queries are supported, exit here 59 | if( respond.mediaQueriesSupported ){ return; } 60 | 61 | //define vars 62 | var doc = win.document, 63 | docElem = doc.documentElement, 64 | mediastyles = [], 65 | rules = [], 66 | appendedEls = [], 67 | parsedSheets = {}, 68 | resizeThrottle = 30, 69 | head = doc.getElementsByTagName( "head" )[0] || docElem, 70 | base = doc.getElementsByTagName( "base" )[0], 71 | links = head.getElementsByTagName( "link" ), 72 | requestQueue = [], 73 | 74 | //loop stylesheets, send text content to translate 75 | ripCSS = function(){ 76 | var sheets = links, 77 | sl = sheets.length, 78 | i = 0, 79 | //vars for loop: 80 | sheet, href, media, isCSS; 81 | 82 | for( ; i < sl; i++ ){ 83 | sheet = sheets[ i ], 84 | href = sheet.href, 85 | media = sheet.media, 86 | isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet"; 87 | 88 | //only links plz and prevent re-parsing 89 | if( !!href && isCSS && !parsedSheets[ href ] ){ 90 | // selectivizr exposes css through the rawCssText expando 91 | if (sheet.styleSheet && sheet.styleSheet.rawCssText) { 92 | translate( sheet.styleSheet.rawCssText, href, media ); 93 | parsedSheets[ href ] = true; 94 | } else { 95 | if( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base) 96 | || href.replace( RegExp.$1, "" ).split( "/" )[0] === win.location.host ){ 97 | requestQueue.push( { 98 | href: href, 99 | media: media 100 | } ); 101 | } 102 | } 103 | } 104 | } 105 | makeRequests(); 106 | }, 107 | 108 | //recurse through request queue, get css text 109 | makeRequests = function(){ 110 | if( requestQueue.length ){ 111 | var thisRequest = requestQueue.shift(); 112 | 113 | ajax( thisRequest.href, function( styles ){ 114 | translate( styles, thisRequest.href, thisRequest.media ); 115 | parsedSheets[ thisRequest.href ] = true; 116 | makeRequests(); 117 | } ); 118 | } 119 | }, 120 | 121 | //find media blocks in css text, convert to style blocks 122 | translate = function( styles, href, media ){ 123 | var qs = styles.match( /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi ), 124 | ql = qs && qs.length || 0, 125 | //try to get CSS path 126 | href = href.substring( 0, href.lastIndexOf( "/" )), 127 | repUrls = function( css ){ 128 | return css.replace( /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, "$1" + href + "$2$3" ); 129 | }, 130 | useMedia = !ql && media, 131 | //vars used in loop 132 | i = 0, 133 | j, fullq, thisq, eachq, eql; 134 | 135 | //if path exists, tack on trailing slash 136 | if( href.length ){ href += "/"; } 137 | 138 | //if no internal queries exist, but media attr does, use that 139 | //note: this currently lacks support for situations where a media attr is specified on a link AND 140 | //its associated stylesheet has internal CSS media queries. 141 | //In those cases, the media attribute will currently be ignored. 142 | if( useMedia ){ 143 | ql = 1; 144 | } 145 | 146 | 147 | for( ; i < ql; i++ ){ 148 | j = 0; 149 | 150 | //media attr 151 | if( useMedia ){ 152 | fullq = media; 153 | rules.push( repUrls( styles ) ); 154 | } 155 | //parse for styles 156 | else{ 157 | fullq = qs[ i ].match( /@media *([^\{]+)\{([\S\s]+?)$/ ) && RegExp.$1; 158 | rules.push( RegExp.$2 && repUrls( RegExp.$2 ) ); 159 | } 160 | 161 | eachq = fullq.split( "," ); 162 | eql = eachq.length; 163 | 164 | for( ; j < eql; j++ ){ 165 | thisq = eachq[ j ]; 166 | mediastyles.push( { 167 | media : thisq.split( "(" )[ 0 ].match( /(only\s+)?([a-zA-Z]+)\s?/ ) && RegExp.$2 || "all", 168 | rules : rules.length - 1, 169 | hasquery: thisq.indexOf("(") > -1, 170 | minw : thisq.match( /\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ), 171 | maxw : thisq.match( /\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ) 172 | } ); 173 | } 174 | } 175 | 176 | applyMedia(); 177 | }, 178 | 179 | lastCall, 180 | 181 | resizeDefer, 182 | 183 | // returns the value of 1em in pixels 184 | getEmValue = function() { 185 | var ret, 186 | div = doc.createElement('div'), 187 | body = doc.body, 188 | fakeUsed = false; 189 | 190 | div.style.cssText = "position:absolute;font-size:1em;width:1em"; 191 | 192 | if( !body ){ 193 | body = fakeUsed = doc.createElement( "body" ); 194 | body.style.background = "none"; 195 | } 196 | 197 | body.appendChild( div ); 198 | 199 | docElem.insertBefore( body, docElem.firstChild ); 200 | 201 | ret = div.offsetWidth; 202 | 203 | if( fakeUsed ){ 204 | docElem.removeChild( body ); 205 | } 206 | else { 207 | body.removeChild( div ); 208 | } 209 | 210 | //also update eminpx before returning 211 | ret = eminpx = parseFloat(ret); 212 | 213 | return ret; 214 | }, 215 | 216 | //cached container for 1em value, populated the first time it's needed 217 | eminpx, 218 | 219 | //enable/disable styles 220 | applyMedia = function( fromResize ){ 221 | var name = "clientWidth", 222 | docElemProp = docElem[ name ], 223 | currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp, 224 | styleBlocks = {}, 225 | lastLink = links[ links.length-1 ], 226 | now = (new Date()).getTime(); 227 | 228 | //throttle resize calls 229 | if( fromResize && lastCall && now - lastCall < resizeThrottle ){ 230 | clearTimeout( resizeDefer ); 231 | resizeDefer = setTimeout( applyMedia, resizeThrottle ); 232 | return; 233 | } 234 | else { 235 | lastCall = now; 236 | } 237 | 238 | for( var i in mediastyles ){ 239 | var thisstyle = mediastyles[ i ], 240 | min = thisstyle.minw, 241 | max = thisstyle.maxw, 242 | minnull = min === null, 243 | maxnull = max === null, 244 | em = "em"; 245 | 246 | if( !!min ){ 247 | min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); 248 | } 249 | if( !!max ){ 250 | max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); 251 | } 252 | 253 | // if there's no media query at all (the () part), or min or max is not null, and if either is present, they're true 254 | if( !thisstyle.hasquery || ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ) ){ 255 | if( !styleBlocks[ thisstyle.media ] ){ 256 | styleBlocks[ thisstyle.media ] = []; 257 | } 258 | styleBlocks[ thisstyle.media ].push( rules[ thisstyle.rules ] ); 259 | } 260 | } 261 | 262 | //remove any existing respond style element(s) 263 | for( var i in appendedEls ){ 264 | if( appendedEls[ i ] && appendedEls[ i ].parentNode === head ){ 265 | head.removeChild( appendedEls[ i ] ); 266 | } 267 | } 268 | 269 | //inject active styles, grouped by media type 270 | for( var i in styleBlocks ){ 271 | var ss = doc.createElement( "style" ), 272 | css = styleBlocks[ i ].join( "\n" ); 273 | 274 | ss.type = "text/css"; 275 | ss.media = i; 276 | 277 | //originally, ss was appended to a documentFragment and sheets were appended in bulk. 278 | //this caused crashes in IE in a number of circumstances, such as when the HTML element had a bg image set, so appending beforehand seems best. Thanks to @dvelyk for the initial research on this one! 279 | head.insertBefore( ss, lastLink.nextSibling ); 280 | 281 | if ( ss.styleSheet ){ 282 | ss.styleSheet.cssText = css; 283 | } 284 | else { 285 | ss.appendChild( doc.createTextNode( css ) ); 286 | } 287 | 288 | //push to appendedEls to track for later removal 289 | appendedEls.push( ss ); 290 | } 291 | }, 292 | //tweaked Ajax functions from Quirksmode 293 | ajax = function( url, callback ) { 294 | var req = xmlHttp(); 295 | if (!req){ 296 | return; 297 | } 298 | req.open( "GET", url, true ); 299 | req.onreadystatechange = function () { 300 | if ( req.readyState != 4 || req.status != 200 && req.status != 304 ){ 301 | return; 302 | } 303 | callback( req.responseText ); 304 | } 305 | if ( req.readyState == 4 ){ 306 | return; 307 | } 308 | req.send( null ); 309 | }, 310 | //define ajax obj 311 | xmlHttp = (function() { 312 | var xmlhttpmethod = false; 313 | try { 314 | xmlhttpmethod = new XMLHttpRequest(); 315 | } 316 | catch( e ){ 317 | xmlhttpmethod = new ActiveXObject( "Microsoft.XMLHTTP" ); 318 | } 319 | return function(){ 320 | return xmlhttpmethod; 321 | }; 322 | })(); 323 | 324 | //translate CSS 325 | ripCSS(); 326 | 327 | //expose update for re-running respond later on 328 | respond.update = ripCSS; 329 | 330 | //adjust on resize 331 | function callMedia(){ 332 | applyMedia( true ); 333 | } 334 | if( win.addEventListener ){ 335 | win.addEventListener( "resize", callMedia, false ); 336 | } 337 | else if( win.attachEvent ){ 338 | win.attachEvent( "onresize", callMedia ); 339 | } 340 | })(this); 341 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Tests/ReportViewerForMvc.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {8133D27D-C746-434E-A733-9BC8965A6073} 7 | Library 8 | Properties 9 | ReportViewerForMvc.Tests 10 | ReportViewerForMvc.Tests 11 | v4.6.1 12 | 512 13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 10.0 15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages 17 | False 18 | UnitTest 19 | SAK 20 | SAK 21 | SAK 22 | SAK 23 | 24 | 25 | 26 | true 27 | full 28 | false 29 | bin\Debug\ 30 | DEBUG;TRACE 31 | prompt 32 | 4 33 | 34 | 35 | pdbonly 36 | true 37 | bin\Release\ 38 | TRACE 39 | prompt 40 | 4 41 | 42 | 43 | 44 | ..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll 45 | 46 | 47 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.Common.dll 48 | 49 | 50 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.DataVisualization.dll 51 | 52 | 53 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.Design.dll 54 | 55 | 56 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.ProcessingObjectModel.dll 57 | 58 | 59 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WebDesign.dll 60 | 61 | 62 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WebForms.dll 63 | 64 | 65 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WinForms.dll 66 | 67 | 68 | ..\packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll 69 | 70 | 71 | True 72 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | False 81 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 82 | 83 | 84 | False 85 | ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 86 | 87 | 88 | False 89 | ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 90 | 91 | 92 | False 93 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 94 | 95 | 96 | False 97 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 98 | 99 | 100 | False 101 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | Designer 133 | 134 | 135 | 136 | 137 | 138 | {b7f6a951-ece3-4bdd-be20-0f7ffd944695} 139 | ReportViewerForMvc 140 | 141 | 142 | 143 | 144 | Always 145 | 146 | 147 | 148 | 149 | 150 | PreserveNewest 151 | 152 | 153 | PreserveNewest 154 | 155 | 156 | PreserveNewest 157 | 158 | 159 | PreserveNewest 160 | 161 | 162 | 163 | 164 | 165 | 166 | False 167 | 168 | 169 | False 170 | 171 | 172 | False 173 | 174 | 175 | False 176 | 177 | 178 | 179 | 180 | 181 | 182 | 189 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/ReportViewerForMvc.Example.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {F239E560-E292-48B9-B937-9D0CFF12C884} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | ReportViewerForMvc.Example 15 | ReportViewerForMvc.Example 16 | v4.6.1 17 | false 18 | true 19 | 20 | 21 | 22 | 23 | SAK 24 | SAK 25 | SAK 26 | SAK 27 | 28 | 29 | 30 | 31 | 32 | true 33 | full 34 | false 35 | bin\ 36 | DEBUG;TRACE 37 | prompt 38 | 4 39 | 40 | 41 | pdbonly 42 | true 43 | bin\ 44 | TRACE 45 | prompt 46 | 4 47 | 48 | 49 | 50 | 51 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.Common.dll 52 | 53 | 54 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.DataVisualization.dll 55 | 56 | 57 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.Design.dll 58 | 59 | 60 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.ProcessingObjectModel.dll 61 | 62 | 63 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WebDesign.dll 64 | 65 | 66 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WebForms.dll 67 | 68 | 69 | ..\packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.140.1000.523\lib\net40\Microsoft.ReportViewer.WinForms.dll 70 | 71 | 72 | ..\packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | False 86 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 87 | 88 | 89 | False 90 | ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 91 | 92 | 93 | False 94 | ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 95 | 96 | 97 | False 98 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 99 | 100 | 101 | False 102 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 103 | 104 | 105 | False 106 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | True 117 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 118 | 119 | 120 | 121 | 122 | 123 | 124 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.1\lib\net40\System.Web.Optimization.dll 125 | 126 | 127 | True 128 | ..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll 129 | 130 | 131 | 132 | True 133 | ..\packages\WebGrease.1.5.2\lib\WebGrease.dll 134 | 135 | 136 | True 137 | ..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | Global.asax 152 | 153 | 154 | 155 | dsLocalReport.xsd 156 | 157 | 158 | True 159 | True 160 | dsLocalReport.xsd 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | dsLocalReport.xsd 175 | 176 | 177 | Designer 178 | MSDataSetGenerator 179 | dsLocalReport.Designer.cs 180 | 181 | 182 | dsLocalReport.xsd 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | PreserveNewest 194 | 195 | 196 | PreserveNewest 197 | 198 | 199 | PreserveNewest 200 | 201 | 202 | PreserveNewest 203 | 204 | 205 | Designer 206 | 207 | 208 | Web.config 209 | 210 | 211 | Web.config 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | Designer 229 | 230 | 231 | 232 | 233 | 234 | {b7f6a951-ece3-4bdd-be20-0f7ffd944695} 235 | ReportViewerForMvc 236 | 237 | 238 | 239 | 240 | 241 | 242 | 10.0 243 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | True 256 | True 257 | 51890 258 | / 259 | http://localhost:57416/ 260 | False 261 | False 262 | 263 | 264 | False 265 | 266 | 267 | 268 | 269 | 270 | if exist "$(TargetDir)ReportViewerWebForm.aspx" move /Y "$(TargetDir)ReportViewerWebForm.aspx" "$(ProjectDir)ReportViewerWebForm.aspx" 271 | 272 | 278 | -------------------------------------------------------------------------------- /ReportViewerForMvc.Example/Reports/LocalReportExample.rdlc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | true 13 | true 14 | 15 | 16 | 17 | 18 | Dept 19 | 25 | 26 | 27 | 35 | 36 | #4c68a2 37 | 2pt 38 | 2pt 39 | 2pt 40 | 2pt 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 1in 52 | 53 | 54 | 1in 55 | 56 | 57 | 58 | 59 | 0.25in 60 | 61 | 62 | 63 | 64 | true 65 | true 66 | 67 | 68 | 69 | 70 | =Count(Fields!EmployeeID.Value) 71 | 75 | 76 | 77 | 85 | 86 | 2pt 87 | 2pt 88 | 2pt 89 | 2pt 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | =Count(Fields!EmployeeID.Value) 104 | 109 | 110 | 111 | 119 | 120 | #7292cc 121 | 2pt 122 | 2pt 123 | 2pt 124 | 2pt 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 0.25in 133 | 134 | 135 | 136 | 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | =Count(Fields!EmployeeID.Value) 144 | 149 | 150 | 151 | 159 | 160 | #7292cc 161 | 2pt 162 | 2pt 163 | 2pt 164 | 2pt 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | true 173 | true 174 | 175 | 176 | 177 | 178 | =Count(Fields!EmployeeID.Value) 179 | 184 | 185 | 186 | 194 | 195 | #7292cc 196 | 2pt 197 | 2pt 198 | 2pt 199 | 2pt 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | =Fields!Shift.Value 214 | 215 | 216 | 217 | 218 | =Fields!Shift.Value 219 | 220 | 221 | 222 | 0.25in 223 | 224 | 225 | true 226 | true 227 | 228 | 229 | 230 | 231 | =Fields!Shift.Value 232 | 237 | 238 | 239 | 247 | 248 | #9eb6e4 249 | 2pt 250 | 2pt 251 | 2pt 252 | 2pt 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 0.25in 264 | 265 | 266 | true 267 | true 268 | 269 | 270 | 271 | 272 | Total 273 | 278 | 279 | 280 | 288 | 289 | #7292cc 290 | 2pt 291 | 2pt 292 | 2pt 293 | 2pt 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | =Fields!Dept.Value 307 | 308 | 309 | 310 | 311 | =Fields!Dept.Value 312 | 313 | 314 | 315 | 1in 316 | 317 | 318 | true 319 | true 320 | 321 | 322 | 323 | 324 | =Fields!Dept.Value 325 | 330 | 331 | 332 | 340 | 341 | #9eb6e4 342 | 2pt 343 | 2pt 344 | 2pt 345 | 2pt 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 1in 357 | 358 | 359 | true 360 | true 361 | 362 | 363 | 364 | 365 | Total 366 | 371 | 372 | 373 | 381 | 382 | #7292cc 383 | 2pt 384 | 2pt 385 | 2pt 386 | 2pt 387 | 388 | 389 | 390 | 391 | Before 392 | 393 | 394 | 395 | dsLocalReport 396 | 0.75in 397 | 3in 398 | 401 | 402 | 403 | 404 | 405 | 2in 406 | 435 | 436 | 2pt 437 | 2pt 438 | 2pt 439 | 2pt 440 | 441 | 442 | 443 | 446 | 447 | 448 | 449 | 1in 450 | 1in 451 | 1in 452 | 1in 453 |