public static void CheckQuotaValue(PackageContext cntx, List<string> errors, string quotaName, long currentVal, long val, string messageKey)
        {
            if (!cntx.Quotas.ContainsKey(quotaName))
                return;

            QuotaValueInfo quota = cntx.Quotas[quotaName];

            if (val == -1 && quota.QuotaExhausted) // check if quota already reached
            {
                errors.Add(messageKey + ":" + quota.QuotaAllocatedValue);
            }
            else if (quota.QuotaAllocatedValue == -1)
                return; // unlimited
            else if (quota.QuotaTypeId == 1 && val == 1 && quota.QuotaAllocatedValue == 0) // bool quota
                errors.Add(messageKey);
            else if (quota.QuotaTypeId == 2)
            {
                long maxValue = quota.QuotaAllocatedValue - quota.QuotaUsedValue + currentVal;
                if (val > maxValue)
                    errors.Add(messageKey + ":" + maxValue);
            }
            else if (quota.QuotaTypeId == 3 && val > quota.QuotaAllocatedValue)
            {
                int maxValue = quota.QuotaAllocatedValue;
                errors.Add(messageKey + ":" + maxValue);
            }
        }
        private void BindConfiguration()
        {
            VirtualMachine vm = null;

            try
            {
                // load machine
                vm = ES.Services.VPS2012.GetVirtualMachineItem(PanelRequest.ItemID);

                if (vm == null)
                {
                    messageBox.ShowErrorMessage("VPS_LOAD_VM_META_ITEM");
                    return;
                }

                // bind CPU cores
                int            maxCores = ES.Services.VPS2012.GetMaximumCpuCoresNumber(vm.PackageId);
                PackageContext cntx     = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                QuotaValueInfo cpuQuota2      = cntx.Quotas[Quotas.VPS2012_CPU_NUMBER];
                int            cpuQuotausable = (cpuQuota2.QuotaAllocatedValue - cpuQuota2.QuotaUsedValue) + vm.CpuCores;

                if (cpuQuota2.QuotaAllocatedValue == -1)
                {
                    for (int i = 1; i < maxCores + 1; i++)
                    {
                        ddlCpu.Items.Add(i.ToString());
                    }

                    ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                }
                else if (cpuQuota2.QuotaAllocatedValue >= cpuQuota2.QuotaUsedValue)
                {
                    if (cpuQuotausable > maxCores)
                    {
                        for (int i = 1; i < maxCores + 1; i++)
                        {
                            ddlCpu.Items.Add(i.ToString());
                        }

                        ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                    }
                    else
                    {
                        for (int i = 1; i < cpuQuotausable + 1; i++)
                        {
                            ddlCpu.Items.Add(i.ToString());
                        }

                        ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                    }
                }
                else
                {
                    for (int i = 1; i < vm.CpuCores + 1; i++)
                    {
                        ddlCpu.Items.Add(i.ToString());
                    }

                    ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                }

                // bind item
                ddlCpu.SelectedValue  = vm.CpuCores.ToString();
                txtRam.Text           = vm.RamSize.ToString();
                txtHdd.Text           = vm.HddSize[0].ToString();
                hiddenTxtValHdd.Value = vm.HddSize[0].ToString();
                BindAdditionalHdd(vm);
                txtHddMinIOPS.Text = vm.HddMinimumIOPS.ToString();
                txtHddMaxIOPS.Text = vm.HddMaximumIOPS.ToString();
                txtSnapshots.Text  = vm.SnapshotsNumber.ToString();

                chkDvdInstalled.Checked = vm.DvdDriveInstalled;
                chkBootFromCd.Checked   = vm.BootFromCD;
                chkNumLock.Checked      = vm.NumLockEnabled;
                chkSecureBoot.Checked   = vm.EnableSecureBoot;
                if (vm.Generation == 1)
                {
                    chkSecureBoot.Checked = false;
                    chkSecureBoot.Enabled = false;
                }

                chkStartShutdown.Checked = vm.StartTurnOffAllowed;
                chkPauseResume.Checked   = vm.PauseResumeAllowed;
                chkReset.Checked         = vm.ResetAllowed;
                chkReboot.Checked        = vm.RebootAllowed;
                chkReinstall.Checked     = vm.ReinstallAllowed;

                chkExternalNetworkEnabled.Checked = vm.ExternalNetworkEnabled;
                chkPrivateNetworkEnabled.Checked  = vm.PrivateNetworkEnabled;

                chkIgnoreHddWarning.Visible = (PanelSecurity.EffectiveUser.Role != UserRole.User);

                // other quotas
                BindCheckboxOption(chkDvdInstalled, Quotas.VPS2012_DVD_ENABLED);
                chkBootFromCd.Enabled = PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPS2012_BOOT_CD_ALLOWED);

                BindCheckboxOption(chkStartShutdown, Quotas.VPS2012_START_SHUTDOWN_ALLOWED);
                BindCheckboxOption(chkPauseResume, Quotas.VPS2012_PAUSE_RESUME_ALLOWED);
                BindCheckboxOption(chkReset, Quotas.VPS2012_RESET_ALOWED);
                BindCheckboxOption(chkReboot, Quotas.VPS2012_REBOOT_ALLOWED);
                BindCheckboxOption(chkReinstall, Quotas.VPS2012_REINSTALL_ALLOWED);

                BindCheckboxOption(chkExternalNetworkEnabled, Quotas.VPS2012_EXTERNAL_NETWORK_ENABLED);
                if (chkExternalNetworkEnabled.Enabled && !chkExternalNetworkEnabled.Checked)
                {
                    PackageIPAddress[] ips = ES.Services.Servers.GetPackageUnassignedIPAddresses(PanelSecurity.PackageId, 0, IPAddressPool.VpsExternalNetwork);
                    if (ips.Length == 0)
                    {
                        chkExternalNetworkEnabled.Enabled     = false;
                        EmptyExternalAddressesMessage.Visible = true;
                    }
                }
                BindCheckboxOption(chkPrivateNetworkEnabled, Quotas.VPS2012_PRIVATE_NETWORK_ENABLED);

                this.BindSettingsControls(vm);
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("VPS_LOAD_VM_META_ITEM", ex);
            }
        }
Exemple #3
0
        private void BindSettings()
        {
            try
            {
                BindPasswordSettings();

                // get settings
                OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID,
                                                                                         PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(user.DisplayName);

                lblUserDomainName.Text = user.DomainUserName;

                // bind form
                txtDisplayName.Text = user.DisplayName;

                chkDisable.Checked = user.Disabled;

                txtFirstName.Text = user.FirstName;
                txtInitials.Text  = user.Initials;
                txtLastName.Text  = user.LastName;



                txtJobTitle.Text   = user.JobTitle;
                txtCompany.Text    = user.Company;
                txtDepartment.Text = user.Department;
                txtOffice.Text     = user.Office;
                manager.SetAccount(user.Manager);

                txtBusinessPhone.Text = user.BusinessPhone;
                txtFax.Text           = user.Fax;
                txtHomePhone.Text     = user.HomePhone;
                txtMobilePhone.Text   = user.MobilePhone;
                txtPager.Text         = user.Pager;
                txtWebPage.Text       = user.WebPage;

                txtAddress.Text = user.Address;
                txtCity.Text    = user.City;
                txtState.Text   = user.State;
                txtZip.Text     = user.Zip;
                country.Country = user.Country;

                txtNotes.Text = user.Notes;
                txtExternalEmailAddress.Text = user.ExternalEmail;

                txtExternalEmailAddress.Enabled = user.AccountType == ExchangeAccountType.User;
                lblUserDomainName.Text          = user.DomainUserName;

                txtSubscriberNumber.Text  = user.SubscriberNumber;
                lblUserPrincipalName.Text = user.UserPrincipalName;

                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER))
                {
                    if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1)
                    {
                        locSubscriberNumber.Visible = false;
                        txtSubscriberNumber.Visible = false;
                    }
                }

                if (user.LevelId > 0 && secServiceLevels.Visible)
                {
                    secServiceLevels.IsCollapsed = false;

                    ServiceLevel serviceLevel = ES.Services.Organizations.GetSupportServiceLevel(user.LevelId);

                    litServiceLevel.Visible = true;
                    litServiceLevel.Text    = serviceLevel.LevelName;
                    litServiceLevel.ToolTip = serviceLevel.LevelDescription;

                    bool addLevel = ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()) == null;

                    addLevel = addLevel && cntx.Quotas.ContainsKey(Quotas.SERVICE_LEVELS + serviceLevel.LevelName);

                    addLevel = addLevel ? cntx.Quotas[Quotas.SERVICE_LEVELS + serviceLevel.LevelName].QuotaAllocatedValue != 0 : addLevel;

                    if (addLevel)
                    {
                        ddlServiceLevels.Items.Add(new ListItem(serviceLevel.LevelName, serviceLevel.LevelId.ToString()));
                    }

                    bool levelInDDL = ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()) != null;

                    if (levelInDDL)
                    {
                        ddlServiceLevels.Items.FindByValue(string.Empty).Selected = false;
                        ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()).Selected = true;
                    }
                }
                chkVIP.Checked     = user.IsVIP && secServiceLevels.Visible;
                imgVipUser.Visible = user.IsVIP && secServiceLevels.Visible;


                if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATION_ALLOWCHANGEUPN))
                {
                    if (cntx.Quotas[Quotas.ORGANIZATION_ALLOWCHANGEUPN].QuotaAllocatedValue != 1)
                    {
                        lblUserPrincipalName.Visible = true;
                        upn.Visible = false;
                        ddlEmailAddresses.Visible       = false;
                        btnSetUserPrincipalName.Visible = false;
                        chkInherit.Visible = false;
                    }
                    else
                    {
                        lblUserPrincipalName.Visible = false;
                        upn.Visible = false;
                        ddlEmailAddresses.Visible       = false;
                        btnSetUserPrincipalName.Visible = true;
                        chkInherit.Visible = true;
                        if (user.AccountType == ExchangeAccountType.Mailbox)
                        {
                            ddlEmailAddresses.Visible = true;
                            WebsitePanel.EnterpriseServer.ExchangeEmailAddress[] emails = ES.Services.ExchangeServer.GetMailboxEmailAddresses(PanelRequest.ItemID, PanelRequest.AccountID);

                            foreach (WebsitePanel.EnterpriseServer.ExchangeEmailAddress mail in emails)
                            {
                                ListItem li = new ListItem();
                                li.Text     = mail.EmailAddress;
                                li.Value    = mail.EmailAddress;
                                li.Selected = mail.IsPrimary;
                                ddlEmailAddresses.Items.Add(li);
                            }

                            foreach (ListItem li in ddlEmailAddresses.Items)
                            {
                                if (li.Value == user.UserPrincipalName)
                                {
                                    ddlEmailAddresses.ClearSelection();
                                    li.Selected = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            upn.Visible = true;
                            if (!string.IsNullOrEmpty(user.UserPrincipalName))
                            {
                                string[] Tmp = user.UserPrincipalName.Split('@');
                                upn.AccountName = Tmp[0];

                                if (Tmp.Length > 1)
                                {
                                    upn.DomainName = Tmp[1];
                                }
                            }
                        }
                    }
                }

                if (user.Locked)
                {
                    chkLocked.Enabled = true;
                }
                else
                {
                    chkLocked.Enabled = false;
                }

                chkLocked.Checked = user.Locked;

                password.ValidationEnabled = true;
                password.Password          = string.Empty;

                var settings = ES.Services.Organizations.GetWebDavSystemSettings();

                btnResetUserPassword.Visible = settings != null && Utils.ParseBool(settings[EnterpriseServer.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY], false);

                chkUserMustChangePassword.Checked = user.UserMustChangePassword;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("ORGANIZATION_GET_USER_SETTINGS", ex);
            }
        }
