public static HostingPlanContext GetCachedHostingPlanContext(int planId) { string key = "CachedHostingPlanContext" + planId.ToString(); HostingPlanContext cntx = (HostingPlanContext)HttpContext.Current.Items[key]; if (cntx == null) { // load context cntx = ES.Services.Packages.GetHostingPlanContext(planId); if (cntx != null) { // fill dictionaries foreach (HostingPlanGroupInfo group in cntx.GroupsArray) { cntx.Groups.Add(group.GroupName, group); } foreach (QuotaValueInfo quota in cntx.QuotasArray) { cntx.Quotas.Add(quota.QuotaName, quota); } } else { // create empty context cntx = new HostingPlanContext(); } // add it to the cach HttpContext.Current.Items[key] = cntx; } return(cntx); }
public static void DomainAdd(String f_stDomain, int f_iPlanID) { HostingPlanContext cntx = PackagesHelper.GetCachedHostingPlanContext(f_iPlanID); if (cntx != null) { if (Utils.CheckQouta("Filters.Enable", cntx)) { APICall("domain/add/name/" + f_stDomain, f_iPlanID); } } }
private void BindHostingPlan() { // plan resources int planId = Utils.ParseInt(ddlPlans.SelectedValue, 0); chkCreateResources.Visible = (planId > 0); bool createResources = chkCreateResources.Checked; ResourcesPanel.Visible = createResources & chkCreateResources.Visible; if (!createResources) { return; } bool systemEnabled = false; bool webEnabled = false; bool ftpEnabled = false; bool mailEnabled = false; // load hosting context if (planId > 0) { HostingPlanContext cntx = PackagesHelper.GetCachedHostingPlanContext(planId); if (cntx != null) { systemEnabled = cntx.Groups.ContainsKey(ResourceGroups.Os); webEnabled = cntx.Groups.ContainsKey(ResourceGroups.Web); ftpEnabled = cntx.Groups.ContainsKey(ResourceGroups.Ftp); mailEnabled = cntx.Groups.ContainsKey(ResourceGroups.Mail); } } // toggle group controls fsSystem.Visible = systemEnabled; fsWeb.Visible = webEnabled; chkCreateWebSite.Checked &= webEnabled; fsFtp.Visible = ftpEnabled; chkCreateFtpAccount.Checked &= ftpEnabled; fsMail.Visible = mailEnabled; chkCreateMailAccount.Checked &= mailEnabled; ftpAccountName.Visible = (rbFtpAccountName.SelectedIndex == 1); }
private void BindHostingPlan() { // plan resources int planId = Utils.ParseInt(ddlPlans.SelectedValue, 0); chkCreateResources.Visible = (planId > 0); bool createResources = chkCreateResources.Checked; ResourcesPanel.Visible = createResources & chkCreateResources.Visible; if (!createResources) { return; } if ((PanelSecurity.LoggedUser.Role == UserRole.ResellerCSR) | (PanelSecurity.LoggedUser.Role == UserRole.ResellerHelpdesk)) { this.chkCreateResources.Enabled = this.chkIntegratedOUProvisioning.Enabled = false; } bool systemEnabled = false; bool webEnabled = false; bool ftpEnabled = false; bool mailEnabled = false; bool integratedOUEnabled = false; // load hosting context if (planId > 0) { HostingPlanContext cntx = PackagesHelper.GetCachedHostingPlanContext(planId); if (cntx != null) { systemEnabled = cntx.Groups.ContainsKey(ResourceGroups.Os); webEnabled = cntx.Groups.ContainsKey(ResourceGroups.Web); if (Utils.CheckQouta(Quotas.WEB_ENABLEHOSTNAMESUPPORT, cntx)) { lblHostName.Visible = txtHostName.Visible = true; UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.LoggedUserId, UserSettings.WEB_POLICY); txtHostName.Text = String.IsNullOrEmpty(settings["HostName"]) ? "" : settings["HostName"]; } else { lblHostName.Visible = txtHostName.Visible = false; txtHostName.Text = ""; } ftpEnabled = cntx.Groups.ContainsKey(ResourceGroups.Ftp); mailEnabled = cntx.Groups.ContainsKey(ResourceGroups.Mail); if (Utils.CheckQouta(Quotas.ORGANIZATION_DOMAINS, cntx)) { integratedOUEnabled = true; } } } // toggle group controls fsSystem.Visible = systemEnabled; fsWeb.Visible = webEnabled; chkCreateWebSite.Checked &= webEnabled; fsFtp.Visible = ftpEnabled; chkCreateFtpAccount.Checked &= ftpEnabled; fsMail.Visible = mailEnabled; chkCreateMailAccount.Checked &= mailEnabled; ftpAccountName.Visible = (rbFtpAccountName.SelectedIndex == 1); chkIntegratedOUProvisioning.Checked = chkIntegratedOUProvisioning.Visible = (chkCreateResources.Visible && integratedOUEnabled); }
public static bool CheckQouta(string key, HostingPlanContext cntx) { return(cntx.Quotas.ContainsKey(key) && ((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) || (cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1)))); }
private void BindItem() { try { if (!IsPostBack) { string[] supportedDrivers = null; ArrayList drivers = null; // load item if required if (PanelRequest.ItemID > 0) { // existing item try { item = ES.Services.OperatingSystems.GetOdbcSource(PanelRequest.ItemID); } catch (Exception ex) { ShowErrorMessage("DSN_GET", ex); return; } if (item != null) { // save package info ViewState["PackageId"] = item.PackageId; fileLookup.PackageId = item.PackageId; dsnName.SetPackagePolicy(item.PackageId, UserSettings.OS_POLICY, "DsnNamePolicy"); supportedDrivers = ES.Services.OperatingSystems.GetInstalledOdbcDrivers(item.PackageId); } else { RedirectToBrowsePage(); } } else { // new item bool isMsSQLavailable = false; ViewState["PackageId"] = PanelSecurity.PackageId; dsnName.SetPackagePolicy(PanelSecurity.PackageId, UserSettings.OS_POLICY, "DsnNamePolicy"); fileLookup.PackageId = PanelSecurity.PackageId; fileLookup.SelectedFile = "\\"; supportedDrivers = ES.Services.OperatingSystems.GetInstalledOdbcDrivers(PanelSecurity.PackageId); PackageInfo pack = ES.Services.Packages.GetPackage(PanelSecurity.PackageId); HostingPlanContext cont = ES.Services.Packages.GetHostingPlanContext(pack.PlanId); HostingPlanGroupInfo[] groups = cont.GroupsArray; foreach (HostingPlanGroupInfo info in (groups)) { if (info.GroupName.Contains("MsSQL")) { isMsSQLavailable = true; } } drivers = new ArrayList(supportedDrivers); if (!isMsSQLavailable) { //remove unnecessary drivers from list if MS SQL Server is not available in Hosting Plan drivers.Remove("MsSql"); drivers.Remove("MsSqlNative"); } } // bind drivers if (supportedDrivers != null) { foreach (string driver in supportedDrivers) { ddlDriver.Items.Add(new ListItem(driver, driver)); } } ToggleDriverControls(ddlDriver.SelectedValue); } if (!IsPostBack) { // bind item to controls if (item != null) { // bind item to controls passwordControl.EditMode = true; fileLookup.PackageId = item.PackageId; dsnName.Text = item.Name; dsnName.EditMode = true; Utils.SelectListItem(ddlDriver, item.Driver); ddlDriver.Enabled = false; ddlDatabaseName.Enabled = false; ddlDatabaseUser.Enabled = false; ToggleDriverControls(ddlDriver.SelectedValue); // database string driverName = item.Driver; if (driverName == "MsSql" || driverName == "MsSqlNative" || driverName == "MySql") { // unselect currently selected item if (ddlDatabaseName.SelectedIndex != -1) { ddlDatabaseName.SelectedItem.Selected = false; } foreach (ListItem li in ddlDatabaseName.Items) { if (li.Value.StartsWith(item.DatabaseName + "|")) { li.Selected = true; break; } } } else { fileLookup.SelectedFile = item.DatabaseName; } // user if (driverName == "MsAccess") { txtUser.Text = item.DatabaseUser; } else { Utils.SelectListItem(ddlDatabaseUser, item.DatabaseUser); } } } } catch { ShowWarningMessage("INIT_SERVICE_ITEM_FORM"); DisableFormControls(this, btnCancel); } }