Пример #1
0
        /// <summary>
        /// Start directory scan progress indicator.
        /// </summary>
        void _directoryEngine_OnBeginDirectoryScan(object sender, EventParameters2 eventArgs)
        {
            switch (eventArgs.Method)
            {
            case "DirList":
                _copyViewer.CursorMode    = CursorModes.Wait;
                _copyViewer.StatusMessage = "Scanning directories ...";
                _SoFarBytes = 0;
                if (_processingNew)
                {
                    _TotalBytes = 0;
                    _currentActivityProgress = new ProgressLink();
                    ActionBeginProgress(_currentActivityProgress);
                    _copyViewer.CurrentActivityProgress = _currentActivityProgress;
                }
                else
                {
                    _overallProgress = new ProgressLink();
                    ActionBeginProgress(_overallProgress);
                    _copyViewer.OverallProgress = _overallProgress;
                }
                break;

            case "Changes":
                break;

            case "Comparisons":
                break;
            }
        }
Пример #2
0
 internal Presenter(ICopyEngine copyEngine, ICopyViewer copyViewer, DirectoryEngine directoryEngine, SynchronizeEngine synchronizeEngine, IProfileManager profileManager)
 {
     _copyEngine        = copyEngine;
     _copyViewer        = copyViewer;
     _directoryEngine   = directoryEngine;
     _synchronizeEngine = synchronizeEngine;
     _copyViewer.OnPreviousSelectionSelectedIndexChanged += new PreviousSelectionSelectedIndexChangedHandler(_copyViewer_OnPreviousSelectionSelectedIndexChanged);
     _copyViewer.OnRemovePreviousSelection += new RemovePreviousSelectionHandler(_copyViewer_OnRemovePreviousSelection);
     _copyViewer.OnChooseNewBaseDirectory  += new ChooseNewBaseDirectoryHandler(_copyViewer_OnChooseNewBaseDirectory);
     _copyViewer.OnChooseOldBaseDirectory  += new ChooseOldBaseDirectoryHandler(_copyViewer_OnChooseOldBaseDirectory);
     _copyViewer.OnCopyNewBaseDirectory    += new CopyNewBaseDirectoryHandler(_copyViewer_OnCopyNewBaseDirectory);
     _copyViewer.OnCopyOldBaseDirectory    += new CopyOldBaseDirectoryHandler(_copyViewer_OnCopyOldBaseDirectory);
     _copyViewer.OnCopyAction   += new CopyActionHandler(_copyViewer_OnCopyAction);
     _copyViewer.OnDeleteAction += new DeleteActionHandler(_copyViewer_OnDeleteAction);
     _copyViewer.OnSynchronizePreventDeleteAction += new SynchronizePreventDeleteActionHandler(_copyViewer_OnSynchronizePreventDeleteAction);
     _copyViewer.OnSynchronizeAction        += new SynchronizeActionHandler(_copyViewer_OnSynchronizeAction);
     _copyViewer.OnSynchronizeAllAction     += new SynchronizeAllActionHandler(_copyViewer_OnSynchronizeAllAction);
     _copyViewer.OnSynchronizePlusAction    += new SynchronizePlusActionHandler(_copyViewer_OnSynchronizePlusAction);
     _copyViewer.OnSynchronizePlusAllAction += new SynchronizePlusAllActionHandler(_copyViewer_OnSynchronizePlusAllAction);
     _copyViewer.OnCancelAction             += new CancelActionHandler(_copyViewer_OnCancelAction);
     _profileManager          = profileManager;
     _currentActivityProgress = new ProgressLink();
     _overallProgress         = new ProgressLink();
     _copyViewer.EnableControls(true);
     LoadParameters();
     RefreshCombo();
 }
Пример #3
0
 void _copyEngine_OnBeginCount(CopyEngine.BeginCopyEventArgs e)
 {
     _copyViewer.CursorMode    = CursorModes.Wait;
     _copyViewer.StatusMessage = "Counting ...";
     _TotalBytes = 0;
     _SoFarBytes = 0;
     _currentActivityProgress = new ProgressLink();
     ActionBeginProgress(_currentActivityProgress);
     _copyViewer.CurrentActivityProgress = _currentActivityProgress;
 }