Exemple #4
0
        private void AddPlan()
        {
            try
            {
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                Providers.HostedSolution.LyncUserPlan plan = new Providers.HostedSolution.LyncUserPlan();
                plan.LyncUserPlanName = txtPlan.Text;
                plan.IsDefault        = false;

                plan.IM           = true;
                plan.Mobility     = chkMobility.Checked;
                plan.Federation   = chkFederation.Checked;
                plan.Conferencing = chkConferencing.Checked;

                bool enterpriseVoiceQuota = Utils.CheckQouta(Quotas.LYNC_ENTERPRISEVOICE, cntx);
                bool enterpriseVoice      = enterpriseVoiceQuota && (ddTelephony.SelectedValue == "2");

                plan.EnterpriseVoice = enterpriseVoice;

                plan.VoicePolicy = LyncVoicePolicyType.None;

                /* because not used
                 * if (!plan.EnterpriseVoice)
                 * {
                 *  plan.VoicePolicy = LyncVoicePolicyType.None;
                 * }
                 * else
                 * {
                 *  if (chkEmergency.Checked)
                 *      plan.VoicePolicy = LyncVoicePolicyType.Emergency;
                 *  else if (chkNational.Checked)
                 *      plan.VoicePolicy = LyncVoicePolicyType.National;
                 *  else if (chkMobile.Checked)
                 *      plan.VoicePolicy = LyncVoicePolicyType.Mobile;
                 *  else if (chkInternational.Checked)
                 *      plan.VoicePolicy = LyncVoicePolicyType.International;
                 *  else
                 *      plan.VoicePolicy = LyncVoicePolicyType.None;
                 *
                 * }
                 */

                plan.RemoteUserAccess = chkRemoteUserAccess.Checked;

                plan.AllowOrganizeMeetingsWithExternalAnonymous = chkAllowOrganizeMeetingsWithExternalAnonymous.Checked;

                int telephonyId = -1;
                int.TryParse(ddTelephony.SelectedValue, out telephonyId);
                plan.Telephony = telephonyId;

                plan.ServerURI = tbServerURI.Text;

                plan.ArchivePolicy           = ddArchivingPolicy.SelectedValue;
                plan.TelephonyDialPlanPolicy = ddTelephonyDialPlanPolicy.SelectedValue;
                plan.TelephonyVoicePolicy    = ddTelephonyVoicePolicy.SelectedValue;

                int result = ES.Services.Lync.AddLyncUserPlan(PanelRequest.ItemID,
                                                              plan);


                if (result < 0)
                {
                    messageBox.ShowResultMessage(result);
                    messageBox.ShowErrorMessage("LYNC_UNABLE_TO_ADD_PLAN");
                    return;
                }

                Response.Redirect(EditUrl("ItemID", PanelRequest.ItemID.ToString(), "lync_userplans",
                                          "SpaceID=" + PanelSecurity.PackageId));
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("LYNC_ADD_PLAN", ex);
            }
        }
 public RemoveDto(PackageContext context, IEnumerable <InstalledPackage> packages) : this()
 {
     this.Context = context;
     this.Packages.AddRange(packages);
 }
        private void ShortcutRedirect()
        {
            if (PanelSecurity.EffectiveUser.Role == UserRole.Administrator)
            {
                return; // not for administrators
            }
            string shortcut = Request["shortcut"];

            if ("vps".Equals(shortcut, StringComparison.InvariantCultureIgnoreCase))
            {
                // load hosting spaces
                PackageInfo[] packages = ES.Services.Packages.GetMyPackages(PanelSecurity.EffectiveUserId);
                if (packages.Length == 0)
                {
                    return; // no spaces - exit
                }
                // check if some package has VPS resource enabled
                foreach (PackageInfo package in packages)
                {
                    int            packageId = package.PackageId;
                    PackageContext cntx      = PackagesHelper.GetCachedPackageContext(packageId);
                    if (cntx.Groups.ContainsKey(ResourceGroups.VPS))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPS.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPS"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPS"));
                        }
                    }


                    if (cntx.Groups.ContainsKey(ResourceGroups.VPS2012))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPS2012.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS2012", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPS2012"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS2012", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPS2012"));
                        }
                    }


                    if (cntx.Groups.ContainsKey(ResourceGroups.VPSForPC))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPSPC.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPSForPC", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPSForPC"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPSForPC", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPSForPC"));
                        }
                    }
                }

                // no VPS resources found
                // redirect to space home
                if (packages.Length == 1)
                {
                    Response.Redirect(PortalUtils.GetSpaceHomePageUrl(packages[0].PackageId));
                }
            }
        }
