Esempio n. 1
0
        private void ShootDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker      = sender as BackgroundWorker;
            string           shootString = (string)e.Argument;

            _cube.ProcessShootString(shootString, worker, e, _synchronizer);
        }
Esempio n. 2
0
        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");
        }