public static ReportCell[] GetDetailRow(UserCostDetail userCostDetail, String detailType) { ReportCell[] cells; switch (detailType) { case "PrintingCosts": cells = new ReportCell[] { new ReportCell(userCostDetail.jobTime.ToString()), new ReportCell(userCostDetail.documentName), new ReportCell(userCostDetail.printerName), new ReportCell(userCostDetail.pageAmount), new ReportCell(userCostDetail.cost) }; break; case "CopyingCosts": cells = new ReportCell[] { new ReportCell(userCostDetail.jobTime.ToString()), new ReportCell(userCostDetail.printerName), new ReportCell(userCostDetail.pageAmount), new ReportCell(userCostDetail.cost) }; break; default: cells = new ReportCell[] { }; break; } return(cells); }
public override void BuildReport() { Dictionary <String, Object> reportData = GetReportData(detailType); TenantDAO tenantDAO = new TenantDAO(sqlConnection); Tenant tenant = tenantDAO.GetTenant(tenantId); UserDAO userDAO = new UserDAO(sqlConnection); User user = userDAO.GetUser(tenantId, userId); UserCostDetailDAO userCostDetailDAO = new UserCostDetailDAO(sqlConnection); List <Object> userCostDetails = userCostDetailDAO.GetUserCostDetails(tenantId, userId, startDate, endDate, detailType); reportBuilder.OpenMedia(reportMedia); // Abre a mídia para o output do relatório Dictionary <String, Object> reportFilter = new Dictionary <String, Object>(); reportFilter.Add("tenantId", tenantId); reportFilter.Add("userId", userId); reportFilter.Add("startDate", startDate); reportFilter.Add("endDate", endDate); reportFilter.Add("detailType", detailType); reportBuilder.SetReportHeadings(reportData["title"] + ". " + "Usuário: " + user.name, tenant.alias, reportFilter); String[] columnNames = (String[])reportData["columnNames"]; int[] columnWidths = (int[])reportData["columnWidths"]; int rowCount = userCostDetails.Count; reportBuilder.CreateDataTable(columnNames, columnWidths, rowCount); if (reportBuilder.IsNavigable()) { Dictionary <String, Object> exportOptions = ExportFormatContext.GetExportOptions(tenantId, sqlConnection); reportBuilder.SetNavigationData(this.GetType().Name, rowCount, exportOptions); // neste caso recordCount = rowCount reportBuilder.SetReportPage(action, currentPage); } for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { UserCostDetail userCostDetail = (UserCostDetail)userCostDetails[rowIndex]; reportBuilder.InsertRow(rowIndex, GetDetailRow(userCostDetail, detailType)); } reportBuilder.InsertFooter(GetFooterCells(detailType)); reportBuilder.CloseMedia(); }