public TenantQuota SaveTenantQuota(TenantQuota quota) { quota = service.SaveTenantQuota(quota); var store = GetTenantQuotasInernal(); store[quota.Id] = quota; return quota; }
public QuotaWrapper(TenantQuota quota, IList<TenantQuotaRow> quotaRows) { StorageSize = (ulong) Math.Max(0, quota.MaxTotalSize); MaxFileSize = (ulong) Math.Max(0, quota.MaxFileSize); UsedSize = (ulong) Math.Max(0, quotaRows.Sum(r => r.Counter)); StorageUsage = quotaRows.Select(x => new QuotaUsage() {Path = x.Path.TrimStart('/').TrimEnd('/'), Size = x.Counter,}). ToList(); }
public static int GetPrevUsersCount(TenantQuota quota) { var prevQuota = GetPrevQuota(quota); if (prevQuota == null || prevQuota.Trial) return 1; if (prevQuota.DocsEdition != quota.DocsEdition) return 1; return prevQuota.ActiveUsers + 1; }
public QuotaWrapper(TenantQuota quota, IList<TenantQuotaRow> quotaRows) { StorageSize = (ulong)Math.Max(0, quota.MaxTotalSize); UsedSize = (ulong)Math.Max(0, quotaRows.Sum(r => r.Counter)); MaxFileSize = Math.Min(AvailableSize, (ulong)quota.MaxFileSize); MaxUsersCount = TenantExtra.GetTenantQuota().ActiveUsers; UsersCount = TenantStatisticsProvider.GetUsersCount(); StorageUsage = quotaRows .Select(x => new QuotaUsage {Path = x.Path.TrimStart('/').TrimEnd('/'), Size = x.Counter,}) .ToList(); }
private static TenantQuota GetPrevQuota(TenantQuota curQuota) { TenantQuota prev = null; foreach (var quota in GetTenantQuotas().OrderBy(r => r.ActiveUsers).Where(r => r.DocsEdition && r.Year == curQuota.Year)) { if (quota.Id == curQuota.Id) return prev; prev = quota; } return null; }
public TenantQuota SaveTenantQuota(TenantQuota quota) { if (quota == null) throw new ArgumentNullException("quota"); var i = Insert(tenants_quota, quota.Id) .InColumnValue("name", quota.Name) .InColumnValue("description", quota.Desc) .InColumnValue("max_file_size", quota.MaxFileSize) .InColumnValue("max_total_size", quota.MaxTotalSize) .InColumnValue("active_users", quota.ActiveUsers) .InColumnValue("features", quota.Features) .InColumnValue("price", quota.Price) .InColumnValue("avangate_id", quota.AvangateId); ExecNonQuery(i); return quota; }
protected string GetShoppingUri(TenantQuota quota) { var uri = string.Empty; if (quota != null && quota.ActiveUsers >= TenantStatisticsProvider.GetUsersCount() && quota.MaxTotalSize >= TenantStatisticsProvider.GetUsedSize()) { if (Partner == null) { var link = CoreContext.PaymentManager.GetShoppingUri(TenantProvider.CurrentTenantID, quota.Id); if (link == null) { LogManager.GetLogger("ASC.Web.Billing").Error(string.Format("GetShoppingUri return null for tenant {0} and quota {1}", TenantProvider.CurrentTenantID, quota == null ? 0 : quota.Id)); } else { uri = link.ToString(); } } else if (Partner.PaymentMethod == PartnerPaymentMethod.External) { uri = (Partner.PaymentUrl ?? "") .ToLower() .Replace("{partnerid}", Partner.Id) .Replace("{tariffid}", quota.ActiveUsers + (quota.Year ? "year" : "month")) .Replace("{portal}", CoreContext.TenantManager.GetCurrentTenant().TenantAlias) .Replace("{currency}", Region.ISOCurrencySymbol) .Replace("{price}", ((int)quota.Price).ToString()); } } return uri; }
protected string GetTypeLink(TenantQuota quota) { return quota.ActiveUsers >= UsersCount && quota.MaxTotalSize >= UsedSize ? (CurrentQuota.Trial || Equals(quota.Id, CurrentQuota.Id)) ? "pay" : "change" : "limit"; }
protected TenantQuota GetQuotaMonth(TenantQuota quota) { return _quotaList.FirstOrDefault(r => r.ActiveUsers == quota.ActiveUsers && !r.Year); }
protected void Page_Load(object sender, EventArgs e) { UsersCount = TenantStatisticsProvider.GetUsersCount(); UsedSize = TenantStatisticsProvider.GetUsedSize(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); var partnerId = CoreContext.TenantManager.GetCurrentTenant().PartnerId; if (!string.IsNullOrEmpty(partnerId)) { var partner = CoreContext.PaymentManager.GetPartner(partnerId); if (partner != null && partner.Status == PartnerStatus.Approved && !partner.Removed && partner.PartnerType != PartnerType.System) { Partner = partner; _quotaList = CoreContext.PaymentManager.GetPartnerTariffs(Partner.Id); SalesMail = Partner.SalesEmail; if (!string.IsNullOrEmpty(Partner.Currency)) { Region = new RegionInfo(Partner.Currency); } var control = (TariffPartner)LoadControl(TariffPartner.Location); control.CurPartner = Partner; control.TariffNotPaid = CurrentTariff.State >= TariffState.NotPaid; control.TariffProlongable = CurrentTariff.Prolongable; PaymentsCodeHolder.Controls.Add(control); } } if (_quotaList == null || !_quotaList.Any()) { _quotaList = TenantExtra.GetTenantQuotas(); } else if (!CurrentQuota.Trial) { CurrentQuota = _quotaList.First(q => q.Id == CurrentQuota.Id) ?? CurrentQuota; } _quotaList = _quotaList.OrderBy(r => r.ActiveUsers).ToList().Where(r => !r.Trial); QuotasYear = _quotaList.Where(r => r.Year).ToList(); HideBuyRecommendation = CurrentTariff.Autorenewal || TariffSettings.GetTariffSettings() || Partner != null; downgradeInfoContainer.Options.IsPopup = true; buyRecommendationContainer.Options.IsPopup = true; AjaxPro.Utility.RegisterTypeForAjax(GetType()); if (StudioSmsNotificationSettings.IsVisibleSettings && SettingsManager.Instance.LoadSettings<StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID).EnableSetting && Partner == null) { SmsEnable = true; SmsBuyHolder.Controls.Add(LoadControl(SmsBuy.Location)); } if (Partner == null) { RegisterScript(); } }
protected string GetTypeLink(TenantQuota quota) { return quota.ActiveUsers >= UsersCount && quota.MaxTotalSize >= UsedSize ? !quota.Free ? (CurrentQuota.Trial || CurrentQuota.Free || CoreContext.Configuration.Standalone && CurrentTariff.QuotaId.Equals(Tenant.DEFAULT_TENANT) || Equals(quota.Id, CurrentQuota.Id)) ? "pay" : "change" : CurrentTariff.State == TariffState.NotPaid ? "free" : "stopfree" : "limit"; }
protected void Page_Load(object sender, EventArgs e) { Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/tariffsettings/js/tariffusage.js")); Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/usercontrols/management/tariffsettings/css/tariffusage.less")); UsersCount = TenantStatisticsProvider.GetUsersCount(); UsedSize = TenantStatisticsProvider.GetUsedSize(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); var partner = CoreContext.PaymentManager.GetApprovedPartner(); if (partner != null) { Partner = partner; _quotaList = CoreContext.PaymentManager.GetPartnerTariffs(Partner.Id); if (!string.IsNullOrEmpty(Partner.Currency)) { _region = new RegionInfo(Partner.Currency); } var control = (TariffPartner)LoadControl(TariffPartner.Location); control.CurPartner = Partner; control.TariffNotPaid = CurrentTariff.State >= TariffState.NotPaid; control.TariffProlongable = CurrentTariff.Prolongable; PaymentsCodeHolder.Controls.Add(control); } if (_quotaList == null || !_quotaList.Any()) { _quotaList = TenantExtra.GetTenantQuotas(); } else if (!CurrentQuota.Trial) { CurrentQuota = _quotaList.FirstOrDefault(q => q.Id == CurrentQuota.Id) ?? CurrentQuota; } _quotaList = _quotaList.OrderBy(r => r.ActiveUsers).ToList().Where(r => !r.Trial); QuotasYear = _quotaList.Where(r => r.Year).ToList(); HideBuyRecommendation = CurrentTariff.Autorenewal || TariffSettings.HideRecommendation || Partner != null; AnnualDiscount = QuotasYear.All(q => q.Price2 != decimal.Zero); HideAnnualRecomendation = !AnnualDiscount || (CurrentQuota.Year && !CurrentQuota.Free && !CurrentQuota.Trial) || TariffSettings.HideAnnualRecomendation || CurrentQuota.NonProfit; if (!HideAnnualRecomendation) { AnnualQuotaForDisplay = QuotaForDisplay; if (AnnualQuotaForDisplay == null || AnnualQuotaForDisplay.Free || AnnualQuotaForDisplay.Trial || !AnnualQuotaForDisplay.Visible) { HideAnnualRecomendation = true; } else if (!AnnualQuotaForDisplay.Year) { AnnualQuotaForDisplay = _quotaList.FirstOrDefault(r => r.ActiveUsers == AnnualQuotaForDisplay.ActiveUsers && r.Year); if (AnnualQuotaForDisplay == null) { HideAnnualRecomendation = true; } } } downgradeInfoContainer.Options.IsPopup = true; buyRecommendationContainer.Options.IsPopup = true; annualRecomendationContainer.Options.IsPopup = true; AjaxPro.Utility.RegisterTypeForAjax(GetType()); if (StudioSmsNotificationSettings.IsVisibleSettings && (SettingsManager.Instance.LoadSettings<StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID).EnableSetting || CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID)) && Partner == null) { SmsEnable = true; var smsBuy = (SmsBuy)LoadControl(SmsBuy.Location); smsBuy.ShowLink = !SettingsManager.Instance.LoadSettings<StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID).EnableSetting; SmsBuyHolder.Controls.Add(smsBuy); } if (VoipPaymentSettings.IsVisibleSettings && CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID) && Partner == null) { VoipEnable = true; var voipBuy = (VoipBuy)LoadControl(VoipBuy.Location); VoipBuyHolder.Controls.Add(voipBuy); } if (Partner == null) { RegisterScript(); } if (Partner == null && Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName == "ru") { _region = new RegionInfo("RU"); RateRuble = SetupInfo.ExchangeRateRuble; SetStar(string.Format(Resource.TariffsCurrencyRu, RateRuble)); } }
private static void SetQuota(TenantQuota quota) { if (quota == null) throw new ArgumentNullException("quota"); if (TenantStatisticsProvider.GetUsersCount() > quota.ActiveUsers) throw new Exception(string.Format(Resources.Resource.PortalAccessSettingsUserLimitException, quota.ActiveUsers)); if (TenantStatisticsProvider.GetUsedSize() > quota.MaxTotalSize) throw new Exception(string.Format(Resources.Resource.PortalAccessSettingsDiscSpaceLimitException, quota.MaxTotalSize / 1024 / 1024)); CoreContext.PaymentManager.SetTariff(TenantProvider.CurrentTenantID, new Tariff { QuotaId = quota.Id, DueDate = DateTime.MaxValue }); }