protected void Page_Load(object sender, EventArgs e)
        {
            ClientScriptManager cs = Page.ClientScript;
            cs.RegisterClientScriptInclude("jquery", ResolveUrl("~/JavaScript/jquery-1.4.4.min.js"));

            locTitle.Text = ArchivingBoxes ? GetLocalizedString("locTitleArchiving.Text") : GetLocalizedString("locTitle.Text");

            btnCreateMailbox.Visible = !ArchivingBoxes;

            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (!IsPostBack)
            {
                chkMailboxes.Checked = true;
                chkResourceMailboxes.Checked = true;
                chkSharedMailboxes.Checked = true;

                BindStats();
            }

            BindServiceLevels();

            if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER))
            {
                if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1)
                {
                    gvMailboxes.Columns[6].Visible = false;
                }
            }

            gvMailboxes.Columns[4].Visible = cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // load package context
            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            // bind root node
            BindMenu(menu.Items, PortalUtils.GetModuleMenuItems(this));
        }
        private void BindQuotas()
        {
            // load package context
            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
            
            int packageId = ES.Services.Packages.GetPackage(PanelSecurity.PackageId).PackageId;
            lnkViewBandwidthDetails.NavigateUrl = GetNavigateBandwidthDetails(packageId);
			lnkViewDiskspaceDetails.NavigateUrl = GetNavigateDiskspaceDetails(packageId);
        }
        private void BindQuota(PackageContext cntx)
        {
            OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
            rdsServersQuota.QuotaUsedValue = stats.CreatedRdsServers;
            rdsServersQuota.QuotaValue = stats.AllocatedRdsServers;

            if (stats.AllocatedUsers != -1)
            {
                rdsServersQuota.QuotaAvailable = stats.AllocatedRdsServers - stats.CreatedRdsServers;
            }
        }
        private void BindQuota(PackageContext cntx)
        {            
            OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
            OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID);
            collectionsQuota.QuotaUsedValue = stats.CreatedRdsCollections;
            collectionsQuota.QuotaValue = stats.AllocatedRdsCollections;

            if (stats.AllocatedUsers != -1)
            {
                collectionsQuota.QuotaAvailable = tenantStats.AllocatedRdsCollections - tenantStats.CreatedRdsCollections;
            }            
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // load package context
            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            // bind root node
            MenuItem rootItem = new MenuItem(locMenuTitle.Text);
            rootItem.Selectable = false;

            menu.Items.Add(rootItem);

            BindMenu(rootItem.ChildItems, PortalUtils.GetModuleMenuItems(this));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string downloadFile = Request["DownloadFile"];
            if (downloadFile != null)
            {
                // download file
                Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(downloadFile));
                Response.ContentType = "application/octet-stream";

                int FILE_BUFFER_LENGTH = 5000000;
                byte[] buffer = null;
                int offset = 0;
                do
                {
                    try
                    {
                        // read remote content
                        buffer = ES.Services.Organizations.GetArchiveFileBinaryChunk(PanelSecurity.PackageId, PanelRequest.ItemID, PanelRequest.AccountID, offset, FILE_BUFFER_LENGTH);
                    }
                    catch (Exception ex)
                    {
                        messageBox.ShowErrorMessage("ARCHIVE_FILE_READ_FILE", ex);
                        break;
                    }

                    // write to stream
                    Response.BinaryWrite(buffer);

                    offset += FILE_BUFFER_LENGTH;
                }
                while (buffer.Length == FILE_BUFFER_LENGTH);
                Response.End();
            }

            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (!IsPostBack)
            {    
                BindStats();
            }

            BindServiceLevels();

            gvDeletedUsers.Columns[3].Visible = cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ClientScriptManager cs = Page.ClientScript;
            cs.RegisterClientScriptInclude("jquery", ResolveUrl("~/JavaScript/jquery-1.4.4.min.js"));

            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            BindServiceLevels();

            if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER))
            {
                if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1)
                {
                    gvUsers.Columns[6].Visible = false;
                }
            }
            gvUsers.Columns[4].Visible = cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels);
        }
		private void ToggleWizardSteps()
		{
			//CPU Core
			if (cntx == null)
				cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); //Load package context

			if (ddlCpu.Items.Count == 0 || String.IsNullOrWhiteSpace(ddlCpu.SelectedValue))
			{
				int maxCores = 0;
				if (!String.IsNullOrWhiteSpace(listOperatingSystems.SelectedValue))
				{
					maxCores = ES.Services.VPSPC.GetMaximumCpuCoresNumber(PanelSecurity.PackageId, listOperatingSystems.SelectedItem.Value);
				}

				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
			}

			// external network
			if (!PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPSForPC_EXTERNAL_NETWORK_ENABLED))
			{
				wizard.WizardSteps.Remove(stepExternalNetwork);
				chkExternalNetworkEnabled.Checked = false;
			}

			// private network
			if (!PackagesHelper.IsQuotaEnabled(PanelSecurity.PackageId, Quotas.VPSForPC_PRIVATE_NETWORK_ENABLED))
			{
				wizard.WizardSteps.Remove(stepPrivateNetwork);
				chkPrivateNetworkEnabled.Checked = false;
			}
		}
		protected void wizard_ActiveStepChanged(object sender, EventArgs e)
		{
			if (cntx == null)
				cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

			if ((wizard.ActiveStepIndex == 1)
			 && (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;

					if (availSize <= 0)
					{
						txtHdd.Text = "0";
						txtHdd.Enabled = false;

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

						messageBox.ShowErrorMessage("VPS_ERROR_CREATE", new Exception("The HDD quota has been exhausted."));
						return;
					}
					else
					{
						txtHdd.Text = availSize.ToString();
					}

					txtHdd.Text = "";
				}
			}

			BindSummary();
		}
        private void BindServiceLevelsStats(PackageContext cntx)
        {
            WebsitePanel.EnterpriseServer.Base.HostedSolution.ServiceLevel[] serviceLevels = ES.Services.Organizations.GetSupportServiceLevels();
            OrganizationUser[] accounts = ES.Services.Organizations.SearchAccounts(PanelRequest.ItemID, "", "", "", true);

            foreach (var quota in Array.FindAll<QuotaValueInfo>(
                    cntx.QuotasArray, x => x.QuotaName.Contains(Quotas.SERVICE_LEVELS)))
            {
                HtmlTableRow tr = new HtmlTableRow();
                    tr.Attributes["class"] = "OrgStatsRow";
                HtmlTableCell col1 = new HtmlTableCell();
                    col1.Attributes["class"] = "OrgStatsQuota";
                    col1.Attributes["nowrap"] = "nowrap";
                HyperLink link = new HyperLink();
                link.ID = "lnk_" + quota.QuotaName.Replace(Quotas.SERVICE_LEVELS, "").Replace(" ", string.Empty).Trim();
                    link.Text = quota.QuotaDescription.Replace(", users", " (users):");

                    col1.Controls.Add(link);

                    int levelId = serviceLevels.Where(x => x.LevelName == quota.QuotaName.Replace(Quotas.SERVICE_LEVELS, "")).FirstOrDefault().LevelId;
                    int usedInOrgCount = accounts.Where(x => x.LevelId == levelId).Count();

                HtmlTableCell col2 = new HtmlTableCell();
                QuotaViewer quotaControl = (QuotaViewer)LoadControl("../UserControls/QuotaViewer.ascx");
                    quotaControl.ID = quota.QuotaName.Replace(Quotas.SERVICE_LEVELS, "").Replace(" ", string.Empty).Trim() + "Stats";
                    quotaControl.QuotaTypeId = quota.QuotaTypeId;
                    quotaControl.DisplayGauge = true;
                    quotaControl.QuotaValue = quota.QuotaAllocatedValue;
                    quotaControl.QuotaUsedValue = usedInOrgCount;
                    //quotaControl.QuotaUsedValue = quota.QuotaUsedValue;
                    if (quota.QuotaAllocatedValue != -1) 
                        quotaControl.QuotaAvailable = quota.QuotaAllocatedValue - quota.QuotaUsedValue;

                    col2.Controls.Add(quotaControl);


                tr.Controls.Add(col1);
                tr.Controls.Add(col2);
                serviceLevelsStatsPanel.Controls.Add(tr);
            }
        }
        private void BindExchangeStats(bool hideItems, PackageContext cntx)
        {
            OrganizationStatistics exchangeOrgStats = ES.Services.ExchangeServer.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);

            lnkMailboxes.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "mailboxes",
            "SpaceID=" + PanelSecurity.PackageId.ToString());


            lnkSharedMailboxes.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "mailboxes",
            "SpaceID=" + PanelSecurity.PackageId.ToString());

            lnkResourceMailboxes.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "mailboxes",
            "SpaceID=" + PanelSecurity.PackageId.ToString());


            lnkContacts.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "contacts",
            "SpaceID=" + PanelSecurity.PackageId.ToString());

            lnkLists.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "dlists",
            "SpaceID=" + PanelSecurity.PackageId.ToString());

            lnkExchangeStorage.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "storage_usage",
            "SpaceID=" + PanelSecurity.PackageId.ToString());

            lnkFolders.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "public_folders",
            "SpaceID=" + PanelSecurity.PackageId.ToString());

            lnkExchangeLitigationHold.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "storage_usage",
            "SpaceID=" + PanelSecurity.PackageId.ToString());

            lnkExchangeArchiving.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "archivingmailboxes",
            "SpaceID=" + PanelSecurity.PackageId.ToString());


            mailboxesStats.QuotaUsedValue = exchangeOrgStats.CreatedMailboxes;
            mailboxesStats.QuotaValue = exchangeOrgStats.AllocatedMailboxes;
            if (exchangeOrgStats.AllocatedMailboxes != -1) mailboxesStats.QuotaAvailable = exchangeOrgStats.AllocatedMailboxes - exchangeOrgStats.CreatedMailboxes;

            mailboxesSharedStats.QuotaUsedValue = exchangeOrgStats.CreatedSharedMailboxes;
            mailboxesSharedStats.QuotaValue = exchangeOrgStats.AllocatedSharedMailboxes;
            if (exchangeOrgStats.AllocatedSharedMailboxes != -1) mailboxesSharedStats.QuotaAvailable = exchangeOrgStats.AllocatedSharedMailboxes - exchangeOrgStats.CreatedSharedMailboxes;

            mailboxesResourceStats.QuotaUsedValue = exchangeOrgStats.CreatedResourceMailboxes;
            mailboxesResourceStats.QuotaValue = exchangeOrgStats.AllocatedResourceMailboxes;
            if (exchangeOrgStats.AllocatedResourceMailboxes != -1) mailboxesResourceStats.QuotaAvailable = exchangeOrgStats.AllocatedResourceMailboxes - exchangeOrgStats.CreatedResourceMailboxes;

            if (exchangeOrgStats.AllocatedContacts == 0) this.rowContacts.Style.Add("display", "none");
            else
            {
                contactsStats.QuotaUsedValue = exchangeOrgStats.CreatedContacts;
                contactsStats.QuotaValue = exchangeOrgStats.AllocatedContacts;
                if (exchangeOrgStats.AllocatedContacts != -1) contactsStats.QuotaAvailable = exchangeOrgStats.AllocatedContacts - exchangeOrgStats.CreatedContacts;
            }

            if (exchangeOrgStats.AllocatedDistributionLists == 0) this.rowLists.Style.Add("display", "none");
            else
            {
                listsStats.QuotaUsedValue = exchangeOrgStats.CreatedDistributionLists;
                listsStats.QuotaValue = exchangeOrgStats.AllocatedDistributionLists;
                if (exchangeOrgStats.AllocatedDistributionLists != -1) listsStats.QuotaAvailable = exchangeOrgStats.AllocatedDistributionLists - exchangeOrgStats.CreatedDistributionLists;
            }

            if (!hideItems)
            {
                exchangeStorageStats.QuotaUsedValue = exchangeOrgStats.UsedDiskSpace;
                exchangeStorageStats.QuotaValue = exchangeOrgStats.AllocatedDiskSpace;
                if (exchangeOrgStats.AllocatedDiskSpace != -1)
                {
                    exchangeStorageStats.QuotaAvailable = exchangeOrgStats.AllocatedDiskSpace - exchangeOrgStats.UsedDiskSpace;
                }
            }
            else
                this.rowExchangeStorage.Style.Add("display", "none");

            if (exchangeOrgStats.AllocatedPublicFolders == 0) this.rowFolders.Style.Add("display", "none");
            else
            {
                foldersStats.QuotaUsedValue = exchangeOrgStats.CreatedPublicFolders;
                foldersStats.QuotaValue = exchangeOrgStats.AllocatedPublicFolders;
                if (exchangeOrgStats.AllocatedPublicFolders != -1) foldersStats.QuotaAvailable = exchangeOrgStats.AllocatedPublicFolders - exchangeOrgStats.CreatedPublicFolders;
            }

            if ((!hideItems) && (Utils.CheckQouta(Quotas.EXCHANGE2007_ALLOWLITIGATIONHOLD, cntx)))
            {
                exchangeLitigationHoldStats.QuotaUsedValue = exchangeOrgStats.UsedLitigationHoldSpace;
                exchangeLitigationHoldStats.QuotaValue = exchangeOrgStats.AllocatedLitigationHoldSpace;
                if (exchangeOrgStats.AllocatedLitigationHoldSpace != -1)
                {
                    exchangeLitigationHoldStats.QuotaAvailable = exchangeOrgStats.AllocatedLitigationHoldSpace - exchangeOrgStats.UsedLitigationHoldSpace;
                }
            }
            else
                this.rowExchangeLitigationHold.Style.Add("display", "none");

            if (!hideItems)
            {
                exchangeArchivingStatus.QuotaUsedValue = exchangeOrgStats.UsedArchingStorage;
                exchangeArchivingStatus.QuotaValue = exchangeOrgStats.AllocatedArchingStorage;
                if (exchangeOrgStats.AllocatedArchingStorage != -1)
                {
                    exchangeArchivingStatus.QuotaAvailable = exchangeOrgStats.AllocatedArchingStorage - exchangeOrgStats.UsedArchingStorage;
                }
            }
            else
                this.rowExchangeArchiving.Style.Add("display", "none");

        }
		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", ex));
			}
			// 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);
		}
