// Agrupa os custos(impressões) dos usuários existentes no "branch" (ramo de centros de custo), todos os centros // de custo derivados são contabilizados e o próprio ramo é um centro de custo com seus usuários associados private GroupPrintingCost AssembleCosts(CostBranch costBranch, String branchQualifiedName) { GroupPrintingCost groupPrintingCost = new GroupPrintingCost(); groupPrintingCost.costCenterId = costBranch.Id; groupPrintingCost.costCenterName = branchQualifiedName; SearchAssociates(costBranch, true); foreach (int userId in associates) { comparisonValue = userId; UserPrintingCost userPrintingCost = (UserPrintingCost)userPrintingCosts.Find(CheckCostMethod); if (userPrintingCost != null) { groupPrintingCost.bwPageCount += userPrintingCost.bwPageCount; groupPrintingCost.colorPageCount += userPrintingCost.colorPageCount; groupPrintingCost.totalPageCount += userPrintingCost.totalPageCount; groupPrintingCost.bwCost += userPrintingCost.bwCost; groupPrintingCost.colorCost += userPrintingCost.colorCost; groupPrintingCost.totalCost += userPrintingCost.totalCost; } } return(groupPrintingCost); }
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(); }
private Boolean CheckCostMethod(Object userPrintingCost) { UserPrintingCost objToCheck = (UserPrintingCost)userPrintingCost; if (objToCheck.userId != comparisonValue) { return(false); } return(true); }
private ReportCell GetUserCell(UserPrintingCost userPrintingCost, Boolean navigateToUserDetails) { // Se o relatório não é navegável apenas retorna a célula com o nome do usuário if (!navigateToUserDetails) { return(new ReportCell(userPrintingCost.userName)); } // Se o relatório é navegável cria o link que permite acessar os detalhes sobre o usuário String queryString = "?userId=" + userPrintingCost.userId.ToString() + "&" + "startDate=" + startDate.ToString() + "&" + "endDate=" + endDate.ToString() + "&" + "detailType=PrintingCosts"; return(new ReportCell(userPrintingCost.userName, "UserCostDetails.aspx" + queryString)); }
/// <summary> /// Retorna uma lista com os custos de impressão por usuário associado /// </summary> public List <Object> GetCostsOfAssociates(CostBranch branch) { List <Object> costsOfAssociates = new List <Object>(); // Caso não tenham sido passados os custos por usuário retorna a lista em branco if ((userPrintingCosts == null) || (userPrintingCosts.Count < 1)) { return(costsOfAssociates); } SearchAssociates(branch, true); foreach (int userId in associates) { comparisonValue = userId; UserPrintingCost userPrintingCost = (UserPrintingCost)userPrintingCosts.Find(CheckCostMethod); if (userPrintingCost != null) { costsOfAssociates.Add(userPrintingCost); } } return(costsOfAssociates); }