Closed pineportal closed 3 years ago
i am add this code. But the image is deleted automatically
public class CarouselAlbumProvider : IAlbumProvider, IMediaTrackDetector
{
public const string Name = "carousel";
private readonly CarouselObjectContext _dbContext;
public CarouselAlbumProvider(CarouselObjectContext dbContext)
{
_dbContext = dbContext;
}
public IEnumerable<MediaAlbum> GetAlbums()
{
MediaAlbum album = new MediaAlbum()
{
Name = "carousel",
ResKey = "Plugins.FriendlyName.SmartPlugins.Carousel",
CanDetectTracks = true
};
yield return album;
}
public AlbumDisplayHint GetDisplayHint(MediaAlbum album)
{
return null;
}
public void ConfigureTracks(string albumName, TrackedMediaPropertyTable table)
{
if (albumName == "carousel")
{
table.Register<CarouselItemRecord>(x => x.BackgroundGraphicId);
}
}
public IEnumerable<MediaTrack> DetectAllTracks(string albumName)
{
var ctx = _dbContext;
string name = nameof(CarouselItemRecord);
var p = new FastPager<CarouselItemRecord>(ctx.Set<CarouselItemRecord>().AsNoTracking().Where(x => x.BackgroundGraphicId > 0), 5000);
while (p.ReadNextPage(x => new { x.Id, x.BackgroundGraphicId }, x => x.Id, out var list))
{
foreach (var x in list)
{
yield return new MediaTrack { EntityId = x.Id, EntityName = name, MediaFileId = x.BackgroundGraphicId, Property = nameof(x.BackgroundGraphicId) };
}
}
}
}
I am use IMediaTracker in Controller. fix problem
after upload file IsTransient is true; how to change in false?