Quota: fix
This commit is contained in:
parent
b1bd5a100f
commit
21075fd4c3
@ -60,6 +60,12 @@ 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)
|
||||
{
|
||||
|
@ -132,13 +132,12 @@ public class FilesSpaceUsageStatManager : SpaceUsageStatManager, IUserSpaceUsage
|
||||
|
||||
public async Task RecalculateUserQuota(int TenantId, Guid userId)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(TenantId);
|
||||
|
||||
|
||||
var size = await GetUserSpaceUsageAsync(userId);
|
||||
|
||||
_tenantManager.SetTenantQuotaRow(
|
||||
new TenantQuotaRow { Tenant = TenantId, Path = $"/{FileConstant.ModuleId}/", Counter = size, Tag = WebItemManager.DocumentsProductID.ToString(), UserId = userId, LastModified = DateTime.UtcNow },
|
||||
true);
|
||||
false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,10 +82,10 @@ public class UsersQuotaSyncJob : DistributedTaskProgress
|
||||
{
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly IDaoFactory _daoFactory;
|
||||
private readonly FilesSpaceUsageStatManager _filesSpaceUsageStatManager;
|
||||
private readonly WebItemManager _webItemManager;
|
||||
private readonly WebItemManagerSecurity _webItemManagerSecurity;
|
||||
|
||||
private readonly SecurityContext _securityContext;
|
||||
private readonly AuthManager _authentication;
|
||||
|
||||
protected readonly IDbContextFactory<FilesDbContext> _dbContextFactory;
|
||||
|
||||
|
||||
@ -105,16 +105,16 @@ public class UsersQuotaSyncJob : DistributedTaskProgress
|
||||
|
||||
public UsersQuotaSyncJob(IServiceScopeFactory serviceScopeFactory,
|
||||
IDaoFactory daoFactory,
|
||||
FilesSpaceUsageStatManager filesSpaceUsageStatManager,
|
||||
WebItemManager webItemManager,
|
||||
WebItemManagerSecurity webItemManagerSecurity
|
||||
WebItemManagerSecurity webItemManagerSecurity,
|
||||
SecurityContext securityContext,
|
||||
AuthManager authentication
|
||||
)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_daoFactory = daoFactory;
|
||||
_filesSpaceUsageStatManager = filesSpaceUsageStatManager;
|
||||
_webItemManager = webItemManager;
|
||||
_webItemManagerSecurity = webItemManagerSecurity;
|
||||
_securityContext = securityContext;
|
||||
_authentication = authentication;
|
||||
}
|
||||
public void InitJob(Tenant tenant)
|
||||
{
|
||||
@ -131,16 +131,13 @@ public class UsersQuotaSyncJob : DistributedTaskProgress
|
||||
|
||||
_tenantManager.SetCurrentTenant(TenantId);
|
||||
|
||||
var fileDao = _daoFactory.GetFileDao<int>();
|
||||
|
||||
var users = _userManager.GetUsers();
|
||||
var webItems = _webItemManagerSecurity.GetItems(Web.Core.WebZones.WebZoneType.All, ItemAvailableState.All);
|
||||
|
||||
foreach (var user in users)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(TenantId);
|
||||
var spaceUsage = _filesSpaceUsageStatManager.GetUserSpaceUsageAsync(user.Id);
|
||||
|
||||
var account = _authentication.GetAccountByID(TenantId, user.Id);
|
||||
_securityContext.AuthenticateMe(account);
|
||||
|
||||
foreach (var item in webItems)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user