Exemple #7
0
        private void BindDomain()
        {
            try
            {
                // load domain
                DomainInfo domain = ES.Services.Servers.GetDomain(PanelRequest.DomainID);
                if (domain == null)
                {
                    RedirectToBrowsePage();
                }


                // load package context
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(domain.PackageId);

                DomainName.Text = domain.DomainName;

                bool webEnabled  = cntx.Groups.ContainsKey(ResourceGroups.Web);
                bool mailEnabled = cntx.Groups.ContainsKey(ResourceGroups.Mail);
                bool dnsEnabled  = cntx.Groups.ContainsKey(ResourceGroups.Dns);

                // web site
                if (webEnabled && domain.WebSiteId > 0)
                {
                    WebSitePanel.Visible      = true;
                    WebSiteAliasPanel.Visible = true;

                    WebSiteName.Text            = domain.WebSiteName;
                    WebSiteParkedPanel.Visible  = (String.Compare(domain.WebSiteName, domain.DomainName, true) == 0);
                    WebSitePointedPanel.Visible = !WebSiteParkedPanel.Visible;

                    BrowseWebSite.NavigateUrl = "http://" + domain.DomainName;
                }

                // mail domain
                if (mailEnabled && domain.MailDomainId > 0)
                {
                    MailDomainPanel.Visible      = true;
                    MailDomainAliasPanel.Visible = true;

                    MailDomainName.Text          = domain.MailDomainName;
                    MailEnabledPanel.Visible     = (String.Compare(domain.MailDomainName, domain.DomainName, true) == 0);
                    PointMailDomainPanel.Visible = !MailEnabledPanel.Visible;
                }

                // DNS
                if (dnsEnabled)
                {
                    DnsPanel.Visible         = true;
                    DnsEnabledPanel.Visible  = (domain.ZoneItemId > 0);
                    DnsDisabledPanel.Visible = !DnsEnabledPanel.Visible;

                    // dns editor
                    EditDnsRecords.Visible = (cntx.Quotas.ContainsKey(Quotas.DNS_EDITOR) &&
                                              cntx.Quotas[Quotas.DNS_EDITOR].QuotaAllocatedValue != 0) ||
                                             PanelSecurity.LoggedUser.Role == UserRole.Administrator;
                }

                // instant alias
                bool instantAliasAllowed = !String.IsNullOrEmpty(domain.InstantAliasName);
                bool instantAliasExists  = (domain.InstantAliasId > 0);
                if (instantAliasAllowed &&
                    !domain.IsDomainPointer && !domain.IsInstantAlias)
                {
                    InstantAliasPanel.Visible    = true;
                    InstantAliasEnabled.Visible  = instantAliasExists;
                    InstantAliasDisabled.Visible = !instantAliasExists;

                    // load instant alias
                    DomainInfo instantAlias = ES.Services.Servers.GetDomain(domain.InstantAliasId);
                    if (instantAlias != null)
                    {
                        WebSiteAliasPanel.Visible    = (instantAlias.WebSiteId > 0);
                        MailDomainAliasPanel.Visible = (instantAlias.MailDomainId > 0);
                    }

                    // instant alias
                    InstantAliasName.Text = domain.InstantAliasName;

                    // web site alias
                    WebSiteAlias.Text = WebSiteAlias.NavigateUrl = "http://" + domain.InstantAliasName;

                    // mail domain alias
                    MailDomainAlias.Text = "@" + domain.InstantAliasName;
                }

                // resellers
                AllowSubDomains.Checked = domain.HostingAllowed;
                if (PanelSecurity.EffectiveUser.Role != UserRole.User &&
                    !(domain.IsDomainPointer || domain.IsSubDomain || domain.IsInstantAlias))
                {
                    ResellersPanel.Visible = true;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("DOMAIN_GET_DOMAIN", ex);
                return;
            }
        }
 public static void CheckBooleanQuota(PackageContext cntx, List<string> errors, string quotaName, bool val, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, 0, val ? 1 : 0, messageKey);
 }
        private MenuItem CreateMenuItem(PackageContext cntx, XmlNode xmlNode)
        {
            string pageId = GetXmlAttribute(xmlNode, "pageID");

            if (!PortalUtils.PageExists(pageId))
            {
                return(null);
            }

            string url           = GetXmlAttribute(xmlNode, "url");
            string title         = GetXmlAttribute(xmlNode, "title");
            string imageUrl      = GetXmlAttribute(xmlNode, "imageUrl");
            string target        = GetXmlAttribute(xmlNode, "target");
            string resourceGroup = GetXmlAttribute(xmlNode, "resourceGroup");
            string quota         = GetXmlAttribute(xmlNode, "quota");
            bool   disabled      = Utils.ParseBool(GetXmlAttribute(xmlNode, "disabled"), false);

            string titleresourcekey = GetXmlAttribute(xmlNode, "titleresourcekey");

            if (!String.IsNullOrEmpty(titleresourcekey))
            {
                title = GetLocalizedString(titleresourcekey + ".Text");
            }

            // get custom page parameters
            XmlNodeList   xmlParameters = xmlNode.SelectNodes("Parameters/Add");
            List <string> parameters    = new List <string>();

            foreach (XmlNode xmlParameter in xmlParameters)
            {
                parameters.Add(xmlParameter.Attributes["name"].Value
                               + "=" + xmlParameter.Attributes["value"].Value);
            }

            // add menu item
            string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL(
                pageId, PortalUtils.SPACE_ID_PARAM, cntx.Package.PackageId.ToString(), parameters.ToArray());
            string   pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId);
            MenuItem item     = new MenuItem(pageName, "", "", disabled ? null : pageUrl);

            item.ImageUrl = PortalUtils.GetThemedIcon(imageUrl);

            if (!String.IsNullOrEmpty(target))
            {
                item.Target = target;
            }
            item.Selectable = !disabled;

            // check groups/quotas
            bool display = true;

            if (cntx != null)
            {
                display = (String.IsNullOrEmpty(resourceGroup) ||
                           cntx.Groups.ContainsKey(resourceGroup)) &&
                          (String.IsNullOrEmpty(quota) ||
                           (cntx.Quotas.ContainsKey(quota) &&
                            cntx.Quotas[quota].QuotaAllocatedValue != 0));
            }

            // process nested menu items
            XmlNodeList xmlMenuNodes = xmlNode.SelectNodes("Icon");

            if (xmlMenuNodes.Count == 0)
            {
                xmlMenuNodes = xmlNode.SelectNodes("MenuItems/MenuItem");
            }
            foreach (XmlNode xmlMenuNode in xmlMenuNodes)
            {
                MenuItem menuItem = CreateMenuItem(cntx, xmlMenuNode);
                if (menuItem != null)
                {
                    item.ChildItems.Add(menuItem);
                }
            }

            // test
            //return item;

            if (display && !(disabled && item.ChildItems.Count == 0))
            {
                return(item);
            }

            return(null);
        }
        public bool IsOrgPanelVisible(int packageId)
        {
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            return(cntx.Groups.ContainsKey(ResourceGroups.HostedOrganizations));
        }
        private void BindControls()
        {
            // get domain type
            DomainType type = GetDomainType(Request["DomainType"]);

            // enable domain/sub-domain fields
            if (type == DomainType.Domain || type == DomainType.DomainPointer)
            {
                // domains
                DomainName.IsSubDomain = false;
            }
            else
            {
                // sub-domains
                DomainName.IsSubDomain = true;

                // fill sub-domains
                if (!IsPostBack)
                {
                    if (type == DomainType.SubDomain)
                    {
                        BindUserDomains();
                    }
                    else
                    {
                        BindResellerDomains();
                    }
                }
            }
            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if ((type == DomainType.DomainPointer || (type == DomainType.Domain)) && !IsPostBack)
            {
                // bind web sites
                WebSitesList.DataSource = ES.Services.WebServers.GetWebSites(PanelSecurity.PackageId, false);
                WebSitesList.DataBind();
            }

            if ((type == DomainType.DomainPointer || (type == DomainType.Domain)) && !IsPostBack)
            {
                // bind mail domains
                MailDomainsList.DataSource = ES.Services.MailServers.GetMailDomains(PanelSecurity.PackageId, false);
                MailDomainsList.DataBind();
            }


            // create web site option
            CreateWebSitePanel.Visible = (type == DomainType.Domain || type == DomainType.SubDomain) &&
                                         cntx.Groups.ContainsKey(ResourceGroups.Web);

            if (PointWebSite.Checked)
            {
                CreateWebSite.Checked = false;
                CreateWebSite.Enabled = false;
            }
            else
            {
                CreateWebSite.Enabled  = true;
                CreateWebSite.Checked &= CreateWebSitePanel.Visible;
            }

            // point Web site
            PointWebSitePanel.Visible = (type == DomainType.DomainPointer || (type == DomainType.Domain)) &&
                                        cntx.Groups.ContainsKey(ResourceGroups.Web) && WebSitesList.Items.Count > 0;
            WebSitesList.Enabled = PointWebSite.Checked;

            // point mail domain
            PointMailDomainPanel.Visible = (type == DomainType.DomainPointer || (type == DomainType.Domain)) &&
                                           cntx.Groups.ContainsKey(ResourceGroups.Mail) && MailDomainsList.Items.Count > 0;
            MailDomainsList.Enabled = PointMailDomain.Checked;

            // DNS option
            EnableDnsPanel.Visible = cntx.Groups.ContainsKey(ResourceGroups.Dns);
            EnableDns.Checked     &= EnableDnsPanel.Visible;

            // instant alias
            // check if instant alias was setup
            bool            instantAliasAllowed = false;
            PackageSettings settings            = ES.Services.Packages.GetPackageSettings(PanelSecurity.PackageId, PackageSettings.INSTANT_ALIAS);

            instantAliasAllowed = (settings != null && !String.IsNullOrEmpty(settings["InstantAlias"]));

            InstantAliasPanel.Visible   = instantAliasAllowed && (type != DomainType.DomainPointer) /*&& EnableDnsPanel.Visible*/;
            CreateInstantAlias.Checked &= InstantAliasPanel.Visible;

            // allow sub-domains
            AllowSubDomainsPanel.Visible = (type == DomainType.Domain) && PanelSecurity.EffectiveUser.Role != UserRole.User;

            if (IsPostBack)
            {
                CheckForCorrectIdnDomainUsage(DomainName.Text);
            }
        }
 public static void CheckNumericQuota(PackageContext cntx, List<string> errors, string quotaName, long currentVal, long val, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, currentVal, val, messageKey);
 }
 public static void CheckListsQuota(PackageContext cntx, List<string> errors, string quotaName, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, 0, -1, messageKey);
 }
Exemple #14
0
        private void BindConfiguration()
        {
            VirtualMachine vm = null;

            try
            {
                // load machine
                vm = ES.Services.VPS.GetVirtualMachineItem(PanelRequest.ItemID);

                if (vm == null)
                {
                    messageBox.ShowErrorMessage("VPS_LOAD_VM_META_ITEM");
                    return;
                }

                // bind CPU cores
                int            maxCores = ES.Services.VPS.GetMaximumCpuCoresNumber(vm.PackageId);
                PackageContext cntx     = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                QuotaValueInfo cpuQuota2      = cntx.Quotas[Quotas.VPS_CPU_NUMBER];
                int            cpuQuotausable = (cpuQuota2.QuotaAllocatedValue - cpuQuota2.QuotaUsedValue) + vm.CpuCores;

                if (cpuQuota2.QuotaAllocatedValue == -1)
                {
                    for (int i = 1; i < maxCores + 1; i++)
                    {
                        ddlCpu.Items.Add(i.ToString());
                    }

                    ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                }
                else if (cpuQuota2.QuotaAllocatedValue >= cpuQuota2.QuotaUsedValue)
                {
                    if (cpuQuotausable > maxCores)
                    {
                        for (int i = 1; i < maxCores + 1; i++)
                        {
                            ddlCpu.Items.Add(i.ToString());
                        }

                        ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                    }
                    else
                    {
                        for (int i = 1; i < cpuQuotausable + 1; i++)
                        {
                            ddlCpu.Items.Add(i.ToString());
                        }

                        ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                    }
                }
                else
                {
                    for (int i = 1; i < vm.CpuCores + 1; i++)
                    {
                        ddlCpu.Items.Add(i.ToString());
                    }

                    ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item
                }

                // bind item
                ddlCpu.SelectedValue = vm.CpuCores.ToString();
                txtRam.Text          = vm.RamSize.ToString();
                txtHdd.Text          = vm.HddSize.ToString();
                txtSnapshots.Text    = vm.SnapshotsNumber.ToString();

                chkDvdInstalled.Checked = vm.DvdDriveInstalled;
                chkBootFromCd.Checked   = vm.BootFromCD;
                chkNumLock.Checked      = vm.NumLockEnabled;

                chkStartShutdown.Checked = vm.StartTurnOffAllowed;
                chkPauseResume.Checked   = vm.PauseResumeAllowed;
                chkReset.Checked         = vm.ResetAllowed;
                chkReboot.Checked        = vm.RebootAllowed;
                chkReinstall.Checked     = vm.ReinstallAllowed;

                chkExternalNetworkEnabled.Checked = vm.ExternalNetworkEnabled;
                chkPrivateNetworkEnabled.Checked  = vm.PrivateNetworkEnabled;

                // other quotas
                BindCheckboxOption(chkDvdInstalled, Quotas.VPS_DVD_ENABLED);
                chkBootFromCd.Enabled = PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPS_BOOT_CD_ALLOWED);

                BindCheckboxOption(chkStartShutdown, Quotas.VPS_START_SHUTDOWN_ALLOWED);
                BindCheckboxOption(chkPauseResume, Quotas.VPS_PAUSE_RESUME_ALLOWED);
                BindCheckboxOption(chkReset, Quotas.VPS_RESET_ALOWED);
                BindCheckboxOption(chkReboot, Quotas.VPS_REBOOT_ALLOWED);
                BindCheckboxOption(chkReinstall, Quotas.VPS_REINSTALL_ALLOWED);

                BindCheckboxOption(chkExternalNetworkEnabled, Quotas.VPS_EXTERNAL_NETWORK_ENABLED);
                BindCheckboxOption(chkPrivateNetworkEnabled, Quotas.VPS_PRIVATE_NETWORK_ENABLED);
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("VPS_LOAD_VM_META_ITEM", ex);
            }
        }
Exemple #15
0
 public static void CheckNumericQuota(PackageContext cntx, List <string> errors, string quotaName, int currentVal, int val, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, Convert.ToInt64(currentVal), Convert.ToInt64(val), messageKey);
 }
