Пример #1
0
 private static void RecordThumbnail(ThumbnailViewModel thumbnail)
 {
     try
     {
         ThumbnailFacade.InsertOrReplace(thumbnail);
         s_logger.Debug($"Recorded Thumbnail into database. {thumbnail.ToString()}");
     }
     catch (Exception e)
     {
         s_logger.Error(e);
     }
 }
Пример #2
0
        public static void DeleteThumbnail(ImageViewModel target, DataOperationUnit dataOpUnit = null)
        {
            Contract.Requires(target != null);
            Contract.Requires(target.Thumbnail != null);

            var deleting = target.Thumbnail;

            target.Thumbnail = null;

            Thread.Sleep(0);

            File.Delete(deleting.AbsoluteMasterPath);
            s_logger.Debug($"Deleted File:{deleting.AbsoluteMasterPath}");

            ThumbnailFacade.DeleteWhereIDIs(deleting.ID);
        }
Пример #3
0
        private static void CreateEntities(ILibrary _libraryVM, PageViewModel _page, CoverSegmenting cs, DataOperationUnit dataOpUnit)
        {
            Guid imageID = Guid.NewGuid();
            var  image   = new ImageViewModel(imageID, "cover", cs._masterPath, Configuration.ApplicationConfiguration);

            image.Configuration  = Configuration.ApplicationConfiguration;
            image.ID             = imageID;
            image.UnescapedTitle = "cover";
            if (System.IO.Path.IsPathRooted(cs._masterPath))
            {
                image.RelativeMasterPath = ImageViewModel.MakeRelativeMasterPath(Configuration.ApplicationConfiguration.WorkingDirectory, cs._masterPath);
            }
            else
            {
                image.RelativeMasterPath = cs._masterPath;
            }
            ImageFacade.Insert(image, dataOpUnit);

            var pageID = Guid.NewGuid();
            var page   = new PageViewModel();

            page.Configuration  = Configuration.ApplicationConfiguration;
            page.ID             = pageID;
            page.UnescapedTitle = "cover";
            page.ImageID        = imageID;
            page.BookID         = _page.BookID;
            page.PageIndex      = 1;
            page.Image          = image;
            PageFacade.Insert(page, dataOpUnit);

            var book = _libraryVM.OnStage.Where(b => b.ID.Equals(_page.BookID)).Single();

            book.FirstPage = page;
            if (book.FirstPage.Image.ThumbnailRecorded)
            {
                book.FirstPage.Image.Thumbnail = ThumbnailFacade.FindByImageID(book.FirstPage.ImageID, dataOpUnit);
            }

            if (!book.FirstPage.Image.ThumbnailLoaded || !book.FirstPage.Image.ThumbnailGenerated)
            {
                ThumbnailGenerating.GenerateThumbnail(book.FirstPage.Image, dataOpUnit);
            }

            cs._book = book;
        }
Пример #4
0
 internal static void DeleteRecordFromStorage(PageViewModel page, DataOperationUnit dataOpUnit = null)
 {
     Debug.Assert(page != null);
     PageFacade.DeleteWhereIDIs(page.ID, dataOpUnit);
     ImageFacade.DeleteWhereIDIs(page.ImageID, dataOpUnit);
     if (page.Image != null)
     {
         var image = page.Image;
         if (image.ThumbnailRecorded)
         {
             if (!image.ThumbnailLoaded)
             {
                 image.Thumbnail = ThumbnailFacade.FindByImageID(image.ID, dataOpUnit);
             }
             ThumbnailFacade.DeleteWhereIDIs(image.Thumbnail.ID, dataOpUnit);
         }
     }
 }
Пример #5
0
        public static void GenerateThumbnailIf(BookViewModel book, DataOperationUnit dataOpUnit = null)
        {
            var firstPage = book.FirstPage;

            if (firstPage != null)
            {
                var firstPageImage = firstPage.Image;

                if (!firstPageImage.ThumbnailLoaded)
                {
                    firstPageImage.Thumbnail = ThumbnailFacade.FindByImageID(firstPageImage.ID, dataOpUnit);
                }

                if (!firstPageImage.ThumbnailLoaded ||
                    firstPageImage.Thumbnail?.RelativeMasterPath == null ||
                    !firstPageImage.ThumbnailGenerated)
                {
                    ThumbnailGenerating.GenerateThumbnail(firstPageImage, dataOpUnit);
                }
            }
        }