public override void BuildReport() { TenantDAO tenantDAO = new TenantDAO(sqlConnection); Tenant tenant = tenantDAO.GetTenant(tenantId); CostTreePersistence persistence = new CostTreePersistence(sqlConnection); CostTree tree = persistence.GetCostTree(tenantId); UserPrintingCostDAO userPrintingCostDAO = new UserPrintingCostDAO(sqlConnection); List <Object> userPrintingCosts = userPrintingCostDAO.GetUserPrintingCosts(tenantId, startDate, endDate); PrintingCostsAssembler costAssembler = new PrintingCostsAssembler(userPrintingCosts); List <Object> groupPrintingCosts = costAssembler.GetCostsOfBranches(tree); 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("startDate", startDate); reportFilter.Add("endDate", endDate); reportBuilder.SetReportHeadings("Custos de impressão por Grupo (CC)", tenant.alias, reportFilter); String[] columnNames = new String[] { "Centro de custo", "Páginas Pb", "Páginas Cor", "Total Páginas", "Custo Pb", "Custo Cor", "Total Custo" }; int[] columnWidths = new int[] { 50, 15, 15, 15, 15, 15, 15 }; int rowCount = groupPrintingCosts.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++) { GroupPrintingCost groupPrintingCost = (GroupPrintingCost)groupPrintingCosts[rowIndex]; ReportCell[] cells = new ReportCell[] { GetGroupCell(groupPrintingCost, reportBuilder.IsNavigable()), new ReportCell(groupPrintingCost.bwPageCount), new ReportCell(groupPrintingCost.colorPageCount), new ReportCell(groupPrintingCost.totalPageCount), new ReportCell(groupPrintingCost.bwCost), new ReportCell(groupPrintingCost.colorCost), new ReportCell(groupPrintingCost.totalCost) }; reportBuilder.InsertRow(rowIndex, cells); } reportBuilder.CloseMedia(); }
// Retorna os custos de impressão relacionados aos usuários de um centro de custo private List <Object> GetDetailedCosts(CostBranch branch) { List <Object> detailedCosts = new List <Object>(); UserPrintingCostDAO userPrintingCostDAO = new UserPrintingCostDAO(sqlConnection); List <Object> userPrintingCosts = userPrintingCostDAO.GetUserPrintingCosts(tenantId, startDate, endDate); PrintingCostsAssembler costAssembler = new PrintingCostsAssembler(userPrintingCosts); detailedCosts = costAssembler.GetCostsOfAssociates(branch); return(detailedCosts); }