예제 #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");
            }
        }
예제 #3
0
        /// <summary>
        /// Open workspace to edit sync pair provided.
        /// </summary>
        /// <param name="syncpair"></param>
        public void EditSyncPair(object syncpair)
        {
            // Create sync pair view model.
            SyncPairViewModel syncpairVM = syncpair as SyncPairViewModel;

            // Use commands supplied by parent to add new workspace.
            _wsCommands.AddWorkspace(syncpairVM);
        }
예제 #4
0
        /// <summary>
        /// Handles OnSyncPairAddedToRepository Event
        /// </summary>
        /// <param name="sender">Sending Object</param>
        /// <param name="e">Event Arguments</param>
        void OnSyncPairAddedToRepository(object sender, SyncPairAddedEventArgs e)
        {
            // Create new sync pair view model with supplied args.
            var viewModel = new SyncPairViewModel(e.NewSyncPair, _syncPairRepository, _wsCommands);

            // Add view model to observable collection.
            AllSyncPairs.Add(viewModel);
        }
예제 #5
0
        /// <summary>
        /// Adds a workspace for creating a Sync Pair
        /// </summary>
        void CreateNewSyncPair()
        {
            // Create sync pair.
            SyncPair newSyncPair = SyncPair.CreateNewSyncPair();
            // Create new sync pair model passing sync pair, repository and itself??? TODO Fix this.
            SyncPairViewModel workspace = new SyncPairViewModel(newSyncPair, _syncPairRepository, this);

            // Add sync pair view model to workspaces.
            Workspaces.Add(workspace);
            // Give workspace focus.
            SetActiveWorkspace(workspace);
        }