/// <summary> /// tempFolderPath is where to put the book. Note that a few files (e.g., customCollectionStyles.css) /// are copied into its parent in order to be in the expected location relative to the book, /// so that needs to be a folder we can write in. /// </summary> public static Book.Book MakeDeviceXmatterTempBook(string bookFolderPath, BookServer bookServer, string tempFolderPath, bool isTemplateBook, Dictionary <string, int> omittedPageLabels = null) { BookStorage.CopyDirectory(bookFolderPath, tempFolderPath); BookStorage.EnsureSingleHtmFile(tempFolderPath); // We can always save in a temp book var bookInfo = new BookInfo(tempFolderPath, true, new AlwaysEditSaveContext()) { UseDeviceXMatter = !isTemplateBook }; var modifiedBook = bookServer.GetBookFromBookInfo(bookInfo); modifiedBook.BringBookUpToDate(new NullProgress(), true); modifiedBook.RemoveNonPublishablePages(omittedPageLabels); var domForVideoProcessing = modifiedBook.OurHtmlDom; var videoContainerElements = HtmlDom.SelectChildVideoElements(domForVideoProcessing.RawDom.DocumentElement).Cast <XmlElement>(); if (videoContainerElements.Any()) { SignLanguageApi.ProcessVideos(videoContainerElements, modifiedBook.FolderPath); } modifiedBook.Save(); modifiedBook.UpdateSupportFiles(); return(modifiedBook); }
/// <summary> /// If we do not have enterprise enabled, copy the book and remove all enterprise level features. /// </summary> internal static bool PrepareBookForUpload(ref Book.Book book, BookServer bookServer, string tempFolderPath, IProgress progress) { if (book.CollectionSettings.HaveEnterpriseFeatures) { return(false); } // We need to be sure that any in-memory changes have been written to disk // before we start copying/loading the new book to/from disk book.Save(); Directory.CreateDirectory(tempFolderPath); BookStorage.CopyDirectory(book.FolderPath, tempFolderPath); var bookInfo = new BookInfo(tempFolderPath, true); var copiedBook = bookServer.GetBookFromBookInfo(bookInfo); copiedBook.BringBookUpToDate(new NullProgress(), true); var pages = new List <XmlElement>(); foreach (XmlElement page in copiedBook.GetPageElements()) { pages.Add(page); } ISet <string> warningMessages = new HashSet <string>(); PublishHelper.RemoveEnterpriseFeaturesIfNeeded(copiedBook, pages, warningMessages); PublishHelper.SendBatchedWarningMessagesToProgress(warningMessages, progress); copiedBook.Save(); copiedBook.Storage.UpdateSupportFiles(); book = copiedBook; return(true); }
/// <summary> /// tempFolderPath is where to put the book. Note that a few files (e.g., customCollectionStyles.css) /// are copied into its parent in order to be in the expected location relative to the book, /// so that needs to be a folder we can write in. /// </summary> public static Book.Book MakeDeviceXmatterTempBook(string bookFolderPath, BookServer bookServer, string tempFolderPath, HashSet <string> omittedPageLabels = null) { BookStorage.CopyDirectory(bookFolderPath, tempFolderPath); var bookInfo = new BookInfo(tempFolderPath, true) { UseDeviceXMatter = true }; var modifiedBook = bookServer.GetBookFromBookInfo(bookInfo); modifiedBook.BringBookUpToDate(new NullProgress(), true); modifiedBook.RemoveNonPublishablePages(omittedPageLabels); var domForVideoProcessing = modifiedBook.OurHtmlDom; var videoContainerElements = HtmlDom.SelectChildVideoElements(domForVideoProcessing.RawDom.DocumentElement).Cast <XmlElement>(); if (videoContainerElements.Any()) { SignLanguageApi.ProcessVideos(videoContainerElements, modifiedBook.FolderPath); } modifiedBook.Save(); modifiedBook.Storage.UpdateSupportFiles(); return(modifiedBook); }