Beispiel #14
0
        public ServiceProviderItemDiskSpace[] CalculateItems(int serviceId, List <ServiceProviderItem> items)
        {
            // convert items to SoapObjects
            List <SoapServiceProviderItem> objItems = new List <SoapServiceProviderItem>();

            //hack for organization... Refactoring!!!


            List <ServiceProviderItemDiskSpace> organizationDiskSpaces = new List <ServiceProviderItemDiskSpace>();

            foreach (ServiceProviderItem item in items)
            {
                long size = 0;
                if (item is Organization)
                {
                    Organization org = (Organization)item;

                    //Exchange DiskSpace
                    if (!string.IsNullOrEmpty(org.GlobalAddressList))
                    {
                        int exchangeServiceId = GetExchangeServiceID(org.PackageId);
                        if (exchangeServiceId > 0)
                        {
                            ServiceProvider exchangeProvider = ExchangeServerController.GetExchangeServiceProvider(exchangeServiceId, item.ServiceId);

                            SoapServiceProviderItem        soapOrg        = SoapServiceProviderItem.Wrap(org);
                            ServiceProviderItemDiskSpace[] itemsDiskspace =
                                exchangeProvider.GetServiceItemsDiskSpace(new SoapServiceProviderItem[] { soapOrg });

                            if (itemsDiskspace != null && itemsDiskspace.Length > 0)
                            {
                                size += itemsDiskspace[0].DiskSpace;
                            }
                        }
                    }

                    // Crm DiskSpace
                    if (org.CrmOrganizationId != Guid.Empty)
                    {
                        //CalculateCrm DiskSpace
                    }

                    //SharePoint DiskSpace

                    int res;

                    PackageContext cntx = PackageController.GetPackageContext(org.PackageId);

                    if (cntx.Groups.ContainsKey(ResourceGroups.SharepointFoundationServer))
                    {
                        SharePointSiteDiskSpace[] sharePointSiteDiskSpaces =
                            HostedSharePointServerController.CalculateSharePointSitesDiskSpace(org.Id, out res);
                        if (res == 0)
                        {
                            foreach (SharePointSiteDiskSpace currecnt in sharePointSiteDiskSpaces)
                            {
                                size += currecnt.DiskSpace;
                            }
                        }
                    }

                    if (cntx.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
                    {
                        SharePointSiteDiskSpace[] sharePointSiteDiskSpaces =
                            HostedSharePointServerEntController.CalculateSharePointSitesDiskSpace(org.Id, out res);
                        if (res == 0)
                        {
                            foreach (SharePointSiteDiskSpace currecnt in sharePointSiteDiskSpaces)
                            {
                                size += currecnt.DiskSpace;
                            }
                        }
                    }

                    ServiceProviderItemDiskSpace tmp = new ServiceProviderItemDiskSpace();
                    tmp.ItemId    = item.Id;
                    tmp.DiskSpace = size;
                    organizationDiskSpaces.Add(tmp);
                }
                else
                {
                    objItems.Add(SoapServiceProviderItem.Wrap(item));
                }
            }


            int attempt  = 0;
            int ATTEMPTS = 3;

            while (attempt < ATTEMPTS)
            {
                // increment attempt
                attempt++;

                try
                {
                    // send packet for calculation
                    // invoke service provider
                    //TaskManager.Write(String.Format("{0} - Invoke GetServiceItemsDiskSpace method ('{1}' items) - {2} attempt",
                    //    DateTime.Now, objItems.Count, attempt));

                    if (objItems.Count > 0)
                    {
                        ServiceProvider prov = new ServiceProvider();
                        ServiceProviderProxy.Init(prov, serviceId);
                        ServiceProviderItemDiskSpace[] itemsDiskSpace = prov.GetServiceItemsDiskSpace(objItems.ToArray());
                        if (itemsDiskSpace != null && itemsDiskSpace.Length > 0)
                        {
                            organizationDiskSpaces.AddRange(itemsDiskSpace);
                        }
                    }

                    return(organizationDiskSpaces.ToArray());
                }
                catch (Exception ex)
                {
                    TaskManager.WriteError(ex.ToString());
                }
            }

            throw new Exception("The number of attemtps has been reached. The package calculation has been aborted.");
        }
        public static GalleryApplicationResult GetGalleryApplicationDetails(int packageId, string applicationId)
        {
            GalleryApplicationResult result;

            //
            try
            {
                TaskManager.StartTask(TASK_MANAGER_SOURCE, GET_GALLERY_APP_DETAILS_TASK);

                // check if WAG is installed
                WebServer webServer = GetAssociatedWebServer(packageId);
                if (!webServer.IsMsDeployInstalled())
                {
                    return(Error <GalleryApplicationResult>(GalleryErrors.MsDeployIsNotInstalled));
                }

                // get application details
                result = webServer.GetGalleryApplication(applicationId);

                if (!result.IsSuccess)
                {
                    return(Error <GalleryApplicationResult>(result, GalleryErrors.GetApplicationError));
                }

                // check application requirements
                PackageContext context = PackageController.GetPackageContext(packageId);

                GalleryApplication app = result.Value;

                // ASP.NET 2.0
                if ((app.WellKnownDependencies & GalleryApplicationWellKnownDependency.AspNet20) == GalleryApplicationWellKnownDependency.AspNet20 &&
                    context.Quotas.ContainsKey(Quotas.WEB_ASPNET20) && context.Quotas[Quotas.WEB_ASPNET20].QuotaAllocatedValue < 1)
                {
                    result.ErrorCodes.Add(GalleryErrors.AspNet20Required);
                }

                // ASP.NET 4.0
                else if ((app.WellKnownDependencies & GalleryApplicationWellKnownDependency.AspNet40) == GalleryApplicationWellKnownDependency.AspNet40 &&
                         context.Quotas.ContainsKey(Quotas.WEB_ASPNET40) && context.Quotas[Quotas.WEB_ASPNET40].QuotaAllocatedValue < 1)
                {
                    result.ErrorCodes.Add(GalleryErrors.AspNet40Required);
                }

                // PHP
                else if ((app.WellKnownDependencies & GalleryApplicationWellKnownDependency.PHP) == GalleryApplicationWellKnownDependency.PHP &&
                         context.Quotas.ContainsKey(Quotas.WEB_PHP4) && context.Quotas[Quotas.WEB_PHP4].QuotaAllocatedValue < 1 &&
                         context.Quotas.ContainsKey(Quotas.WEB_PHP5) && context.Quotas[Quotas.WEB_PHP5].QuotaAllocatedValue < 1)
                {
                    result.ErrorCodes.Add(GalleryErrors.PhpRequired);
                }

                // any database
                GalleryApplicationWellKnownDependency anyDatabaseFlag = GalleryApplicationWellKnownDependency.SQL | GalleryApplicationWellKnownDependency.MySQL;
                if ((app.WellKnownDependencies & anyDatabaseFlag) == anyDatabaseFlag &&
                    !(context.Groups.ContainsKey(ResourceGroups.MsSql2000) ||
                      context.Groups.ContainsKey(ResourceGroups.MsSql2005) ||
                      context.Groups.ContainsKey(ResourceGroups.MsSql2008) ||
                      context.Groups.ContainsKey(ResourceGroups.MySql4) ||
                      context.Groups.ContainsKey(ResourceGroups.MySql5)))
                {
                    result.ErrorCodes.Add(GalleryErrors.DatabaseRequired);
                }

                // SQL Server
                else if ((app.WellKnownDependencies & GalleryApplicationWellKnownDependency.SQL) == GalleryApplicationWellKnownDependency.SQL &&
                         !(context.Groups.ContainsKey(ResourceGroups.MsSql2000) ||
                           context.Groups.ContainsKey(ResourceGroups.MsSql2005) ||
                           context.Groups.ContainsKey(ResourceGroups.MsSql2008)))
                {
                    result.ErrorCodes.Add(GalleryErrors.SQLRequired);
                }

                // MySQL
                else if ((app.WellKnownDependencies & GalleryApplicationWellKnownDependency.MySQL) == GalleryApplicationWellKnownDependency.MySQL &&
                         !(context.Groups.ContainsKey(ResourceGroups.MySql4) ||
                           context.Groups.ContainsKey(ResourceGroups.MySql5)))
                {
                    result.ErrorCodes.Add(GalleryErrors.MySQLRequired);
                }

                if (result.ErrorCodes.Count > 0)
                {
                    GalleryApplicationResult warning = Warning <GalleryApplicationResult>(result, GalleryErrors.PackageDoesNotMeetRequirements);
                    warning.Value = app;
                    return(warning);
                }
            }
            catch (Exception ex)
            {
                TaskManager.WriteError(ex);
                return(Error <GalleryApplicationResult>(GalleryErrors.GeneralError, ex.Message));
            }
            finally
            {
                TaskManager.CompleteTask();
            }
            //
            return(result);
        }
Beispiel #16
0
        private void PrepareEnterpriseStorageMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
        {
            MenuGroup enterpriseStorageGroup =
                   new MenuGroup(GetLocalizedString("Text.EnterpriseStorageGroup"), imagePath + "spaces16.png");

            enterpriseStorageGroup.MenuItems.Add(CreateMenuItem("EnterpriseStorageFolders", "enterprisestorage_folders"));

            groups.Add(enterpriseStorageGroup);
        }
        public static GalleryApplicationsResult GetGalleryApplications(int packageId, string categoryId)
        {
            GalleryApplicationsResult result;

            //
            try
            {
                TaskManager.StartTask(TASK_MANAGER_SOURCE, GET_GALLERY_APPS_TASK);

                // check if WAG is installed
                WebServer webServer = GetAssociatedWebServer(packageId);
                if (!webServer.IsMsDeployInstalled())
                {
                    return(Error <GalleryApplicationsResult>(GalleryErrors.MsDeployIsNotInstalled));
                }

                // get applications
                result = webServer.GetGalleryApplications(categoryId);

                if (!result.IsSuccess)
                {
                    return(Error <GalleryApplicationsResult>(result, GalleryErrors.GetApplicationsError));
                }

                // get space quotas
                PackageContext context = PackageController.GetPackageContext(packageId);

                //// filter applications
                //List<string> appsFilter = new List<string>();
                //// if either ASP.NET 1.1 or 2.0 enabled in the hosting plan
                //if (context.Quotas[Quotas.WEB_ASPNET11].QuotaAllocatedValue == 1 ||
                //    context.Quotas[Quotas.WEB_ASPNET20].QuotaAllocatedValue == 1 ||
                //    context.Quotas[Quotas.WEB_ASPNET40].QuotaAllocatedValue == 1)
                //{
                //    appsFilter.AddRange(SupportedAppDependencies.ASPNET_SCRIPTING);
                //}
                //// if either PHP 4 or 5 enabled in the hosting plan
                //if (context.Quotas[Quotas.WEB_PHP4].QuotaAllocatedValue == 1 ||
                //    context.Quotas[Quotas.WEB_PHP5].QuotaAllocatedValue == 1)
                //{
                //    appsFilter.AddRange(SupportedAppDependencies.PHP_SCRIPTING);
                //}
                //// if either MSSQL 2000, 2005 or 2008 enabled in the hosting plan
                //if (context.Groups.ContainsKey(ResourceGroups.MsSql2000) ||
                //    context.Groups.ContainsKey(ResourceGroups.MsSql2005) ||
                //    context.Groups.ContainsKey(ResourceGroups.MsSql2008))
                //{
                //    appsFilter.AddRange(SupportedAppDependencies.MSSQL_DATABASE);
                //}
                //// if either MySQL 4 or 5 enabled in the hosting plan
                //if (context.Groups.ContainsKey(ResourceGroups.MySql4) ||
                //    context.Groups.ContainsKey(ResourceGroups.MySql5))
                //{
                //    appsFilter.AddRange(SupportedAppDependencies.MYSQL_DATABASE);
                //}
                //// Match applications based on the hosting plan restrictions collected
                //result.Value = new List<GalleryApplication>(Array.FindAll<GalleryApplication>(result.Value.ToArray(),
                //    x => MatchGalleryAppDependencies(x.Dependency, appsFilter.ToArray())
                //        || MatchMenaltoGalleryApp(x, appsFilter.ToArray())));

                {
                    int userId = SecurityContext.User.UserId;
                    //
                    SecurityContext.SetThreadSupervisorPrincipal();
                    //
                    string[] filteredApps = GetServiceAppsCatalogFilter(packageId);
                    //
                    if (filteredApps != null)
                    {
                        result.Value = new List <GalleryApplication>(Array.FindAll(result.Value.ToArray(),
                                                                                   x => !Array.Exists(filteredApps,
                                                                                                      z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
                    }
                    //
                    SecurityContext.SetThreadPrincipal(userId);
                }
            }
            catch (Exception ex)
            {
                TaskManager.WriteError(ex);
                return(Error <GalleryApplicationsResult>(GalleryErrors.GeneralError, ex.Message));
            }
            finally
            {
                TaskManager.CompleteTask();
            }
            //
            return(result);
        }
Beispiel #18
0
        private void PrepareBlackBerryMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
        {
            MenuGroup bbGroup = new MenuGroup(GetLocalizedString("Text.BlackBerryGroup"), imagePath + "blackberry16.png");

            bbGroup.MenuItems.Add(CreateMenuItem("BlackBerryUsers", "blackberry_users"));


            if (bbGroup.MenuItems.Count > 0)
                groups.Add(bbGroup);

        }
Beispiel #19
0
        private void PrepareOCSMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
        {
            MenuGroup ocsGroup =
                   new MenuGroup(GetLocalizedString("Text.OCSGroup"), imagePath + "ocs16.png");
            ocsGroup.MenuItems.Add(CreateMenuItem("OCSUsers", "ocs_users"));


            groups.Add(ocsGroup);
        }
Beispiel #20
0
        private void PrepareOrganizationMenu(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;
            }

            if (!hideItems)
            {
                MenuGroup organizationGroup = new MenuGroup(GetLocalizedString("Text.OrganizationGroup"), imagePath + "company24.png");

                if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx) == false)
                {
                    if (Utils.CheckQouta(Quotas.ORGANIZATION_DOMAINS, cntx))
                        organizationGroup.MenuItems.Add(CreateMenuItem("DomainNames", "org_domains"));
                }
                
                if (Utils.CheckQouta(Quotas.ORGANIZATION_USERS, cntx))
                    organizationGroup.MenuItems.Add(CreateMenuItem("Users", "users"));

                if (Utils.CheckQouta(Quotas.ORGANIZATION_DELETED_USERS, cntx))
                    organizationGroup.MenuItems.Add(CreateMenuItem("DeletedUsers", "deleted_users"));

				if (Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPS, cntx))
                    organizationGroup.MenuItems.Add(CreateMenuItem("SecurityGroups", "secur_groups"));
				
                if (organizationGroup.MenuItems.Count > 0)
                    groups.Add(organizationGroup);
            }

        }
        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 static bool IsApplicattionFitsRequirements(PackageContext cntx, ApplicationInfo app)
        {
            if (app.Requirements == null)
                return true; // empty requirements

            foreach (ApplicationRequirement req in app.Requirements)
            {
                // check if this is a group
                if (req.Groups != null)
                {
                    bool groupFits = false;
                    foreach (string group in req.Groups)
                    {
                        if (cntx.Groups.ContainsKey(group))
                        {
                            groupFits = true;
                            break;
                        }
                    }

                    if (!groupFits)
                        return false;
                }

                // check if this is a quota
                if (req.Quotas != null)
                {
                    bool quotaFits = false;
                    foreach (string quota in req.Quotas)
                    {
                        if (cntx.Quotas.ContainsKey(quota) &&
                            !cntx.Quotas[quota].QuotaExhausted)
                        {
                            quotaFits = true;
                            break;
                        }
                    }

                    if (!quotaFits)
                        return false;
                }
            }

            return true;
        }
