public override void BuildReport() { TenantDAO tenantDAO = new TenantDAO(sqlConnection); Tenant tenant = tenantDAO.GetTenant(tenantId); // Obtem a lista de documentos considerando o filtro (faixa de datas, usuário, impressora) PrintedDocumentDAO printedDocumentDAO = new PrintedDocumentDAO(sqlConnection); List <Object> printedDocuments = printedDocumentDAO.GetPrintedDocuments(tenantId, startDate, endDate, userId, printerId); 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); reportFilter.Add("userId", userId); reportFilter.Add("printerId", printerId); reportBuilder.SetReportHeadings("Relatório de Impressões", tenant.alias, reportFilter); String[] columnNames = new String[] { "Data/Hora", "Usuário", "Impressora", "Páginas", "Nome do documento" }; int[] columnWidths = new int[] { 25, 25, 25, 15, 45 }; int rowCount = printedDocuments.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++) { PrintedDocument printedDocument = (PrintedDocument)printedDocuments[rowIndex]; ReportCell[] cells = new ReportCell[] { new ReportCell(printedDocument.jobTime.ToString()), new ReportCell(printedDocument.userName), new ReportCell(printedDocument.printerName), new ReportCell(printedDocument.pageCount * printedDocument.copyCount), new ReportCell(printedDocument.name) }; reportBuilder.InsertRow(rowIndex, cells); } reportBuilder.CloseMedia(); }
public int LogPrintedDocuments(List <PrintedDocument> printedDocuments) { if (printedDocuments == null) { return(0); } if (printedDocuments.Count == 0) { return(0); } StartDBAccess(); int tenantId = printedDocuments[0].tenantId; DateTime startDate = DateTime.Now.Date; DateTime endDate = startDate.Add(new TimeSpan(23, 59, 59)); JobDataDependency jobDataDependency = new JobDataDependency(printedDocuments, dataAccess.GetConnection(), tenantId); jobDataDependency.CreateDataDependency(); PrintedDocumentDAO printedDocumentDAO = new PrintedDocumentDAO(dataAccess.GetConnection()); List <Object> alreadyInserted = printedDocumentDAO.GetPrintedDocuments(tenantId, startDate, endDate, null, null); int rowCount = 0; foreach (PrintedDocument printedDocument in printedDocuments) { currentJob = printedDocument; if (alreadyInserted.Find(CheckPrintedDocument) == null) // Verifica se o registro já existe { // Caso não exista insere no banco printedDocumentDAO.InsertPrintedDocument(printedDocument); rowCount++; } } FinishDBAccess(); return(rowCount); }
/// <summary> /// Verifica se o arquivo já foi importado previamente /// </summary> public Boolean FileImported(DateRange dateRange) { Boolean imported = false; // Verifica se a faixa de datas foi fornecida if (dateRange == null) { return(false); } // Verifica se existe alguma impressão no intervalo de datas PrintedDocumentDAO printedDocumentDAO = new PrintedDocumentDAO(sqlConnection); List <Object> printedDocuments = printedDocumentDAO.GetPrintedDocuments(tenantId, dateRange.GetFirstDay(), dateRange.GetLastDay(), null, null); if (printedDocuments.Count > 0) { NotifyListener("Já existiam registros inseridos anteriormente no intervalo de datas."); imported = true; } return(imported); }