コード例 #1
0
 /// <summary>
 /// Adiciona um documento a ser enviado, quando a lista atinge o tamanho máximo do buffer
 /// realiza o envio
 /// </summary>
 public void AddCopiedDocument(CopiedDocument copiedDocument)
 {
     copiedDocumentList.Add(copiedDocument);
     if (copiedDocumentList.Count >= bufferSize)
     {
         SendCopyLogs();
     }
 }
コード例 #2
0
        /// <summary>
        /// Importa os registros do arquivo de log(.CSV) e insere no banco de dados, importa apenas
        /// os registros da data especificada em "logDate" (ignora a hora, minutos e segundos em logDate)
        /// </summary>
        public Boolean ImportFile(String fileName, DateTime logDate)
        {
            // Informações de trace são enviadas ao listener através de NotifyListener()
            // O listener grava essas informações em log de arquivo
            CSVReader reader = new CSVReader(fileName, listener);

            NotifyListener("Fazendo a leitura do CSV.");
            DataTable fullTable = reader.Read(0);
            int       rowCount  = fullTable.Rows.Count;

            // Verifica se existem registros no CSV
            if (rowCount < 1)
            {
                NotifyListener("CSV inválido. Nenhum registro encontrado.");
                return(false);
            }

            // Informa a quantidade de registros no CSV e uma amostra de seu conteúdo
            NotifyListener("Quantidade de registros no CSV - " + rowCount);
            String sampleData = fullTable.Rows[0]["Date"].ToString() + " " +
                                fullTable.Rows[0]["Time"].ToString() + " - " +
                                fullTable.Rows[0]["User Name"].ToString() + " " +
                                fullTable.Rows[0]["Print Pages"].ToString() + " página(s)";

            NotifyListener("Amostra dos dados - " + sampleData);

            // Gera uma view do log apenas com as cópias
            DataView  view = new DataView(fullTable, "Type='Copy'", null, DataViewRowState.Added);
            DataTable copiedDocumentTable = view.ToTable();

            // Obtem o nome da impressora a partir do nome do arquivo
            String printerName = Path.GetFileNameWithoutExtension(fileName);

            CopiedDocumentDAO copiedDocumentDAO = new CopiedDocumentDAO(sqlConnection);
            CopiedDocument    copiedDocument;

            foreach (DataRow row in copiedDocumentTable.Rows)
            {
                copiedDocument             = new CopiedDocument();
                copiedDocument.tenantId    = tenantId;
                copiedDocument.jobTime     = DateTime.Parse(row["Date"] + " " + row["Time"]);
                copiedDocument.userName    = row["User Name"].ToString();
                copiedDocument.printerName = printerName;
                copiedDocument.pageCount   = int.Parse(row["Print Pages"].ToString());
                copiedDocument.duplex      = false;
                copiedDocument.color       = false;

                // Insere no BD apenas se a data do registro for aquela que se deseja importar
                if (copiedDocument.jobTime.Date.CompareTo(logDate.Date) == 0)
                {
                    copiedDocumentDAO.InsertCopiedDocument(copiedDocument);
                }
            }

            return(true);
        }
コード例 #3
0
        public void InsertCopiedDocument(CopiedDocument copiedDocument)
        {
            ProcedureCall storeCopiedDocument = new ProcedureCall("pr_storeCopiedDocument", sqlConnection);

            storeCopiedDocument.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, copiedDocument.tenantId));
            storeCopiedDocument.parameters.Add(new ProcedureParam("@jobTime", SqlDbType.DateTime, 8, copiedDocument.jobTime));
            storeCopiedDocument.parameters.Add(new ProcedureParam("@userName", SqlDbType.VarChar, 100, copiedDocument.userName));
            storeCopiedDocument.parameters.Add(new ProcedureParam("@printerName", SqlDbType.VarChar, 100, copiedDocument.printerName));
            storeCopiedDocument.parameters.Add(new ProcedureParam("@pageCount", SqlDbType.Int, 4, copiedDocument.pageCount));
            storeCopiedDocument.parameters.Add(new ProcedureParam("@duplex", SqlDbType.Bit, 1, copiedDocument.duplex));
            storeCopiedDocument.parameters.Add(new ProcedureParam("@color", SqlDbType.Bit, 1, copiedDocument.color));
            storeCopiedDocument.Execute(false);
        }
コード例 #4
0
        public Boolean ProcessCopyLog(DataTable logData, CopyLogSender copyLogSender, int tenantId)
        {
            int     logType;
            Boolean isNumeric = int.TryParse(device.logType, out logType);

            if (!isNumeric)
            {
                return(false);
            }

            switch (logType)
            {
            case 1:
                // Gera uma view do log apenas com as cópias
                String    rowFilter           = "Type='Copy'";
                DataView  view                = new DataView(logData, rowFilter, null, DataViewRowState.Added);
                DataTable copiedDocumentTable = view.ToTable();

                // Define uma faixa de horário para filtrar os registros mais recentes
                DateTime startHour = DateTime.Now.AddHours(-1);
                DateTime endHour   = DateTime.Now.AddHours(+1);

                CopiedDocument copiedDocument;
                foreach (DataRow row in copiedDocumentTable.Rows)
                {
                    copiedDocument             = new CopiedDocument();
                    copiedDocument.tenantId    = tenantId;
                    copiedDocument.jobTime     = DateTime.Parse(row["Date"] + " " + row["Time"]);
                    copiedDocument.userName    = row["User Name"].ToString();
                    copiedDocument.printerName = device.printerName;
                    copiedDocument.pageCount   = int.Parse(row["Print Pages"].ToString());
                    copiedDocument.duplex      = false;
                    copiedDocument.color       = false;

                    if ((copiedDocument.jobTime > startHour) && (copiedDocument.jobTime < endHour))
                    {
                        copyLogSender.AddCopiedDocument(copiedDocument);
                    }
                }
                break;

            case 2:
                break;

            default:
                return(false);
            }

            return(true);
        }
コード例 #5
0
        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)
            CopiedDocumentDAO copiedDocumentDAO = new CopiedDocumentDAO(sqlConnection);
            List <Object>     copiedDocuments   = copiedDocumentDAO.GetCopiedDocuments(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 Cópias", tenant.alias, reportFilter);

            String[] columnNames  = new String[] { "Data/Hora", "Usuário", "Copiadora", "Páginas" };
            int[]    columnWidths = new int[] { 45, 35, 40, 15 };
            int      rowCount     = copiedDocuments.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++)
            {
                CopiedDocument copiedDocument = (CopiedDocument)copiedDocuments[rowIndex];
                ReportCell[]   cells          = new ReportCell[]
                {
                    new ReportCell(copiedDocument.jobTime.ToString()),
                    new ReportCell(copiedDocument.userName),
                    new ReportCell(copiedDocument.printerName),
                    new ReportCell(copiedDocument.pageCount)
                };
                reportBuilder.InsertRow(rowIndex, cells);
            }

            reportBuilder.CloseMedia();
        }
コード例 #6
0
        private Boolean CheckCopiedDocument(Object obj)
        {
            CopiedDocument current = (CopiedDocument)currentJob;
            CopiedDocument match   = (CopiedDocument)obj;

            if (current.jobTime != match.jobTime)
            {
                return(false);
            }

            if (current.userName.ToUpper() != match.userName.ToUpper())
            {
                return(false);
            }

            if (current.printerName.ToUpper() != match.printerName.ToUpper())
            {
                return(false);
            }

            return(true);
        }