Example #1
0
        public static DataTable GetHotBooks(int top, int notop)
        {
            #region 查询热门图书
            return(BookServer.GetHotBooks(top, notop));

            #endregion
        }
Example #2
0
        public static bool SearchISBN(string isbn)
        {
            #region 查询是否存在ISBN
            return(BookServer.SearchISBN(isbn));

            #endregion
        }
Example #3
0
        public static DataTable GetNewMonthBooks(int top)
        {
            #region 查询本月最新图书
            return(BookServer.GetNewMonthBooks(top));

            #endregion
        }
Example #4
0
        public static Books GetBookDetailById(int Id)
        {
            #region 通过图书Id获取图书详细信息
            return(BookServer.GetBookDetailById(Id));

            #endregion
        }
Example #5
0
        public CollectionModel(string pathToCollection, CollectionSettings collectionSettings,
                               BookSelection bookSelection,
                               SourceCollectionsList sourceCollectionsList,
                               BookCollection.Factory bookCollectionFactory,
                               EditBookCommand editBookCommand,
                               CreateFromSourceBookCommand createFromSourceBookCommand,
                               BookServer bookServer,
                               CurrentEditableCollectionSelection currentEditableCollectionSelection,
                               BookThumbNailer thumbNailer,
                               TeamCollectionManager tcManager,
                               BloomWebSocketServer webSocketServer,
                               BookCollectionHolder bookCollectionHolder,
                               LocalizationChangedEvent localizationChangedEvent)
        {
            _bookSelection         = bookSelection;
            _pathToCollection      = pathToCollection;
            _collectionSettings    = collectionSettings;
            _sourceCollectionsList = sourceCollectionsList;
            _bookCollectionFactory = bookCollectionFactory;
            _editBookCommand       = editBookCommand;
            _bookServer            = bookServer;
            _currentEditableCollectionSelection = currentEditableCollectionSelection;
            _thumbNailer              = thumbNailer;
            _tcManager                = tcManager;
            _webSocketServer          = webSocketServer;
            _bookCollectionHolder     = bookCollectionHolder;
            _localizationChangedEvent = localizationChangedEvent;

            createFromSourceBookCommand.Subscribe(CreateFromSourceBook);
        }
                                                    BloomWebSocketServer webSocketServer); //autofac uses this

        public BulkBloomPubCreator(BookServer bookServer, CollectionModel collectionModel,
                                   BloomWebSocketServer webSocketServer)
        {
            _bookServer      = bookServer;
            _collectionModel = collectionModel;
            _webSocketServer = webSocketServer;
        }
Example #7
0
        public static void Save(Book.Book book, BookServer bookServer, Color backColor, WebSocketProgress progress, AndroidPublishSettings settings = null)
        {
            var progressWithL10N = progress.WithL10NPrefix("PublishTab.Android.File.Progress.");

            var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            if (!string.IsNullOrWhiteSpace(Settings.Default.BloomDeviceFileExportFolder) && Directory.Exists(Settings.Default.BloomDeviceFileExportFolder))
            {
                folder = Settings.Default.BloomDeviceFileExportFolder;
            }
            var initialPath = Path.Combine(folder, book.Storage.FolderName + BookCompressor.BloomPubExtensionWithDot);

            var bloomdFileDescription = LocalizationManager.GetString("PublishTab.Android.bloomdFileFormatLabel", "Bloom Book for Devices",
                                                                      "This is shown in the 'Save' dialog when you save a bloom book in the format that works with the Bloom Reader Android App");
            var filter = $"{bloomdFileDescription}|*{BookCompressor.BloomPubExtensionWithDot}";

            var destFileName = Utils.MiscUtils.GetOutputFilePathOutsideCollectionFolder(initialPath, filter);

            if (String.IsNullOrEmpty(destFileName))
            {
                return;
            }

            Settings.Default.BloomDeviceFileExportFolder = Path.GetDirectoryName(destFileName);
            PublishToAndroidApi.CheckBookLayout(book, progress);
            PublishToAndroidApi.SendBook(book, bookServer, destFileName, null,
                                         progressWithL10N,
                                         (publishedFileName, bookTitle) => progressWithL10N.GetMessageWithParams("Saving", "{0} is a file path", "Saving as {0}", destFileName),
                                         null,
                                         backColor,
                                         settings: settings);
            PublishToAndroidApi.ReportAnalytics("file", book);
        }