Exemple #16
0
        private List <MenuGroup> PrepareMenu()
        {
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            List <MenuGroup> groups = new List <MenuGroup>();

            string imagePath = String.Concat("~/", DefaultPage.THEMES_FOLDER, "/", Page.Theme, "/", "Images/Exchange", "/");

            //Organization menu group;
            if (cntx.Groups.ContainsKey(ResourceGroups.HostedOrganizations))
            {
                PrepareOrganizationMenu(cntx, groups, imagePath);
            }


            //Exchange menu group;
            if (cntx.Groups.ContainsKey(ResourceGroups.Exchange))
            {
                PrepareExchangeMenu(cntx, groups, imagePath);
            }

            //BlackBerry Menu
            if (cntx.Groups.ContainsKey(ResourceGroups.BlackBerry))
            {
                PrepareBlackBerryMenu(cntx, groups, imagePath);
            }

            //SharePoint menu group;
            if (cntx.Groups.ContainsKey(ResourceGroups.SharepointFoundationServer))
            {
                PrepareSharePointMenu(cntx, groups, imagePath, GetLocalizedString("Text.SharePointFoundationServerGroup"));
            }

            if (cntx.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
            {
                PrepareSharePointEnterpriseMenu(cntx, groups, imagePath, GetLocalizedString("Text.SharePointEnterpriseServerGroup"));
            }

            //CRM Menu
            if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM2013))
            {
                PrepareCRMMenu2013(cntx, groups, imagePath);
            }
            else if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM))
            {
                PrepareCRMMenu(cntx, groups, imagePath);
            }


            //OCS Menu
            if (cntx.Groups.ContainsKey(ResourceGroups.OCS))
            {
                PrepareOCSMenu(cntx, groups, imagePath);
            }

            //Lync Menu
            if (cntx.Groups.ContainsKey(ResourceGroups.Lync))
            {
                PrepareLyncMenu(cntx, groups, imagePath);
            }

            //SfB Menu
            if (cntx.Groups.ContainsKey(ResourceGroups.SfB))
            {
                PrepareSfBMenu(cntx, groups, imagePath);
            }

            //EnterpriseStorage Menu
            if (cntx.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
            {
                PrepareEnterpriseStorageMenu(cntx, groups, imagePath);
            }


            return(groups);
        }
Exemple #17
0
 public static void CheckBooleanQuota(PackageContext cntx, List <string> errors, string quotaName, bool val, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, 0, val ? 1 : 0, messageKey);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (PanelSecurity.SelectedUser.Role == UserRole.Administrator)
            {
                orgMenu.Visible = false;
                return;
            }

            if (PanelSecurity.PackageId == 0)
            {
                myPackages = new PackagesHelper().GetMyPackages();
                //For selectedUser have Packages or not then HIDE Menu
                if (myPackages.Tables[0].Rows.Count == 0)
                {
                    orgMenu.Visible = false;
                    return;
                }

                if (Session["currentPackage"] == null || ((int)Session["currentUser"]) != PanelSecurity.SelectedUserId)
                {
                    if (myPackages.Tables[0].Rows.Count > 0)
                    {
                        Session["currentPackage"] = myPackages.Tables[0].Rows[0][0].ToString();
                        Session["currentUser"]    = PanelSecurity.SelectedUserId;
                    }
                }
                currentPackage = Convert.ToInt32(Session["currentPackage"]);
            }
            else
            {
                currentPackage = PanelSecurity.PackageId;
            }
            // load package context
            cntx = PackagesHelper.GetCachedPackageContext(currentPackage);

            ShortMenu = false;
            ShowImg   = false;

            //if (currentPackage > 0 && PanelRequest.ItemID == 0)
            //{
            //    DataTable l_OrgTable;
            //    l_OrgTable = new OrganizationsHelper().GetOrganizations(currentPackage, false);
            //    if (l_OrgTable.Rows.Count > 0)
            //    {
            //        l_CurrentItem = Convert.ToInt32(l_OrgTable.Rows[0]["ItemID"]);
            //    }
            // }
            // else
            // {
            //     l_CurrentItem = PanelRequest.ItemID;
            // }


            // organization



            // if (l_CurrentItem > 0)
            // {

            //    if (!Request[DefaultPage.PAGE_ID_PARAM].Equals(PID_SPACE_EXCHANGE_SERVER, StringComparison.InvariantCultureIgnoreCase)) {
            //       MenuItem rootItem = new MenuItem(locMenuTitle.Text);
            //      rootItem.Selectable = false;

            //       menu.Items.Add(rootItem);
            //      //Add "Organization Home" menu item
            //     MenuItem item = new MenuItem(
            //      GetLocalizedString("Text.OrganizationHome"),
            //       "",
            //       "",
            //      PortalUtils.EditUrl("ItemID", l_CurrentItem.ToString(), "organization_home", "SpaceID=" + currentPackage));//, "mid=135"
            //       makeSelectedMenu(item);
            //       rootItem.ChildItems.Add(item);
            //       this.ItemID = l_CurrentItem;
            //       this.PackageId = currentPackage;
            //       BindMenu(rootItem.ChildItems);
            //     }

            //   }
            if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATIONS))
            {
                if ((cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue > 0) || (cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue == -1))
                {
                    MenuItem rootItem = new MenuItem(locMenuTitle.Text);
                    rootItem.Value      = "ORGANIZATION MENU";
                    rootItem.Selectable = false;

                    menu.Items.Add(rootItem);
                    MenuItem item = new MenuItem(
                        "Hosted Organizations",
                        "",
                        "",
                        "~/Default.aspx?pid=SpaceExchangeServer&SpaceID=" + currentPackage);
                    makeSelectedMenu(item);
                    rootItem.ChildItems.Add(item);
                    this.PackageId = currentPackage;
                    BindMenu(rootItem.ChildItems);
                }
            }
        }
Exemple #19
0
 public static void CheckListsQuota(PackageContext cntx, List <string> errors, string quotaName, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, 0, -1, messageKey);
 }
Exemple #20
0
        private void BindFormControls()
        {
            try
            {
                // OS templates
                listOperatingSystems.DataSource = ES.Services.VPSPC.GetOperatingSystemTemplatesPC(PanelSecurity.PackageId);
                listOperatingSystems.DataBind();
            }
            catch (Exception ex)
            {
                listOperatingSystems.Items.Add(new ListItem(GetLocalizedString("SelectOsTemplate.Text"), ""));
                listOperatingSystems.Enabled = false;
                txtVmName.Enabled            = false;

                Button btn;

                btn = ((Button)wizard.FindControl("StepNavigationTemplateContainerID").FindControl("btnNext"));
                if (btn != null)
                {
                    btn.Enabled = false;
                }

                btn = ((Button)wizard.FindControl("StartNavigationTemplateContainerID").FindControl("btnNext"));
                if (btn != null)
                {
                    btn.Enabled = false;
                }

                messageBox.ShowErrorMessage("VPS_ERROR_CREATE", new Exception("no templates"));
            }
            // summary letter e-mail
            PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId);

            if (package != null)
            {
                UserInfo user = ES.Services.Users.GetUserById(package.UserId);
                if (user != null)
                {
                    chkSendSummary.Checked = true;
                    txtSummaryEmail.Text   = user.Email;
                }
            }

            // load package context
            if (cntx == null)
            {
                cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
            }

            // bind CPU cores
            int maxCores = 0;

            if (!String.IsNullOrWhiteSpace(listOperatingSystems.SelectedValue))
            {
                maxCores = ES.Services.VPSPC.GetMaximumCpuCoresNumber(PanelSecurity.PackageId, listOperatingSystems.SelectedValue);
            }

            if (cntx.Quotas.ContainsKey(Quotas.VPSForPC_CPU_NUMBER))
            {
                QuotaValueInfo cpuQuota = cntx.Quotas[Quotas.VPSForPC_CPU_NUMBER];

                if (cpuQuota.QuotaAllocatedValue != -1 &&
                    maxCores > cpuQuota.QuotaAllocatedValue)
                {
                    maxCores = cpuQuota.QuotaAllocatedValue;
                }
            }

            for (int i = 1; i < maxCores + 1; i++)
            {
                ddlCpu.Items.Add(i.ToString());
            }

            ddlCpu.SelectedIndex = (ddlCpu.Items.Count > 0 ? 0 : -1); // select last (maximum) item

            #region Network
            // external network details
            if (PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPSForPC_EXTERNAL_NETWORK_ENABLED))
            {
            }

            // private network
            if (PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPSForPC_PRIVATE_NETWORK_ENABLED))
            {
                //Fill VLanID list
                UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);
                chkPrivateNetworkEnabled.Checked = chkPrivateNetworkEnabled.Enabled = tablePrivateNetwork.Visible = user.Vlans.Count > 0;
                pVLanListIsEmptyMessage.Visible  = user.Vlans.Count == 0;

                ddlPrivateVLanID.DataSource = user.Vlans;
                ddlPrivateVLanID.DataBind();
            }
            #endregion

            // RAM size
            if (cntx.Quotas.ContainsKey(Quotas.VPSForPC_RAM))
            {
                QuotaValueInfo ramQuota = cntx.Quotas[Quotas.VPSForPC_RAM];
                if (ramQuota.QuotaAllocatedValue == -1)
                {
                    // unlimited RAM
                    txtRam.Text = "";
                }
                else
                {
                    int availSize = ramQuota.QuotaAllocatedValue - ramQuota.QuotaUsedValue;
                    txtRam.Text = availSize < 0 ? "" : availSize.ToString();
                }

                txtRam.Text = "";
            }

            // HDD size
            if (cntx.Quotas.ContainsKey(Quotas.VPSForPC_HDD))
            {
                QuotaValueInfo hddQuota = cntx.Quotas[Quotas.VPSForPC_HDD];
                if (hddQuota.QuotaAllocatedValue == -1)
                {
                    // unlimited HDD
                    txtHdd.Text = "";
                }
                else
                {
                    int availSize = hddQuota.QuotaAllocatedValue - hddQuota.QuotaUsedValue;

                    txtHdd.Text = availSize < 0 ? "" : availSize.ToString();
                }

                txtHdd.Text = "";
            }

            // snapshots number
            if (cntx.Quotas.ContainsKey(Quotas.VPSForPC_SNAPSHOTS_NUMBER))
            {
                int snapsNumber = cntx.Quotas[Quotas.VPSForPC_SNAPSHOTS_NUMBER].QuotaAllocatedValue;
                txtSnapshots.Text    = (snapsNumber != -1) ? snapsNumber.ToString() : "";
                txtSnapshots.Enabled = (snapsNumber != 0);
            }

            // toggle controls
            BindCheckboxOption(chkDvdInstalled, Quotas.VPS_DVD_ENABLED);
            chkBootFromCd.Enabled = PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPSForPC_BOOT_CD_ALLOWED);

            BindCheckboxOption(chkStartShutdown, Quotas.VPSForPC_START_SHUTDOWN_ALLOWED);
            BindCheckboxOption(chkPauseResume, Quotas.VPSForPC_PAUSE_RESUME_ALLOWED);
            BindCheckboxOption(chkReset, Quotas.VPSForPC_RESET_ALOWED);
            BindCheckboxOption(chkReboot, Quotas.VPSForPC_REBOOT_ALLOWED);
            BindCheckboxOption(chkReinstall, Quotas.VPSForPC_REINSTALL_ALLOWED);
        }
