private void CreateFromSourceBook(Book.Book sourceBook) { try { var newBook = _bookServer.CreateFromSourceBook(sourceBook, TheOneEditableCollection.PathToDirectory); if (newBook == null) { return; //This can happen if there is a configuration dialog and the user clicks Cancel } TheOneEditableCollection.AddBookInfo(newBook.BookInfo); if (_bookSelection != null) { _bookSelection.SelectBook(newBook); } //enhance: would be nice to know if this is a new shell if (sourceBook.IsShellOrTemplate) { Analytics.Track("Create Book", new Dictionary <string, string>() { { "Category", sourceBook.CategoryForUsageReporting } }); } _editBookCommand.Raise(newBook); } catch (Exception e) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(e, "Bloom ran into an error while creating that book. (Sorry!)"); } }
public void DoUpdatesOfAllBooks(IProgress progress) { int i = 0; foreach (var bookInfo in TheOneEditableCollection.GetBookInfos()) { i++; var book = _bookServer.GetBookFromBookInfo(bookInfo); //gets overwritten: progress.WriteStatus(book.TitleBestForUserDisplay); progress.WriteMessage("Processing " + book.TitleBestForUserDisplay + " " + i + "/" + TheOneEditableCollection.GetBookInfos().Count()); book.BringBookUpToDate(progress); } }
public void UpdateLabelOfBookInEditableCollection(Book.Book book) { // We can find a more efficient way to do this if necessary. //ReloadEditableCollection(); // This allows it to get resorted. Is that good? It may move dramatically, even disappear from the screen. TheOneEditableCollection.UpdateBookInfo(book.BookInfo); // This actually changes the label. (One would think that re-rendering the collection would do this, // but somehow the way we are caching the book title as state in anticipation of the following // message was preventing this. It might be redundant now.) BookCommandsApi.UpdateButtonTitle(_webSocketServer, book.BookInfo, book.NameBestForUserDisplay); // happens as a side effect //_webSocketServer.SendEvent("editableCollectionList", "reload:" + _bookCollections[0].PathToDirectory); }
public bool DeleteBook(Book.Book book) //, BookCollection collection) { Debug.Assert(book == _bookSelection.CurrentSelection); if (_bookSelection.CurrentSelection != null && _bookSelection.CurrentSelection.CanDelete) { if (IsCurrentBookInCollection()) { if (!_tcManager.CanEditBook()) { var msg = LocalizationManager.GetString("TeamCollection.CheckOutForDelete", "Please check out the book before deleting it."); ErrorReport.NotifyUserOfProblem(msg); return(false); } if (_tcManager.CannotDeleteBecauseDisconnected(_bookSelection.CurrentSelection.FolderPath)) { var msg = LocalizationManager.GetString("TeamCollection.ConnectForDelete", "Please connect to the Team Collection before deleting books that are part of it."); ErrorReport.NotifyUserOfProblem(msg); return(false); } } var title = _bookSelection.CurrentSelection.TitleBestForUserDisplay; var confirmRecycleDescription = L10NSharp.LocalizationManager.GetString("CollectionTab.ConfirmRecycleDescription", "The book '{0}'"); if (ConfirmRecycleDialog.JustConfirm(string.Format(confirmRecycleDescription, title), false, "Palaso")) { // The sequence of these is a bit arbitrary. We'd like to delete the book in both places. // Either could conceivably fail. If something goes wrong with removing the selection // from it (very unlikely), we may as well leave nothing changed. If we delete it from // the local collection but fail to delete it from the repo, it will come back at the // next startup. If we delete it from the repo but fail to delete it locally, // it will just stick around, and at least the desired team collection result has // been achieved and the local result won't be a surprise later. So it seems marginally // better to do them in this order. _bookSelection.SelectBook(null); _tcManager.CurrentCollection?.DeleteBookFromRepo(book.FolderPath); TheOneEditableCollection.DeleteBook(book.BookInfo); #if Chorus _sendReceiver.CheckInNow(string.Format("Deleted '{0}'", title)); #endif return(true); } } return(false); }
public bool DeleteBook(Book.Book book) //, BookCollection collection) { Debug.Assert(book == _bookSelection.CurrentSelection); if (_bookSelection.CurrentSelection != null && _bookSelection.CurrentSelection.CanDelete) { var title = _bookSelection.CurrentSelection.TitleBestForUserDisplay; var confirmRecycleDescription = L10NSharp.LocalizationManager.GetString("CollectionTab.ConfirmRecycleDescription", "The book '{0}'"); if (ConfirmRecycleDialog.JustConfirm(string.Format(confirmRecycleDescription, title), false, "Palaso")) { TheOneEditableCollection.DeleteBook(book.BookInfo); _bookSelection.SelectBook(null); _sendReceiver.CheckInNow(string.Format("Deleted '{0}'", title)); return(true); } } return(false); }
public void DuplicateBook(Book.Book book) { var newBookDir = book.Storage.Duplicate(); // Get rid of any TC status we copied from the original, so Bloom treats it correctly as a new book. BookStorage.RemoveLocalOnlyFiles(newBookDir); ReloadEditableCollection(); var dupInfo = TheOneEditableCollection.GetBookInfos() .FirstOrDefault(info => info.FolderPath == newBookDir); if (dupInfo != null) { var newBook = GetBookFromBookInfo(dupInfo); SelectBook(newBook); BookHistory.AddEvent(newBook, BookHistoryEventType.Created, $"Duplicated from existing book \"{book.Title}\""); } }
private void CreateFromSourceBook(Book.Book sourceBook) { var newBook = _bookServer.CreateFromSourceBook(sourceBook, TheOneEditableCollection.PathToDirectory); TheOneEditableCollection.AddBookInfo(newBook.BookInfo); if (_bookSelection != null) { _bookSelection.SelectBook(newBook); } //enhance: would be nice to know if this is a new shell if (sourceBook.IsShellOrTemplate) { Analytics.Track("Create Book", new Dictionary <string, string>() { { "Category", sourceBook.CategoryForUsageReporting } }); } _editBookCommand.Raise(newBook); }
public void DoChecksOfAllBooksBackgroundWork(ProgressDialogBackground dialog, string pathToFolderOfReplacementImages) { var bookInfos = TheOneEditableCollection.GetBookInfos(); var count = bookInfos.Count(); if (count == 0) { return; } foreach (var bookInfo in bookInfos) { //not allowed in this thread: dialog.ProgressBar.Value++; dialog.Progress.ProgressIndicator.PercentCompleted += 100 / count; var book = _bookServer.GetBookFromBookInfo(bookInfo); dialog.Progress.WriteMessage("Checking " + book.TitleBestForUserDisplay); book.CheckBook(dialog.Progress, pathToFolderOfReplacementImages); dialog.ProgressString.WriteMessage(""); } dialog.ProgressBar.Value++; }
private void CreateFromSourceBook(Book.Book sourceBook) { try { var newBook = _bookServer.CreateFromSourceBook(sourceBook, TheOneEditableCollection.PathToDirectory); if (newBook == null) { return; //This can happen if there is a configuration dialog and the user clicks Cancel } TheOneEditableCollection.AddBookInfo(newBook.BookInfo); if (_bookSelection != null) { Book.Book.SourceToReportForNextRename = Path.GetFileName(sourceBook.FolderPath); _bookSelection.SelectBook(newBook, aboutToEdit: true); } //enhance: would be nice to know if this is a new shell if (sourceBook.IsShellOrTemplate) { Analytics.Track("Create Book", new Dictionary <string, string>() { { "Category", sourceBook.CategoryForUsageReporting }, { "BookId", newBook.ID }, { "Country", _collectionSettings.Country } }); } // Better reported in Book_BookTitleChanged as a side effect of selecting it. // BookHistory.AddEvent(newBook, BookHistoryEventType.Created, "New book created"); _editBookCommand.Raise(newBook); } catch (Exception e) { SIL.Reporting.ErrorReport.NotifyUserOfProblem(e, "Bloom ran into an error while creating that book. (Sorry!)"); } }