Пример #4
0
        void _copyViewer_OnDeleteAction(EventArgs e)
        {
            _copyViewer.EnableControls(false);
            _overallProgress                    = new ProgressLink();
            _copyViewer.OverallProgress         = _overallProgress;
            _currentActivityProgress            = new ProgressLink();
            _copyViewer.CurrentActivityProgress = _currentActivityProgress;

            //Validate all fields.
            int errorCount = ValidateFields();

            if (errorCount > 0)
            {
                return;
            }

            //Save Parameters.
            _profileManager.UserSettings.Select(_currentKey);
            _profileManager.Interrupt.Reason = "OK";
            SaveParameters();
            RefreshCombo();

            //Copy.
            _copyEngine = new CopyEngine();
            _copyEngine.OnBeginCount      += new CopyEngine.BeginCountHandler(_copyEngine_OnBeginCount);
            _copyEngine.OnUpdateCount     += new CopyEngine.UpdateCountHandler(_copyEngine_OnUpdateCount);
            _copyEngine.OnEndOfCount      += new CopyEngine.EndOfCountHandler(_copyEngine_OnEndOfCount);
            _copyEngine.OnBeginDelete     += new CopyEngine.BeginDeleteHandler(_copyEngine_OnBeginDelete);
            _copyEngine.OnUpdateDelete    += new CopyEngine.UpdateDeleteHandler(_copyEngine_OnUpdateDelete);
            _copyEngine.OnEndOfDelete     += new CopyEngine.EndOfDeleteHandler(_copyEngine_OnEndOfDelete);
            _copyEngine.CopyRule           = _profileManager.UserSettings.SelectedItem.CopyRule;
            _copyEngine.MonitoredTypesOnly = _profileManager.UserSettings.SelectedItem.MonitoredTypesOnly;
            _copyEngine.Interrupt          = _profileManager.Interrupt;

            try
            {
                _copyEngine.XDelete(_profileManager.UserSettings.SelectedItem.NewBaseDir);
                Administrator.View();
            }
            catch (ParameterException pe)
            {
                _copyViewer.SetFieldError(pe.Parameter, pe.Message);
                //_copyViewer.DisplayMessageBox(ae.Message, _copyViewer.Caption, MsgButtons.OK, MsgIcon.Error);
            }
            finally
            {
                _copyViewer.EnableControls(true);
            }
        }
Пример #5
0
        private void ActionUpdateProgress(ProgressLink progressLink, long increment)
        {
            _SoFarBytes += increment;
            if (_TotalBytes < _SoFarBytes)
            {
                _TotalBytes = _SoFarBytes * 2;
            }
            long percent = 0;

            if (_TotalBytes > 0)
            {
                percent  = _SoFarBytes * 100;
                percent /= _TotalBytes;
            }
            progressLink.Value = (int)percent;
        }
Пример #6
0
        void _copyViewer_OnSynchronizePlusAction(EventArgs e)
        {
            Administrator.Reset();
            _copyViewer.EnableControls(false);
            _overallProgress                    = new ProgressLink();
            _copyViewer.OverallProgress         = _overallProgress;
            _currentActivityProgress            = new ProgressLink();
            _copyViewer.CurrentActivityProgress = _currentActivityProgress;

            //Validate all fields.
            int errorCount = ValidateFields();

            if (errorCount > 0)
            {
                return;
            }

            //Save Parameters.
            _profileManager.UserSettings.Select(_currentKey);
            _profileManager.Interrupt.Reason = "OK";
            SaveParameters();
            RefreshCombo();

            //Use directory engine to scan both directories to determine the differences.
            DateTime startAllDateTime = Administrator.Now;

            _directoryEngine                      = new DirectoryEngine();
            _directoryEngine.Interrupt            = _profileManager.Interrupt;
            _directoryEngine.EventBeginProgress  += new Copy8.EventDelegate(_directoryEngine_OnBeginDirectoryScan);
            _directoryEngine.EventUpdateProgress += new Copy8.EventDelegate(_directoryEngine_OnUpdateDirectoryScan);
            _directoryEngine.EventEndOfProgress  += new Copy8.EventDelegate(_directoryEngine_OnEndOfDirectoryScan);
            _directoryEngine.MonitoredTypesOnly   = _profileManager.UserSettings.SelectedItem.MonitoredTypesOnly;
            _directoryEngine.Interrupt            = _profileManager.Interrupt;
            _processingNew       = true;
            _NewDirectoryListing = _directoryEngine.DirList(_profileManager.UserSettings.SelectedItem.NewBaseDir, ref mnNewFilesEstimate);
            _TotalBytes          = mnNewFilesEstimate;
            //Delete log files older that the specified number of days.
            DeleteOldLogFiles();
            _processingNew = false;
            string targetDirectory = _profileManager.UserSettings.SelectedItem.OldBaseDir;

            if (!Directory.Exists(targetDirectory))
            {
                Directory.CreateDirectory(targetDirectory);
            }
            _directoryEngine.TargetHlq = targetDirectory;
            mnOldFilesEstimate         = mnNewFilesEstimate;
            // Instead of scanning the target directory.
            // Load the previously synchronized snapshot to compare against.
            if (File.Exists(getSnapshotFileSpec(targetDirectory)))
            {
                _OldDirectoryListing = new DirectoryEntries();
                _OldDirectoryListing.Load(getSnapshotFileSpec(targetDirectory), DirectoryEntries.InterpretationEnum.Target);
            }
            else
            {
                _OldDirectoryListing = _directoryEngine.DirList(targetDirectory, ref mnOldFilesEstimate);
            }
            _directoryEngine.Compare(ref _OldDirectoryListing, ref _NewDirectoryListing);
            _directoryEngine.Changes(_OldDirectoryListing, _NewDirectoryListing, ref _ChangedDirectoryListing, ref mnChgFilesEstimate);
            _comparisons          = _directoryEngine.Comparisons;
            _copyEngine.Interrupt = _profileManager.Interrupt;

            //Use the Synchronize engine to perform the synchronize.
            //TODO: Move the directory engine calls inside the Synchronize engine.
            _synchronizeEngine = new SynchronizeEngine();
            _synchronizeEngine.OnBeginSynchronize  += new SynchronizeEngine.BeginSynchronizeHandler(_SynchronizeEngine_OnBeginSynchronize);
            _synchronizeEngine.OnUpdateSynchronize += new SynchronizeEngine.UpdateSynchronizeHandler(_SynchronizeEngine_OnUpdateSynchronize);
            _synchronizeEngine.OnEndOfSynchronize  += new SynchronizeEngine.EndOfSynchronizeHandler(_SynchronizeEngine_OnEndOfSynchronize);
            _synchronizeEngine.CopyRule             = _profileManager.UserSettings.SelectedItem.CopyRule;
            _synchronizeEngine.MonitoredTypesOnly   = _profileManager.UserSettings.SelectedItem.MonitoredTypesOnly;
            _synchronizeEngine.Interrupt            = _profileManager.Interrupt;

            try
            {
                _synchronizeEngine.Process(_comparisons, startAllDateTime);
                //After synchronization the target directory is synchronized with the source directory.
                _NewDirectoryListing.Save(getSnapshotFileSpec(targetDirectory));
                Administrator.View();
            }
            catch (ParameterException pe)
            {
                _copyViewer.SetFieldError(pe.Parameter, pe.Message);
                //_copyViewer.DisplayMessageBox(ae.Message, _copyViewer.Caption, MsgButtons.OK, MsgIcon.Error);
            }
            finally
            {
                _copyViewer.EnableControls(true);
            }
        }
Пример #7
0
 private void ActionEndOfProgress(ProgressLink progressLink)
 {
     _TotalBytes = _SoFarBytes;
     _SoFarBytes = 0;
 }
Пример #8
0
 private void ActionBeginProgress(ProgressLink progressLink)
 {
     progressLink.Minimum = 0;
     progressLink.Maximum = 100;
     progressLink.Value   = 0;
 }