Beispiel #23
0
        public static List <ApplicationInfo> GetApplications(int packageId, string categoryId)
        {
            string key = "WebApplicationsList";

            Dictionary <string, ApplicationInfo> apps = null;

            // look up in the cache
            if (HttpContext.Current != null)
            {
                apps = (Dictionary <string, ApplicationInfo>)HttpContext.Current.Cache[key];
            }

            if (apps == null)
            {
                // create apps list
                apps = new Dictionary <string, ApplicationInfo>();

                string   appsRoot = ConfigSettings.WebApplicationsPath;
                string[] dirs     = Directory.GetDirectories(appsRoot);
                foreach (string dir in dirs)
                {
                    string appFile = Path.Combine(dir, "Application.xml");

                    if (!File.Exists(appFile))
                    {
                        continue;
                    }

                    // read and parse web applications xml file
                    XmlDocument doc = new XmlDocument();
                    doc.Load(appFile);

                    XmlNode nodeApp = doc.SelectSingleNode("//application");

                    string appFolder = dir;

                    // parse node
                    ApplicationInfo app = CreateApplicationInfoFromXml(appFolder, nodeApp);

                    // add to the collection
                    apps.Add(app.Id, app);
                }

                // place to the cache
                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Cache.Insert(key, apps, new CacheDependency(appsRoot));
                }
            }

            // filter applications based on category
            List <ApplicationInfo> categoryApps = new List <ApplicationInfo>();

            // check if the application fits requirements
            PackageContext cntx = PackageController.GetPackageContext(packageId);

            List <ApplicationCategory> categories = GetCategories();

            foreach (ApplicationCategory category in categories)
            {
                // skip category if required
                if (!String.IsNullOrEmpty(categoryId) &&
                    String.Compare(category.Id, categoryId, true) != 0)
                {
                    continue;
                }

                // iterate through applications
                foreach (string appId in category.Applications)
                {
                    if (apps.ContainsKey(appId) &&
                        IsApplicattionFitsRequirements(cntx, apps[appId]))
                    {
                        categoryApps.Add(apps[appId]);
                    }
                }
            }

            return(categoryApps);
        }
        private static void CheckQuotaValue(PackageContext cntx, List<string> errors, string quotaName, int currentVal, int 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)
            {
                int 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);
            }
        }
