Esempio n. 1
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.InitializeMasterPageComponents();
            dataAccess = administratorMasterPage.dataAccess;

            int     tenantId;
            Boolean isNumeric = int.TryParse(Request.QueryString["tenantId"], out tenantId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            TenantDAO tenantDAO = new TenantDAO(dataAccess.GetConnection());
            Tenant    tenant    = tenantDAO.GetTenant(tenantId);

            // Caso a empresa não exista cria uma nova
            if (tenant == null)
            {
                tenant = new Tenant();
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", tenant.id.ToString());
            settingsInput.Add("txtName", "Identificador", tenant.name);
            settingsInput.Add("txtAlias", "Nome amigável", tenant.alias);
        }
Esempio n. 2
0
        public void Execute()
        {
            TenantDAO     tenantDAO     = new TenantDAO(sqlConnection);
            CostCenterDAO costCenterDAO = new CostCenterDAO(sqlConnection);

            Tenant storedTenant = tenantDAO.GetTenant(tenant.id);

            // Se o tenant já existe no banco bem como sua massa de dados, então só altera alguns dados
            if (storedTenant != null)
            {
                // seta identificador e nome amigável
                tenantDAO.SetTenant(tenant);
                // seta departamento raiz com o nome do tenant
                CostCenter mainCostCenter = costCenterDAO.GetMainCostCenter(tenant.id);
                mainCostCenter.name = tenant.alias;
                costCenterDAO.SetCostCenter(mainCostCenter);
                return;
            }

            // Cria um novo tenant e sua massa de dados inicial
            int?tenantId = tenantDAO.SetTenant(tenant);

            tenant.id = tenantId.Value;

            SetTenantPreference();
            SetTenantAccess();
            SetTenantDefaultSmtp();
            SetTenantRootCC();
        }
Esempio n. 3
0
        public override void BuildReport()
        {
            TenantDAO tenantDAO = new TenantDAO(sqlConnection);
            Tenant    tenant    = tenantDAO.GetTenant(tenantId);

            DuplexPrintingCostDAO duplexPrintingCostDAO = new DuplexPrintingCostDAO(sqlConnection);
            List <Object>         duplexPrintingCosts   = duplexPrintingCostDAO.GetDuplexPrintingCosts(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("Relatório de custos de impressão Simplex/Duplex", tenant.alias, reportFilter);

            String[] columnNames  = new String[] { "Usuário", "Páginas Simplex", "Páginas Duplex", "Total Páginas", "Custo Simplex", "Custo Duplex", "Total Custo" };
            int[]    columnWidths = new int[] { 50, 15, 15, 15, 15, 15, 15 };
            int      rowCount     = duplexPrintingCosts.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++)
            {
                DuplexPrintingCost duplexPrintingCost = (DuplexPrintingCost)duplexPrintingCosts[rowIndex];
                ReportCell[]       cells = new ReportCell[]
                {
                    new ReportCell(duplexPrintingCost.userName),
                    new ReportCell(duplexPrintingCost.simplexPageCount),
                    new ReportCell(duplexPrintingCost.duplexPageCount),
                    new ReportCell(duplexPrintingCost.totalPageCount),
                    new ReportCell(duplexPrintingCost.simplexCost),
                    new ReportCell(duplexPrintingCost.duplexCost),
                    new ReportCell(duplexPrintingCost.totalCost)
                };
                reportBuilder.InsertRow(rowIndex, cells);
            }
            ReportCell[] footerCells = new ReportCell[]
            {
                new ReportCell("TOTAL", Color.Red),
                new ReportCell("paginasSimplex", ReportCellType.Number),
                new ReportCell("paginasDuplex", ReportCellType.Number),
                new ReportCell("totalPaginas", ReportCellType.Number),
                new ReportCell("custoSimplex", ReportCellType.Money),
                new ReportCell("custoDuplex", 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);

            DeviceCopyingCostDAO deviceCopyingCostDAO = new DeviceCopyingCostDAO(sqlConnection);
            List <Object>        deviceCopyingCosts   = deviceCopyingCostDAO.GetDeviceCopyingCosts(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 Cópia por Equipamento", tenant.alias, reportFilter);

            String[] columnNames  = new String[] { "Copiadora", "Páginas", "Percentual de páginas", "Custo", "Percentual de custo" };
            int[]    columnWidths = new int[] { 25, 15, 30, 15, 30 };
            int      rowCount     = deviceCopyingCosts.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++)
            {
                DeviceCopyingCost deviceCopyingCost = (DeviceCopyingCost)deviceCopyingCosts[rowIndex];
                ReportCell[]      cells             = new ReportCell[]
                {
                    GetDeviceCell(deviceCopyingCost, reportBuilder.IsNavigable()),
                    new ReportCell(deviceCopyingCost.pageAmount),
                    new ReportCell(deviceCopyingCost.pagePercentage),
                    new ReportCell(deviceCopyingCost.cost),
                    new ReportCell(deviceCopyingCost.costPercentage)
                };
                reportBuilder.InsertRow(rowIndex, cells);
            }
            ReportCell[] footerCells = new ReportCell[]
            {
                new ReportCell("TOTAL", Color.Red),
                new ReportCell("totalPaginas", ReportCellType.Number),
                new ReportCell("totalPercPag", ReportCellType.Percentage),
                new ReportCell("totalCusto", ReportCellType.Money),
                new ReportCell("totalPercCusto", ReportCellType.Percentage)
            };
            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();
        }
        public Boolean ValidateCredentials()
        {
            // Divide o loginName em dominio(empresa) e nome do usuário
            String[] nameParts = loginName.Split(new Char[] { '\\' });
            if (nameParts.Length != 2)
            {
                errorMessage = @"Informar empresa e usuário (Ex.: Datacopy\guest)!";
                return(false);
            }

            // Verifica se foi entrado um domínio válido (se empresa existe)
            TenantDAO tenantDAO = new TenantDAO(sqlConnection);

            tenant = tenantDAO.GetTenant(nameParts[0]);
            if (tenant == null)
            {
                errorMessage = "Empresa inexistente!";
                return(false);
            }

            // A consulta ao tenant no BD não é case sensitive, devido a isso o tenant é retornado
            // independente se as letras estão em maiúsculas ou minúsculas. Agora faço a comparação
            // case sensitive
            if (tenant.name != nameParts[0])
            {
                errorMessage = "A empresa não confere!";
                return(false);
            }

            String username = nameParts[1];
            String userpass = Cipher.GenerateHash(password);

            // A consulta ao username no BD não é case sensitive, devido a isso o login é retornado
            // independente se as letras estão em maiúsculas ou minúsculas. Posteriormente  é  feita
            // uma comparação case sensitive no username ( em loginValidator )
            LoginDAO loginDAO = new LoginDAO(sqlConnection);

            login = loginDAO.GetLogin(tenant.id, username);

            LoginValidator loginValidator = new LoginValidator(login);

            if (!loginValidator.CheckCredentials(username, userpass))
            {
                errorMessage = loginValidator.GetLastError();
                return(false);
            }

            // Se todas a verificações foram bem sucedidas retorna status de sucesso
            return(true);
        }
        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 override void BuildReport()
        {
            Dictionary <String, Object> reportData = GetReportData(detailType);

            TenantDAO tenantDAO = new TenantDAO(sqlConnection);
            Tenant    tenant    = tenantDAO.GetTenant(tenantId);

            PrinterDAO printerDAO = new PrinterDAO(sqlConnection);
            Printer    printer    = printerDAO.GetPrinter(tenantId, printerId);

            DeviceCostDetailDAO deviceCostDetailDAO = new DeviceCostDetailDAO(sqlConnection);
            List <Object>       deviceCostDetails   = deviceCostDetailDAO.GetDeviceCostDetails(tenantId, printerId, startDate, endDate, detailType);

            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("printerId", printerId);
            reportFilter.Add("startDate", startDate);
            reportFilter.Add("endDate", endDate);
            reportFilter.Add("detailType", detailType);
            reportBuilder.SetReportHeadings(reportData["title"] + ". " + "Impressora: " + printer.name, tenant.alias, reportFilter);

            String[] columnNames  = (String[])reportData["columnNames"];
            int[]    columnWidths = (int[])reportData["columnWidths"];
            int      rowCount     = deviceCostDetails.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++)
            {
                DeviceCostDetail deviceCostDetail = (DeviceCostDetail)deviceCostDetails[rowIndex];
                reportBuilder.InsertRow(rowIndex, GetDetailRow(deviceCostDetail, detailType));
            }
            reportBuilder.InsertFooter(GetFooterCells(detailType));

            reportBuilder.CloseMedia();
        }
        public override void BuildReport()
        {
            TenantDAO tenantDAO = new TenantDAO(sqlConnection);
            Tenant    tenant    = tenantDAO.GetTenant(tenantId);

            List <Object> quotaExceededUsers = GetQuotaExceededUsers();

            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("Relatório de Cotas Excedidas", tenant.alias, reportFilter);

            String[] columnNames  = new String[] { "Usuário", "Cota Definida", "Valor Impressões", "Valor Excedido" };
            int[]    columnWidths = new int[] { 50, 30, 30, 30 };
            int      rowCount     = quotaExceededUsers.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++)
            {
                String[]     rowValues = (String[])quotaExceededUsers[rowIndex];
                ReportCell[] cells     = new ReportCell[]
                {
                    new ReportCell(rowValues[0]),
                    new ReportCell(rowValues[1]),
                    new ReportCell(rowValues[2]),
                    new ReportCell(rowValues[3])
                };
                reportBuilder.InsertRow(rowIndex, cells);
            }

            reportBuilder.CloseMedia();
        }
Esempio n. 10
0
        public override void BuildReport()
        {
            TenantDAO tenantDAO = new TenantDAO(sqlConnection);
            Tenant    tenant    = tenantDAO.GetTenant(tenantId);

            CostCenterDAO costCenterDAO = new CostCenterDAO(sqlConnection);
            CostCenter    costCenter    = costCenterDAO.GetCostCenter(tenantId, costCenterId);

            CostTreePersistence persistence = new CostTreePersistence(sqlConnection);
            CostTree            tree        = persistence.GetCostTree(tenantId);

            CostBranch    branch        = tree.GetBranchById(costCenterId);
            List <Object> detailedCosts = GetDetailedCosts(branch);

            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("costCenterId", costCenterId);
            reportFilter.Add("startDate", startDate);
            reportFilter.Add("endDate", endDate);
            reportBuilder.SetReportHeadings("Relatório de Custos de Impressão" + ". " + "Centro de Custo:  " + costCenter.name, 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     = detailedCosts.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)detailedCosts[rowIndex];
                ReportCell[]     cells            = new ReportCell[]
                {
                    new ReportCell(userPrintingCost.userName),
                    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();
        }