コード例 #1
0
 /// <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 .bloomContainer file and, if one is found,
 /// the book is treated as part of that collection (e.g., for determining vernacular language).
 /// If no collection is found there it uses whatever collection was last open, or the current default.
 /// 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>
 /// <param name="folder"></param>
 /// <param name="container"></param>
 /// <param name="excludeAudio"></param>
 /// <remarks>This method is triggered by starting Bloom with "upload" on the cmd line.</remarks>
 public void UploadFolder(string folder, ApplicationContainer container, bool excludeAudio = false)
 {
     if (!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.");
         Console.WriteLine(oldVersionMsg);
     }
     if (!LogIn(Settings.Default.WebUserId, Settings.Default.WebPassword))
     {
         SIL.Reporting.ErrorReport.NotifyUserOfProblem("Could not log you in using user='******' and pwd='" + Settings.Default.WebPassword + "'." + System.Environment.NewLine +
                                                       "For some reason, from the command line, we cannot get these credentials out of Settings.Default. However if you place your command line arguments in the properties of the project in visual studio and run from there, it works. If you are already doing that and get this message, then try running Bloom normally (gui), go to publish, and make sure you are logged in. Then quit and try this again.");
         Console.WriteLine("\nFailed to login.");
         return;
     }
     using (var dlg = new BulkUploadProgressDlg())
     {
         var worker = new BackgroundWorker();
         worker.WorkerReportsProgress = true;
         worker.DoWork             += BackgroundUpload;
         worker.RunWorkerCompleted += (sender, args) =>
         {
             if (args.Error != null)
             {
                 throw args.Error;
             }
             dlg.Close();
         };
         worker.RunWorkerAsync(new object[] { folder, dlg, container, excludeAudio });
         dlg.ShowDialog();                 // waits until worker completed closes it.
     }
 }
コード例 #2
0
 /// <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 .bloomContainer file and, if one is found,
 /// the book is treated as part of that collection (e.g., for determining vernacular language).
 /// If no collection is found there it uses whatever collection was last open, or the current default.
 /// </summary>
 /// <param name="folder"></param>
 public void UploadFolder(string folder, ApplicationContainer container)
 {
     if (!LogIn(Settings.Default.WebUserId, Settings.Default.WebPassword))
     {
         Palaso.Reporting.ErrorReport.NotifyUserOfProblem("Could not log you in using user='******' and pwd='" + Settings.Default.WebPassword + "'." + System.Environment.NewLine +
                                                          "For some reason, from the command line, we cannot get these credentials out of Settings.Default. However if you place your command line arguments in the properties of the project in visual studio and run from there, it works. If you are already doing that and get this message, then try running Bloom normally (gui), go to publish, and make sure you are logged in. Then quit and try this again.");
         return;
     }
     using (var dlg = new BulkUploadProgressDlg())
     {
         var worker = new BackgroundWorker();
         worker.DoWork             += BackgroundUpload;
         worker.RunWorkerCompleted += (sender, args) =>
         {
             dlg.Close();
         };
         worker.RunWorkerAsync(new object[] { folder, dlg, container });
         dlg.ShowDialog();                 // waits until worker completed closes it.
     }
 }