帮助重构旧版自定义报告模块
我有 Intranet win.forms(单击一次)应用程序,带有自定义内置报告模块(40 多个 WinWord 和 Excel 报告)。模块处于分离的组件中并通过接口进行抽象。我们有消息来源并继续支持它。
常见的界面如下:
IReportProvider {
// introspection stuff
IEnumerable<ReportCategoryInfo> GetReportGroups();
IEnumerable<ReportInfo> GetReports(Guid categoryId);
...
// common function
ReportResult CreateReport(Guid reportId, ReportParamCollection prms, ..)
}
ReportInfo描述了基本信息和信息。所需参数。自动生成 UI,让用户选择报告参数。
class ReportInfo {
public Guid Id { get; set; }
public string Title { get; set; }
public List<ReportParameterInfo> Params { get; set; }
...
}
ReportResult提供二进制报告表示以及二进制类型(是Word2003、Excel2003等)
class ReportResult {
public byte[] Document { get; set; }
public ReportType DocumentType { get; set; }
public List<string> Warnings { get; set; }
...
}
没有身份验证要求,并且必须使用word/excel表示。 PDF 不受欢迎。
问题是 - 每次添加/更正报告时,我们都会更新报告模块并发布新的应用程序版本(因为它们是捆绑在一起的)。
我想:
- 更新报告时避免使用新的应用程序版本。
- 我们还必须添加 Intranet Web 界面来进行报告。
我将按以下方式重构当前代码:
- 将报告功能提取到单独的 WCF 服务中
- 将报告模板文件(Excel 和 Word 模板)从应用程序中取出,并放入仅报告服务可访问的文件夹中。
- 新的 WCF 服务将提供自省接口(存在哪些报告以及需要哪些参数)以及检索二进制报告表示形式(word 或 excel)的方法
- 应该有两个客户端与 WCF 服务通信:当前客户端的 Win.Forms 和 Web 客户端。客户端将提供报告导航UI界面,让用户填写参数并接收返回的报告文件。 Win.Forms 客户端将执行 WinWord 或 Excel 以显示收到的报告。
你对此有何看法?
I have intranet win.forms (click once) application with custom built-in reporting module (40+ WinWord & Excel reports). Module is in separated assembly and abstracted via interfaces. We have sources and continue to support it.
Common interfaces look like:
IReportProvider {
// introspection stuff
IEnumerable<ReportCategoryInfo> GetReportGroups();
IEnumerable<ReportInfo> GetReports(Guid categoryId);
...
// common function
ReportResult CreateReport(Guid reportId, ReportParamCollection prms, ..)
}
ReportInfo describes basic info & parameters required. UI is auto generated to let user choose report parameters.
class ReportInfo {
public Guid Id { get; set; }
public string Title { get; set; }
public List<ReportParameterInfo> Params { get; set; }
...
}
and ReportResult provides binary report representation as well as binary type (is it Word2003, Excel2003, e.t.c)
class ReportResult {
public byte[] Document { get; set; }
public ReportType DocumentType { get; set; }
public List<string> Warnings { get; set; }
...
}
There is no authentication requirements and word/excel representation is the must. PDF is not welcomed.
Problem is - every time report is added/corrected we update reporting module and publish new application version ('cos they are tied together).
I want to:
- avoid new application versions when reports are updated.
- We also have to add intranet web interface to reporting.
I am going to refactor present code the following way:
- Extract reporting functionality into separate WCF service
- Put report template files (excel & word templates) out of application and put to folder accessible to reporting service only.
- New WCF service will provide introspection interfaces (what reports are present and what parameters are required) and method to retrieve binary report representation (word or excel)
- There should be two clients that communicate with WCF service: Win.Forms for present client and Web one. Client will provide reporting navigation UI-interface to let user fill parameters and receive report file back. Win.Forms client will execute WinWord or Excel to show report received.
What do you think of that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先:内网win.forms?您是在谈论 ClickOnce WinForms 应用程序、MSIE 托管的 WinForms 应用程序、带有嵌入式 Web 浏览器的 WinForms 还是更奇特的东西?我将假设您实际上有一个中央数据存储,因为否则您的 Intranet Web 界面将不会出现...
这实际上取决于您的 WCF 服务的接口(或者您选择托管和连接您的 WCF 服务的任何方式)服务逻辑)。你还没有真正描述过它们。需要思考的一些问题:
令我有些担心的是,您让 WCF 服务知道关于甚至处理报告模板文件(模板目录、内省接口)。为什么?让模板仅依赖于数据检索服务不是更干净吗?无论如何,您不会与网络报道有这种关系吗?
First of all: intranet win.forms? Are you talking about a ClickOnce WinForms application, an MSIE hosted WinForms application, a WinForms with an embedded web browser, or something even more exotic? I'm going to assume that you actually have a central data store, since otherwise your intranet web interface won't be happening...
This really depends on the interfaces to your WCF services (or whatever way you choose to host and interface your service logic). You haven't really described them. Some questions to ponder:
What worries me somewhat is that you let the WCF service know about and even handle the report template files (template directory, introspection interfaces). Why? Wouldn't it be cleaner to have the templates depend only on a data retrieval service? Won't you have that relation with the web reports anyway?