/// <summary> /// Use explorer to edit destination. /// </summary> /// <param name="param"></param> private void BrowseDstRoot(object param) { // Create dialog window. System.Diagnostics.Process.Start("explorer.exe", _syncPair.DstRoot); // Raise event for directory tree view. UpdateDirectoryPath?.Invoke(this, EventArgs.Empty); }
/// <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; } }
/// <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"); } }
/// <summary> /// Use folder browser dialog to collect path for destination /// root directory, and notify tree view. /// </summary> /// <param name="param"></param> private void GetDstRoot(object param) { // Create dialog window. var dialog = new FolderBrowserDialog(); // Open dialog window. DialogResult result = dialog.ShowDialog(); // Retrieve selected path. DstRoot = dialog.SelectedPath; // Raise event for directory tree view. UpdateDirectoryPath?.Invoke(this, EventArgs.Empty); }