Quota: fix
This commit is contained in:
parent
ac0e87e581
commit
ea86b81c7e
@ -60,12 +60,6 @@ public class AuthManager
|
||||
|
||||
public IAccount GetAccountByID(int tenantId, Guid id)
|
||||
{
|
||||
var tenant = _tenantManager.GetCurrentTenant(false);
|
||||
if (tenant == null)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(tenantId);
|
||||
}
|
||||
|
||||
var s = Configuration.Constants.SystemAccounts.FirstOrDefault(a => a.ID == id);
|
||||
if (s != null)
|
||||
{
|
||||
|
@ -130,10 +130,9 @@ public class FilesSpaceUsageStatManager : SpaceUsageStatManager, IUserSpaceUsage
|
||||
.SumAsync(r => r.ContentLength);
|
||||
}
|
||||
|
||||
public async Task RecalculateUserQuota(int TenantId, Guid userId)
|
||||
public void RecalculateUserQuota(int TenantId, Guid userId)
|
||||
{
|
||||
|
||||
var size = await GetUserSpaceUsageAsync(userId);
|
||||
var size = GetUserSpaceUsageAsync(userId).Result;
|
||||
|
||||
_tenantManager.SetTenantQuotaRow(
|
||||
new TenantQuotaRow { Tenant = TenantId, Path = $"/{FileConstant.ModuleId}/", Counter = size, Tag = WebItemManager.DocumentsProductID.ToString(), UserId = userId, LastModified = DateTime.UtcNow },
|
||||
|
@ -82,9 +82,6 @@ public class UsersQuotaSyncJob : DistributedTaskProgress
|
||||
{
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly IDaoFactory _daoFactory;
|
||||
private readonly WebItemManagerSecurity _webItemManagerSecurity;
|
||||
private readonly SecurityContext _securityContext;
|
||||
private readonly AuthManager _authentication;
|
||||
|
||||
protected readonly IDbContextFactory<FilesDbContext> _dbContextFactory;
|
||||
|
||||
@ -103,24 +100,16 @@ public class UsersQuotaSyncJob : DistributedTaskProgress
|
||||
}
|
||||
}
|
||||
|
||||
public UsersQuotaSyncJob(IServiceScopeFactory serviceScopeFactory,
|
||||
IDaoFactory daoFactory,
|
||||
WebItemManagerSecurity webItemManagerSecurity,
|
||||
SecurityContext securityContext,
|
||||
AuthManager authentication
|
||||
)
|
||||
public UsersQuotaSyncJob(IServiceScopeFactory serviceScopeFactory, IDaoFactory daoFactory)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_daoFactory = daoFactory;
|
||||
_webItemManagerSecurity = webItemManagerSecurity;
|
||||
_securityContext = securityContext;
|
||||
_authentication = authentication;
|
||||
}
|
||||
public void InitJob(Tenant tenant)
|
||||
{
|
||||
TenantId = tenant.Id;
|
||||
}
|
||||
protected override async void DoJob()
|
||||
protected override void DoJob()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -128,9 +117,10 @@ public class UsersQuotaSyncJob : DistributedTaskProgress
|
||||
|
||||
var _tenantManager = scope.ServiceProvider.GetRequiredService<TenantManager>();
|
||||
var _userManager = scope.ServiceProvider.GetRequiredService<UserManager>();
|
||||
|
||||
_tenantManager.SetCurrentTenant(TenantId);
|
||||
|
||||
var _authentication = scope.ServiceProvider.GetRequiredService<AuthManager>();
|
||||
var _securityContext = scope.ServiceProvider.GetRequiredService<SecurityContext>();
|
||||
var _webItemManagerSecurity = scope.ServiceProvider.GetRequiredService<WebItemManagerSecurity>();
|
||||
|
||||
var users = _userManager.GetUsers();
|
||||
var webItems = _webItemManagerSecurity.GetItems(Web.Core.WebZones.WebZoneType.All, ItemAvailableState.All);
|
||||
|
||||
@ -150,8 +140,7 @@ public class UsersQuotaSyncJob : DistributedTaskProgress
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
await manager.RecalculateUserQuota(TenantId, user.Id);
|
||||
manager.RecalculateUserQuota(TenantId, user.Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,5 +44,5 @@ public interface IUserSpaceUsage
|
||||
{
|
||||
Task<long> GetUserSpaceUsageAsync(Guid userId);
|
||||
|
||||
Task RecalculateUserQuota(int tenantId, Guid userId);
|
||||
void RecalculateUserQuota(int tenantId, Guid userId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user