Exemple #21
0
 public static void CheckNumericQuota(PackageContext cntx, List <string> errors, string quotaName, long currentVal, long val, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, currentVal, val, messageKey);
 }
Exemple #22
0
 public static bool CheckQouta(string key, PackageContext 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))));
 }
Exemple #23
0
        private void BindDomain()
        {
            try
            {
                // load domain
                DomainInfo domain = ES.Services.Servers.GetDomain(PanelRequest.DomainID);
                if (domain == null)
                {
                    RedirectToBrowsePage();
                }


                // load package context
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(domain.PackageId);

                DomainName.Text = domain.DomainName;

                bool webEnabled  = cntx.Groups.ContainsKey(ResourceGroups.Web);
                bool mailEnabled = cntx.Groups.ContainsKey(ResourceGroups.Mail);
                bool dnsEnabled  = cntx.Groups.ContainsKey(ResourceGroups.Dns);

                // web site
                if (webEnabled && domain.WebSiteId > 0)
                {
                    SolidCP.Visible           = true;
                    WebSiteAliasPanel.Visible = true;

                    WebSiteName.Text            = domain.WebSiteName;
                    WebSiteParkedPanel.Visible  = (String.Compare(domain.WebSiteName, domain.DomainName, true) == 0);
                    WebSitePointedPanel.Visible = !WebSiteParkedPanel.Visible;

                    BrowseWebSite.NavigateUrl = "http://" + domain.DomainName;
                }

                // mail domain
                if (mailEnabled && domain.MailDomainId > 0)
                {
                    MailDomainPanel.Visible      = true;
                    MailDomainAliasPanel.Visible = true;

                    MailDomainName.Text          = domain.MailDomainName;
                    MailEnabledPanel.Visible     = (String.Compare(domain.MailDomainName, domain.DomainName, true) == 0);
                    PointMailDomainPanel.Visible = !MailEnabledPanel.Visible;
                }

                // DNS
                if (dnsEnabled)
                {
                    DnsPanel.Visible         = true;
                    DnsEnabledPanel.Visible  = (domain.ZoneItemId > 0);
                    DnsDisabledPanel.Visible = !DnsEnabledPanel.Visible;

                    // dns editor
                    EditDnsRecords.Visible = (cntx.Quotas.ContainsKey(Quotas.DNS_EDITOR) &&
                                              cntx.Quotas[Quotas.DNS_EDITOR].QuotaAllocatedValue != 0) ||
                                             PanelSecurity.LoggedUser.Role == UserRole.Administrator;

                    //DNS Export
                    ExportDnsRecords.Visible = (cntx.Quotas.ContainsKey(Quotas.DNS_EDITOR) &&
                                                cntx.Quotas[Quotas.DNS_EDITOR].QuotaAllocatedValue != 0) ||
                                               PanelSecurity.LoggedUser.Role == UserRole.Administrator;

                    //DNS Import
                    ImportDnsRecords.Visible = (cntx.Quotas.ContainsKey(Quotas.DNS_EDITOR) &&
                                                cntx.Quotas[Quotas.DNS_EDITOR].QuotaAllocatedValue != 0) ||
                                               PanelSecurity.LoggedUser.Role == UserRole.Administrator;
                }

                // Preview Domain
                PackageSettings settings = ES.Services.Packages.GetPackageSettings(PanelSecurity.PackageId, PackageSettings.INSTANT_ALIAS);

                bool instantAliasAllowed = !String.IsNullOrEmpty(domain.PreviewDomainName);
                bool instantAliasExists  = (domain.PreviewDomainId > 0) && (settings != null && !String.IsNullOrEmpty(settings["PreviewDomain"]));
                if (instantAliasAllowed &&
                    !domain.IsDomainPointer && !domain.IsPreviewDomain)
                {
                    PreviewDomainPanel.Visible    = true;
                    PreviewDomainEnabled.Visible  = instantAliasExists;
                    PreviewDomainDisabled.Visible = !instantAliasExists;

                    // load Preview Domain
                    DomainInfo instantAlias = ES.Services.Servers.GetDomain(domain.PreviewDomainId);
                    WebSiteAliasPanel.Visible = false;
                    if (instantAlias != null)
                    {
                        DomainInfo[] Domains = ES.Services.Servers.GetDomainsByDomainId(domain.PreviewDomainId);
                        foreach (DomainInfo d in Domains)
                        {
                            if (d.WebSiteId > 0)
                            {
                                WebSiteAliasPanel.Visible = true;
                            }
                        }

                        MailDomainAliasPanel.Visible = (instantAlias.MailDomainId > 0);
                    }

                    // Preview Domain
                    PreviewDomainName.Text = domain.PreviewDomainName;

                    // web site alias
                    WebSiteAlias.Text = WebSiteAlias.NavigateUrl = "http://" + domain.PreviewDomainName;

                    // mail domain alias
                    MailDomainAlias.Text = "@" + domain.PreviewDomainName;
                }

                // resellers
                AllowSubDomains.Checked = domain.HostingAllowed;
                if (PanelSecurity.EffectiveUser.Role != UserRole.User &&
                    !(domain.IsDomainPointer || domain.IsSubDomain || domain.IsPreviewDomain))
                {
                    ResellersPanel.Visible = true;
                }

                if (!(domain.IsDomainPointer || domain.IsSubDomain || domain.IsPreviewDomain))
                {
                    UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);

                    if (user != null)
                    {
                        if (user.Role == UserRole.User)
                        {
                            btnDelete.Enabled = !Utils.CheckQouta(Quotas.OS_NOTALLOWTENANTCREATEDOMAINS, cntx);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("DOMAIN_GET_DOMAIN", ex);
                return;
            }
        }
 public RemoveDto(PackageContext context, params InstalledPackage[] packages) : this(context, (IEnumerable <InstalledPackage>)packages)
 {
 }
Exemple #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM2013))
                {
                    ddlLicenseType.Items.Add(new System.Web.UI.WebControls.ListItem(
                                                 GetSharedLocalizedString("HostedCRM.LicenseProfessional"), CRMUserLycenseTypes.PROFESSIONAL.ToString()));
                    ddlLicenseType.Items.Add(new System.Web.UI.WebControls.ListItem(
                                                 GetSharedLocalizedString("HostedCRM.LicenseBasic"), CRMUserLycenseTypes.BASIC.ToString()));
                    ddlLicenseType.Items.Add(new System.Web.UI.WebControls.ListItem(
                                                 GetSharedLocalizedString("HostedCRM.LicenseEssential"), CRMUserLycenseTypes.ESSENTIAL.ToString()));
                }
                else
                {
                    ddlLicenseType.Items.Add(new System.Web.UI.WebControls.ListItem(
                                                 GetSharedLocalizedString("HostedCRM.LicenseFull"), CRMUserLycenseTypes.FULL.ToString()));
                    ddlLicenseType.Items.Add(new System.Web.UI.WebControls.ListItem(
                                                 GetSharedLocalizedString("HostedCRM.LicenseLimited"), CRMUserLycenseTypes.LIMITED.ToString()));
                    ddlLicenseType.Items.Add(new System.Web.UI.WebControls.ListItem(
                                                 GetSharedLocalizedString("HostedCRM.LicenseESS"), CRMUserLycenseTypes.ESS.ToString()));
                }


                try
                {
                    OrganizationUser user =
                        ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID);

                    CrmUserResult userResult = ES.Services.CRM.GetCrmUser(PanelRequest.ItemID, PanelRequest.AccountID);

                    if (userResult.IsSuccess)
                    {
                        btnActive.Visible  = userResult.Value.IsDisabled;
                        locEnabled.Visible = !userResult.Value.IsDisabled;

                        btnDeactivate.Visible = !userResult.Value.IsDisabled;
                        locDisabled.Visible   = userResult.Value.IsDisabled;
                        lblDisplayName.Text   = user.DisplayName;
                        lblEmailAddress.Text  = user.PrimaryEmailAddress;
                        lblDomainName.Text    = user.DomainUserName;

                        int cALType = userResult.Value.CALType + ((int)userResult.Value.ClientAccessMode) * 10;

                        Utils.SelectListItem(ddlLicenseType, cALType);
                    }
                    else
                    {
                        messageBox.ShowMessage(userResult, "GET_CRM_USER", "HostedCRM");
                        return;
                    }

                    CrmRolesResult res =
                        ES.Services.CRM.GetCrmRoles(PanelRequest.ItemID, PanelRequest.AccountID, PanelSecurity.PackageId);

                    if (res.IsSuccess)
                    {
                        gvRoles.DataSource = res.Value;
                        gvRoles.DataBind();
                    }
                    else
                    {
                        messageBox.ShowMessage(res, "GET_CRM_USER_ROLES", "HostedCRM");
                    }
                }
                catch (Exception ex)
                {
                    messageBox.ShowErrorMessage("GET_CRM_USER_ROLES", ex);
                }
            }
        }
