Merge branch 'feature/stripe' of github.com:ONLYOFFICE/AppServer into feature/stripe

This commit is contained in:
Tatiana Lopaeva 2022-09-12 09:35:08 +03:00
commit 738f803371
18 changed files with 168 additions and 120 deletions

View File

@ -121,13 +121,13 @@ public abstract class BaseStartup
services.AddScoped<ITenantQuotaFeatureChecker, CountManagerChecker>();
services.AddScoped<CountManagerChecker>();
services.AddScoped<ITenantQuotaFeatureStatisticCount<CountManagerFeature>, CountManagerStatistic>();
services.AddScoped<ITenantQuotaFeatureStat<CountManagerFeature, int>, CountManagerStatistic>();
services.AddScoped<CountManagerStatistic>();
services.AddScoped<ITenantQuotaFeatureChecker, MaxTotalSizeChecker>();
services.AddScoped<MaxTotalSizeChecker>();
services.AddScoped<ITenantQuotaFeatureStatisticLength<MaxTotalSizeFeature>, MaxTotalSizeStatistic>();
services.AddScoped<ITenantQuotaFeatureStat<MaxTotalSizeFeature, long>, MaxTotalSizeStatistic>();
services.AddScoped<MaxTotalSizeStatistic>();

View File

@ -31,7 +31,6 @@ public class DbQuota : BaseEntity, IMapFrom<TenantQuota>
public int Tenant { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public long MaxFileSize { get; set; }
public string Features { get; set; }
public decimal Price { get; set; }
public string ProductId { get; set; }
@ -44,8 +43,7 @@ public class DbQuota : BaseEntity, IMapFrom<TenantQuota>
public void Mapping(Profile profile)
{
profile.CreateMap<TenantQuota, DbQuota>()
.ForMember(dest => dest.MaxFileSize, opt => opt.MapFrom(src => ByteConverter.GetInMBytes(src.MaxFileSize)));
profile.CreateMap<TenantQuota, DbQuota>();
}
}
public static class DbQuotaExtension
@ -61,8 +59,7 @@ public static class DbQuotaExtension
Tenant = -1,
Name = "trial",
Description = null,
MaxFileSize = 100,
Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1",
Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,file_size:100,manager:1",
Price = decimal.Parse("0,00"),
ProductId = null,
Visible = false
@ -72,8 +69,7 @@ public static class DbQuotaExtension
Tenant = -2,
Name = "admin",
Description = null,
MaxFileSize = 1024,
Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1",
Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,file_size:1024,manager:1",
Price = decimal.Parse("30,00"),
ProductId = "1002",
Visible = true
@ -83,8 +79,7 @@ public static class DbQuotaExtension
Tenant = -3,
Name = "startup",
Description = null,
MaxFileSize = 100,
Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3",
Features = "free,audit,ldap,sso,restore,total_size:2147483648,file_size:100,manager:5,rooms:3",
Price = decimal.Parse("0,00"),
ProductId = null,
Visible = false
@ -124,10 +119,6 @@ public static class DbQuotaExtension
.HasColumnName("features")
.HasColumnType("text");
entity.Property(e => e.MaxFileSize)
.HasColumnName("max_file_size")
.HasDefaultValueSql("'0'");
entity.Property(e => e.Name)
.HasColumnName("name")
.HasColumnType("varchar(128)")
@ -169,10 +160,6 @@ public static class DbQuotaExtension
entity.Property(e => e.Features).HasColumnName("features");
entity.Property(e => e.MaxFileSize)
.HasColumnName("max_file_size")
.HasDefaultValueSql("'0'");
entity.Property(e => e.Name)
.HasColumnName("name")
.HasColumnType("character varying");

View File

