private static void HandleDownload(string order)
{
// We will start up just enough to download the book. This avoids the code that normally tries to keep only a single instance running.
// There is probably a pathological case here where we are overwriting an existing template just as the main instance is trying to
// do something with it. The time interval would be very short, because download uses a temp folder until it has the whole thing
// and then copies (or more commonly moves) it over in one step, and making a book from a template involves a similarly short
// step of copying the template to the new book. Hopefully users have (or will soon learn) enough sense not to
// try to use a template while in the middle of downloading a new version.
SetUpErrorHandling();
using(_applicationContainer = new ApplicationContainer())
{
SetUpLocalization();
//JT please review: is this needed? InstallerSupport.MakeBloomRegistryEntries(args);
BookDownloadSupport.EnsureDownloadFolderExists();
Browser.SetUpXulRunner();
Browser.XulRunnerShutdown += OnXulRunnerShutdown;
LocalizationManager.SetUILanguage(Settings.Default.UserInterfaceLanguage, false);
var transfer = new BookTransfer(new BloomParseClient(), ProjectContext.CreateBloomS3Client(),
_applicationContainer.BookThumbNailer, new BookDownloadStartingEvent()) /*not hooked to anything*/;
transfer.HandleBloomBookOrder(order);
PathToBookDownloadedAtStartup = transfer.LastBookDownloadedPath;
// BL-2143: Don't show download complete message if download was not successful
if (!string.IsNullOrEmpty(PathToBookDownloadedAtStartup))
{
var caption = LocalizationManager.GetString("Download.CompletedCaption", "Download complete");
var message = LocalizationManager.GetString("Download.Completed",
@"Your download ({0}) is complete. You can see it in the 'Books from BloomLibrary.org' section of your Collections.");
message = string.Format(message, Path.GetFileName(PathToBookDownloadedAtStartup));
MessageBox.Show(message, caption);
}
}
}