Beispiel #25
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 (!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);

        }
        public static PackageContext GetPackageContext(int packageId)
        {
            PackageContext context = new PackageContext();

            // load package
            context.Package = GetPackage(packageId);
            if (context.Package == null)
                return null;

            // load groups and quotas
            DataSet ds = GetPackageQuotas(packageId);

            List<HostingPlanGroupInfo> groups = new List<HostingPlanGroupInfo>();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                HostingPlanGroupInfo group = new HostingPlanGroupInfo();
                group.GroupId = (int)dr["GroupID"];
                group.GroupName = (string)dr["GroupName"];
                group.Enabled = true;
                group.CalculateBandwidth = (bool)dr["CalculateBandwidth"];
                group.CalculateDiskSpace = (bool)dr["CalculateDiskSpace"];
                groups.Add(group);
                context.Groups.Add(group.GroupName, group);
            }

            List<QuotaValueInfo> quotas = new List<QuotaValueInfo>();
            foreach (DataRow dr in ds.Tables[1].Rows)
            {
                QuotaValueInfo quota = new QuotaValueInfo();
                quota.QuotaId = (int)dr["QuotaId"];
                quota.GroupId = (int)dr["GroupId"];
                quota.QuotaName = (string)dr["QuotaName"];
                quota.QuotaTypeId = (int)dr["QuotaTypeId"];
                quota.QuotaAllocatedValue = (int)dr["QuotaValue"];
                quota.QuotaUsedValue = (int)dr["QuotaUsedValue"];
                quota.QuotaExhausted = (packageId < 2) || (quota.QuotaAllocatedValue != -1 && quota.QuotaUsedValue >= quota.QuotaAllocatedValue);
                quotas.Add(quota);
                context.Quotas.Add(quota.QuotaName, quota);
            }

            context.GroupsArray = groups.ToArray();
            context.QuotasArray = quotas.ToArray();

            return context;
        }
