public void ShowAndDoWork(Action <IProgress> work) { _work = work; Progress.ProgressIndicator = ProgressBar; Progress.AddStatusProgress(_status); Progress.AddMessageProgress(_messageLabelProgress); Progress.Add(new ApplicationDoEventsProgress()); //this will keep our UI alive var stringProgress = new StringBuilderProgress(); Progress.Add(stringProgress); Application.Idle += StartWorking; ShowDialog(); if (Progress.ErrorEncountered) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem("There was a problem performing that operation.\r\n\r\n" + stringProgress.Text); } }
public void ErrorsEncountered_ErrorOriginatesWithOneHandler_MultiProgressHasErrorsEncountered() { var multiProgress = new MultiProgress(); var statusProgress = new StatusProgress(); multiProgress.Add(statusProgress); var consoleProgress = new ConsoleProgress(); multiProgress.AddMessageProgress(consoleProgress); statusProgress.WriteError("some error happened!"); Assert.That(multiProgress.ErrorEncountered, Is.True); }
public void ErrorsEncountered_ErrorOriginatesWithMultiProgress_BothHandlersHaveErrorsEncountered() { var multiProgress = new MultiProgress(); var statusProgress = new StatusProgress(); multiProgress.Add(statusProgress); var consoleProgress = new ConsoleProgress(); multiProgress.AddMessageProgress(consoleProgress); multiProgress.WriteError("error!"); Assert.That(consoleProgress.ErrorEncountered, Is.True); Assert.That(statusProgress.ErrorEncountered, Is.True); }
public SyncControlModel(ProjectFolderConfiguration projectFolderConfiguration, SyncUIFeatures uiFeatureFlags, IChorusUser user) { _user = user; _progress = new MultiProgress(); StatusProgress = new SimpleStatusProgress(); _progress.Add(StatusProgress); Features = uiFeatureFlags; _synchronizer = Synchronizer.FromProjectConfiguration(projectFolderConfiguration, _progress); _backgroundWorker = new BackgroundWorker(); _backgroundWorker.WorkerSupportsCancellation = true; _backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_backgroundWorker_RunWorkerCompleted); _backgroundWorker.DoWork += worker_DoWork; //clients will normally change these SyncOptions = new SyncOptions(); SyncOptions.CheckinDescription = "[" + Application.ProductName + ": " + Application.ProductVersion + "] sync"; SyncOptions.DoPullFromOthers = true; SyncOptions.DoMergeWithOthers = true; SyncOptions.RepositorySourcesToTry.AddRange(GetRepositoriesToList().Where(r => r.Enabled)); }
public void AddProgress(IProgress p) { _progress.Add(p); }
/// <summary> /// Upload bloom books in the specified folder to the bloom library. /// Folders that contain exactly one .htm file are interpreted as books and uploaded. /// Other folders are searched recursively for children that appear to be bloom books. /// The parent folder of a bloom book is searched for a .bloomCollection file and, if one is found, /// the book is treated as part of that collection (e.g., for determining vernacular language). /// If the .bloomCollection file is not found, the book is not uploaded. /// N.B. The bulk upload process will go ahead and upload templates and books that are already on the server /// (over-writing the existing book) without informing the user. /// </summary> /// <remarks>This method is triggered by starting Bloom with "upload" on the cmd line.</remarks> public void BulkUpload(ApplicationContainer container, UploadParameters options) { BookUpload.Destination = options.Dest; using (var progress = new MultiProgress()) { var logFilePath = Path.Combine(options.Path, "BloomBulkUploadLog.txt"); progress.Add(new Bloom.Utils.ConsoleProgress()); progress.Add(new FileLogProgress(logFilePath)); if (!_singleBookUploader.IsThisVersionAllowedToUpload()) { var oldVersionMsg = LocalizationManager.GetString("PublishTab.Upload.OldVersion", "Sorry, this version of Bloom Desktop is not compatible with the current version of BloomLibrary.org. Please upgrade to a newer version."); progress.WriteMessage(oldVersionMsg); return; } Debug.Assert(!String.IsNullOrWhiteSpace(options.UploadUser)); if (!_singleBookUploader.ParseClient.AttemptSignInAgainForCommandLine(options.UploadUser, options.Dest, progress)) { progress.WriteError("Problem logging in. See messages above."); System.Environment.Exit(1); } progress.WriteMessage("Uploading books as user {0}", options.UploadUser); var bookParams = new BookUploadParameters(options); BulkRepairInstanceIds(options.Path); ProjectContext context = null; // Expensive to create; hold each one we make until we find a book that needs a different one. try { _collectionFoldersUploaded = new HashSet <string>(); _newBooksUploaded = 0; _booksUpdated = 0; _booksSkipped = 0; _booksWithErrors = 0; progress.WriteMessageWithColor("green", $"\n\nStarting upload at {DateTime.Now.ToString()}\n"); progress.WriteMessageWithColor("Magenta", $"Looking in '{bookParams.Folder}'..."); UploadCollectionOrKeepLookingDeeper(progress, container, bookParams, ref context); if (_collectionFoldersUploaded.Count > 0) { progress.WriteMessageWithColor("green", "\n\nAll finished!"); progress.WriteMessage("Processed {0} collection folders.", _collectionFoldersUploaded.Count); } else { progress.WriteError("Did not find any collections to upload."); } progress.WriteMessage("Uploaded {0} new books.", _newBooksUploaded); progress.WriteMessage("Updated {0} books that had changed.", _booksUpdated); progress.WriteMessage("Skipped {0} books that had not changed.", _booksSkipped); if (_booksSkipped > 0) { progress.WriteMessage("(If you don't want Bloom to skip books it thinks have not changed, you can use the --force argument to force all books to re-upload, or just use the Bloom UI to force upload this one book)."); } if (_booksWithErrors > 0) { progress.WriteError("Failed to upload {0} books. See \"{1}\" for details.", _booksWithErrors, logFilePath); } } finally { context?.Dispose(); } } }