Код: Выделить всё
public async Task GenerateAttendanceReportAsync(int sessionId, int unitId)
{
try
{
// Get all required data
var (session, unit, attendanceDetails) = await GetAttendanceDataAsync(sessionId, unitId);
// Create DataSet for proper data binding
var ds = new DataSet();
DataTable dt = CreateDataTable(attendanceDetails, unit.UnitName);
dt.TableName = "tabledata"; // Match the table name in template
ds.Tables.Add(dt);
// Generate report
using var report = new Report();
string templatePath = GetTemplatePath();
await using (var fileStream = new FileStream(templatePath, FileMode.Open, FileAccess.Read))
{
report.Load(fileStream);
}
// Register data and parameters
RegisterDataAndParameters(report, ds, session.SessionName, unit.UnitName);
// Generate PDF
return await GeneratePdfAsync(report);
}
catch (Exception ex)
{
var message = GetDetailedErrorMessage(ex);
throw new ReportGenerationException(message, ex);
}
}
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/791 ... i-fix-this
Мобильная версия