internal void HandleBloomBookOrder(string argument) { _downloadRequest = argument; using (_progressDialog = new ProgressDialog()) { _progressDialog.CanCancel = false; // one day we may allow this... _progressDialog.Overview = LocalizationManager.GetString("Download.DownloadingDialogTitle", "Downloading book"); _progressDialog.ProgressRangeMaximum = 14; // a somewhat minimal file count. We will fine-tune it when we know. if (IsUrlOrder(argument)) { var link = new BloomLinkArgs(argument); _progressDialog.StatusText = link.Title; } else { _progressDialog.StatusText = Path.GetFileNameWithoutExtension(argument); } // We must do the download in a background thread, even though the whole process is doing nothing else, // so we can invoke stuff on the main thread to (e.g.) update the progress bar. BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += OnDoDownload; _progressDialog.BackgroundWorker = worker; //dlg.CancelRequested += new EventHandler(OnCancelRequested); _progressDialog.ShowDialog(); // hidden automatically when task completes if (_progressDialog.ProgressStateResult != null && _progressDialog.ProgressStateResult.ExceptionThatWasEncountered != null) { Palaso.Reporting.ErrorReport.ReportFatalException( _progressDialog.ProgressStateResult.ExceptionThatWasEncountered); } } }
internal void HandleBloomBookOrder(string order) { _downloadRequest = order; using (var progressDialog = new ProgressDialog()) { _progressDialog = new ProgressDialogWrapper(progressDialog); progressDialog.CanCancel = true; progressDialog.Overview = LocalizationManager.GetString("Download.DownloadingDialogTitle", "Downloading book"); progressDialog.ProgressRangeMaximum = 14; // a somewhat minimal file count. We will fine-tune it when we know. if (IsUrlOrder(order)) { var link = new BloomLinkArgs(order); progressDialog.StatusText = link.Title; } else { progressDialog.StatusText = Path.GetFileNameWithoutExtension(order); } // We must do the download in a background thread, even though the whole process is doing nothing else, // so we can invoke stuff on the main thread to (e.g.) update the progress bar. BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += OnDoDownload; progressDialog.BackgroundWorker = worker; progressDialog.ShowDialog(); // hidden automatically when task completes if (progressDialog.ProgressStateResult != null && progressDialog.ProgressStateResult.ExceptionThatWasEncountered != null) { var exc = progressDialog.ProgressStateResult.ExceptionThatWasEncountered; ProblemReportApi.ShowProblemDialog(null, exc, "", "fatal"); } } }
public void LinkArgs_WithoutTitle_GetsCorrectOrderAndTitle() { var order = HttpUtility.UrlEncode("somepath/whatever=.BookOrder"); var input = BloomLinkArgs.kBloomUrlPrefix + BloomLinkArgs.kOrderFile + "=" + order; var args = new BloomLinkArgs(input); Assert.That(args.OrderUrl, Is.EqualTo("somepath/whatever=.BookOrder")); Assert.That(args.Title, Is.EqualTo("whatever=")); }
public void LinkArgs_WithTitle_GetsCorrectOrderAndTitle() { var order = HttpUtility.UrlEncode("whatever=&?!<>'\".BookOrder"); var title = HttpUtility.UrlEncode("title=&?!<>'\""); var input = BloomLinkArgs.kBloomUrlPrefix + BloomLinkArgs.kOrderFile + "=" + order + "&title=" + title; var args = new BloomLinkArgs(input); Assert.That(args.OrderUrl, Is.EqualTo("whatever=&?!<>'\".BookOrder")); Assert.That(args.Title, Is.EqualTo("title=&?!<>'\"")); }
/// <summary> /// this runs in a worker thread /// </summary> private void OnDoDownload(object sender, DoWorkEventArgs args) { // If we are passed a bloom book order URL, download the corresponding book and open it. if (IsUrlOrder(_downloadRequest)) { var link = new BloomLinkArgs(_downloadRequest); DownloadFromOrderUrl(link.OrderUrl, DownloadFolder); } // If we are passed a bloom book order, download the corresponding book and open it. else if (_downloadRequest.ToLower().EndsWith(BookTransfer.BookOrderExtension.ToLower()) && File.Exists(_downloadRequest)) { HandleBookOrder(_downloadRequest); } }
/// <summary> /// this runs in a worker thread /// </summary> private void OnDoDownload(object sender, DoWorkEventArgs args) { // If we are passed a bloom book order URL, download the corresponding book and open it. if (IsUrlOrder(_downloadRequest)) { var link = new BloomLinkArgs(_downloadRequest); DownloadFromOrderUrl(_downloadRequest, DownloadFolder, link.Title); } // If we are passed a bloom book order, download the corresponding book and open it. else if (_downloadRequest.ToLowerInvariant().EndsWith(BookTransfer.BookOrderExtension.ToLowerInvariant()) && RobustFile.Exists(_downloadRequest)) { HandleBookOrder(_downloadRequest); } }
internal void HandleBloomBookOrder(string order) { _downloadRequest = order; using (var progressDialog = new ProgressDialog()) { _progressDialog = new ProgressDialogWrapper(progressDialog); progressDialog.CanCancel = false; // one day we may allow this... progressDialog.Overview = LocalizationManager.GetString("Download.DownloadingDialogTitle", "Downloading book"); progressDialog.ProgressRangeMaximum = 14; // a somewhat minimal file count. We will fine-tune it when we know. if (IsUrlOrder(order)) { var link = new BloomLinkArgs(order); progressDialog.StatusText = link.Title; } else { progressDialog.StatusText = Path.GetFileNameWithoutExtension(order); } // We must do the download in a background thread, even though the whole process is doing nothing else, // so we can invoke stuff on the main thread to (e.g.) update the progress bar. BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += OnDoDownload; progressDialog.BackgroundWorker = worker; //dlg.CancelRequested += new EventHandler(OnCancelRequested); progressDialog.ShowDialog(); // hidden automatically when task completes if (progressDialog.ProgressStateResult != null && progressDialog.ProgressStateResult.ExceptionThatWasEncountered != null) { SIL.Reporting.ErrorReport.ReportFatalException( progressDialog.ProgressStateResult.ExceptionThatWasEncountered); } } }