Beispiel #27
0
        private void PrepareCRMMenu2013(PackageContext cntx, List<MenuGroup> groups, string imagePath)
        {
            MenuGroup crmGroup = new MenuGroup(GetLocalizedString("Text.CRMGroup2013"), imagePath + "crm_16.png");

            crmGroup.MenuItems.Add(CreateMenuItem("CRMOrganization", "CRMOrganizationDetails"));
            crmGroup.MenuItems.Add(CreateMenuItem("CRMUsers", "CRMUsers"));
            crmGroup.MenuItems.Add(CreateMenuItem("StorageLimits", "crm_storage_settings"));

            if (crmGroup.MenuItems.Count > 0)
                groups.Add(crmGroup);

        }
Beispiel #28
0
		private 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)));
		}
Beispiel #29
0
        private void PrepareSharePointEnterpriseMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath, string menuItemText)
        {
            MenuGroup sharepointGroup =
                    new MenuGroup(menuItemText, imagePath + "sharepoint24.png");
            sharepointGroup.MenuItems.Add(CreateMenuItem("SiteCollections", "sharepoint_enterprise_sitecollections"));
            sharepointGroup.MenuItems.Add(CreateMenuItem("StorageUsage", "sharepoint_enterprise_storage_usage"));
            sharepointGroup.MenuItems.Add(CreateMenuItem("StorageLimits", "sharepoint_enterprise_storage_settings"));

            groups.Add(sharepointGroup);


        }
