using System;
namespace XP.ReportEngine.Models
{
///
/// 报告服务结果 | Report service result
/// 封装报告生成的最终结果信息
/// Encapsulates the final result of report generation
///
public class ReportServiceResult
{
///
/// 是否成功 | Whether successful
///
public bool IsSuccess { get; set; }
///
/// 输出文件路径(成功时有值)| Output file path (has value when successful)
///
public string OutputFilePath { get; set; }
///
/// 报告编号 | Report ID
///
public string ReportId { get; set; }
///
/// 错误信息(失败时有值)| Error message (has value when failed)
///
public string ErrorMessage { get; set; }
///
/// 异常对象(失败时有值)| Exception object (has value when failed)
///
public Exception Exception { get; set; }
///
/// 创建成功结果 | Create success result
///
public static ReportServiceResult Success(string outputFilePath, string reportId)
=> new() { IsSuccess = true, OutputFilePath = outputFilePath, ReportId = reportId };
///
/// 创建失败结果 | Create failure result
///
public static ReportServiceResult Failure(string message, Exception ex = null)
=> new() { IsSuccess = false, ErrorMessage = message, Exception = ex };
}
}