Exemple #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (!IsPostBack)
            {
                string[] archivePolicy = ES.Services.Lync.GetPolicyList(PanelRequest.ItemID, LyncPolicyType.Archiving, null);
                if (archivePolicy != null)
                {
                    foreach (string policy in archivePolicy)
                    {
                        if (policy.ToLower() == "global")
                        {
                            continue;
                        }
                        string txt = policy.Replace("Tag:", "");
                        ddArchivingPolicy.Items.Add(new System.Web.UI.WebControls.ListItem(txt, policy));
                    }
                }

                if (PanelRequest.GetInt("LyncUserPlanId") != 0)
                {
                    Providers.HostedSolution.LyncUserPlan plan = ES.Services.Lync.GetLyncUserPlan(PanelRequest.ItemID, PanelRequest.GetInt("LyncUserPlanId"));

                    txtPlan.Text               = plan.LyncUserPlanName;
                    chkIM.Checked              = plan.IM;
                    chkIM.Enabled              = false;
                    chkFederation.Checked      = plan.Federation;
                    chkConferencing.Checked    = plan.Conferencing;
                    chkMobility.Checked        = plan.Mobility;
                    chkEnterpriseVoice.Checked = plan.EnterpriseVoice;

                    /* because not used
                     * switch (plan.VoicePolicy)
                     * {
                     *  case LyncVoicePolicyType.None:
                     *      break;
                     *  case LyncVoicePolicyType.Emergency:
                     *      chkEmergency.Checked = true;
                     *      break;
                     *  case LyncVoicePolicyType.National:
                     *      chkNational.Checked = true;
                     *      break;
                     *  case LyncVoicePolicyType.Mobile:
                     *      chkMobile.Checked = true;
                     *      break;
                     *  case LyncVoicePolicyType.International:
                     *      chkInternational.Checked = true;
                     *      break;
                     *  default:
                     *      chkNone.Checked = true;
                     *      break;
                     * }
                     */

                    chkRemoteUserAccess.Checked = plan.RemoteUserAccess;
                    chkAllowOrganizeMeetingsWithExternalAnonymous.Checked = plan.AllowOrganizeMeetingsWithExternalAnonymous;

                    Utils.SelectListItem(ddTelephony, plan.Telephony);

                    tbServerURI.Text = plan.ServerURI;

                    string planArchivePolicy = "";              if (plan.ArchivePolicy != null)
                    {
                        planArchivePolicy = plan.ArchivePolicy;
                    }
                    string planTelephonyDialPlanPolicy = "";    if (plan.TelephonyDialPlanPolicy != null)
                    {
                        planTelephonyDialPlanPolicy = plan.TelephonyDialPlanPolicy;
                    }
                    string planTelephonyVoicePolicy = "";       if (plan.TelephonyVoicePolicy != null)
                    {
                        planTelephonyVoicePolicy = plan.TelephonyVoicePolicy;
                    }

                    ddArchivingPolicy.Items.Clear();
                    ddArchivingPolicy.Items.Add(new System.Web.UI.WebControls.ListItem(planArchivePolicy.Replace("Tag:", ""), planArchivePolicy));
                    ddTelephonyDialPlanPolicy.Items.Clear();
                    ddTelephonyDialPlanPolicy.Items.Add(new System.Web.UI.WebControls.ListItem(planTelephonyDialPlanPolicy.Replace("Tag:", ""), planTelephonyDialPlanPolicy));
                    ddTelephonyVoicePolicy.Items.Clear();
                    ddTelephonyVoicePolicy.Items.Add(new System.Web.UI.WebControls.ListItem(planTelephonyVoicePolicy.Replace("Tag:", ""), planTelephonyVoicePolicy));

                    locTitle.Text        = plan.LyncUserPlanName;
                    this.DisableControls = true;
                }
                else
                {
                    chkIM.Checked = true;
                    chkIM.Enabled = false;

                    // chkNone.Checked = true; because not used

                    if (cntx != null)
                    {
                        foreach (QuotaValueInfo quota in cntx.QuotasArray)
                        {
                            switch (quota.QuotaId)
                            {
                            case 371:
                                chkFederation.Checked = Convert.ToBoolean(quota.QuotaAllocatedValue);
                                chkFederation.Enabled = Convert.ToBoolean(quota.QuotaAllocatedValue);
                                break;

                            case 372:
                                chkConferencing.Checked = Convert.ToBoolean(quota.QuotaAllocatedValue);
                                chkConferencing.Enabled = Convert.ToBoolean(quota.QuotaAllocatedValue);
                                break;
                            }
                        }
                    }
                    else
                    {
                        this.DisableControls = true;
                    }
                }
            }

            bool enterpriseVoiceQuota = Utils.CheckQouta(Quotas.LYNC_ENTERPRISEVOICE, cntx);

            PlanFeaturesTelephony.Visible    = enterpriseVoiceQuota;
            secPlanFeaturesTelephony.Visible = enterpriseVoiceQuota;
            if (!enterpriseVoiceQuota)
            {
                Utils.SelectListItem(ddTelephony, "0");
            }

            bool enterpriseVoice = enterpriseVoiceQuota && (ddTelephony.SelectedValue == "2");

            chkEnterpriseVoice.Enabled = false;
            chkEnterpriseVoice.Checked = enterpriseVoice;
            pnEnterpriseVoice.Visible  = enterpriseVoice;

            switch (ddTelephony.SelectedValue)
            {
            case "3":
            case "4":
                pnServerURI.Visible = true;
                break;

            default:
                pnServerURI.Visible = false;
                break;
            }
        }
