void OnDestinationSkippedChange(object sender, SkippedChangeEventArgs e)
        {
            if (e.SkipReason == SkipReason.ApplicationRequest)
            {
                _progress.WriteMessage("Skipping '{0}  {1}'", e.NewFilePath ?? "", e.CurrentFilePath ?? "");
                return;
            }

            if (e.Exception.Message.Contains("space") ||
                e.Exception.Message.Contains("full") ||
                e.Exception.GetType() == typeof(System.IO.IOException))
            {
                _progress.WriteError(e.SkipReason.ToString());
                _progress.WriteError(e.Exception.Message);
                _gotIOExceptionProbablyDiskFull = true;
                _agent.Cancel();                //will just end this group, not close the window
                return;
            }
            //ConflictLoserWriteError. This reason will be raised if a change is skipped because an attempt to recycle a losing file fails.
//			var path = e.CurrentFilePath == null ? e.NewFilePath : e.CurrentFilePath;
            try
            {
                _progress.WriteError("File Skipped ['{0}'/'{1}']. Reason={2}. Exception Follows:", e.NewFilePath ?? "", e.CurrentFilePath ?? "", e.SkipReason);
                if (e.Exception != null)
                {
                    _progress.WriteException(e.Exception);
                }

                _errorCountSinceLastSuccess++;
                if (_errorCountSinceLastSuccess > MaxErrorsBeforeAbort)
                {
                    _progress.WriteError("Error count exceeded limit. Will abort.");
                    _cancelRequested = true;
                    _agent.Cancel();
                }
            }
            catch (Exception error)
            {
                try
                {
                    _progress.WriteException(error);
                }
                catch (Exception progressException)
                {
                    Palaso.Reporting.ErrorReport.ReportFatalException(progressException);
                }
            }
        }
Esempio n. 2
0
 public void CancelSync()
 {
     if (_orchestrator != null && (_orchestrator.State == SyncOrchestratorState.Uploading || _orchestrator.State == SyncOrchestratorState.Downloading))
     {
         _orchestrator.Cancel();
     }
 }
Esempio n. 3
0
 public void SyncCancel()
 {
     if (_syncAgent == null)
     {
         throw new NullReferenceException("Sync session not started");
     }
     if (SyncInProgress)
     {
         _syncAgent.Cancel();
     }
 }
Esempio n. 4
0
        public void InvokeProgress()
        {
            Func <bool> handler = FileProgress;

            if (handler != null)
            {
                if (handler())
                {
                    _cancelRequested = true;
                    _agent.Cancel();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// This method is called when changes are done to a file
        /// <para>Counts the number of changes already done by the sync framework</para>
        /// <para>Reports the progress percentage to the backgroundWorkerForSync</para>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnAppliedChange(object sender, AppliedChangeEventArgs args)
        {
            if ((agent.State == SyncOrchestratorState.Downloading || agent.State == SyncOrchestratorState.Uploading ||
                 agent.State == SyncOrchestratorState.UploadingAndDownloading) && backgroundWorkerForSync.CancellationPending)
            {
                agent.Cancel();
            }

            countDoneChanges++;

            // This method will raise an event to the backgroundWorkerForSync via backgroundWorkerForSync_ProgressChanged
            backgroundWorkerForSync.ReportProgress((int)((double)countDoneChanges / countChanges * 100));
        }
Esempio n. 6
0
 public static void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             //_networkListManager.NetworkConnectivityChanged -= _networkListManager_NetworkConnectivityChanged;
         }
         if (_agent.State != SyncOrchestratorState.Ready)
         {
             _agent.Cancel();
             _agent = null;
         }
         _disposed = true;
     }
 }