private List <Object> GetQuotaExceededUsers() { List <Object> quotaExceededUsers = new List <Object>(); UserPrintingCostDAO userPrintingCostDAO = new UserPrintingCostDAO(sqlConnection); List <Object> userPrintingCosts = userPrintingCostDAO.GetUserPrintingCosts(tenantId, startDate, endDate); User user = null; UserDAO userDAO = new UserDAO(sqlConnection); foreach (UserPrintingCost userPrintingCost in userPrintingCosts) { Decimal userQuota = Decimal.MaxValue; user = userDAO.GetUser(tenantId, userPrintingCost.userId); if (user.quota != null) { userQuota = user.quota.Value; } if (userPrintingCost.totalCost > userQuota) { String[] rowValues = new String[] { userPrintingCost.userName, String.Format("{0:0.000}", userQuota), String.Format("{0:0.000}", userPrintingCost.totalCost), String.Format("{0:0.000}", userPrintingCost.totalCost - userQuota), }; quotaExceededUsers.Add(rowValues); } } return(quotaExceededUsers); }
public override void BuildReport() { TenantDAO tenantDAO = new TenantDAO(sqlConnection); Tenant tenant = tenantDAO.GetTenant(tenantId); UserPrintingCostDAO userPrintingCostDAO = new UserPrintingCostDAO(sqlConnection); List <Object> userPrintingCosts = userPrintingCostDAO.GetUserPrintingCosts(tenantId, startDate, endDate); 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 usuário", tenant.alias, reportFilter); String[] columnNames = new String[] { "Usuário", "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 = userPrintingCosts.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++) { UserPrintingCost userPrintingCost = (UserPrintingCost)userPrintingCosts[rowIndex]; ReportCell[] cells = new ReportCell[] { GetUserCell(userPrintingCost, reportBuilder.IsNavigable()), new ReportCell(userPrintingCost.bwPageCount), new ReportCell(userPrintingCost.colorPageCount), new ReportCell(userPrintingCost.totalPageCount), new ReportCell(userPrintingCost.bwCost), new ReportCell(userPrintingCost.colorCost), new ReportCell(userPrintingCost.totalCost) }; reportBuilder.InsertRow(rowIndex, cells); } ReportCell[] footerCells = new ReportCell[] { new ReportCell("TOTAL", Color.Red), new ReportCell("paginasPb", ReportCellType.Number), new ReportCell("paginasCor", ReportCellType.Number), new ReportCell("totalPaginas", ReportCellType.Number), new ReportCell("custoPb", ReportCellType.Money), new ReportCell("custoCor", ReportCellType.Money), new ReportCell("totalCusto", ReportCellType.Money) }; reportBuilder.InsertFooter(footerCells); reportBuilder.CloseMedia(); }
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); }