Beispiel #30
0
        private void PrepareExchangeMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
        {
                        
            MenuGroup exchangeGroup = new MenuGroup(GetLocalizedString("Text.ExchangeGroup"), imagePath + "exchange24.png");

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

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

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

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


            
            exchangeGroup.MenuItems.Add(CreateMenuItem("StorageUsage", "storage_usage"));
            exchangeGroup.MenuItems.Add(CreateMenuItem("StorageLimits", "storage_limits"));

            if (CheckQouta(Quotas.EXCHANGE2007_ACTIVESYNCENABLED, cntx))
                exchangeGroup.MenuItems.Add(CreateMenuItem("ActiveSyncPolicy", "activesync_policy"));

            if (exchangeGroup.MenuItems.Count > 0)
                groups.Add(exchangeGroup);

        }
Beispiel #31
0
        private void PrepareLyncMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
        {
            MenuGroup lyncGroup =
                   new MenuGroup(GetLocalizedString("Text.LyncGroup"), imagePath + "lync16.png");
            lyncGroup.MenuItems.Add(CreateMenuItem("LyncUsers", "lync_users"));

            lyncGroup.MenuItems.Add(CreateMenuItem("LyncUserPlans", "lync_userplans"));


            if (Utils.CheckQouta(Quotas.LYNC_FEDERATION, cntx))
                lyncGroup.MenuItems.Add(CreateMenuItem("LyncFederationDomains", "lync_federationdomains"));

            if (Utils.CheckQouta(Quotas.LYNC_PHONE, cntx))
                lyncGroup.MenuItems.Add(CreateMenuItem("LyncPhoneNumbers", "lync_phonenumbers"));

            groups.Add(lyncGroup);
        }