Exemple #27
0
 public GetModificationPackagesDto(string fullPackageName, PackageContext context = PackageContext.CurrentUser)
 {
     this.FullPackageName = fullPackageName;
     this.Context         = context;
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            try
            {
                // check rights
                bool manageAllowed = VirtualMachines2012Helper.IsVirtualMachineManagementAllowed(PanelSecurity.PackageId);
                if (!manageAllowed)
                {
                    return;
                }

                // check snapshots
                VirtualMachineSnapshot[] snapshots = ES.Services.VPS2012.GetVirtualMachineSnapshots(PanelRequest.ItemID);
                if (snapshots.Length > 0)
                {
                    return;
                }

                VirtualMachine virtualMachine = new VirtualMachine();
                VirtualMachine vm             = ES.Services.VPS2012.GetVirtualMachineItem(PanelRequest.ItemID);

                if (!chkIgnoreHddWarning.Checked || PanelSecurity.EffectiveUser.Role == UserRole.User)
                {
                    if (Utils.ParseInt(hiddenTxtValHdd.Value) > Utils.ParseInt(txtHdd.Text.Trim()))
                    {
                        messageBox.ShowWarningMessage("VPS_CHANGE_HDD_SIZE");
                        return;
                    }
                    List <AdditionalHdd> hdds = GetAdditionalHdd();
                    foreach (AdditionalHdd hdd in hdds)
                    {
                        for (int i = 0; i < vm.VirtualHardDrivePath.Length; i++)
                        {
                            if (String.IsNullOrEmpty(vm.VirtualHardDrivePath[i]))
                            {
                                continue;
                            }
                            if (Path.GetFileName(vm.VirtualHardDrivePath[i]).ToLower().Equals(Path.GetFileName(hdd.DiskPath).ToLower()) && Utils.ParseInt(hdd.DiskSize.Trim()) < vm.HddSize[i])
                            {
                                messageBox.ShowWarningMessage("VPS_CHANGE_HDD_SIZE");
                                return;
                            }
                        }
                    }
                }

                // the custom provider control
                this.SaveSettingsControls(ref virtualMachine);
                virtualMachine.CpuCores = Utils.ParseInt(ddlCpu.SelectedValue);
                virtualMachine.RamSize  = Utils.ParseInt(txtRam.Text.Trim());
                List <int>    hddSize = new List <int>();
                List <String> hddPath = new List <String>();
                hddSize.Add(Utils.ParseInt(txtHdd.Text.Trim()));
                hddPath.Add(vm.VirtualHardDrivePath[0]);
                List <AdditionalHdd> additionalHdd = GetAdditionalHdd();
                foreach (AdditionalHdd hdd in additionalHdd)
                {
                    int size = Utils.ParseInt(hdd.DiskSize.Trim());
                    if (size > 0)
                    {
                        hddSize.Add(size);
                        hddPath.Add(hdd.DiskPath);
                    }
                }
                virtualMachine.HddSize = hddSize.ToArray();
                virtualMachine.VirtualHardDrivePath   = hddPath.ToArray();
                virtualMachine.SnapshotsNumber        = Utils.ParseInt(txtSnapshots.Text.Trim());
                virtualMachine.HddMinimumIOPS         = Utils.ParseInt(txtHddMinIOPS.Text.Trim());
                virtualMachine.HddMaximumIOPS         = Utils.ParseInt(txtHddMaxIOPS.Text.Trim());
                virtualMachine.DvdDriveInstalled      = chkDvdInstalled.Checked;
                virtualMachine.BootFromCD             = chkBootFromCd.Checked;
                virtualMachine.NumLockEnabled         = chkNumLock.Checked;
                virtualMachine.EnableSecureBoot       = chkSecureBoot.Checked;
                virtualMachine.StartTurnOffAllowed    = chkStartShutdown.Checked;
                virtualMachine.PauseResumeAllowed     = chkPauseResume.Checked;
                virtualMachine.RebootAllowed          = chkReboot.Checked;
                virtualMachine.ResetAllowed           = chkReset.Checked;
                virtualMachine.ReinstallAllowed       = chkReinstall.Checked;
                virtualMachine.ExternalNetworkEnabled = chkExternalNetworkEnabled.Checked;
                virtualMachine.PrivateNetworkEnabled  = chkPrivateNetworkEnabled.Checked;
                virtualMachine.NeedReboot             = chkForceReboot.Checked;

                bool setupExternalNetwork = !vm.ExternalNetworkEnabled && chkExternalNetworkEnabled.Checked;
                bool setupPrivateNetwork  = !vm.PrivateNetworkEnabled && chkPrivateNetworkEnabled.Checked;

                if (setupExternalNetwork)
                {
                    PackageIPAddress[] ips = ES.Services.Servers.GetPackageUnassignedIPAddresses(PanelSecurity.PackageId, 0, IPAddressPool.VpsExternalNetwork);
                    if (ips.Length > 0)
                    {
                        virtualMachine.defaultaccessvlan = ips[0].VLAN;
                        int[] ipId = new int[1];
                        ipId[0] = ips[0].PackageAddressID;
                        ES.Services.VPS2012.AddVirtualMachineExternalIPAddresses(PanelRequest.ItemID, false, 1, ipId);
                    }
                }

                if (setupPrivateNetwork)
                {
                    PackageVLANsPaged vlans = ES.Services.Servers.GetPackagePrivateNetworkVLANs(PanelSecurity.PackageId, "", 0, Int32.MaxValue);
                    if (vlans.Count > 0)
                    {
                        virtualMachine.PrivateNetworkVlan = vlans.Items[0].Vlan;
                    }

                    PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                    if (cntx.Quotas.ContainsKey(Quotas.VPS2012_PRIVATE_IP_ADDRESSES_NUMBER))
                    {
                        QuotaValueInfo privQuota    = cntx.Quotas[Quotas.VPS2012_PRIVATE_IP_ADDRESSES_NUMBER];
                        int            privAdrCount = 0;
                        if (privQuota.QuotaAllocatedValue > 0 || privQuota.QuotaAllocatedValue == -1)
                        {
                            privAdrCount = 1;
                        }
                        if (privAdrCount > 0)
                        {
                            ES.Services.VPS2012.AddVirtualMachinePrivateIPAddresses(PanelRequest.ItemID, true, privAdrCount, new string[0], false, null, null, null, null);
                        }
                    }
                }

                ResultObject res = ES.Services.VPS2012.UpdateVirtualMachineResource(PanelRequest.ItemID, virtualMachine);
                //ResultObject res = ES.Services.VPS2012.UpdateVirtualMachineConfiguration(PanelRequest.ItemID,
                //    Utils.ParseInt(ddlCpu.SelectedValue),
                //    Utils.ParseInt(txtRam.Text.Trim()),
                //    Utils.ParseInt(txtHdd.Text.Trim()),
                //    Utils.ParseInt(txtSnapshots.Text.Trim()),
                //    chkDvdInstalled.Checked,
                //    chkBootFromCd.Checked,
                //    chkNumLock.Checked,
                //    chkStartShutdown.Checked,
                //    chkPauseResume.Checked,
                //    chkReboot.Checked,
                //    chkReset.Checked,
                //    chkReinstall.Checked,
                //    chkExternalNetworkEnabled.Checked,
                //    chkPrivateNetworkEnabled.Checked,
                //    virtualMachine);

                if (res.IsSuccess)
                {
                    // redirect back
                    RedirectBack("changed");
                }
                else
                {
                    // show error
                    messageBox.ShowMessage(res, "VPS_CHANGE_VM_CONFIGURATION", "VPS");
                }
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("VPS_CHANGE_VM_CONFIGURATION", ex);
            }
        }
        private void BindFormControls()
        {
            var virtualMachine = new VirtualMachine
            {
                DynamicMemory = new DynamicMemory
                {
                    Buffer   = 20,
                    Priority = 50
                }
            };

            // bind password policy
            password.SetPackagePolicy(PanelSecurity.PackageId, UserSettings.VPS_POLICY, "AdministratorPasswordPolicy");

            // OS templates
            listOperatingSystems.DataSource = ES.Services.VPS2012.GetOperatingSystemTemplates(PanelSecurity.PackageId);
            listOperatingSystems.DataBind();
            listOperatingSystems.Items.Insert(0, new ListItem(GetLocalizedString("SelectOsTemplate.Text"), ""));

            // summary letter e-mail
            PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId);

            if (package != null)
            {
                UserInfo user = ES.Services.Users.GetUserById(package.UserId);
                if (user != null)
                {
                    chkSendSummary.Checked = true;
                    txtSummaryEmail.Text   = user.Email;
                }
            }

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            // bind CPU cores
            int maxCores = ES.Services.VPS2012.GetMaximumCpuCoresNumber(PanelSecurity.PackageId);

            if (cntx.Quotas.ContainsKey(Quotas.VPS2012_CPU_NUMBER))
            {
                QuotaValueInfo cpuQuota = cntx.Quotas[Quotas.VPS2012_CPU_NUMBER];

                if (cpuQuota.QuotaAllocatedValue != -1 &&
                    maxCores > cpuQuota.QuotaAllocatedValue)
                {
                    maxCores = cpuQuota.QuotaAllocatedValue;
                }
            }

            for (int i = 1; i < maxCores + 1; i++)
            {
                ddlCpu.Items.Add(i.ToString());
            }

            ddlCpu.SelectedIndex = ddlCpu.Items.Count - 1; // select last (maximum) item

            // external network details
            if (PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPS2012_EXTERNAL_NETWORK_ENABLED))
            {
                // bind list
                PackageIPAddress[] ips = ES.Services.Servers.GetPackageUnassignedIPAddresses(PanelSecurity.PackageId, 0, IPAddressPool.VpsExternalNetwork);
                foreach (PackageIPAddress ip in ips)
                {
                    string txt = ip.ExternalIP;
                    if (!String.IsNullOrEmpty(ip.DefaultGateway))
                    {
                        txt += "/" + ip.DefaultGateway;
                    }
                    listExternalAddresses.Items.Add(new ListItem(txt, ip.PackageAddressID.ToString()));
                }

                // toggle controls
                int maxAddresses = listExternalAddresses.Items.Count;
                litMaxExternalAddresses.Text = String.Format(GetLocalizedString("litMaxExternalAddresses.Text"), maxAddresses);
                if (maxAddresses > 0)
                {
                    txtExternalAddressesNumber.Text = "1";
                }
            }

            // private network
            if (PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPS2012_PRIVATE_NETWORK_ENABLED))
            {
                NetworkAdapterDetails nic = ES.Services.VPS2012.GetPrivateNetworkDetails(PanelSecurity.PackageId);
                litPrivateNetworkFormat.Text = nic.NetworkFormat;
                litPrivateSubnetMask.Text    = nic.SubnetMask;

                // set max number
                QuotaValueInfo privQuota  = cntx.Quotas[Quotas.VPS2012_PRIVATE_IP_ADDRESSES_NUMBER];
                int            maxPrivate = privQuota.QuotaAllocatedValue;
                if (maxPrivate == -1)
                {
                    maxPrivate = 10;
                }

                // handle DHCP mode
                if (nic.IsDHCP)
                {
                    maxPrivate        = 0;
                    ViewState["DHCP"] = true;
                }

                txtPrivateAddressesNumber.Text = "1";
                litMaxPrivateAddresses.Text    = String.Format(GetLocalizedString("litMaxPrivateAddresses.Text"), maxPrivate);
            }

            // RAM size
            if (cntx.Quotas.ContainsKey(Quotas.VPS2012_RAM))
            {
                QuotaValueInfo ramQuota = cntx.Quotas[Quotas.VPS2012_RAM];
                if (ramQuota.QuotaAllocatedValue == -1)
                {
                    // unlimited RAM
                    txtRam.Text = "";
                }
                else
                {
                    int availSize = ramQuota.QuotaAllocatedValue - ramQuota.QuotaUsedValue;
                    txtRam.Text = availSize < 0 ? "" : availSize.ToString();

                    if (availSize > 0)
                    {
                        virtualMachine.DynamicMemory.Minimum = availSize / 2;
                        virtualMachine.DynamicMemory.Maximum = availSize;
                    }
                }
            }

            // HDD size
            if (cntx.Quotas.ContainsKey(Quotas.VPS2012_HDD))
            {
                QuotaValueInfo hddQuota = cntx.Quotas[Quotas.VPS2012_HDD];
                if (hddQuota.QuotaAllocatedValue == -1)
                {
                    // unlimited HDD
                    txtHdd.Text = "";
                }
                else
                {
                    int availSize = hddQuota.QuotaAllocatedValue - hddQuota.QuotaUsedValue;
                    txtHdd.Text = availSize < 0 ? "" : availSize.ToString();
                }
            }

            // snapshots number
            if (cntx.Quotas.ContainsKey(Quotas.VPS2012_SNAPSHOTS_NUMBER))
            {
                int snapsNumber = cntx.Quotas[Quotas.VPS2012_SNAPSHOTS_NUMBER].QuotaAllocatedValue;
                txtSnapshots.Text    = (snapsNumber != -1) ? snapsNumber.ToString() : "";
                txtSnapshots.Enabled = (snapsNumber != 0);
            }

            // toggle controls
            BindCheckboxOption(chkDvdInstalled, Quotas.VPS2012_DVD_ENABLED);
            chkBootFromCd.Enabled = PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPS2012_BOOT_CD_ALLOWED);

            BindCheckboxOption(chkStartShutdown, Quotas.VPS2012_START_SHUTDOWN_ALLOWED);
            BindCheckboxOption(chkPauseResume, Quotas.VPS2012_PAUSE_RESUME_ALLOWED);
            BindCheckboxOption(chkReset, Quotas.VPS2012_RESET_ALOWED);
            BindCheckboxOption(chkReboot, Quotas.VPS2012_REBOOT_ALLOWED);
            BindCheckboxOption(chkReinstall, Quotas.VPS2012_REINSTALL_ALLOWED);

            // the settings user controls
            this.BindSettingsControls(virtualMachine);
        }
        private void BindTabs()
        {
            // load item
            VirtualMachine vm = VirtualMachinesHelper.GetCachedVirtualMachine(PanelRequest.ItemID);

            if (!String.IsNullOrEmpty(vm.CurrentTaskId))
            {
                // show panel
                TaskTable.Visible = true;

                // bind task details
                BindTask(vm);

                return;
            }

            if (TaskTable.Visible)
            {
                Response.Redirect(Request.Url.ToString()); // refresh screen
            }
            // show tabs
            TabsTable.Visible = true;

            // disable timer
            refreshTimer.Enabled = false;

            // check if VPS created with error
            bool createError = (vm.ProvisioningStatus == VirtualMachineProvisioningStatus.Error);

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            // build tabs list
            List <Tab> tabsList = new List <Tab>();

            tabsList.Add(CreateTab("vps_general", "Tab.General"));

            if (!createError)
            {
                tabsList.Add(CreateTab("vps_config", "Tab.Configuration"));
            }

            if (vm.DvdDriveInstalled && !createError)
            {
                tabsList.Add(CreateTab("vps_dvd", "Tab.DVD"));
            }

            if (vm.SnapshotsNumber > 0 && !createError)
            {
                tabsList.Add(CreateTab("vps_snapshots", "Tab.Snapshots"));
            }

            if ((vm.ExternalNetworkEnabled || vm.PrivateNetworkEnabled) && !createError)
            {
                tabsList.Add(CreateTab("vps_network", "Tab.Network"));
            }

            //tabsList.Add(CreateTab("vps_permissions", "Tab.Permissions"));
            //tabsList.Add(CreateTab("vps_tools", "Tab.Tools"));
            tabsList.Add(CreateTab("vps_audit_log", "Tab.AuditLog"));

            if (!createError)
            {
                tabsList.Add(CreateTab("vps_help", "Tab.Help"));
            }


            // find selected menu item
            int idx = 0;

            foreach (Tab tab in tabsList)
            {
                if (String.Compare(tab.Id, SelectedTab, true) == 0)
                {
                    break;
                }
                idx++;
            }
            dlTabs.SelectedIndex = idx;

            dlTabs.DataSource = tabsList;
            dlTabs.DataBind();

            // show provision error message
            if (createError && idx == 0)
            {
                messageBox.ShowErrorMessage("VPS_PROVISION_ERROR");
            }
        }
