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(); }
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(); }
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)); }