Ejemplo 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);
        }
Ejemplo n.º 2
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.AddMenuItems();
            administratorMasterPage.InitializeMasterPageComponents();

            TenantDAO  tenantDAO  = new TenantDAO(administratorMasterPage.dataAccess.GetConnection());
            LicenseDAO licenseDAO = new LicenseDAO(administratorMasterPage.dataAccess.GetConnection());

            String[] columnNames = new String[] { "Empresa", "Quantidade de Licenças" };
            String   addScript   = "window.open('AddLicenses.aspx?tenantId=' + {0}, 'AddLicenses', 'width=540,height=600');";

            EditableListButton[] buttons = new EditableListButton[]
            {
                // Botões que devem aparecer para os items da lista
                new EditableListButton("Adicionar", addScript, ButtonTypeEnum.Edit)
            };

            EditableList  editableList = new EditableList(configurationArea, columnNames, buttons);
            List <Object> tenantList   = tenantDAO.GetAllTenants();

            foreach (Tenant tenant in tenantList)
            {
                String[] itemProperties = new String[]
                {
                    tenant.alias,
                    licenseDAO.GetAllLicenses(tenant.id).Count.ToString()
                };
                editableList.InsertItem(tenant.id, false, itemProperties);
            }
            editableList.DrawList();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        public void Execute()
        {
            // Verifica se as dependências foram instanciadas (se o método InitializeTaskState foi chamado)
            if (taskParams == null)
            {
                return;
            }
            if (dataAccess == null)
            {
                return;
            }
            if (notifications == null)
            {
                return;
            }
            if (fileLogger == null)
            {
                return;
            }

            dataAccess.OpenConnection();

            TenantDAO     tenantDAO     = new TenantDAO(dataAccess.GetConnection());
            PreferenceDAO preferenceDAO = new PreferenceDAO(dataAccess.GetConnection());
            MailingDAO    mailingDAO    = new MailingDAO(dataAccess.GetConnection());

            List <Object> tenantList = tenantDAO.GetAllTenants();

            foreach (Tenant tenant in tenantList)
            {
                currentTenant = tenant.id;
                Preference senderPreference = preferenceDAO.GetTenantPreference(currentTenant, "sysSender");
                currentSysSender = senderPreference.value;
                Preference exportPreference = preferenceDAO.GetTenantPreference(currentTenant, "exportFormat");
                int        exportFormat     = 0; // o default é eportar para PDF
                if (exportPreference != null)
                {
                    exportFormat = int.Parse(exportPreference.value);
                }
                currentFormatExtension = GetFormatExtension(exportFormat);
                Preference endDatePreference = preferenceDAO.GetTenantPreference(currentTenant, "periodEndDate");
                currentPeriodEndDate = 1; // o default é o periodo entre o dia 1 deste mês e o dia 1 do mês passado
                if (endDatePreference != null)
                {
                    currentPeriodEndDate = int.Parse(endDatePreference.value);
                }
                currentReportBuilder = GetReportBuilder(exportFormat);

                List <Object> mailingList = mailingDAO.GetAllMailings(currentTenant);
                foreach (Mailing mailing in mailingList)
                {
                    ProcessMailing(mailingDAO, mailing);
                }
            }

            dataAccess.CloseConnection();
        }
        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();
        }
Ejemplo n.º 12
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();
        }
