2022-03-15 18:00:53 +00:00
|
|
|
|
// (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.EF;
|
2022-02-15 11:52:43 +00:00
|
|
|
|
|
|
|
|
|
public class DbQuota : BaseEntity, IMapFrom<TenantQuota>
|
2019-12-02 09:12:16 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
public int Tenant { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
public long MaxFileSize { get; set; }
|
|
|
|
|
public long MaxTotalSize { get; set; }
|
|
|
|
|
public int ActiveUsers { get; set; }
|
|
|
|
|
public string Features { get; set; }
|
|
|
|
|
public decimal Price { get; set; }
|
|
|
|
|
public string AvangateId { get; set; }
|
|
|
|
|
public bool Visible { get; set; }
|
|
|
|
|
|
|
|
|
|
public override object[] GetKeys()
|
2019-12-02 09:12:16 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
return new object[] { Tenant };
|
|
|
|
|
}
|
2022-02-15 10:30:05 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
public void Mapping(Profile profile)
|
|
|
|
|
{
|
|
|
|
|
profile.CreateMap<TenantQuota, DbQuota>()
|
|
|
|
|
.ForMember(dest => dest.MaxFileSize, opt => opt.MapFrom(src => ByteConverter.GetInMBytes(src.MaxFileSize)))
|
|
|
|
|
.ForMember(dest => dest.MaxTotalSize, opt => opt.MapFrom(src => ByteConverter.GetInMBytes(src.MaxTotalSize)));
|
2019-12-02 09:12:16 +00:00
|
|
|
|
}
|
2022-02-15 11:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
public static class DbQuotaExtension
|
|
|
|
|
{
|
|
|
|
|
public static ModelBuilderWrapper AddDbQuota(this ModelBuilderWrapper modelBuilder)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
modelBuilder
|
|
|
|
|
.Add(MySqlAddDbQuota, Provider.MySql)
|
|
|
|
|
.Add(PgSqlAddDbQuota, Provider.PostgreSql)
|
|
|
|
|
.HasData(
|
|
|
|
|
new DbQuota
|
|
|
|
|
{
|
|
|
|
|
Tenant = -1,
|
|
|
|
|
Name = "default",
|
|
|
|
|
Description = null,
|
|
|
|
|
MaxFileSize = 102400,
|
|
|
|
|
MaxTotalSize = 10995116277760,
|
|
|
|
|
ActiveUsers = 10000,
|
|
|
|
|
Features = "domain,audit,controlpanel,healthcheck,ldap,sso,whitelabel,branding,ssbranding,update,support,portals:10000,discencryption,privacyroom,restore",
|
|
|
|
|
Price = decimal.Parse("0,00"),
|
|
|
|
|
AvangateId = "0",
|
|
|
|
|
Visible = false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return modelBuilder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MySqlAddDbQuota(this ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<DbQuota>(entity =>
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.HasKey(e => e.Tenant)
|
|
|
|
|
.HasName("PRIMARY");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-07-08 11:24:18 +00:00
|
|
|
|
entity.ToTable("tenants_quota")
|
|
|
|
|
.HasCharSet("utf8");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-07-08 11:24:18 +00:00
|
|
|
|
entity.Property(e => e.Tenant)
|
|
|
|
|
.HasColumnName("tenant")
|
|
|
|
|
.ValueGeneratedNever();
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-07-08 11:24:18 +00:00
|
|
|
|
entity.Property(e => e.ActiveUsers)
|
|
|
|
|
.HasColumnName("active_users")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.AvangateId)
|
|
|
|
|
.HasColumnName("avangate_id")
|
|
|
|
|
.HasColumnType("varchar(128)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Description)
|
|
|
|
|
.HasColumnName("description")
|
|
|
|
|
.HasColumnType("varchar(128)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Features)
|
|
|
|
|
.HasColumnName("features")
|
|
|
|
|
.HasColumnType("text")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-07-08 11:24:18 +00:00
|
|
|
|
entity.Property(e => e.MaxFileSize)
|
|
|
|
|
.HasColumnName("max_file_size")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-07-08 11:24:18 +00:00
|
|
|
|
entity.Property(e => e.MaxTotalSize)
|
|
|
|
|
.HasColumnName("max_total_size")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Name)
|
|
|
|
|
.HasColumnName("name")
|
|
|
|
|
.HasColumnType("varchar(128)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Price)
|
|
|
|
|
.HasColumnName("price")
|
2022-07-08 11:24:18 +00:00
|
|
|
|
.HasDefaultValueSql("'0.00'")
|
2022-02-15 11:52:43 +00:00
|
|
|
|
.HasColumnType("decimal(10,2)");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-07-08 11:24:18 +00:00
|
|
|
|
entity.Property(e => e.Visible)
|
|
|
|
|
.HasColumnName("visible")
|
|
|
|
|
.HasColumnType("int")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2022-02-15 11:52:43 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
public static void PgSqlAddDbQuota(this ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<DbQuota>(entity =>
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.HasKey(e => e.Tenant)
|
|
|
|
|
.HasName("tenants_quota_pkey");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.ToTable("tenants_quota", "onlyoffice");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Tenant)
|
|
|
|
|
.HasColumnName("tenant")
|
|
|
|
|
.ValueGeneratedNever();
|
2020-09-29 17:09:39 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.ActiveUsers).HasColumnName("active_users");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.AvangateId)
|
|
|
|
|
.HasColumnName("avangate_id")
|
|
|
|
|
.HasMaxLength(128)
|
|
|
|
|
.HasDefaultValueSql("NULL");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Description)
|
|
|
|
|
.HasColumnName("description")
|
|
|
|
|
.HasColumnType("character varying");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Features).HasColumnName("features");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.MaxFileSize)
|
|
|
|
|
.HasColumnName("max_file_size")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.MaxTotalSize)
|
|
|
|
|
.HasColumnName("max_total_size")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Name)
|
|
|
|
|
.HasColumnName("name")
|
|
|
|
|
.HasColumnType("character varying");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Price)
|
|
|
|
|
.HasColumnName("price")
|
|
|
|
|
.HasColumnType("numeric(10,2)")
|
|
|
|
|
.HasDefaultValueSql("0.00");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Visible).HasColumnName("visible");
|
|
|
|
|
});
|
2020-08-21 02:34:37 +00:00
|
|
|
|
}
|
2019-12-02 09:12:16 +00:00
|
|
|
|
}
|