Example #8
0
        /// <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);
        }
Example #9
0
        public static void Save(Book.Book book, BookServer bookServer, Color backColor, WebSocketProgress progress, AndroidPublishSettings settings = null)
        {
            var progressWithL10N = progress.WithL10NPrefix("PublishTab.Android.File.Progress.");

            using (var dlg = new DialogAdapters.SaveFileDialogAdapter())
            {
                dlg.DefaultExt = BookCompressor.ExtensionForDeviceBloomBook;
                var bloomdFileDescription = LocalizationManager.GetString("PublishTab.Android.bloomdFileFormatLabel", "Bloom Book for Devices", "This is shown in the 'Save' dialog when you save a bloom book in the format that works with the Bloom Reader Android App");
                dlg.Filter   = $"{bloomdFileDescription}|*{BookCompressor.ExtensionForDeviceBloomBook}";
                dlg.FileName = Path.GetFileName(book.FolderPath) + BookCompressor.ExtensionForDeviceBloomBook;
                if (!string.IsNullOrWhiteSpace(Settings.Default.BloomDeviceFileExportFolder) &&
                    Directory.Exists(Settings.Default.BloomDeviceFileExportFolder))
                {
                    dlg.InitialDirectory = Settings.Default.BloomDeviceFileExportFolder;
                    //(otherwise leave to default save location)
                }
                dlg.OverwritePrompt = true;
                if (DialogResult.OK == dlg.ShowDialog())
                {
                    Settings.Default.BloomDeviceFileExportFolder = Path.GetDirectoryName(dlg.FileName);
                    PublishToAndroidApi.CheckBookLayout(book, progress);
                    PublishToAndroidApi.SendBook(book, bookServer, dlg.FileName, null,
                                                 progressWithL10N,
                                                 (publishedFileName, bookTitle) => progressWithL10N.GetMessageWithParams("Saving", "{0} is a file path", "Saving as {0}", dlg.FileName),
                                                 null,
                                                 backColor,
                                                 settings: settings);
                    PublishToAndroidApi.ReportAnalytics("file", book);
                }
            }
        }
Example #10
0
 public override void Setup()
 {
     base.Setup();
     Program.SetUpLocalization(new ApplicationContainer());
     _bookServer = CreateBookServer();
     s_bookSelection.SelectBook(CreateBook());
 }
Example #11
0
        public static DataTable GetBookListDataTable(string CategorieId, string order, string search)
        {
            #region 返回所有图书列表
            return(BookServer.GetBookListDataTable(CategorieId, order, search));

            #endregion
        }
Example #12
0
        /// <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);
        }
        public static string StageBloomD(Book.Book book, BookServer bookServer, WebSocketProgress progress, Color backColor, AndroidPublishSettings settings = null)
        {
            progress.Message("PublishTab.Epub.PreparingPreview", "Preparing Preview");                  // message shared with Epub publishing
            if (settings?.LanguagesToInclude != null)
            {
                var message = new LicenseChecker().CheckBook(book, settings.LanguagesToInclude.ToArray());
                if (message != null)
                {
                    progress.MessageWithoutLocalizing(message, MessageKind.Error);
                    return(null);
                }
            }

            _stagingFolder?.Dispose();
            if (AudioProcessor.IsAnyCompressedAudioMissing(book.FolderPath, book.RawDom))
            {
                progress.Message("CompressingAudio", "Compressing audio files");
                AudioProcessor.TryCompressingAudioAsNeeded(book.FolderPath, book.RawDom);
            }
            // We don't use the folder found here, but this method does some checks we want done.
            BookStorage.FindBookHtmlInFolder(book.FolderPath);
            _stagingFolder = new TemporaryFolder(StagingFolder);
            var modifiedBook = BloomReaderFileMaker.PrepareBookForBloomReader(book.FolderPath, bookServer, _stagingFolder, progress, settings: settings);

            progress.Message("Common.Done", "Shown in a list of messages when Bloom has completed a task.", "Done");
            return(modifiedBook.FolderPath.ToLocalhost());
        }
