// Running on the UI thread. Here we report the end of the synchronization.
        private void bw_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            _t.Stop();
            lock (reportLock)
            {
                this.progressBar1.Value = 100;

                FifoStackLogger logger = _syncEngine.Logger as FifoStackLogger;

                if (null == logger)
                {
                    this.WriteTraceLine("Invalid Logger instance!");
                }

                SyncState syncState = logger.SyncState;

                if (null != syncState)
                {
                    for (int i = _nextSyncStateMessageIndex; _nextSyncStateMessageIndex < syncState.Messages.Count; _nextSyncStateMessageIndex++)
                    {
                        this.WriteTraceLine(syncState.Messages[_nextSyncStateMessageIndex]);
                    }

                    if (!string.IsNullOrEmpty(syncState.ErrorMsg))
                    {
                        this.WriteTraceLine("An error occurred: " + Environment.NewLine + syncState.ErrorMsg);
                    }
                }
            }
            this.btnClose.Enabled = true;
        }
Esempio n. 2
0
        private void Synchronize(SynchronisationDirection direction)
        {
            try
            {
                if (!PersistFormToModel())
                {
                    return;
                }

                // Create a new instance of the sync engine
                // and add a Logger. The Logger of type FifoStackLogger appended here
                // will provide a stack of messages that can be polled.
                Engine          syncEngine = new Engine(this.toolStripRunName.Text, DateTime.Now, direction, _syncInfo);
                FifoStackLogger logger     = new FifoStackLogger();
                logger.SeverityFilter = Severity.Info;
                syncEngine.Logger     = logger;

                // Create and diaplay progress form that will start the syncEngine
                ProgressForm progressForm = new ProgressForm(syncEngine);
                progressForm.ShowDialog(this);
            }

            catch (Exception ex)
            {
                MessageBox.Show("An unexpected error occured: " + Environment.NewLine + ex.Message);
            }
            finally
            {
                try
                {
                    int runCounter = this.GetRunCounter();
                    runCounter++;
                    // Change the RunCounter and display new next run Name
                    this.SetRunCounter(runCounter);
                    this.toolStripRunName.Text = string.Format(RUNNAME_TEMPLATE, runCounter);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Failed to save config file: " + Environment.NewLine + exception.Message);
                }
            }
        }
        // gets and reports the current sync state
        private void timer_Tick(object sender, EventArgs e)
        {
            FifoStackLogger logger = _syncEngine.Logger as FifoStackLogger;

            if (null == logger)
            {
                this.WriteTraceLine("Invalid Logger instance!");
            }

            SyncState syncState = logger.SyncState;

            if (null != syncState)
            {
                if (_step < 100)
                {
                    _step++;
                }

                // invoke progress changed event at background worker.
                bw.ReportProgress(_step, syncState);
            }
        }
Esempio n. 4
0
        private void Synchronize(SynchronisationDirection direction)
        {
            try
            {

                if (!PersistFormToModel())
                    return;

                // Create a new instance of the sync engine
                // and add a Logger. The Logger of type FifoStackLogger appended here
                // will provide a stack of messages that can be polled.
                Engine syncEngine = new Engine(this.toolStripRunName.Text, DateTime.Now, direction, _syncInfo);
                FifoStackLogger logger = new FifoStackLogger();
                logger.SeverityFilter = Severity.Info;
                syncEngine.Logger = logger;

                // Create and diaplay progress form that will start the syncEngine
                ProgressForm progressForm = new ProgressForm(syncEngine);
                progressForm.ShowDialog(this);
            }

            catch (Exception ex)
            {
                MessageBox.Show("An unexpected error occured: " + Environment.NewLine + ex.Message);
            }
            finally
            {
                try
                {
                    int runCounter = this.GetRunCounter();
                    runCounter++;
                    // Change the RunCounter and display new next run Name
                    this.SetRunCounter(runCounter);
                    this.toolStripRunName.Text = string.Format(RUNNAME_TEMPLATE, runCounter);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Failed to save config file: " + Environment.NewLine + exception.Message);
                }
            }
        }