/// <summary> /// Common routine used in normal upload and bulk upload. /// </summary> /// <param name="book"></param> /// <param name="progressBox"></param> /// <param name="publishView"></param> /// <param name="parseId"></param> /// <param name="invokeTarget"></param> /// <returns></returns> internal string FullUpload(Book.Book book, LogBox progressBox, PublishView publishView, out string parseId, Form invokeTarget = null) { var bookFolder = book.FolderPath; // Set this in the metadata so it gets uploaded. Do this in the background task as it can take some time. // These bits of data can't easily be set while saving the book because we save one page at a time // and they apply to the book as a whole. book.BookInfo.LanguageTableReferences = _parseClient.GetLanguagePointers(book.CollectionSettings.MakeLanguageUploadData(book.AllLanguages.ToArray())); book.BookInfo.PageCount = book.GetPages().Count(); book.BookInfo.Save(); progressBox.WriteStatus(LocalizationManager.GetString("PublishTab.Upload.MakingThumbnail", "Making thumbnail image...")); MakeThumbnail(book, 70, invokeTarget); MakeThumbnail(book, 256, invokeTarget); //the largest thumbnail I found on Amazon was 300px high. Prathambooks.org about the same. var uploadPdfPath = Path.Combine(bookFolder, Path.ChangeExtension(Path.GetFileName(bookFolder), ".pdf")); // If there is not already a locked preview in the book folder // (which we take to mean the user has created a customized one that he prefers), // make sure we have a current correct preview and then copy it to the book folder so it gets uploaded. if (!FileUtils.IsFileLocked(uploadPdfPath)) { progressBox.WriteStatus(LocalizationManager.GetString("PublishTab.Upload.MakingPdf", "Making PDF Preview...")); publishView.MakePublishPreview(); if (File.Exists(publishView.PdfPreviewPath)) { File.Copy(publishView.PdfPreviewPath, uploadPdfPath, true); } } string result = UploadBook(bookFolder, progressBox, out parseId); return(result); }
/// <summary> /// Common routine used in normal upload and bulk upload. /// </summary> /// <param name="book"></param> /// <param name="progressBox"></param> /// <param name="publishView"></param> /// <param name="languages"></param> /// <param name="parseId"></param> /// <param name="excludeAudio"></param> /// <returns></returns> internal string FullUpload(Book.Book book, LogBox progressBox, PublishView publishView, string[] languages, out string parseId, bool excludeAudio = true) { var bookFolder = book.FolderPath; parseId = ""; // in case of early return // Set this in the metadata so it gets uploaded. Do this in the background task as it can take some time. // These bits of data can't easily be set while saving the book because we save one page at a time // and they apply to the book as a whole. book.BookInfo.LanguageTableReferences = _parseClient.GetLanguagePointers(book.CollectionSettings.MakeLanguageUploadData(languages)); book.BookInfo.PageCount = book.GetPages().Count(); book.BookInfo.Save(); progressBox.WriteStatus(LocalizationManager.GetString("PublishTab.Upload.MakingThumbnail", "Making thumbnail image...")); //the largest thumbnail I found on Amazon was 300px high. Prathambooks.org about the same. _thumbnailer.MakeThumbnailOfCover(book, 70); // this is a sacrificial one to prime the pump, to fix BL-2673 _thumbnailer.MakeThumbnailOfCover(book, 70); if (progressBox.CancelRequested) { return(""); } _thumbnailer.MakeThumbnailOfCover(book, 256); if (progressBox.CancelRequested) { return(""); } // It is possible the user never went back to the Collection tab after creating/updating the book, in which case // the 'normal' thumbnail never got created/updating. See http://issues.bloomlibrary.org/youtrack/issue/BL-3469. _thumbnailer.MakeThumbnailOfCover(book); if (progressBox.CancelRequested) { return(""); } var uploadPdfPath = UploadPdfPath(bookFolder); // If there is not already a locked preview in the book folder // (which we take to mean the user has created a customized one that he prefers), // make sure we have a current correct preview and then copy it to the book folder so it gets uploaded. if (!FileUtils.IsFileLocked(uploadPdfPath)) { progressBox.WriteStatus(LocalizationManager.GetString("PublishTab.Upload.MakingPdf", "Making PDF Preview...")); publishView.MakePublishPreview(); if (RobustFile.Exists(publishView.PdfPreviewPath)) { RobustFile.Copy(publishView.PdfPreviewPath, uploadPdfPath, true); } } if (progressBox.CancelRequested) { return(""); } return(UploadBook(bookFolder, progressBox, out parseId, Path.GetFileName(uploadPdfPath), excludeAudio)); }