Example #14
0
        public LibraryModel(string pathToLibrary, CollectionSettings collectionSettings,
                            //SendReceiver sendReceiver,
                            BookSelection bookSelection,
                            SourceCollectionsList sourceCollectionsList,
                            BookCollection.Factory bookCollectionFactory,
                            EditBookCommand editBookCommand,
                            CreateFromSourceBookCommand createFromSourceBookCommand,
                            BookServer bookServer,
                            CurrentEditableCollectionSelection currentEditableCollectionSelection,
                            BookThumbNailer thumbNailer,
                            TeamCollectionManager tcManager)
        {
            _bookSelection      = bookSelection;
            _pathToLibrary      = pathToLibrary;
            _collectionSettings = collectionSettings;
            //_sendReceiver = sendReceiver;
            _sourceCollectionsList = sourceCollectionsList;
            _bookCollectionFactory = bookCollectionFactory;
            _editBookCommand       = editBookCommand;
            _bookServer            = bookServer;
            _currentEditableCollectionSelection = currentEditableCollectionSelection;
            _thumbNailer = thumbNailer;
            _tcManager   = tcManager;

            createFromSourceBookCommand.Subscribe(CreateFromSourceBook);
        }
Example #15
0
        /// <summary>
        /// Creates an ePub file at the location specified by parameters
        /// </summary>
        /// <param name="parameters">BookPath and epubOutputPath should be set.</param>
        /// <param name="control">The epub code needs a control that goes back to the main thread, in order to run some tasks that need to be on the main thread</param>
        public static void CreateEpubArtifact(CreateArtifactsParameters parameters, Control control)
        {
            if (String.IsNullOrEmpty(parameters.EpubOutputPath))
            {
                return;
            }

            string directoryName = Path.GetDirectoryName(parameters.EpubOutputPath);

            Directory.CreateDirectory(directoryName);                   // Ensures that the directory exists

            BookServer      bookServer  = _projectContext.BookServer;
            BookThumbNailer thumbNailer = _projectContext.ThumbNailer;
            var             maker       = new EpubMaker(thumbNailer, bookServer);

            maker.ControlForInvoke = control;

            maker.Book            = _book;
            maker.Unpaginated     = true;         // so far they all are
            maker.OneAudioPerPage = true;         // default used in EpubApi
            // Enhance: maybe we want book to have image descriptions on page? use reader font sizes?

            // Make the epub
            maker.SaveEpub(parameters.EpubOutputPath, new NullWebSocketProgress());
        }
Example #16
0
 public void WithDefaultValues()
 {
     this._collectionSettings    = new CollectionSettings();
     this._bookSelection         = new BookSelection();
     this._teamCollectionManager = null;                 // ENHANCE: This would be better off calling the builder for TeamCollectionManager, when it's implemented.
     this._bookServer            = null;
     this._bloomWebSocketServer  = null;
 }
Example #17
0
        public static void EditBook(Books book)
        {
            #region 更新图书信息

            BookServer.EditBook(book);

            #endregion
        }
 public TeamCollectionApiBuilder WithDefaultMocks()
 {
     this.MockCollectionSettings    = new Mock <CollectionSettings>();
     this.MockBookSelection         = new Mock <BookSelection>();
     this.MockTeamCollectionManager = new Mock <ITeamCollectionManager>();
     this._bookServer           = null;
     this._bloomWebSocketServer = null;
     return(this);
 }
Example #19
0
        // Create a BloomReader book while also creating the temporary folder for it (according to the specified parameter) and disposing of it
        public static void CreateBloomPub(string outputPath, string bookFolderPath, BookServer bookServer,

                                          IWebSocketProgress progress, bool isTemplateBook, string tempFolderName = BRExportFolder,
                                          string creator = kCreatorBloom, AndroidPublishSettings settings = null)
        {
            using (var temp = new TemporaryFolder(tempFolderName))
            {
                CreateBloomPub(outputPath, bookFolderPath, bookServer, progress, temp, creator, isTemplateBook, settings);
            }
        }
