报告处理程序架构问题
我正在尝试使用 ReportHandler 服务来处理报告创建。 报告可以有多个不同数量的可设置参数。 目前系统中有多种不同的创建报告的方法(MS 报告服务、html 报告等),并且每种报告生成数据的方式也不同。 我正在尝试将所有内容整合到 ActiveReports 中。 我无法更改系统并更改参数,因此在某些情况下,我基本上会得到一个 where 子句来生成结果,而在另一种情况下,我将得到必须用于生成结果的键/值对。 我考虑过使用工厂模式,但由于查询过滤器的数量不同,这行不通。
我希望有一个 ReportHandler 可以接受我的各种输入并输出报告。 此时,除了使用大型 switch 语句来根据 reportName 处理每个报告之外,我没有看到任何其他方法。 有什么建议我可以更好地解决这个问题吗?
I am attempting to have a ReportHandler service to handle report creation. Reports can have multiple, differing number of parameters that could be set. In the system currently there are several different methods of creating reports (MS reporting services, html reports, etc) and the way the data is generated for each report is different. I am trying to consolidate everything into ActiveReports. I can't alter the system and change the parameters, so in some cases I will essentially get a where clause to generate the results, and in another case I will get key/value pairs that I must use to generate the results. I thought about using the factory pattern, but because of the different number of query filters this won't work.
I would love to have a single ReportHandler that would take my varied inputs and spit out report. At this point I'm not seeing any other way than to use a big switch statement to handle each report based on the reportName. Any suggestions how I could solve this better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您的描述,如果您正在寻找比 Factory 更匹配的模式,请尝试策略:
策略模式< /a>
希望有帮助!
From your description, if you're looking for a pattern that matches better than Factory, try Strategy:
Strategy Pattern
Hope that helps!
除了策略模式之外,您还可以为每个底层解决方案创建一个适配器。 然后使用策略来改变它们。 我已经构建了类似的每个报告解决方案,并由我所谓的引擎支持,除了变量报告解决方案之外,我们还有变量存储解决方案 - 输出可以存储在 SQL 服务器或文件系统中。
我建议使用容器,然后使用正确的引擎初始化它,例如:
然后 ReportContainer 将工作委托给依赖的引擎...
In addition to the strategy pattern, you can also create one adaptor for each of your underlying solutions. Then use strategy to vary them. I've built similar with each report solution being supported by what I called engines, In addition to the variable report solution we have variable storage solution as well - output can be stored in SQL server or file system.
I would suggest using a container then initializing it with the correct engine, e.g.:
then ReportContainer delegates work to the dependent engines...
我们遇到了类似的问题,并采用了“连接器”的概念,它是主报告生成器应用程序和不同报告引擎之间的接口。 通过这样做,我们能够创建一个“通用报表服务器”应用程序。 您应该访问 www.versareports.com 进行查看。
We had a similar problem and went with the concept of "connectors" that are interfaces between the main report generator application and the different report engines. By doing this, we were able to create a "universal report server" application. You should check it out at www.versareports.com.