コード例 #1
0
        /// <summary>
        /// Create sync view from sync pair supplied.
        /// </summary>
        /// <param name="syncpair"></param>
        public void Sync(object syncpair)
        {
            // Check sync pair is ready to sync.
            if (_syncPair.IsValid)
            {
                ResultLog = new ObservableCollection <string>(); //reset log

                bool isFullSync        = false;
                SyncPairViewModel spvm = (SyncPairViewModel)syncpair;
                if (spvm != null)
                {
                    isFullSync = spvm.IsFullSync;
                }
                SharpToolsSynch.Sync(_syncPair.SrcRoot, _syncPair.DstRoot, isFullSync);
                // Put sync on background thread
                //Task.Factory.StartNew(() => { SharpToolsSynch.Sync(_syncPair.SrcRoot, _syncPair.DstRoot); }).ContinueWith(_ => { IsSynchronising = false; });


                UpdateDirectoryPath?.Invoke(this, EventArgs.Empty);

                // TODO throw new InvalidOperationException(Strings.SyncPairViewModel_Exception_CannotSave);

                return;
            }
        }
コード例 #2
0
        /// <summary>
        /// Create/Read sync metadata, and display results in message box. This method is invoked by the PreviewCommand.
        /// </summary>
        public void Preview(object syncpair)
        {
            bool isFullSync        = false;
            SyncPairViewModel spvm = (SyncPairViewModel)syncpair;

            if (spvm != null)
            {
                isFullSync = spvm.IsFullSync;
            }

            SyncOperationStatistics sos = SharpToolsSynch.PreviewSync(_syncPair.SrcRoot, _syncPair.DstRoot, isFullSync);
            string msg;

            if (sos != null)
            {
                UpdateDirectoryPath?.Invoke(this, EventArgs.Empty);
                // Display statistics for the synchronization operation.
                msg = "Synchronization analysis...\n\n" +
                      sos.DownloadChangesApplied + " update(s) to source pending.\n" +
                      sos.DownloadChangesFailed + " update(s) to source will fail.\n" +
                      sos.UploadChangesApplied + " update(s) to destination pending.\n" +
                      sos.UploadChangesFailed + " update(s) to destination will fail.";
                System.Windows.MessageBox.Show(msg, "Synchronization Results");
            }
        }