Example #20
0
 public PublishEpubApi(BookThumbNailer thumbNailer, NavigationIsolator isolator, BookServer bookServer,
                       BookSelection bookSelection, CollectionSettings collectionSettings, BloomWebSocketServer webSocketServer)
 {
     _thumbNailer        = thumbNailer;
     _bookServer         = bookServer;
     _bookSelection      = bookSelection;
     _collectionSettings = collectionSettings;
     _webSocketServer    = webSocketServer;
     _standardProgress   = new WebSocketProgress(_webSocketServer, kWebsocketContext);
 }
        /// <summary>
        /// Creates the .bloomd and bloomdigital folders
        /// </summary>
        private static CreateArtifactsExitCode CreateBloomDigitalArtifacts(string bookPath, string creator, string zippedBloomDOutputPath, string unzippedBloomDigitalOutputPath)
        {
#if DEBUG
            // Useful for allowing debugging of Bloom while running the harvester
            //MessageBox.Show("Attach debugger now");
#endif
            var exitCode = CreateArtifactsExitCode.Success;

            using (var tempBloomD = TempFile.CreateAndGetPathButDontMakeTheFile())
            {
                if (String.IsNullOrEmpty(zippedBloomDOutputPath))
                {
                    zippedBloomDOutputPath = tempBloomD.Path;
                }

                BookServer bookServer = _projectContext.BookServer;

                var  metadata       = BookMetaData.FromFolder(bookPath);
                bool isTemplateBook = metadata.IsSuitableForMakingShells;

                using (var folderForUnzipped = new TemporaryFolder("BloomCreateArtifacts_Unzipped"))
                {
                    // Ensure directory exists, just in case.
                    Directory.CreateDirectory(Path.GetDirectoryName(zippedBloomDOutputPath));
                    // Make the bloomd
                    string unzippedPath = Publish.Android.BloomPubMaker.CreateBloomPub(
                        zippedBloomDOutputPath,
                        bookPath,
                        bookServer,
                        System.Drawing.Color.Azure,                 // TODO: What should this be?
                        new Bloom.web.NullWebSocketProgress(),
                        folderForUnzipped,
                        creator,
                        isTemplateBook);

                    // Currently the zipping process does some things we actually need, like making the cover picture
                    // transparent (BL-7437). Eventually we plan to separate the preparation and zipping steps (BL-7445).
                    // Until that is done, the most reliable way to get an unzipped BloomD for our preview is to actually
                    // unzip the BloomD.
                    if (!String.IsNullOrEmpty(unzippedBloomDigitalOutputPath))
                    {
                        SIL.IO.RobustIO.DeleteDirectory(unzippedBloomDigitalOutputPath, recursive: true);                           // In case the folder isn't already empty

                        // Ensure directory exists, just in case.
                        Directory.CreateDirectory(Path.GetDirectoryName(unzippedBloomDigitalOutputPath));

                        ZipFile.ExtractToDirectory(zippedBloomDOutputPath, unzippedBloomDigitalOutputPath);

                        exitCode |= RenameBloomDigitalFiles(unzippedBloomDigitalOutputPath);
                    }
                }
            }

            return(exitCode);
        }
Example #22
0
 // Called by autofac, which creates the one instance and registers it with the server.
 public TeamCollectionApi(CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings settings, BookSelection bookSelection, ITeamCollectionManager tcManager, BookServer bookServer, BloomWebSocketServer socketServer)
 {
     _currentBookCollectionSelection = currentBookCollectionSelection;
     _settings  = settings;
     _tcManager = tcManager;
     _tcManager.CurrentCollection?.SetupMonitoringBehavior();
     _bookSelection = bookSelection;
     _socketServer  = socketServer;
     _bookServer    = bookServer;
     TheOneInstance = this;
 }
 public static AndroidPublishSettings GetPublishSettingsForBook(BookServer bookServer, BookInfo bookInfo)
 {
     // Normally this is setup by the Publish screen, but if you've never visited the Publish screen for this book,
     // then this will be null. In that case, initialize it here.
     if (bookInfo.PublishSettings.BloomPub.TextLangs == null)
     {
         var book         = bookServer.GetBookFromBookInfo(bookInfo);
         var allLanguages = book.AllPublishableLanguages(includeLangsOccurringOnlyInXmatter: true);
         PublishToAndroidApi.InitializeLanguagesInBook(bookInfo, allLanguages, book.CollectionSettings);
     }
     return(FromBookInfo(bookInfo));
 }
