Quota: Quota limit string -> long

This commit is contained in:
Nikolay Rechkin 2022-09-13 00:40:10 +03:00
parent 882445e371
commit 068e3c051b
10 changed files with 15 additions and 17 deletions

View File

@ -150,7 +150,7 @@ public class LdapObjectExtension
var skype = GetContacts(ldapUser, Mapping.Skype, settings);
var quotaSettings = _settingsManager.LoadForTenant<UserQuotaSettings>(_tenantManager.GetCurrentTenant().Id);
var quota = settings.LdapMapping.ContainsKey(Mapping.UserQuotaLimit) ? GetAttribute(ldapUser, settings.LdapMapping[Mapping.UserQuotaLimit]) : quotaSettings.DefaultUserQuota;
var quota = settings.LdapMapping.ContainsKey(Mapping.UserQuotaLimit) ? ByteConverter.ConvertSizeToBytes(GetAttribute(ldapUser, settings.LdapMapping[Mapping.UserQuotaLimit])) : quotaSettings.DefaultUserQuota;
if (string.IsNullOrEmpty(userName))
{
@ -175,7 +175,7 @@ public class LdapObjectExtension
Location = !string.IsNullOrEmpty(location) ? location : string.Empty,
WorkFromDate = _tenantUtil.DateTimeNow(),
ContactsList = contacts,
QuotaLimit = quotaSettings.EnableUserQuota ? quota : ""
QuotaLimit = quotaSettings.EnableUserQuota ? quota : -1
};
if (!string.IsNullOrEmpty(firstName))

View File

@ -81,4 +81,6 @@ global using Microsoft.Extensions.Logging;
global using Novell.Directory.Ldap;
global using Novell.Directory.Ldap.Controls;
global using Novell.Directory.Ldap.Rfc2251;
global using Novell.Directory.Ldap.Utilclass;
global using Novell.Directory.Ldap.Utilclass;
global using ByteConverter = ASC.Core.Common.ByteConverter;

View File

@ -56,7 +56,7 @@ public class EmployeeFullDto : EmployeeDto
public MobilePhoneActivationStatus MobilePhoneActivationStatus { get; set; }
public bool IsSSO { get; set; }
public DarkThemeSettingsEnum? Theme { get; set; }
public string QuotaLimit { get; set; }
public long QuotaLimit { get; set; }
public double UsedSpace { get; set; }
public static new EmployeeFullDto GetSample()

View File

@ -74,7 +74,7 @@ public sealed class UserInfo : IDirectRecipient, ICloneable, IMapFrom<User>
public string SsoNameId { get; set; } // SSO SAML user identificator
public string SsoSessionId { get; set; } // SSO SAML user session identificator
public DateTime CreateDate { get; set; }
public string QuotaLimit { get; set; }
public long QuotaLimit { get; set; }
public override string ToString()
{

View File

@ -73,8 +73,6 @@ public sealed class Constants
private readonly IConfiguration _configuration;
public static readonly string UserNoQuota = "NoQuota";
#region system group and category groups
public static readonly Guid SysGroupCategoryId = new Guid("{7717039D-FBE9-45ad-81C1-68A1AA10CE1F}");

View File

@ -31,14 +31,14 @@ public class UserQuotaSettings : ISettings<UserQuotaSettings>
{
public bool EnableUserQuota { get; set; }
public string DefaultUserQuota { get; set; }
public long DefaultUserQuota { get; set; }
public UserQuotaSettings GetDefault()
{
return new UserQuotaSettings
{
EnableUserQuota = false,
DefaultUserQuota = ""
DefaultUserQuota = -1
};
}

View File

@ -415,9 +415,9 @@ internal class FileDao : AbstractDao, IFileDao<int>
var user = _userManager.GetUsers(file.Id == default ? _authContext.CurrentAccount.ID : file.CreateBy);
var quotaSettings = _settingsManager.LoadForTenant<UserQuotaSettings>(_tenantManager.GetCurrentTenant().Id);
if (!quotaSettings.EnableUserQuota || user.QuotaLimit != Constants.UserNoQuota)
if (!quotaSettings.EnableUserQuota || user.QuotaLimit != -1)
{
var quotaLimit = ByteConverter.ConvertSizeToBytes(user.QuotaLimit);
var quotaLimit = user.QuotaLimit;
var userUsedSpace = Math.Max(0,
_userManager.FindUserQuotaRows(
_tenantManager.GetCurrentTenant().Id,

View File

@ -1105,14 +1105,12 @@ public class UserController : PeopleControllerBase
foreach (var user in users)
{
if (inDto.Quota != Constants.UserNoQuota)
if (inDto.Quota != -1)
{
var usedSpace = await _globalSpace.GetUserUsedSpaceAsync(user.Id);
var quotaBytes = ByteConverter.ConvertSizeToBytes(inDto.Quota);
var tenanSpaceQuota = _tenantExtra.GetTenantQuota().MaxTotalSize;
if (tenanSpaceQuota < quotaBytes || usedSpace > quotaBytes)
if (tenanSpaceQuota < inDto.Quota || usedSpace > inDto.Quota)
{
continue;
}

View File

@ -29,5 +29,5 @@ namespace ASC.People.ApiModels.RequestDto;
public class UpdateMembersQuotaRequestDto
{
public IEnumerable<Guid> UserIds { get; set; }
public string Quota { get; set; }
public long Quota { get; set; }
}

View File

@ -29,6 +29,6 @@ namespace ASC.Web.Api.ApiModel.RequestsDto;
public class UserQuotaSettingsRequestsDto
{
public bool EnableUserQuota { get; set; }
public string DefaultUserQuota { get; set; }
public long DefaultUserQuota { get; set; }
}