private void ShootCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { LogWriteLn("An error occured while trying to process the shoot string: " + e.Error.Message); } if (e.Cancelled) { LogWriteLn("Scan cancelled by user"); } if (cbSetEXIF.Checked) { string result = ""; LogWriteLn("Setting Exif data for images, checking Z string for LE value"); string le = "38"; try { le = _cube.CubeParameters["LE"]; } catch { LogWriteLn("35mm Focal Length Equivalent was NOT found in the Z string, defaulting to 38\n"); } if (String.IsNullOrWhiteSpace(le)) { LogWriteLn("35mm Focal Length Equivalent was NOT set in the Z string, defaulting to 38\n"); } try { result = result + CubeImageUtils.SetExifInfo(_scan.LocalScanFolder, le); } catch (Exception ex) { result = ex.Message; } LogWriteLn(result); } else { LogWriteLn("Skipping setting EXIF data"); } ToggleUIControls(); }
private void MainWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; for (int i = 1; i <= udIterations.Value; i++) { string batchSubject = String.Format("Batch Scan {0} of {1}", i, udIterations.Value); worker.ReportProgress(DEBUG, batchSubject); if (worker.CancellationPending) { e.Cancel = true; return; } _scan = InitializeScan(_config.ShootPrefix, batchSubject); if (worker.CancellationPending) { e.Cancel = true; return; } try { _cube.ProcessShootString(_config.ShootString, worker, e, _picSynchronizer); } catch (Exception ex) { worker.ReportProgress(ERROR, "Unable to run scan: " + ex.Message); continue; } if (worker.CancellationPending) { e.Cancel = true; return; } if (_config.DoSetEXIF) { try { worker.ReportProgress(INFO, "Setting EXIF data"); CubeImageUtils.SetExifInfo(_scan.LocalScanFolder, _35mmFocalEquivalent); } catch (Exception ex) { worker.ReportProgress(ERROR, "Unable to set Exif: " + ex.Message); } } if (worker.CancellationPending) { e.Cancel = true; return; } string host = _config.SftpHost; string user = _config.SftpUser; string pass = _config.SftpPassword; string uploadBase = _config.SftpUploadBase; string triggerURL = _config.TriggerURL; try { worker.ReportProgress(UploadManager.STATUS_FLAG, "Uploading Scan"); _scan.metadata.uploadStartTime = DateTime.Now.ToString(Scan.DATE_FORMAT); _scan.WriteManifest(); UploadEar(worker, _scan.LocalScanFolder, host, user, pass, uploadBase, _scan.metadata.scanID, triggerURL); } catch (Exception ex) { worker.ReportProgress(ERROR, "Unable to upload scan: " + ex.Message); } worker.ReportProgress(DEBUG, "Scan upload complete"); if (i == udIterations.Value) { continue; // skip the wait time } worker.ReportProgress(DEBUG, String.Format("Waiting {0} minute{1} to start next scan", udDelay.Value, udDelay.Value > 1 ? "s" : "")); worker.ReportProgress(UploadManager.SWITCH_TO_CONTINUOUS, 0); ulong start = Convert.ToUInt64(DateTime.Now.Ticks); Debug.WriteLine("start = " + start); ulong max = Convert.ToUInt64(udDelay.Value) * 60 * 10000000; // convert the time from minutes to ticks, which is a hundred nanoseconds Debug.WriteLine("max = " + max); ulong delta = Convert.ToUInt64(DateTime.Now.Ticks) - start; Debug.WriteLine("first delta = " + delta); while (delta <= max) { Thread.Sleep(5000); if (worker.CancellationPending) { e.Cancel = true; return; } int prog = Convert.ToInt16(Math.Round(((double)delta / (double)max) * 100)); Debug.WriteLine("prog = " + prog); //worker.ReportProgress(DEBUG, prog.ToString()); worker.ReportProgress(prog); delta = Convert.ToUInt64(DateTime.Now.Ticks) - start; Debug.WriteLine("delta = " + delta); } } worker.ReportProgress(UploadManager.SWITCH_TO_CONTINUOUS, null); worker.ReportProgress(DEBUG, "Batch Run Complete"); }