@ -35,27 +35,19 @@ public class CountManagerFeature : TenantQuotaFeatureCount
}
}
public class CountManagerChecker : ITenantQuotaFeatureChecker
public class CountManagerChecker : TenantQuotaFeatureChecker<CountManagerFeature, int>
{
private readonly ITenantQuotaFeatureStatisticCount<CountManagerFeature> _tenantQuotaFeatureStatistic;
public CountManagerChecker(ITenantQuotaFeatureStatisticCount<CountManagerFeature> tenantQuotaFeatureStatistic)
public CountManagerChecker(ITenantQuotaFeatureStat<CountManagerFeature, int> tenantQuotaFeatureStatistic) : base(tenantQuotaFeatureStatistic)
{
_tenantQuotaFeatureStatistic = tenantQuotaFeatureStatistic;
}
public async Task<bool> Check(TenantQuota quota)
{
return await _tenantQuotaFeatureStatistic.GetValue() <= quota.ActiveUsers;
}
public string Exception(TenantQuota quota)
public override string Exception(TenantQuota quota)
{
return "The number of managers should not exceed " + quota.CountManager;
}
}
public class CountManagerStatistic : ITenantQuotaFeatureStatisticCount<CountManagerFeature>
public class CountManagerStatistic : ITenantQuotaFeatureStat<CountManagerFeature, int>
{
private readonly UserManager _userManager;

View File

@ -0,0 +1,40 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Core.Common.Quota.Features;
internal class MaxFileSizeFeature : TenantQuotaFeatureLength
{
public override string Name { get => "file_size"; }
public MaxFileSizeFeature(TenantQuota tenantQuota) : base(tenantQuota)
{
}
protected internal override void Multiply(int quantity)
{
}
}

View File

@ -35,27 +35,19 @@ public class MaxTotalSizeFeature : TenantQuotaFeatureLength
}
}
public class MaxTotalSizeChecker : ITenantQuotaFeatureChecker
public class MaxTotalSizeChecker : TenantQuotaFeatureChecker<MaxTotalSizeFeature, long>
{
private readonly ITenantQuotaFeatureStatisticLength<MaxTotalSizeFeature> _tenantQuotaFeatureStatistic;
public MaxTotalSizeChecker(ITenantQuotaFeatureStatisticLength<MaxTotalSizeFeature> tenantQuotaFeatureStatistic)
public MaxTotalSizeChecker(ITenantQuotaFeatureStat<MaxTotalSizeFeature, long> tenantQuotaFeatureStatistic) : base(tenantQuotaFeatureStatistic)
{
_tenantQuotaFeatureStatistic = tenantQuotaFeatureStatistic;
}
public async Task<bool> Check(TenantQuota quota)
{
return await _tenantQuotaFeatureStatistic.GetValue() <= quota.MaxTotalSize;
}
public string Exception(TenantQuota quota)
public override string Exception(TenantQuota quota)
{
return "The used storage size should not exceed " + quota.MaxTotalSize;
}
}
public class MaxTotalSizeStatistic : ITenantQuotaFeatureStatisticLength<MaxTotalSizeFeature>
public class MaxTotalSizeStatistic : ITenantQuotaFeatureStat<MaxTotalSizeFeature, long>
{
private readonly TenantManager _tenantManager;

View File

@ -30,3 +30,21 @@ public interface ITenantQuotaFeatureChecker
public Task<bool> Check(TenantQuota value);
public string Exception(TenantQuota value);
}
public abstract class TenantQuotaFeatureChecker<T, T1> : ITenantQuotaFeatureChecker where T : TenantQuotaFeature<T1> where T1 : IComparable<T1>
{
private readonly ITenantQuotaFeatureStat<T, T1> _tenantQuotaFeatureStatistic;
public TenantQuotaFeatureChecker(ITenantQuotaFeatureStat<T, T1> tenantQuotaFeatureStatistic)
{
_tenantQuotaFeatureStatistic = tenantQuotaFeatureStatistic;
}
public virtual async Task<bool> Check(TenantQuota quota)
{
return (await _tenantQuotaFeatureStatistic.GetValue()).CompareTo(quota.GetFeature<T>().Value) <= 0;
}
public abstract string Exception(TenantQuota quota);
}

View File

