Files
XplorePlane/XP.ReportEngine/Models/ReportServiceResult.cs
T
QI Mingxuan d72b583319 [XP.ReportEngine] 新增 TXT/CSV/Excel 三种报告输出格式支持;Excel (.xlsx) 报告生成器,基于 ClosedXML,支持结构化生成和模板填充两种模式; 新增 XplorePlane_ReportTemplate.xlsx:Excel 报告模板文件。
[XP.ReportEngine] 模型与配置扩展:ReportOutputFormat 枚举:新增 Excel=1, Csv=2, Txt=3(显式序号,向后兼容);新增多格式相关配置加载。
2026-07-01 11:31:41 +08:00

75 lines
2.7 KiB
C#

using System;
using System.Collections.Generic;
namespace XP.ReportEngine.Models
{
/// <summary>
/// 报告服务结果 | Report service result
/// 封装报告生成的最终结果信息
/// Encapsulates the final result of report generation
/// </summary>
public class ReportServiceResult
{
/// <summary>
/// 是否成功 | Whether successful
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
/// 输出文件路径(成功时有值)| Output file path (has value when successful)
/// 兼容字段,指向首个成功生成的报告路径
/// Compatibility field pointing to the first successfully generated report path
/// </summary>
public string OutputFilePath { get; set; }
/// <summary>
/// 各格式输出文件路径列表(格式 → 路径)| Per-format output file paths (format → path)
/// 仅包含成功生成的格式 | Only contains successfully generated formats
/// </summary>
public List<FormatOutput> OutputFilePaths { get; set; } = new();
/// <summary>
/// 报告编号 | Report ID
/// </summary>
public string ReportId { get; set; }
/// <summary>
/// 错误信息(失败时有值)| Error message (has value when failed)
/// </summary>
public string ErrorMessage { get; set; }
/// <summary>
/// 异常对象(失败时有值)| Exception object (has value when failed)
/// </summary>
public Exception Exception { get; set; }
/// <summary>
/// 创建成功结果 | Create success result
/// </summary>
public static ReportServiceResult Success(string outputFilePath, string reportId)
=> new() { IsSuccess = true, OutputFilePath = outputFilePath, ReportId = reportId };
/// <summary>
/// 创建失败结果 | Create failure result
/// </summary>
public static ReportServiceResult Failure(string message, Exception ex = null)
=> new() { IsSuccess = false, ErrorMessage = message, Exception = ex };
/// <summary>
/// 格式与输出路径的映射 | Mapping of format to output file path
/// </summary>
public class FormatOutput
{
/// <summary>
/// 输出格式 | Output format
/// </summary>
public ReportOutputFormat Format { get; set; }
/// <summary>
/// 该格式对应的输出文件路径 | Output file path for this format
/// </summary>
public string FilePath { get; set; }
}
}
}