Example #24
0
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings, BookServer bookServer)
 {
     BookSelection = bookSelection;
     _pdfMaker     = pdfMaker;
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged);
     BookletPortion                  = BookletPortions.BookletPages;
 }
        public PublishToAndroidApi(BloomWebSocketServer bloomWebSocketServer, BookServer bookServer, RuntimeImageProcessor imageProcessor)
        {
            _webSocketServer = bloomWebSocketServer;
            _bookServer      = bookServer;
            _imageProcessor  = imageProcessor;
            _progress        = new WebSocketProgress(_webSocketServer, kWebSocketContext);
            _wifiPublisher   = new WiFiPublisher(_progress, _bookServer);
#if !__MonoCS__
            _usbPublisher = new UsbPublisher(_progress, _bookServer)
            {
                Stopped = () => SetState("stopped")
            };
#endif
        }
        public PublishToAndroidApi(CollectionSettings collectionSettings, BloomWebSocketServer bloomWebSocketServer, BookServer bookServer, BulkBloomPubCreator bulkBloomPubCreator)
        {
            _collectionSettings  = collectionSettings;
            _webSocketServer     = bloomWebSocketServer;
            _bookServer          = bookServer;
            _bulkBloomPubCreator = bulkBloomPubCreator;
            _progress            = new WebSocketProgress(_webSocketServer, kWebSocketContext);
            _wifiPublisher       = new WiFiPublisher(_progress, _bookServer);
#if !__MonoCS__
            _usbPublisher = new UsbPublisher(_progress, _bookServer)
            {
                Stopped = () => SetState("stopped")
            };
#endif
        }
Example #27
0
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings,
                     BookServer bookServer, BookThumbNailer thumbNailer, NavigationIsolator isolator)
 {
     BookSelection = bookSelection;
     _pdfMaker     = pdfMaker;
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     _thumbNailer                    = thumbNailer;
     bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged);
     _isoloator = isolator;
     //we don't want to default anymore: BookletPortion = BookletPortions.BookletPages;
 }
Example #28
0
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings,
                     BookServer bookServer, BookThumbNailer thumbNailer)
 {
     BookSelection         = bookSelection;
     _pdfMaker             = pdfMaker;
     _pdfMaker.CompressPdf = true;               // See http://issues.bloomlibrary.org/youtrack/issue/BL-3721.
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     _thumbNailer                    = thumbNailer;
     bookSelection.SelectionChanged += OnBookSelectionChanged;
     //we don't want to default anymore: BookletPortion = BookletPortions.BookletPages;
 }
Example #29
0
 public TeamCollectionApiBuilder WithDefaultMocks(bool addFakeBookFolderPath = false)
 {
     this.MockCollectionSettings = new Mock <CollectionSettings>();
     this.MockBookSelection      = new Mock <BookSelection>();
     if (addFakeBookFolderPath)
     {
         var book = new Mock <Bloom.Book.Book>();
         book.Setup(m => m.FolderPath).Returns("");
         MockBookSelection.Setup(m => m.CurrentSelection).Returns(book.Object);
     }
     this.MockTeamCollectionManager = new Mock <ITeamCollectionManager>();
     this._bookServer           = null;
     this._bloomWebSocketServer = null;
     return(this);
 }
        private BookServer CreateBookServer()
        {
            var collectionSettings =
                new CollectionSettings(new NewCollectionSettings()
            {
                PathToSettingsFile  = CollectionSettings.GetPathForNewSettings(_projectFolder.Path, "test"),
                Language1Iso639Code = "xyz"
            });
            var server = new BookServer((bookInfo, storage) =>
            {
                return(new Bloom.Book.Book(bookInfo, storage, null, collectionSettings,
                                           new PageSelection(),
                                           new PageListChangedEvent(), new BookRefreshEvent()));
            }, (path, forSelectedBook) => new BookStorage(path, _fileLocator, null, collectionSettings), () => _starter, null);

            return(server);
        }