@ -31,10 +31,7 @@ public interface ITenantQuotaFeatureStat<T>
Task<T> GetValue();
}
public interface ITenantQuotaFeatureStatisticCount<T> : ITenantQuotaFeatureStat<int> where T : TenantQuotaFeature<int>
public interface ITenantQuotaFeatureStat<T, T1> : ITenantQuotaFeatureStat<T1> where T : TenantQuotaFeature<T1>
{
}
public interface ITenantQuotaFeatureStatisticLength<T> : ITenantQuotaFeatureStat<long> where T : TenantQuotaFeature<long>
{
}

View File

@ -44,7 +44,6 @@ public class TenantQuota : IMapFrom<DbQuota>
public decimal Price { get; set; }
public string ProductId { get; set; }
public bool Visible { get; set; }
public long MaxFileSize { get; set; }
[JsonIgnore]
public IReadOnlyList<TenantQuotaFeature> TenantQuotaFeatures { get; private set; }
@ -70,6 +69,13 @@ public class TenantQuota : IMapFrom<DbQuota>
}
}
private readonly MaxFileSizeFeature _maxFileSizeFeature;
public long MaxFileSize
{
get => ByteConverter.GetInBytes(_maxFileSizeFeature.Value);
set => _maxFileSizeFeature.Value = ByteConverter.GetInMBytes(value);
}
private readonly MaxTotalSizeFeature _maxTotalSizeFeature;
public long MaxTotalSize
{
@ -211,6 +217,7 @@ public class TenantQuota : IMapFrom<DbQuota>
_countManagerFeature = new CountManagerFeature(this);
_countRoomFeature = new CountRoomFeature(this) { Order = 2 };
_maxTotalSizeFeature = new MaxTotalSizeFeature(this);
_maxFileSizeFeature = new MaxFileSizeFeature(this);
_nonProfitFeature = new TenantQuotaFeatureFlag(this) { Name = "non-profit", Visible = false };
_trialFeature = new TenantQuotaFeatureFlag(this) { Name = "trial", Visible = false };
_freeFeature = new TenantQuotaFeatureFlag(this) { Name = "free", Visible = false };
@ -233,6 +240,7 @@ public class TenantQuota : IMapFrom<DbQuota>
_countManagerFeature,
_countRoomFeature,
_maxTotalSizeFeature,
_maxFileSizeFeature,
_nonProfitFeature,
_trialFeature,
_freeFeature,
@ -310,15 +318,17 @@ public class TenantQuota : IMapFrom<DbQuota>
}
var newQuota = new TenantQuota(quota);
newQuota.MaxFileSize = Math.Max(newQuota.MaxFileSize, quota.MaxFileSize);
newQuota.Price += quota.Price;
newQuota.Visible &= quota.Visible;
newQuota.ProductId = "";
foreach (var f in newQuota.TenantQuotaFeatures)
{
if (f is TenantQuotaFeature<int> count)
if (f is MaxFileSizeFeature fileSize)
{
fileSize.Value = Math.Max(fileSize.Value, quota.MaxFileSize);
}
else if (f is TenantQuotaFeature<int> count)
{
count.Value += quota.GetFeature<int>(f.Name).Value;
}
@ -337,8 +347,7 @@ public class TenantQuota : IMapFrom<DbQuota>
public void Mapping(Profile profile)
{
profile.CreateMap<DbQuota, TenantQuota>()
.ForMember(dest => dest.MaxFileSize, opt => opt.MapFrom(src => ByteConverter.GetInBytes(src.MaxFileSize)));
profile.CreateMap<DbQuota, TenantQuota>();
}
public TenantQuotaFeature<T> GetFeature<T>(string name)
@ -346,6 +355,11 @@ public class TenantQuota : IMapFrom<DbQuota>
return TenantQuotaFeatures.OfType<TenantQuotaFeature<T>>().FirstOrDefault(r => r.Name == name);
}
public T GetFeature<T>() where T : TenantQuotaFeature
{
return TenantQuotaFeatures.OfType<T>().FirstOrDefault();
}
internal string GetFeature(string name)
{
return _featuresList.FirstOrDefault(f => f.StartsWith($"{name}"));

View File

@ -51,6 +51,10 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb
name: "max_total_size",
table: "tenants_quota");
migrationBuilder.DropColumn(
name: "max_file_size",
table: "tenants_quota");
migrationBuilder.RenameColumn(
name: "avangate_id",
table: "tenants_quota",
@ -86,18 +90,18 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb
table: "tenants_quota",
keyColumn: "tenant",
keyValue: -1,
columns: new[] { "features", "max_file_size", "name", "product_id" },
values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 100L, "trial", null });
columns: new[] { "features", "name", "product_id" },
values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:107374182400,file_size:100,manager:1", "trial", null });
migrationBuilder.InsertData(
table: "tenants_quota",
columns: new[] { "tenant", "description", "features", "max_file_size", "name", "product_id" },
values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", 100L, "startup", null });
columns: new[] { "tenant", "description", "features", "name", "product_id" },
values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,file_size:100,manager:5,rooms:3", "startup", null });
migrationBuilder.InsertData(
table: "tenants_quota",
columns: new[] { "tenant", "description", "features", "max_file_size", "name", "price", "product_id", "visible" },
values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 1024L, "admin", 30.00m, "1002", true });
columns: new[] { "tenant", "description", "features", "name", "price", "product_id", "visible" },
values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:107374182400,file_size:1024,manager:1", "admin", 30.00m, "1002", true });
}
protected override void Down(MigrationBuilder migrationBuilder)
@ -152,6 +156,13 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb
nullable: false,
defaultValueSql: "'0'");
migrationBuilder.AddColumn<long>(
name: "max_file_size",
table: "tenants_quota",
type: "bigint",
nullable: false,
defaultValueSql: "'0'");
migrationBuilder.UpdateData(
table: "tenants_quota",
keyColumn: "tenant",

View File

@ -35,12 +35,6 @@ namespace ASC.Migrations.MySql.Migrations
.HasColumnType("text")
.HasColumnName("features");
b.Property<long>("MaxFileSize")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasColumnName("max_file_size")
.HasDefaultValueSql("'0'");
b.Property<string>("Name")
.HasColumnType("varchar(128)")
.HasColumnName("name")
@ -76,8 +70,7 @@ namespace ASC.Migrations.MySql.Migrations
new
{
Tenant = -1,
Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1",
MaxFileSize = 100L,
Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,file_size:100,manager:1",
Name = "trial",
Price = 0.00m,
Visible = false
@ -85,8 +78,7 @@ namespace ASC.Migrations.MySql.Migrations
new
{
Tenant = -2,
Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1",
MaxFileSize = 1024L,
Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,file_size:1024,manager:1",
Name = "admin",
Price = 30.00m,
ProductId = "1002",
@ -95,8 +87,7 @@ namespace ASC.Migrations.MySql.Migrations
new
{
Tenant = -3,
Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3",
MaxFileSize = 100L,
Features = "free,audit,ldap,sso,restore,total_size:2147483648,file_size:100,manager:5,rooms:3",
Name = "startup",
Price = 0.00m,
Visible = false

View File

@ -56,6 +56,11 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
schema: "onlyoffice",
table: "tenants_quota");
migrationBuilder.DropColumn(
name: "max_file_size",
schema: "onlyoffice",
table: "tenants_quota");
migrationBuilder.RenameColumn(
name: "avangate_id",
schema: "onlyoffice",
@ -92,20 +97,20 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
table: "tenants_quota",
keyColumn: "tenant",
keyValue: -1,
columns: new[] { "features", "max_file_size", "name", "product_id" },
values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 100L, "trial", null });
columns: new[] { "features", "name", "product_id" },
values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:107374182400,file_size:100,manager:1", "trial", null });
migrationBuilder.InsertData(
schema: "onlyoffice",
table: "tenants_quota",
columns: new[] { "tenant", "description", "features", "max_file_size", "name", "visible" },
values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", 100L, "startup", false });
columns: new[] { "tenant", "description", "features", "name", "visible" },
values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,file_size:100,manager:5,rooms:3", "startup", false });
migrationBuilder.InsertData(
schema: "onlyoffice",
table: "tenants_quota",
columns: new[] { "tenant", "description", "features", "max_file_size", "name", "price", "product_id", "visible" },
values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 1024L, "admin", 30.00m, "1002", true });
columns: new[] { "tenant", "description", "features", "name", "price", "product_id", "visible" },
values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:107374182400,file_size:1024,manager:1", "admin", 30.00m, "1002", true });
}
protected override void Down(MigrationBuilder migrationBuilder)
@ -168,6 +173,14 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb
nullable: false,
defaultValueSql: "'0'");
migrationBuilder.AddColumn<long>(
name: "max_file_size",
schema: "onlyoffice",
table: "tenants_quota",
type: "bigint",
nullable: false,
defaultValueSql: "'0'");
migrationBuilder.UpdateData(
schema: "onlyoffice",
table: "tenants_quota",

View File

@ -35,12 +35,6 @@ namespace ASC.Migrations.PostgreSql.Migrations
.HasColumnType("text")
.HasColumnName("features");
b.Property<long>("MaxFileSize")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasColumnName("max_file_size")
.HasDefaultValueSql("'0'");
b.Property<string>("Name")
.HasColumnType("character varying")
.HasColumnName("name");
@ -71,8 +65,7 @@ namespace ASC.Migrations.PostgreSql.Migrations
new
{
Tenant = -1,
Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1",
MaxFileSize = 100L,
Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,file_size:100,manager:1",
Name = "trial",
Price = 0.00m,
Visible = false
@ -80,8 +73,7 @@ namespace ASC.Migrations.PostgreSql.Migrations
new
{
Tenant = -2,
Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1",
MaxFileSize = 1024L,
Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,file_size:1024,manager:1",
Name = "admin",
Price = 30.00m,
ProductId = "1002",
@ -90,8 +82,7 @@ namespace ASC.Migrations.PostgreSql.Migrations
new
{
Tenant = -3,
Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3",
MaxFileSize = 100L,
Features = "free,audit,ldap,sso,restore,total_size:2147483648,file_size:100,manager:5,rooms:3",
Name = "startup",
Price = 0.00m,
Visible = false

View File

@ -25,27 +25,20 @@
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Files.Core.Core;
public class CountRoomChecker : ITenantQuotaFeatureChecker
public class CountRoomChecker : TenantQuotaFeatureChecker<CountRoomFeature, int>
{
private readonly ITenantQuotaFeatureStatisticCount<CountRoomFeature> _tenantQuotaFeatureStatistic;
public CountRoomChecker(ITenantQuotaFeatureStatisticCount<CountRoomFeature> tenantQuotaFeatureStatistic)
public CountRoomChecker(ITenantQuotaFeatureStat<CountRoomFeature, int> tenantQuotaFeatureStatistic) : base(tenantQuotaFeatureStatistic)
{
_tenantQuotaFeatureStatistic = tenantQuotaFeatureStatistic;
}
public async Task<bool> Check(TenantQuota quota)
{
return await _tenantQuotaFeatureStatistic.GetValue() <= quota.CountRoom;
}
public string Exception(TenantQuota quota)
public override string Exception(TenantQuota quota)
{
return "The number of rooms should not exceed " + quota.MaxTotalSize;
}
}
public class CountRoomCheckerStatistic : ITenantQuotaFeatureStatisticCount<CountRoomFeature>
public class CountRoomCheckerStatistic : ITenantQuotaFeatureStat<CountRoomFeature, int>
{
private readonly IFolderDao<int> _folderDao;
private readonly GlobalFolderHelper _globalFolderHelper;

View File

@ -24,8 +24,6 @@
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
using ASC.Core.Common.Quota;
namespace ASC.Web.Api.Core;
[Scope]
@ -136,24 +134,14 @@ public class QuotaHelper
var maxValue = length.Value == long.MaxValue;
result.Value = maxValue ? -1 : length.Value;
var statisticProvider = (ITenantQuotaFeatureStat<long>)_serviceProvider.GetService(typeof(ITenantQuotaFeatureStatisticLength<>).MakeGenericType(feature.GetType()));
if (statisticProvider != null)
{
used = await statisticProvider.GetValue();
}
await GetStat<long>();
}
else if (feature is TenantQuotaFeature<int> count)
{
var maxValue = count.Value == int.MaxValue;
result.Value = maxValue ? -1 : count.Value;
var statisticProvider = (ITenantQuotaFeatureStat<int>)_serviceProvider.GetService(typeof(ITenantQuotaFeatureStatisticCount<>).MakeGenericType(feature.GetType()));
if (statisticProvider != null)
{
used = await statisticProvider.GetValue();
}
await GetStat<int>();
}
else if (feature is TenantQuotaFeature<bool> flag)
{
@ -192,6 +180,16 @@ public class QuotaHelper
}
yield return result;
async Task GetStat<T>()
{
var statisticProvider = (ITenantQuotaFeatureStat<T>)_serviceProvider.GetService(typeof(ITenantQuotaFeatureStat<,>).MakeGenericType(feature.GetType(), typeof(T)));
if (statisticProvider != null)
{
used = await statisticProvider.GetValue();
}
}
}
}
}

View File

@ -69,6 +69,8 @@ global using ASC.Core.Common.Configuration;
global using ASC.Core.Common.EF;
global using ASC.Core.Common.Notify;
global using ASC.Core.Common.Notify.Push;
global using ASC.Core.Common.Quota;
global using ASC.Core.Common.Quota.Features;
global using ASC.Core.Common.Security;
global using ASC.Core.Common.Settings;
global using ASC.Core.Configuration;
@ -88,6 +90,7 @@ global using ASC.FederatedLogin;
global using ASC.FederatedLogin.Helpers;
global using ASC.FederatedLogin.LoginProviders;
global using ASC.FederatedLogin.Profile;
global using ASC.Files.Core.Core;
global using ASC.Files.Core.EF;
global using ASC.Files.Core.Helpers;
global using ASC.Geolocation;
@ -143,7 +146,6 @@ global using Microsoft.AspNetCore.Mvc;
global using Microsoft.Extensions.Caching.Memory;
global using Microsoft.Extensions.Hosting.WindowsServices;
global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using MimeKit;

View File

@ -24,9 +24,6 @@
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
using ASC.Core.Common.Quota;
using ASC.Core.Common.Quota.Features;
using ASC.Files.Core.Core;
var options = new WebApplicationOptions
{
@ -47,7 +44,7 @@ builder.Host.ConfigureDefault(args, configureServices: (hostContext, services, d
services.AddScoped<ITenantQuotaFeatureChecker, CountRoomChecker>();
services.AddScoped<CountRoomChecker>();
services.AddScoped<ITenantQuotaFeatureStatisticCount<CountRoomFeature>, CountRoomCheckerStatistic>();
services.AddScoped<ITenantQuotaFeatureStat<CountRoomFeature, int>, CountRoomCheckerStatistic>();
services.AddScoped<CountRoomCheckerStatistic>();
});

View File

@ -2166,6 +2166,15 @@ namespace ASC.Web.Core.PublicResources {
}
}
/// <summary>
/// Looks up a localized string similar to Max file size.
/// </summary>
public static string TariffsFeature_file_size {
get {
return ResourceManager.GetString("TariffsFeature_file_size", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Number of managers.
/// </summary>

View File

@ -870,4 +870,7 @@
<data name="TariffsFeature_total_size_price_per" xml:space="preserve">
<value />
</data>
<data name="TariffsFeature_file_size" xml:space="preserve">
<value>Max file size</value>
</data>
</root>