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 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; }
public LibraryModel(string pathToLibrary, CollectionSettings collectionSettings, SendReceiver sendReceiver, BookSelection bookSelection, SourceCollectionsList sourceCollectionsList, BookCollection.Factory bookCollectionFactory, EditBookCommand editBookCommand, CreateFromSourceBookCommand createFromSourceBookCommand, BookServer bookServer, CurrentEditableCollectionSelection currentEditableCollectionSelection) { _bookSelection = bookSelection; _pathToLibrary = pathToLibrary; _collectionSettings = collectionSettings; _sendReceiver = sendReceiver; _sourceCollectionsList = sourceCollectionsList; _bookCollectionFactory = bookCollectionFactory; _editBookCommand = editBookCommand; _bookServer = bookServer; _currentEditableCollectionSelection = currentEditableCollectionSelection; createFromSourceBookCommand.Subscribe(CreateFromSourceBook); }
/// <summary> /// Handles the recursion through directories: if a folder looks like a Bloom book upload it; otherwise, try its children. /// Invisible folders like .hg are ignored. /// </summary> /// <param name="folder"></param> /// <param name="dlg"></param> /// <param name="container"></param> /// <param name="context"></param> private void UploadInternal(string folder, BulkUploadProgressDlg dlg, ApplicationContainer container, ref ProjectContext context) { if (Path.GetFileName(folder).StartsWith(".")) return; // secret folder, probably .hg if (Directory.GetFiles(folder, "*.htm").Count() == 1) { // Exactly one htm file, assume this is a bloom book folder. dlg.Progress.WriteMessage("Starting to upload " + folder); // Make sure the files we want to upload are up to date. // Unfortunately this requires making a book object, which requires making a ProjectContext, which must be created with the // proper parent book collection if possible. var parent = Path.GetDirectoryName(folder); var collectionPath = Directory.GetFiles(parent, "*.bloomCollection").FirstOrDefault(); if (collectionPath == null && context == null) { collectionPath = Settings.Default.MruProjects.Latest; } if (context == null || context.SettingsPath != collectionPath) { if (context != null) context.Dispose(); // optimise: creating a context seems to be quite expensive. Probably the only thing we need to change is // the collection. If we could update that in place...despite autofac being told it has lifetime scope...we would save some time. // Note however that it's not good enough to just store it in the project context. The one that is actually in // the autofac object (_scope in the ProjectContext) is used by autofac to create various objects, in particular, books. context = container.CreateProjectContext(collectionPath); } var server = context.BookServer; var book = server.GetBookFromBookInfo(new BookInfo(folder, true)); book.BringBookUpToDate(new NullProgress()); // Assemble the various arguments needed to make the objects normally involved in an upload. // We leave some constructor arguments not actually needed for this purpose null. var bookSelection = new BookSelection(); bookSelection.SelectBook(book); var currentEditableCollectionSelection = new CurrentEditableCollectionSelection(); if (collectionPath != null) { var collection = new BookCollection(collectionPath, BookCollection.CollectionType.SourceCollection, bookSelection); currentEditableCollectionSelection.SelectCollection(collection); } var publishModel = new PublishModel(bookSelection, new PdfMaker(), currentEditableCollectionSelection, null, server, _thumbnailer, null); publishModel.PageLayout = book.GetLayout(); var view = new PublishView(publishModel, new SelectedTabChangedEvent(), new LocalizationChangedEvent(), this, null, null); string dummy; // Normally we let the user choose which languages to upload. Here, just the ones that have complete information. var langDict = book.AllLanguages; var languagesToUpload = langDict.Keys.Where(l => langDict[l]).ToArray(); if (languagesToUpload.Any()) FullUpload(book, dlg.Progress, view, languagesToUpload, out dummy, dlg); return; } foreach (var sub in Directory.GetDirectories(folder)) UploadInternal(sub, dlg, container, ref context); }