public override IEnumerable <NamedEntity> Enlist() { var pager = new FastPager <Product>(Query.AsNoTracking(), Context.MaximumNodeCount); while (pager.ReadNextPage(x => new { x.Id, x.UpdatedOnUtc }, x => x.Id, out var products)) { if (Context.CancellationToken.IsCancellationRequested) { break; } foreach (var x in products) { yield return(new NamedEntity { EntityName = "Product", Id = x.Id, LastMod = x.UpdatedOnUtc }); } } }
public override IEnumerable <NamedEntity> Enlist() { // Enlist forum groups foreach (var group in _groups) { yield return(new NamedEntity { EntityName = nameof(ForumGroup), Id = group.Id, LastMod = group.UpdatedOnUtc }); } // Enlist forums foreach (var forum in _forums) { yield return(new NamedEntity { EntityName = nameof(Forum), Id = forum.Id, LastMod = forum.UpdatedOnUtc }); } // Enlist topics var pager = new FastPager <ForumTopic>(_topicsQuery.AsNoTracking(), _context.MaximumNodeCount); while (pager.ReadNextPage(x => new { x.Id, x.UpdatedOnUtc, x.Subject }, x => x.Id, out var topics)) { if (_context.CancellationToken.IsCancellationRequested) { break; } foreach (var x in topics) { yield return(new NamedEntity { EntityName = nameof(ForumTopic), Slug = (new ForumTopic { Subject = x.Subject }).GetSeName(), Id = x.Id, LastMod = x.UpdatedOnUtc }); } } }
public IEnumerable <MediaTrackAction> DetectAllTracks(string albumName) { var ctx = _dbContext; var entityName = string.Empty; // TODO: Messages, Forums (?), Store (?) // Products if (albumName == Products) { // Products { var name = nameof(ProductMediaFile); var p = new FastPager <ProductMediaFile>(ctx.Set <ProductMediaFile>().AsNoTracking()); while (p.ReadNextPage(x => new { x.Id, x.ProductId, x.MediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { yield return(new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId }); } } } // ProductAttributeOption { var name = nameof(ProductAttributeOption); var p = new FastPager <ProductAttributeOption>(ctx.Set <ProductAttributeOption>().AsNoTracking().Where(x => x.MediaFileId > 0)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { yield return(new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId }); } } } // ProductVariantAttributeValue { var name = nameof(ProductVariantAttributeValue); var p = new FastPager <ProductVariantAttributeValue>(ctx.Set <ProductVariantAttributeValue>().AsNoTracking().Where(x => x.MediaFileId > 0)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { yield return(new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId }); } } } // SpecificationAttributeOption { var name = nameof(SpecificationAttributeOption); var p = new FastPager <SpecificationAttributeOption>(ctx.Set <SpecificationAttributeOption>().AsNoTracking().Where(x => x.MediaFileId > 0)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { yield return(new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId }); } } } yield break; } // Categories if (albumName == Categories) { var name = nameof(Category); var p = new FastPager <Category>(ctx.Set <Category>().AsNoTracking().Where(x => x.MediaFileId.HasValue)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { yield return(new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId.Value }); } } yield break; } // Brands if (albumName == Brands) { var name = nameof(Manufacturer); var p = new FastPager <Manufacturer>(ctx.Set <Manufacturer>().AsNoTracking().Where(x => x.MediaFileId.HasValue)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { yield return(new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId.Value }); } } yield break; } // BlogPost if (albumName == Blog) { var name = nameof(BlogPost); var p = new FastPager <BlogPost>(ctx.Set <BlogPost>().AsNoTracking().Where(x => x.MediaFileId.HasValue || x.PreviewMediaFileId.HasValue)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId, x.PreviewMediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { if (x.MediaFileId.HasValue) { yield return new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId.Value } } ; if (x.PreviewMediaFileId.HasValue) { yield return new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.PreviewMediaFileId.Value } } ; } } yield break; } // NewsItem if (albumName == News) { var name = nameof(NewsItem); var p = new FastPager <NewsItem>(ctx.Set <NewsItem>().AsNoTracking().Where(x => x.MediaFileId.HasValue || x.PreviewMediaFileId.HasValue)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId, x.PreviewMediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { if (x.MediaFileId.HasValue) { yield return new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId.Value } } ; if (x.PreviewMediaFileId.HasValue) { yield return new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.PreviewMediaFileId.Value } } ; } } yield break; } // Customer if (albumName == Customers) { var name = nameof(Customers); // Avatars var p = new FastPager <GenericAttribute>(ctx.Set <GenericAttribute>().AsNoTracking() .Where(x => x.KeyGroup == nameof(Customer) && x.Key == SystemCustomerAttributeNames.AvatarPictureId)); while (p.ReadNextPage(x => new { x.Id, x.EntityId, x.Value }, x => x.Id, out var list)) { foreach (var x in list) { var id = x.Value.ToInt(); if (id > 0) { yield return(new MediaTrackAction { EntityId = x.EntityId, EntityName = name, MediaFileId = id }); } } } yield break; } // Downloads if (albumName == Downloads) { var name = nameof(Download); var p = new FastPager <Download>(ctx.Set <Download>().AsNoTracking().Where(x => x.MediaFileId.HasValue)); while (p.ReadNextPage(x => new { x.Id, x.MediaFileId }, x => x.Id, out var list)) { foreach (var x in list) { yield return(new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.MediaFileId.Value }); } } yield break; } // Messages if (albumName == Messages) { var name = nameof(MessageTemplate); var p = new FastPager <MessageTemplate>(ctx.Set <MessageTemplate>().AsNoTracking()); while (p.ReadNextPage(x => new { x.Id, x.Attachment1FileId, x.Attachment2FileId, x.Attachment3FileId }, x => x.Id, out var list)) { foreach (var x in list) { if (x.Attachment1FileId.HasValue) { yield return new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.Attachment1FileId.Value } } ; if (x.Attachment2FileId.HasValue) { yield return new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.Attachment2FileId.Value } } ; if (x.Attachment3FileId.HasValue) { yield return new MediaTrackAction { EntityId = x.Id, EntityName = name, MediaFileId = x.Attachment3FileId.Value } } ; } } yield break; } } #endregion } }