Ejemplo n.º 13
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Tenant tenant = (Tenant)Session["tenant"];

            Preference sysSender = new Preference();

            sysSender.tenantId = tenant.id;
            sysSender.name     = "sysSender";
            sysSender.type     = "System.String";

            Preference exportFormat = new Preference();

            exportFormat.tenantId = tenant.id;
            exportFormat.name     = "exportFormat";
            exportFormat.type     = "System.Int32";

            Preference periodEndDate = new Preference();

            periodEndDate.tenantId = tenant.id;
            periodEndDate.name     = "periodEndDate";
            periodEndDate.type     = "System.Int32";

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtTenantAlias"))
                {
                    tenant.alias = Request.Form[fieldName];
                }

                if (fieldName.Contains("txtSysSenderId"))
                {
                    sysSender.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("txtSysSenderValue"))
                {
                    sysSender.value = Request.Form[fieldName];
                }

                if (fieldName.Contains("txtExportFormatId"))
                {
                    exportFormat.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("cmbExportFormatValue"))
                {
                    exportFormat.value = Request.Form[fieldName];
                }

                if (fieldName.Contains("txtPeriodEndDateId"))
                {
                    periodEndDate.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("cmbPeriodEndDateValue"))
                {
                    periodEndDate.value = Request.Form[fieldName];
                }
            }

            // Verifica se os campos foram preenchidos
            if ((String.IsNullOrEmpty(tenant.alias)) || (String.IsNullOrEmpty(sysSender.value)))
            {
                EmbedClientScript.ShowErrorMessage(this, "Favor preencher todos os campos!");
            }

            try
            {
                // Verifica o formato do endereço de e-mail
                MailAddress mailAddress = new MailAddress(sysSender.value);
            }
            catch
            {
                EmbedClientScript.ShowErrorMessage(this, "O endereço de e-mail não está em um formato válido!");
            }

            TenantDAO tenantDAO = new TenantDAO(dataAccess.GetConnection());

            tenantDAO.SetTenant(tenant);
            preferenceDAO.SetTenantPreference(sysSender);
            preferenceDAO.SetTenantPreference(exportFormat);
            preferenceDAO.SetTenantPreference(periodEndDate);
        }
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.AddMenuItems();
            administratorMasterPage.InitializeMasterPageComponents();

            // action:
            //    null -  Sem ação, apenas lista os inquilinos(clientes)
            //    0    -  Excluir cliente, lista as restantes
            int?action   = null;
            int?tenantId = null;

            try
            {
                if (!String.IsNullOrEmpty(Request.QueryString["action"]))
                {
                    action = int.Parse(Request.QueryString["action"]);
                }

                if (!String.IsNullOrEmpty(Request.QueryString["tenantId"]))
                {
                    tenantId = int.Parse(Request.QueryString["tenantId"]);
                }
            }
            catch (System.FormatException)
            {
                // Remove todos os controles da página
                configurationArea.Controls.Clear();
                controlArea.Controls.Clear();

                // Mostra aviso de inconsistência nos parâmetros
                WarningMessage.Show(controlArea, "Erro nos parâmetros passados para a página.");
                return;
            }

            TenantDAO tenantDAO = new TenantDAO(administratorMasterPage.dataAccess.GetConnection());

            if (tenantId != null)
            {
                switch (action)
                {
                case 0:
                    tenantDAO.RemoveTenant(tenantId.Value);
                    Response.Redirect("ConfigTenants.aspx");     // Limpa a QueryString para evitar erros
                    break;

                default:
                    break;
                }
            }
            List <Object> tenantList = tenantDAO.GetAllTenants();

            String[] columnNames  = new String[] { "Empresa", "Nome amigável" };
            String   alterScript  = "window.open('TenantSettings.aspx?tenantId=' + {0}, 'Settings', 'width=540,height=600');";
            String   removeScript = "var confirmed = confirm('Deseja realmente excluir este cliente?'); if (confirmed) window.location='ConfigTenants.aspx?action=0&tenantId=' + {0};";

            EditableListButton[] buttons = new EditableListButton[]
            {
                // Botões que devem aparecer para os items da lista
                new EditableListButton("Editar", alterScript, ButtonTypeEnum.Edit),
                new EditableListButton("Excluir", removeScript, ButtonTypeEnum.Remove)
            };

            EditableList editableList = new EditableList(configurationArea, columnNames, buttons);

            foreach (Tenant tenant in tenantList)
            {
                String[] tenantProperties = new String[]
                {
                    tenant.name,
                    tenant.alias
                };
                editableList.InsertItem(tenant.id, false, tenantProperties);
            }
            editableList.DrawList();

            // O clique do botão chama o script de alteração passando "id = 0", a tela de alteração
            // interpreta "id = 0" como "criar um novo", o id é então gerado no banco de dados.
            btnNovo.Attributes.Add("onClick", String.Format(alterScript, 0));
        }