public void Apply(ComicBookFile comic, FileInfo file, IArchive archive, IEnumerable <IArchiveEntry> pages) { comic.Id = file.FullName.GetHashCode().ToString("X"); comic.Path = file.FullName; comic.OriginalName = file.Name.Remove(file.Name.IndexOf(file.Extension)); comic.Extension = file.Extension; comic.Created = DateTime.Now; }
private string getThumbBase(ComicBookFile comic) { var rootDirectoryparts = config.ComicRepositoryPath.Split(new[] { Path.DirectorySeparatorChar }); var parts = comic.Path.Split(new[] { '.' }).ToList(); var directory = string.Join(".", parts.Take(parts.Count() - 1)); var directoryParts = directory.Split(new[] { Path.DirectorySeparatorChar }); var thumbNameDirectoryParts = directoryParts.Take(rootDirectoryparts.Length) .Concat(new[] { "_thumbs_" }) .Concat(directoryParts.Skip(rootDirectoryparts.Length)); return string.Join(Path.DirectorySeparatorChar.ToString(), thumbNameDirectoryParts); }
private ComicPageFile GetPagefile(ComicBookFile comic, string thumbDirectory, int index, Size imageSize) { var fileName = string.Format("{0}-{1}.{{0}}.{2}", comic.Id, index, "jpg"); return new ComicPageFile() { ComicId = comic.Id, Page = index, FileNameMask = Path.Combine(thumbDirectory, fileName), Height = imageSize.Height, Width = imageSize.Width }; }
public void Apply(ComicBookFile comic, FileInfo file, IArchive archive, IEnumerable<IArchiveEntry> pages) { var index = 0; var thumbDirectory = getThumbBase(comic); Console.WriteLine("Generating Thumbnails in: {0}", thumbDirectory); foreach (var page in pages) { using (var imgStream = page.OpenEntryStream()) using (var image = Image.Load(imgStream)) { var pageFile = GetPagefile(comic, thumbDirectory, index, image.Size()); GenerateThumbnails(pageFile, image); this.context.Pages.Add(pageFile); index++; } Console.Write("."); } Console.Write("\n"); comic.Length = index; }
public virtual ComicBookFile LoadFile(FileInfo file) { return(InArchive(file, (archive, pages) => { ComicBookFile comic = null; try { if (archive.IsSolid) { return null; } // TODO add processing to solid files. comic = new ComicBookFile(); foreach (var interigator in this.interigators) { interigator.Apply(comic, file, archive, pages); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return comic; })); }
public void Store(ComicBookFile file) { this.context.Add(file); this.context.SaveChanges(); }
public void Store(ComicBookFile file) { this.Files.Add(file.Id, file); }