Beispiel #32
0
      private void PrepareOrganizationMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
      {
          MenuGroup organizationGroup = new MenuGroup(GetLocalizedString("Text.OrganizationGroup"), imagePath + "company24.png");
          if (CheckQouta(Quotas.ORGANIZATION_DOMAINS, cntx))
              organizationGroup.MenuItems.Add(CreateMenuItem("DomainNames", "domains"));
          if (CheckQouta(Quotas.ORGANIZATION_USERS, cntx))
              organizationGroup.MenuItems.Add(CreateMenuItem("Users", "users"));
          
          if (organizationGroup.MenuItems.Count >0)
              groups.Add(organizationGroup);
 
      }
 private static bool QuotaEnabled(PackageContext cntx, string quotaName)
 {
     return cntx.Quotas.ContainsKey(quotaName) && !cntx.Quotas[quotaName].QuotaExhausted;
 }
Beispiel #34
0
        private void PrepareSharePointMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
        {
            MenuGroup sharepointGroup =
                    new MenuGroup(GetLocalizedString("Text.SharePointGroup"), imagePath + "sharepoint24.png");
            sharepointGroup.MenuItems.Add(CreateMenuItem("SiteCollections", "sharepoint_sitecollections"));
            sharepointGroup.MenuItems.Add(CreateMenuItem("StorageUsage", "sharepoint_storage_usage"));
            sharepointGroup.MenuItems.Add(CreateMenuItem("StorageLimits", "sharepoint_storage_settings"));
            
            groups.Add(sharepointGroup);


        }