XYS.FR
4.0.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package XYS.FR --version 4.0.0
NuGet\Install-Package XYS.FR -Version 4.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XYS.FR" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XYS.FR" Version="4.0.0" />
<PackageReference Include="XYS.FR" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XYS.FR --version 4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XYS.FR, 4.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XYS.FR@4.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XYS.FR&version=4.0.0
#tool nuget:?package=XYS.FR&version=4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XYS.FR.V3
FastReport 数据契约与配置层。只负责:把 POCO 实体注册为 DataSet 表结构、生成 FastReport Designer 所需的 FRTables.frd、加载模板/行列对照配置。不含任何渲染引擎(PDF/图片/打印由 XYS.FRNet.* / XYS.FRCore.* / XYS.FR.NetCore3 等宿主项目实现,它们继承本项目的 BaseFRService)。
- 目标框架:
net8.0/net462/netcoreapp3.1/netstandard2.0/netstandard2.1 - 依赖:
XYS.Utils.Sys、XYS.Utils.Log4Net(同解决方案项目引用) - 程序集名:
XYS.FR(命名空间同名)
核心概念
| 类型 | 职责 |
|---|---|
IFREntity / FRBaseEntity |
实体标记接口 / 抽象基类;子类用 [FRExport] 标注要导出的属性 |
FRExportAttribute |
属性级导出标记,可选 Name 覆盖列名、IsExport=false 显式排除 |
DataStruct |
静态注册中心:Register(Type) 幂等注册 → GetSet() 拿到空 DataSet 副本 → EnsureXmlFile() 落盘 Designer 用的 frd |
ExportData.ExportEntity |
把实体填充到 DataSet 里的 DataRow |
FRReport |
一次打印/导出的总载荷:模板号 + 实体列表 + 份数/副本名 |
IConfigManager / XmlConfigManager |
模板号 → 模板文件名、行 ID → 列名对照 |
BaseFRService |
服务基类,模板方法:GetFRTypes + InitFRConfig;调用 Init() 一次完成注册 + 配置 |
快速使用
1. 定义实体
using XYS.FR;
public class LabItem : FRBaseEntity
{
[FRExport] public string ItemName { get; set; }
[FRExport] public string Value { get; set; }
[FRExport] public string Unit { get; set; }
[FRExport(false)] public string InternalNote { get; set; } // 不导出
[FRExport(true, "结果标志")] public string Flag { get; set; } // 列名重命名
}
2. 继承 BaseFRService
public sealed class LabFRService : BaseFRService
{
public LabFRService()
{
LoggerName = "LabFRService";
ActualType = typeof(LabFRService);
Init(); // 注册实体 + 加载配置
}
protected override List<Type> GetFRTypes() => new List<Type>
{
typeof(FRInfo),
typeof(LabItem),
};
protected override void InitFRConfig()
{
var cfg = new XmlConfigManager(); // 默认 AppBase/Config/fr.config.xml
cfg.Init(); // 失败会抛异常,视为致命错误
ConfigManager = cfg;
}
public override void ExportStream(FRReport report, Stream stream, ExportType type = ExportType.Pdf)
{
// 由具体渲染引擎实现(见 XYS.FRNet.2021 / XYS.FR.NetCore3 等)
}
public override void Print(FRReport report, string printer = null) { }
}
3. 生产 FRReport 并渲染
var report = new FRReport { ModelNo = "LAB001", RID = "R123" };
report.Items.Add(new FRInfo { ID = "1", RID = "R123", PatName = "张三" });
report.Items.Add(new LabItem { ID = "1", RID = "R123", ItemName = "WBC", Value = "6.5" });
using (var fs = File.Create("out.pdf"))
{
labSvc.ExportStream(report, fs, ExportType.Pdf);
}
4. 配置文件 Config/fr.config.xml 示例
<?xml version="1.0" encoding="utf-8"?>
<frConfig>
<modelMap>
<model modelNo="LAB001" name="常规生化" alias="lab" fileName="lab_normal.frx" />
<model modelNo="LAB002" name="血常规" alias="cbc" fileName="lab_cbc.frx" />
</modelMap>
<mapMap>
<map tType="0" rowId="WBC" colName="C0" />
<map tType="0" rowId="RBC" colName="C1" />
</mapMap>
</frConfig>
关键契约
| 成员 | 语义 |
|---|---|
DataStruct.Register(Type) |
幂等注册;非 IFREntity 或已注册类型静默跳过 |
DataStruct.Register(IEnumerable<Type>) |
批量注册 |
DataStruct.GetSet() |
返回空数据集副本(含全部注册表结构) |
DataStruct.EnsureXmlFile() |
磁盘无 FR/FRTables.frd 时按当前注册生成;已存在不覆盖 |
DataStruct.Types |
已注册类型只读快照 |
ExportData.ExportEntity(entity, ds) |
单实体填充;表未注册抛 InvalidOperationException |
BaseFRService.Init() |
注册 + 生成 frd + 加载配置;同一进程多子类并存安全 |
XmlConfigManager(string) |
可通过构造函数注入配置文件路径 |
IConfigManager.Maps / Models |
IReadOnlyList,实现类内部维护 |
4.0.0 变更(相对 3.1.0)
破坏性
ExportType枚举值改 PascalCase:pdf/jpg/html/xls→Pdf/Jpg/Html/Xls- XML DTO 类重命名:
FRModel_Xml→FRConfigXml、FRModel_M→FRModelXml、FRMap_M→FRMapXml(XML 节点名不变,兼容旧配置文件) IConfigManager.Maps/Models由List<T>收紧为IReadOnlyList<T>;外部不再可整体替换IFREntity接口去掉误导性的[FRExport]装饰(C# 属性 Attribute 不从接口继承,原来就没生效)- 删除死接口
IFRModel、空壳ISetting/BaseSettings FRInfo拼写修正:Equipentment→Equipment、SmapleExp→SampleExp、ColletTime→CollectTime、InceptTime→AcceptTime、InceptSign→AcceptSignDataStruct从"通过公共TList.Add修改集合"改为"通过Register()幂等注册";InitXMLStruct/InitRamStruct已由Register + EnsureXmlFile取代BaseConfigManager.Maps/Models公开的可写属性已改为只读;子类改用 protected 字段_maps/_models
修复
_initFlag是静态导致多子类竞态:现改为HashSet<Type>per-type 幂等注册,多个BaseFRService子类可安全共存[FRExport(false)]曾被忽略:DataStruct.IsExport(PropertyInfo)现真正读取IsExport属性FRExportAttribute.Name曾被忽略:现作为导出列名生效XmlConfigManager.Init静默吞异常:文件不存在 / 解析失败 / 反序列化 null 都会抛异常向上传播Models/Maps节点为 null 时 NRE:分别判空throw ex;丢失堆栈:移除无意义 try/catchExportData.IsExport与DataStruct.IsExport重复代码:统一到DataStructExportData抛通用Exception:改为InvalidOperationException/ArgumentNullException
清理
- 依赖由
PackageReference XYS.Utils.Sys 2.2.1.1 / XYS.Utils.Log4Net 2.1.1.1改为ProjectReference,与解决方案统一 DataStruct.Gender*AttrDic→Build*Attrs(原方法名拼写疑似 Generate 之误)static readonly string常量 →const- 删除
DataStruct.ConvertXml2DataTable/ConvertXml2TableRelation/GetRelationColumns等死代码 MethodBase.GetCurrentMethod().Name反射调用 →nameof
建议
Init()在服务构造末尾调用,WorkerCount等属性设置在前XmlConfigManager配置加载失败视为致命错误,让 App 启动失败胜过运行期打空模板[FRExport(name: "...")]用于列名重命名,Designer 端字段名与 C# 属性名可解耦- 同进程内允许多个
BaseFRService子类共存(如 Lab / Exam / EMR),共享同一DataStruct实体注册表
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- XYS.Utils.Log4Net (>= 2.5.0)
- XYS.Utils.Sys (>= 2.6.0)
-
.NETFramework 4.6.2
- XYS.Utils.Log4Net (>= 2.5.0)
- XYS.Utils.Sys (>= 2.6.0)
-
.NETStandard 2.0
- XYS.Utils.Log4Net (>= 2.5.0)
- XYS.Utils.Sys (>= 2.6.0)
-
.NETStandard 2.1
- XYS.Utils.Log4Net (>= 2.5.0)
- XYS.Utils.Sys (>= 2.6.0)
-
net8.0
- XYS.Utils.Log4Net (>= 2.5.0)
- XYS.Utils.Sys (>= 2.6.0)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on XYS.FR:
| Package | Downloads |
|---|---|
|
XYS.FR.Net462
Description |
|
|
XYS.FR.ZhiFang
Package Description |
|
|
XYS.FR.NetCore
Package Description |
|
|
XYS.FRCore
FastReport.Core 渲染宿主:实现 XYS.FR 的 BaseFRService 导出契约,提供 PDF/JPG/HTML/XLSX 导出。不支持打印(Core 版无打印 API)。 |
|
|
XYS.FR.NetFr4
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.0 | 200 | 9/5/2026 |
| 4.0.0 | 114 | 8/17/2026 |
| 3.0.2.7 | 94 | 9/4/2026 |
| 3.0.2.6 | 340 | 4/18/2024 |
| 3.0.2.5 | 299 | 3/13/2024 |
| 3.0.2.4 | 282 | 1/16/2024 |
| 3.0.2.3 | 268 | 1/16/2024 |
| 3.0.2.2 | 268 | 1/16/2024 |
| 3.0.2.1 | 265 | 12/4/2023 |
| 3.0.1.11 | 267 | 11/26/2023 |
| 3.0.1.10 | 240 | 11/26/2023 |
| 3.0.1.9 | 260 | 11/25/2023 |
| 3.0.1.8 | 235 | 11/25/2023 |
| 3.0.1.7 | 247 | 11/24/2023 |
| 3.0.1.6 | 266 | 10/27/2023 |
| 3.0.1.5 | 239 | 10/27/2023 |
| 3.0.1.4 | 239 | 10/26/2023 |
| 3.0.1.3 | 1,017 | 9/14/2022 |
| 3.0.1.2 | 893 | 9/13/2022 |
| 2.0.3.3 | 836 | 9/14/2022 |
Loading failed