简体   繁体   English

MVC Web API报告

[英]MVC Web API Report

Im trying to solve an issue in MVC4. 我正在尝试解决MVC4中的问题。 Background: We have an existing asp.net web application where we have reports section. 背景:我们有一个现有的asp.net Web应用程序,其中有“报告”部分。 These are rdlc files with datasource and dataset configured to use an SP to populate the rows which is tied to an aspx view. 这些是rdlc文件,其数据源和数据集配置为使用SP填充与aspx视图相关的行。 All these are regular stuff. 这些都是常规的东西。 We have migrated the existing application to MVC rest based web app and apis. 我们已经将现有应用程序迁移到基于MVC rest的Web应用程序和api。 Here, the web app send/receive data in json format and used in view accordingly. 在此,网络应用以json格式发送/接收数据,并相应地在视图中使用。 Problem to solve: the data required for the report to show is coming from one of the rest apis which returns json object. 要解决的问题:报告显示所需的数据来自返回json对象的其余API之一。 The report (.rdlc) traditionally connects to a DB, but in my case, the data is in json. 传统上,报告(.rdlc)连接到数据库,但是在我的情况下,数据位于json中。 How will I go about mapping the json data to the report view? 我将如何将json数据映射到报表视图? Searched lot of forums for couple of days, no real success. 在很多论坛中搜索了几天,但没有真正的成功。 Inputs greatly appreciated. 输入非常感谢。

We have the same situation for our ASP.Net MVC application where the RESTful web services pass back JSON data to the front end applications. 对于ASP.Net MVC应用程序,情况相同,其中RESTful Web服务将JSON数据传递回前端应用程序。 The MVC application doesn't just provide data, it applies business rules to the data before passing it back and these business rules can't be applied at the database level. MVC应用程序不仅提供数据,还在将数据传回数据之前将业务规则应用于数据,并且这些业务规则不能在数据库级别应用。 So reporting is not straightforward. 因此,报告并不简单。

We wanted to call these same web services to get the same data as the front end applications get. 我们希望调用这些相同的Web服务来获取与前端应用程序所获取的数据相同的数据。 Fortunately SSRS is amazingly extensible. 幸运的是,SSRS具有惊人的可扩展性。 I created a custom data processing extension that calls our ASP.Net MVC controllers and returns the data, which is deserialised into datasets for use in the reports. 我创建了一个自定义数据处理扩展 ,该扩展调用了我们的ASP.Net MVC控制器并返回了数据,该数据反序列化为数据集以用于报表中。

While not trivial, it isn't as hard as you might think and implementing a custom data processing extension is a good way to solve your problem. 尽管这并不琐碎,但它并不像您想象的那么难,实现自定义数据处理扩展是解决问题的好方法。 There are plenty of examples online to get you started. 在线上有很多示例可以帮助您入门。 I based mine on the file share example provided with SSRS that queries a network folder and returns the file information as a dataset. 我基于SSRS提供的文件共享示例 ,该示例查询网络文件夹并将文件信息作为数据集返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM