private void BindServiceLevelsStats(OrganizationStatistics stats) { foreach (var quota in stats.ServiceLevels) { 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); 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 = 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 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); } }