protected void ProcessAccountArchivedStatuses( Guid accountId, AccountDbContext accountDbContext, User[] users, Dictionary <Guid, Component> components, Dictionary <Guid, Subscription[]> userToSubscriptions, ILogger logger, Guid?componentId = null) { // получим архивные статусы var archivedStatusRepository = accountDbContext.GetArchivedStatusRepository(); var archivedStatuses = archivedStatusRepository .GetTop(1000) .Include(x => x.Event) .ToArray(); if (componentId.HasValue) { archivedStatuses = archivedStatuses.Where(t => t.Event.OwnerId == componentId.Value).ToArray(); } var now = Now(); var statuses = new List <StatusInfo>(archivedStatuses.Length); foreach (var archivedStatus in archivedStatuses) { DbProcessor.CancellationToken.ThrowIfCancellationRequested(); var eventObj = archivedStatus.Event; components.TryGetValue(eventObj.OwnerId, out var component); if (component == null) { continue; } // удалим, чтобы больше не обрабатывать archivedStatusRepository.Delete(archivedStatus); var status = StatusInfo.Create(eventObj, component, now); statuses.Add(status); } ProcessAccountInternal( accountId, users, userToSubscriptions, statuses, accountDbContext, logger); }