Exemple #31
0
        private void OnSelectClick(object sender, EventArgs e)
        {
            DataNode node = spaceTree.SelectedNode as DataNode;

            if (node == null || node.NodeType != SPACE)
            {
                ShowWarning("Please select hosting space.");
                return;
            }
            PackageInfo data = node.Tag as PackageInfo;

            if (data == null || data.PackageId == 0 || data.PackageId == 1)
            {
                ShowWarning("Invalid hosting space. Please select hosting space with allowed Exchange organizations.");
                return;
            }

            PackageContext cntx = null;

            try
            {
                cntx = PackageController.GetPackageContext(data.PackageId);
            }
            catch (Exception ex)
            {
                ShowError("Unable to load space data", ex);
                return;
            }

            if (cntx == null)
            {
                ShowWarning("Invalid hosting space. Please select hosting space with allowed Exchange organizations.");
                return;
            }

            bool exchangeEnabled = false;
            bool orgEnabled      = false;

            foreach (HostingPlanGroupInfo group in cntx.GroupsArray)
            {
                if (!group.Enabled)
                {
                    continue;
                }
                if (group.GroupName == ResourceGroups.Exchange)
                {
                    exchangeEnabled = true;
                    continue;
                }
                else if (group.GroupName == ResourceGroups.HostedOrganizations)
                {
                    orgEnabled = true;
                    continue;
                }
            }
            if (!exchangeEnabled || !orgEnabled)
            {
                ShowWarning("Invalid hosting space. Please select hosting space with allowed Exchange organizations.");
                return;
            }
            this.selectedSpace = data;
            this.DialogResult  = DialogResult.OK;
            this.Close();
        }
Exemple #32
0
        private void PrepareExchangeMenu(PackageContext cntx, List <MenuGroup> groups, string imagePath)
        {
            bool hideItems = false;

            UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);

            if (user != null)
            {
                if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
                {
                    hideItems = true;
                }
            }

            MenuGroup exchangeGroup = new MenuGroup(GetLocalizedString("Text.ExchangeGroup"), imagePath + "exchange24.png");

            if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
            {
                exchangeGroup.MenuItems.Add(CreateMenuItem("Mailboxes", "mailboxes"));
            }

            if (Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWRETENTIONPOLICY, cntx))
            {
                exchangeGroup.MenuItems.Add(CreateMenuItem("ArchivingMailboxes", "archivingmailboxes"));
            }

            if (Utils.CheckQouta(Quotas.EXCHANGE2007_CONTACTS, cntx))
            {
                exchangeGroup.MenuItems.Add(CreateMenuItem("Contacts", "contacts"));
            }

            if (Utils.CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, cntx))
            {
                exchangeGroup.MenuItems.Add(CreateMenuItem("DistributionLists", "dlists"));
            }

            if (Utils.CheckQouta(Quotas.EXCHANGE2007_PUBLICFOLDERS, cntx))
            {
                exchangeGroup.MenuItems.Add(CreateMenuItem("PublicFolders", "public_folders"));
            }

            if (Utils.CheckQouta(Quotas.EXCHANGE2013_JOURNALINGMAILBOXES, cntx))
            {
                exchangeGroup.MenuItems.Add(CreateMenuItem("JournalingMailboxes", "journaling_mailboxes"));
            }

            if (!hideItems)
            {
                if (Utils.CheckQouta(Quotas.EXCHANGE2007_ACTIVESYNCALLOWED, cntx))
                {
                    exchangeGroup.MenuItems.Add(CreateMenuItem("ActiveSyncPolicy", "activesync_policy"));
                }
            }

            if (!hideItems)
            {
                if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
                {
                    exchangeGroup.MenuItems.Add(CreateMenuItem("MailboxPlans", "mailboxplans"));
                }
            }

            if (!hideItems)
            {
                if (Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWRETENTIONPOLICY, cntx))
                {
                    exchangeGroup.MenuItems.Add(CreateMenuItem("RetentionPolicy", "retentionpolicy"));
                }
            }

            if (!hideItems)
            {
                if (Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWRETENTIONPOLICY, cntx))
                {
                    exchangeGroup.MenuItems.Add(CreateMenuItem("RetentionPolicyTag", "retentionpolicytag"));
                }
            }

            if (!hideItems)
            {
                if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
                {
                    exchangeGroup.MenuItems.Add(CreateMenuItem("ExchangeDomainNames", "domains"));
                }
            }

            if (!hideItems)
            {
                if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
                {
                    exchangeGroup.MenuItems.Add(CreateMenuItem("StorageUsage", "storage_usage"));
                }
            }

            if (!hideItems)
            {
                if (Utils.CheckQouta(Quotas.EXCHANGE2007_DISCLAIMERSALLOWED, cntx))
                {
                    exchangeGroup.MenuItems.Add(CreateMenuItem("Disclaimers", "disclaimers"));
                }
            }

            if (exchangeGroup.MenuItems.Count > 0)
            {
                groups.Add(exchangeGroup);
            }
        }
        private void BindDatabaseEngines(List <DeploymentParameter> parameters)
        {
            // SQL Server
            if (FindParameterByTag(parameters, DeploymentParameterWellKnownTag.Sql) != null)
            {
                // load package context
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                // add SQL Server engines
                if (cntx.Groups.ContainsKey(ResourceGroups.MsSql2008))
                {
                    AddDatabaseEngine(DeploymentParameterWellKnownTag.Sql, ResourceGroups.MsSql2008, GetSharedLocalizedString("ResourceGroup." + ResourceGroups.MsSql2008));
                }
                if (cntx.Groups.ContainsKey(ResourceGroups.MsSql2005))
                {
                    AddDatabaseEngine(DeploymentParameterWellKnownTag.Sql, ResourceGroups.MsSql2005, GetSharedLocalizedString("ResourceGroup." + ResourceGroups.MsSql2005));
                }
                if (cntx.Groups.ContainsKey(ResourceGroups.MsSql2000))
                {
                    AddDatabaseEngine(DeploymentParameterWellKnownTag.Sql, ResourceGroups.MsSql2000, GetSharedLocalizedString("ResourceGroup." + ResourceGroups.MsSql2000));
                }
            }

            // MySQL Server
            if (FindParameterByTag(parameters, DeploymentParameterWellKnownTag.MySql) != null)
            {
                // load package context
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                // add SQL Server engines
                if (cntx.Groups.ContainsKey(ResourceGroups.MySql5))
                {
                    AddDatabaseEngine(DeploymentParameterWellKnownTag.MySql, ResourceGroups.MySql5, GetSharedLocalizedString("ResourceGroup." + ResourceGroups.MySql5));
                }
                if (cntx.Groups.ContainsKey(ResourceGroups.MySql4))
                {
                    AddDatabaseEngine(DeploymentParameterWellKnownTag.MySql, ResourceGroups.MySql4, GetSharedLocalizedString("ResourceGroup." + ResourceGroups.MySql4));
                }
            }

            // SQLite
            if (FindParameterByTag(parameters, DeploymentParameterWellKnownTag.SqLite) != null)
            {
                AddDatabaseEngine(DeploymentParameterWellKnownTag.SqLite, "", GetLocalizedString("DatabaseEngine.SQLite"));
            }

            // VistaFB
            if (FindParameterByTag(parameters, DeploymentParameterWellKnownTag.VistaDB) != null)
            {
                AddDatabaseEngine(DeploymentParameterWellKnownTag.VistaDB, "", GetLocalizedString("DatabaseEngine.VistaDB"));
            }

            // Flat File
            if (FindParameterByTag(parameters, DeploymentParameterWellKnownTag.FlatFile) != null)
            {
                AddDatabaseEngine(DeploymentParameterWellKnownTag.FlatFile, "", GetLocalizedString("DatabaseEngine.FlatFile"));
            }

            // hide module if no database required
            divDatabase.Visible = (databaseEngines.Items.Count > 0);

            // bind parameters
            BindParameters(parameters);
        }
        private void BindSettings()
        {
            try
            {
                // get settings
                OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID,
                                                                                         PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(user.DisplayName);

                lblUserDomainName.Text = user.DomainUserName;

                // bind form
                lblDisplayName.Text = user.DisplayName;

                chkDisable.Checked = user.Disabled;

                lblFirstName.Text = user.FirstName;
                lblInitials.Text  = user.Initials;
                lblLastName.Text  = user.LastName;



                lblJobTitle.Text   = user.JobTitle;
                lblCompany.Text    = user.Company;
                lblDepartment.Text = user.Department;
                lblOffice.Text     = user.Office;

                if (user.Manager != null)
                {
                    lblManager.Text = user.Manager.DisplayName;
                }

                lblBusinessPhone.Text = user.BusinessPhone;
                lblFax.Text           = user.Fax;
                lblHomePhone.Text     = user.HomePhone;
                lblMobilePhone.Text   = user.MobilePhone;
                lblPager.Text         = user.Pager;
                lblWebPage.Text       = user.WebPage;

                lblAddress.Text = user.Address;
                lblCity.Text    = user.City;
                lblState.Text   = user.State;
                lblZip.Text     = user.Zip;
                lblCountry.Text = user.Country;

                lblNotes.Text = user.Notes;
                lblExternalEmailAddress.Text = user.ExternalEmail;

                lblExternalEmailAddress.Enabled = user.AccountType == ExchangeAccountType.User;
                lblUserDomainName.Text          = user.DomainUserName;

                lblSubscriberNumber.Text  = user.SubscriberNumber;
                lblUserPrincipalName.Text = user.UserPrincipalName;

                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER))
                {
                    if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1)
                    {
                        locSubscriberNumber.Visible = false;
                        lblSubscriberNumber.Visible = false;
                    }
                }

                if (user.LevelId > 0 && secServiceLevels.Visible)
                {
                    secServiceLevels.IsCollapsed = false;

                    ServiceLevel serviceLevel = ES.Services.Organizations.GetSupportServiceLevel(user.LevelId);

                    litServiceLevel.Visible = true;
                    litServiceLevel.Text    = serviceLevel.LevelName;
                    litServiceLevel.ToolTip = serviceLevel.LevelDescription;

                    lblServiceLevel.Text = serviceLevel.LevelName;
                }

                chkVIP.Checked     = user.IsVIP && secServiceLevels.Visible;
                imgVipUser.Visible = user.IsVIP && secServiceLevels.Visible;

                if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATION_ALLOWCHANGEUPN))
                {
                    if (cntx.Quotas[Quotas.ORGANIZATION_ALLOWCHANGEUPN].QuotaAllocatedValue != 1)
                    {
                        chkInherit.Visible = false;
                    }
                    else
                    {
                        chkInherit.Visible = true;
                    }
                }

                if (user.Locked)
                {
                    chkLocked.Enabled = true;
                }
                else
                {
                    chkLocked.Enabled = false;
                }

                chkLocked.Checked = user.Locked;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("ORGANIZATION_GET_USER_SETTINGS", ex);
            }
        }
 public static void CheckNumericQuota(PackageContext cntx, List<string> errors, string quotaName, int currentVal, int val, string messageKey)
 {
     CheckQuotaValue(cntx, errors, quotaName, Convert.ToInt64(currentVal), Convert.ToInt64(val), messageKey);
 }